Examples of InstructionFinder


Examples of org.apache.bcel.util.InstructionFinder

    /**
     * Peephole optimization: Remove sequences of [ALOAD, POP].
     */
    private void peepHoleOptimization(MethodGenerator methodGen) {
    InstructionList il = methodGen.getInstructionList();
    InstructionFinder find = new InstructionFinder(il);
  InstructionHandle ih;
  String pattern;

  // Remove seqences of ALOAD, POP (GTM)
  pattern = "`ALOAD'`POP'`Instruction'";
  for(Iterator iter=find.search(pattern); iter.hasNext();){
      InstructionHandle[] match = (InstructionHandle[])iter.next();
      try {
    if ((!match[0].hasTargeters()) && (!match[1].hasTargeters())) {
                    il.delete(match[0], match[1]);
                }
      }
      catch (TargetLostException e) {
                // TODO: move target down into the list
            }
  }
  // Replace sequences of ILOAD_?, ALOAD_?, SWAP with ALOAD_?, ILOAD_?
  pattern = "`ILOAD'`ALOAD'`SWAP'`Instruction'";
  for(Iterator iter=find.search(pattern); iter.hasNext();){
            InstructionHandle[] match = (InstructionHandle[])iter.next();
            try {
                org.apache.bcel.generic.Instruction iload;
                org.apache.bcel.generic.Instruction aload;
                if ((!match[0].hasTargeters()) &&
                    (!match[1].hasTargeters()) &&
                    (!match[2].hasTargeters())) {
                    iload = match[0].getInstruction();
                    aload = match[1].getInstruction();
                    il.insert(match[0], aload);
                    il.insert(match[0], iload);
                    il.delete(match[0], match[2]);
                }
            }
            catch (TargetLostException e) {
                // TODO: move target down into the list
            }
        }
       
        // Replace sequences of ALOAD_1, ALOAD_1 with ALOAD_1, DUP
  pattern = "`ALOAD_1'`ALOAD_1'`Instruction'";
        for(Iterator iter=find.search(pattern); iter.hasNext();){
            InstructionHandle[] match = (InstructionHandle[])iter.next();
            try {
          org.apache.bcel.generic.Instruction iload;
                org.apache.bcel.generic.Instruction aload;
                if ((!match[0].hasTargeters()) && (!match[1].hasTargeters())) {
View Full Code Here

Examples of org.apache.bcel.util.InstructionFinder

     * Peephole optimization: Remove sequences of [ALOAD, POP].
     */
    private void peepHoleOptimization(MethodGenerator methodGen) {
  final String pattern = "`ALOAD'`POP'`Instruction'";
  final InstructionList il = methodGen.getInstructionList();
  final InstructionFinder find = new InstructionFinder(il);
  for(Iterator iter=find.search(pattern); iter.hasNext(); ) {
      InstructionHandle[] match = (InstructionHandle[])iter.next();
      try {
    il.delete(match[0], match[1]);
      }
      catch (TargetLostException e) {
View Full Code Here

Examples of org.apache.bcel.util.InstructionFinder

   *
   * @return the handle to the super/this(...) constructor call.
   */
  public InstructionHandle lookUpSuperConstructorCall() {
    // construct a finder
    InstructionFinder finder =
      new InstructionFinder( iList );
   
    // do the search
    Iterator iter
      = finder.search(
        Constants.OPCODE_NAMES[Constants.INVOKESPECIAL] );
 
    if( iter.hasNext() ) {
      InstructionHandle[] ih
        = (InstructionHandle[])iter.next();
View Full Code Here

Examples of org.apache.bcel.util.InstructionFinder

   * @return a list of matches
   */
  public List<CallMatch> lookUpMethodCall( Pattern invokePattern ) {
   
    // construct a finder
    InstructionFinder finder =
      new InstructionFinder( iList );
   
    // search all invokes
    Iterator iter
      = finder.search(
        Constants.OPCODE_NAMES[Constants.INVOKEINTERFACE]
        + "|"
        + Constants.OPCODE_NAMES[Constants.INVOKESPECIAL]
        + "|"
        + Constants.OPCODE_NAMES[Constants.INVOKESTATIC]
View Full Code Here

Examples of org.apache.bcel.util.InstructionFinder

    int idx =
      constPoolGen.lookupMethodref(
        classname, name, signature );
   
    // construct a finder
    InstructionFinder finder =
      new InstructionFinder( iList );
   
    // do the search
    Iterator iter
      = finder.search(
        Constants.OPCODE_NAMES[Constants.INVOKEVIRTUAL],
        new MethodCallConstraint( idx ) );
   
    // the return list
    List<InstructionHandle> rc = new ArrayList<InstructionHandle>();
View Full Code Here

Examples of org.apache.bcel.util.InstructionFinder

   * @return a list of return statments.
   */
  private List<InstructionHandle> lookUpReturnStatements( boolean skipLast ) {
   
    // construct a finder
    InstructionFinder finder =
      new InstructionFinder( iList );
   
    // do the search
    Iterator iter
      = finder.search( "IRETURN|LRETURN|FRETURN|DRETURN|ARETURN|RETURN" );
   
    List<InstructionHandle> rc = new ArrayList<InstructionHandle>();
   
    while( iter.hasNext() ) {
      InstructionHandle[] ih
View Full Code Here

Examples of org.apache.bcel.util.InstructionFinder

   * @return an iterator of the search-results.
   */
  private Iterator searchLoadInstruction(
    int varIdx, String prefix, String postfix, int instructionIdx ) {

    InstructionFinder finder =
      new InstructionFinder( iList );
 
    if( varIdx > 3 ) { // a constraint checks the variable index
      return finder.search(
        prefix + " " +
        "ALOAD " + postfix,
        new LoadStoreConstraint( varIdx, instructionIdx ) );
    }
    else { // the variable index is included in the instruction
      return finder.search(
        prefix + " " 
        + new ALOAD( varIdx ).toString( false )
        + " " + postfix );
    }
  }
View Full Code Here

Examples of org.apache.bcel.util.InstructionFinder

   * @return an iterator of the search-results.
   */
  private Iterator searchStoreInstruction(
      int varIdx, String prefix, String postfix, int instructionIdx ) {

    InstructionFinder finder =
      new InstructionFinder( iList );
 
    if( varIdx > 3 ) {  // a constraint checks the variable index
      return finder.search(
        prefix + " " +
        "ASTORE " + postfix,
        new LoadStoreConstraint( varIdx, instructionIdx ) );
    }
    else { // the variable index is included in the instruction
      return finder.search(
        prefix + " " 
        + new ASTORE( varIdx ).toString( false )
        + " " + postfix );
    }
  }
View Full Code Here

Examples of org.apache.bcel.util.InstructionFinder

    int referenceCount = 0;
    AccessMethodConstraint constraint = new AccessMethodConstraint(cpoolgen, verbose);
    String pattern = "ALOAD GETFIELD INVOKESTATIC+";
   
    InstructionList list = gmethod.getInstructionList();
    InstructionFinder finder = new InstructionFinder(list);
    for (Iterator i = finder.search(pattern, constraint); i.hasNext(); ) {
      InstructionHandle[] match = (InstructionHandle[])i.next();
      if (match.length > 3) throw new CantInstrumentException(
          "Can't instrument multiply nested triggers.");
      INVOKESTATIC is = (INVOKESTATIC)(match[match.length-1].getInstruction());
      String accessMethodName = is.getMethodName(cpoolgen);
View Full Code Here

Examples of org.apache.bcel.util.InstructionFinder

    /**
     * Peephole optimization: Remove sequences of [ALOAD, POP].
     */
    private void peepHoleOptimization(MethodGenerator methodGen) {
    InstructionList il = methodGen.getInstructionList();
    InstructionFinder find = new InstructionFinder(il);
  InstructionHandle ih;
  String pattern;

  // Remove seqences of ALOAD, POP (GTM)
  pattern = "`ALOAD'`POP'`Instruction'";
  for(Iterator iter=find.search(pattern); iter.hasNext();){
      InstructionHandle[] match = (InstructionHandle[])iter.next();
      try {
    if ((!match[0].hasTargeters()) && (!match[1].hasTargeters())) {
                    il.delete(match[0], match[1]);
                }
      }
      catch (TargetLostException e) {
                // TODO: move target down into the list
            }
  }
  // Replace sequences of ILOAD_?, ALOAD_?, SWAP with ALOAD_?, ILOAD_?
  pattern = "`ILOAD'`ALOAD'`SWAP'`Instruction'";
  for(Iterator iter=find.search(pattern); iter.hasNext();){
            InstructionHandle[] match = (InstructionHandle[])iter.next();
            try {
                org.apache.bcel.generic.Instruction iload;
                org.apache.bcel.generic.Instruction aload;
                if ((!match[0].hasTargeters()) &&
                    (!match[1].hasTargeters()) &&
                    (!match[2].hasTargeters())) {
                    iload = match[0].getInstruction();
                    aload = match[1].getInstruction();
                    il.insert(match[0], aload);
                    il.insert(match[0], iload);
                    il.delete(match[0], match[2]);
                }
            }
            catch (TargetLostException e) {
                // TODO: move target down into the list
            }
        }
       
        // Replace sequences of ALOAD_1, ALOAD_1 with ALOAD_1, DUP
  pattern = "`ALOAD_1'`ALOAD_1'`Instruction'";
        for(Iterator iter=find.search(pattern); iter.hasNext();){
            InstructionHandle[] match = (InstructionHandle[])iter.next();
            try {
          org.apache.bcel.generic.Instruction iload;
                org.apache.bcel.generic.Instruction aload;
                if ((!match[0].hasTargeters()) && (!match[1].hasTargeters())) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.