static private void deleteIns(InstructionList il, InstructionHandle ih, InstructionHandle new_target) { // System.out.println("deleteIns: instructionList = " + il); // System.out.println(" handle = " + ih); 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], new_target); } } } }
public static boolean isThrower(BasicBlock target) { InstructionHandle ins = target.getFirstInstruction(); int maxCount = 7; while (ins != null) { if (maxCount-- <= 0) break; Instruction i = ins.getInstruction(); if (i instanceof ATHROW) { return true; } if (i instanceof InstructionTargeter || i instanceof ReturnInstruction) return false; ins = ins.getNext(); } return false; }
static private void deleteIns(InstructionList il, InstructionHandle a, InstructionHandle b, InstructionHandle new_target) { try { il.delete(a, b); } 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], new_target); } } } }
/** * 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; }