/** * 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) { // TODO: move target down into the list } } }
oldMethodIL.delete(first, last); } catch (TargetLostException e) { InstructionHandle[] targets = e.getTargets();
il.delete(oldIfHandle); } catch (TargetLostException tle) {
/** * Remove instruction from this list. The corresponding Instruction * handles must not be reused! * * @param i instruction to remove */ public void delete(Instruction i) throws TargetLostException { InstructionHandle ih; if((ih = findInstruction1(i)) == null) throw new ClassGenException("Instruction " + i + " is not contained in this list."); delete(ih); }
/** * Remove instruction from this list. The corresponding Instruction handles must not be reused! * * @param i * instruction to remove */ public void delete(final Instruction i) throws TargetLostException { InstructionHandle ih; if ((ih = findInstruction1(i)) == null) { throw new ClassGenException("Instruction " + i + " is not contained in this list."); } delete(ih); }
/** * 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) { // TODO: move target down into the list } } }
/** * 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) { // TODO: move target down into the list } } }
/** * 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) { // TODO: move target down into the list } } }
/** * Remove instructions from instruction `from' to instruction `to' contained * in this list. The user must ensure that `from' is an instruction before * `to', or risk havoc. The corresponding Instruction handles must not be reused! * * @param from where to start deleting (inclusive) * @param to where to end deleting (inclusive) */ public void delete(Instruction from, Instruction to) throws TargetLostException { InstructionHandle from_ih, to_ih; if((from_ih = findInstruction1(from)) == null) throw new ClassGenException("Instruction " + from + " is not contained in this list."); if((to_ih = findInstruction2(to)) == null) throw new ClassGenException("Instruction " + to + " is not contained in this list."); delete(from_ih, to_ih); }
/** * Remove instructions from instruction `from' to instruction `to' contained in this list. The user must ensure that `from' is an instruction before `to', * or risk havoc. The corresponding Instruction handles must not be reused! * * @param from * where to start deleting (inclusive) * @param to * where to end deleting (inclusive) */ public void delete(final Instruction from, final Instruction to) throws TargetLostException { InstructionHandle from_ih; InstructionHandle to_ih; if ((from_ih = findInstruction1(from)) == null) { throw new ClassGenException("Instruction " + from + " is not contained in this list."); } if ((to_ih = findInstruction2(to)) == null) { throw new ClassGenException("Instruction " + to + " is not contained in this list."); } delete(from_ih, to_ih); }
/** * Remove all NOPs from the instruction list (if possible) and update every * object refering to them, i.e., branch instructions, local variables and * exception handlers. */ public void removeNOPs() { if(il != null) { InstructionHandle next; /* Check branch instructions. */ for(InstructionHandle ih = il.getStart(); ih != null; ih = next) { next = ih.next; if((next != null) && (ih.getInstruction() instanceof NOP)) { try { il.delete(ih); } catch(TargetLostException e) { InstructionHandle[] targets = e.getTargets(); for(int i=0; i < targets.length; i++) { InstructionTargeter[] targeters = targets[i].getTargeters(); for(int j=0; j < targeters.length; j++) targeters[j].updateTarget(targets[i], next); } } } } } }
/** * Remove all NOPs from the instruction list (if possible) and update every * object referring to them, i.e., branch instructions, local variables and * exception handlers. */ public void removeNOPs() { if (il != null) { InstructionHandle next; /* Check branch instructions. */ for (InstructionHandle ih = il.getStart(); ih != null; ih = next) { next = ih.getNext(); if ((next != null) && (ih.getInstruction() instanceof NOP)) { try { il.delete(ih); } catch (final TargetLostException e) { for (final InstructionHandle target : e.getTargets()) { for (final InstructionTargeter targeter : target.getTargeters()) { targeter.updateTarget(target, next); } } } } } } }
InstructionHandle[] match = matches.next(); try { list.delete(match[0]); } catch (TargetLostException tlex) { for (InstructionHandle target : tlex.getTargets()) {
InstructionHandle[] match = matches.next(); try { list.delete(match[0]); } catch (TargetLostException tlex) { for (InstructionHandle target : tlex.getTargets()) {
list.delete(astoreInstr, athrowInstr); } catch (TargetLostException tlex) { if (athrowInstr == list.getEnd()) { && (secondToLastInstr.getInstruction() instanceof RETURN)) { try { list.delete(secondToLastInstr); } catch (TargetLostException tlex) { for (InstructionHandle target : tlex.getTargets()) {
list.delete(astoreInstr, athrowInstr); } catch (TargetLostException tlex) { if (athrowInstr == list.getEnd()) { && (secondToLastInstr.getInstruction() instanceof RETURN)) { try { list.delete(secondToLastInstr); } catch (TargetLostException tlex) { for (InstructionHandle target : tlex.getTargets()) {
list.delete(handles[startLoc], handles[endLoc]); } catch (TargetLostException e) { logger.error("Control flow obfuscation evident. Couldn't clear clinit");