Coverage Report - org.apache.commons.nabla.automatic.trimming.DLoadPop2Trimmer
 
Classes in this File Line Coverage Branch Coverage Complexity
DLoadPop2Trimmer
67%
6/9
75%
3/4
0
DLoadPop2Trimmer$1
N/A
N/A
0
DLoadPop2Trimmer$LazyHolder
100%
2/2
N/A
0
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.apache.commons.nabla.automatic.trimming;
 18  
 
 19  
 import org.objectweb.asm.Opcodes;
 20  
 import org.objectweb.asm.tree.AbstractInsnNode;
 21  
 import org.objectweb.asm.tree.InsnList;
 22  
 
 23  
 /** Trimmer removing (DLOAD i, POP2).
 24  
  */
 25  1
 public class DLoadPop2Trimmer extends BytecodeTrimmer {
 26  
 
 27  
     /** Holder for the singleton instance.*/
 28  65
     private static class LazyHolder  {
 29  
         /** The singleton instance. */
 30  1
         private static final BytecodeTrimmer INSTANCE = new DLoadPop2Trimmer();
 31  
     }
 32  
 
 33  
     /** Hidden constructor.
 34  
      */
 35  
     private DLoadPop2Trimmer() {
 36  1
         super(2);
 37  1
     }
 38  
 
 39  
     /** Get the singleton instance.
 40  
      * <p>We use here the Initialization on Demand Holder idiom.</p>
 41  
      * @return the singleton instance
 42  
      */
 43  
     public static BytecodeTrimmer getInstance() {
 44  65
         return LazyHolder.INSTANCE;
 45  
     }
 46  
 
 47  
     /** {@inheritDoc} */
 48  
     @Override
 49  
     protected boolean trimWindow(final InsnList instructions,
 50  
                                  final AbstractInsnNode[] window) {
 51  
 
 52  1800
         if ((window[0].getOpcode() == Opcodes.DUP2) &&
 53  
             (window[1].getOpcode() == Opcodes.POP2)) {
 54  
 
 55  
             // remove the no-op instructions pair
 56  0
             instructions.remove(window[0]);
 57  0
             instructions.remove(window[1]);
 58  
 
 59  0
             return true;
 60  
 
 61  
         }
 62  
 
 63  
         // nothing have been done
 64  1800
         return false;
 65  
 
 66  
     }
 67  
 
 68  
 }