/** * Determine whether or not the given instruction is a control flow merge. * * @param handle * the instruction * @return true if the instruction is a control merge, false otherwise */ private static boolean isMerge(InstructionHandle handle) { if (handle.hasTargeters()) { // Check all targeters of this handle to see if any // of them are branches. If so, the instruction is a merge. InstructionTargeter[] targeterList = handle.getTargeters(); for (InstructionTargeter targeter : targeterList) { if (targeter instanceof BranchInstruction) { return true; } } } return false; }
&& next3.getInstruction() instanceof ICONST && next1.getTargeters().length == 0 && next2.getTargeters().length == 0 && next3.getTargeters().length == 1 && next4.getTargeters().length == 1) { int c1 = ((ICONST) next1.getInstruction()).getValue().intValue(); GOTO g = (GOTO) next2.getInstruction();
InstructionTargeter[] targeters = ih.getTargeters(); InstructionTargeter[] targeters = lostTarget.getTargeters(); for (int j = 0; j < targeters.length; j++) { if (targeters[j] instanceof LocalVariableGen) {
/** * Determine whether or not the given instruction is a control flow merge. * * @param handle * the instruction * @return true if the instruction is a control merge, false otherwise */ private static boolean isMerge(InstructionHandle handle) { if (handle.hasTargeters()) { // Check all targeters of this handle to see if any // of them are branches. If so, the instruction is a merge. InstructionTargeter[] targeterList = handle.getTargeters(); for (InstructionTargeter targeter : targeterList) { if (targeter instanceof BranchInstruction) { return true; } } } return false; }
InstructionTargeter[] targeters= handle.getTargeters(); if (targeters != null) for (InstructionTargeter targeter : handle.getTargeters())
public void testRemoveLocalVariables() throws Exception { final MethodGen mg = getMethod(Foo.class, "bar"); final LocalVariableGen lv = mg.getLocalVariables()[1]; assertEquals("variable name", "a", lv.getName()); final InstructionHandle start = lv.getStart(); final InstructionHandle end = lv.getEnd(); assertNotNull("scope start", start); assertNotNull("scope end", end); assertTrue("scope start not targeted by the local variable", Arrays.asList(start.getTargeters()).contains(lv)); assertTrue("scope end not targeted by the local variable", Arrays.asList(end.getTargeters()).contains(lv)); // now let's remove the local variables mg.removeLocalVariables(); assertFalse("scope start still targeted by the removed variable", Arrays.asList(start.getTargeters()).contains(lv)); assertFalse("scope end still targeted by the removed variable", Arrays.asList(end.getTargeters()).contains(lv)); assertNull("scope start", lv.getStart()); assertNull("scope end", lv.getEnd()); }
public void testRemoveLocalVariable() throws Exception { final MethodGen mg = getMethod(Foo.class, "bar"); final LocalVariableGen lv = mg.getLocalVariables()[1]; assertEquals("variable name", "a", lv.getName()); final InstructionHandle start = lv.getStart(); final InstructionHandle end = lv.getEnd(); assertNotNull("scope start", start); assertNotNull("scope end", end); assertTrue("scope start not targeted by the local variable", Arrays.asList(start.getTargeters()).contains(lv)); assertTrue("scope end not targeted by the local variable", Arrays.asList(end.getTargeters()).contains(lv)); // now let's remove the local variable mg.removeLocalVariable(lv); assertFalse("scope start still targeted by the removed variable", Arrays.asList(start.getTargeters()).contains(lv)); assertFalse("scope end still targeted by the removed variable", Arrays.asList(end.getTargeters()).contains(lv)); assertNull("scope start", lv.getStart()); assertNull("scope end", lv.getEnd()); }
/** * 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); } } } } } } }
} catch (TargetLostException tlex) { for (InstructionHandle target : tlex.getTargets()) { for (InstructionTargeter targeter : target.getTargeters()) { targeter.updateTarget(target, match[1]);
} catch (TargetLostException tlex) { for (InstructionHandle target : tlex.getTargets()) { for (InstructionTargeter targeter : target.getTargeters()) { targeter.updateTarget(target, match[1]);
&& next3.getInstruction() instanceof ICONST && next1.getTargeters().length == 0 && next2.getTargeters().length == 0 && next3.getTargeters().length == 1 && next4.getTargeters().length == 1) { int c1 = ((ICONST) next1.getInstruction()).getValue().intValue(); GOTO g = (GOTO) next2.getInstruction();
for (InstructionTargeter targeter : target.getTargeters()) { targeter.updateTarget(target, toRedirect); } catch (TargetLostException tlex) { for (InstructionHandle target : tlex.getTargets()) { for (InstructionTargeter targeter : target.getTargeters()) { targeter.updateTarget(target, lastInstr);
} catch (TargetLostException tlex) { for (InstructionHandle target : tlex.getTargets()) { for (InstructionTargeter targeter : target.getTargeters()) { logger.debug("redirected " + target + " to " + toRedirect + " in " + cg.getClassName() + "." + mg.getName() + mg.getSignature()); targeter.updateTarget(target, toRedirect); } catch (TargetLostException tlex) { for (InstructionHandle target : tlex.getTargets()) { for (InstructionTargeter targeter : target.getTargeters()) { logger.debug("redirected " + target + " to " + (theBranch.getInstruction() instanceof IFEQ ? lastInstr : toRedirect) + " in " + cg.getClassName() + "." + mg.getName() + mg.getSignature()); targeter.updateTarget(target, theBranch.getInstruction() instanceof IFEQ ?
for (InstructionTargeter targeter : target.getTargeters()) { targeter.updateTarget(target, toRedirect); } catch (TargetLostException tlex) { for (InstructionHandle target : tlex.getTargets()) { for (InstructionTargeter targeter : target.getTargeters()) { targeter.updateTarget(target, lastInstr);
InstructionTargeter[] targeters = ih.getTargeters(); InstructionTargeter[] targeters = lostTarget.getTargeters(); for (int j = 0; j < targeters.length; j++) { if (targeters[j] instanceof LocalVariableGen) {
InstructionTargeter[] targeters = ih.getTargeters(); InstructionTargeter[] targeters = lostTarget.getTargeters(); for (int j = 0; j < targeters.length; j++) { if (targeters[j] instanceof LocalVariableGen) {
InstructionTargeter[] targeters = ih.getTargeters(); InstructionTargeter[] targeters = lostTarget.getTargeters(); for (int j = 0; j < targeters.length; j++) { if (targeters[j] instanceof LocalVariableGen) {