/** * Looks up the label <code>l</code> in the <code>gotoTable</code>, thus * translating it from a Label in the original code, to a Label in the * inlined code that is appropriate for use by an instruction that * branched to the original label. * * @param l * The label we will be translating * @return a label for use by a branch instruction in the inlined code * @see #rangeLabel */ public LabelNode gotoLabel(final LabelNode l) { // owner should never be null, because owner is only null // if an instruction cannot be reached from this subroutine Instantiation owner = findOwner(instructions.indexOf(l)); return owner.rangeTable.get(l); }
/** * Creates a control flow graph edge corresponding to an exception handler. * The default implementation of this method delegates to * {@link #newControlFlowExceptionEdge(int, int) * newControlFlowExceptionEdge(int, int)}. It can be overridden in order to * construct the control flow graph of a method (this method is called by * the {@link #analyze analyze} method during its visit of the method's * code). * * @param insn * an instruction index. * @param tcb * TryCatchBlockNode corresponding to this edge. * @return true if this edge must be considered in the data flow analysis * performed by this analyzer, or false otherwise. The default * implementation of this method delegates to * {@link #newControlFlowExceptionEdge(int, int) * newControlFlowExceptionEdge(int, int)}. */ protected boolean newControlFlowExceptionEdge(final int insn, final TryCatchBlockNode tcb) { return newControlFlowExceptionEdge(insn, insns.indexOf(tcb.handler)); }
/** * Walks the method and determines which internal subroutine(s), if any, * each instruction is a method of. */ private void markSubroutines() { BitSet anyvisited = new BitSet(); // First walk the main subroutine and find all those instructions which // can be reached without invoking any JSR at all markSubroutineWalk(mainSubroutine, 0, anyvisited); // Go through the head of each subroutine and find any nodes reachable // to that subroutine without following any JSR links. for (Iterator<Map.Entry<LabelNode, BitSet>> it = subroutineHeads .entrySet().iterator(); it.hasNext();) { Map.Entry<LabelNode, BitSet> entry = it.next(); LabelNode lab = entry.getKey(); BitSet sub = entry.getValue(); int index = instructions.indexOf(lab); markSubroutineWalk(sub, index, anyvisited); } }
} else { JumpInsnNode jnode = (JumpInsnNode) node; findSubroutine(insns.indexOf(jnode.label), sub, calls); findSubroutine(insns.indexOf(tsnode.dflt), sub, calls); for (int i = tsnode.labels.size() - 1; i >= 0; --i) { LabelNode l = tsnode.labels.get(i); findSubroutine(insns.indexOf(l), sub, calls); findSubroutine(insns.indexOf(lsnode.dflt), sub, calls); for (int i = lsnode.labels.size() - 1; i >= 0; --i) { LabelNode l = lsnode.labels.get(i); findSubroutine(insns.indexOf(l), sub, calls); for (int i = 0; i < insnHandlers.size(); ++i) { TryCatchBlockNode tcb = insnHandlers.get(i); findSubroutine(insns.indexOf(tcb.handler), sub, calls);
int destidx = instructions.indexOf(jnode.label); markSubroutineWalkDFS(sub, destidx, anyvisited); int destidx = instructions.indexOf(tsnode.dflt); markSubroutineWalkDFS(sub, destidx, anyvisited); for (int i = tsnode.labels.size() - 1; i >= 0; --i) { LabelNode l = tsnode.labels.get(i); destidx = instructions.indexOf(l); markSubroutineWalkDFS(sub, destidx, anyvisited); int destidx = instructions.indexOf(lsnode.dflt); markSubroutineWalkDFS(sub, destidx, anyvisited); for (int i = lsnode.labels.size() - 1; i >= 0; --i) { LabelNode l = lsnode.labels.get(i); destidx = instructions.indexOf(l); markSubroutineWalkDFS(sub, destidx, anyvisited);
int begin = insns.indexOf(tcb.start); int end = insns.indexOf(tcb.end); for (int j = begin; j < end; ++j) { List<TryCatchBlockNode> insnHandlers = handlers[j]; sub = new Subroutine(jsr.label, m.maxLocals, jsr); subroutineHeads.put(jsr.label, sub); findSubroutine(insns.indexOf(jsr.label), sub, subroutineCalls); } else { sub.callers.add(jsr); int jump = insns.indexOf(j.label); if (insnOpcode == JSR) { merge(jump, current, new Subroutine(j.label, } else if (insnNode instanceof LookupSwitchInsnNode) { LookupSwitchInsnNode lsi = (LookupSwitchInsnNode) insnNode; int jump = insns.indexOf(lsi.dflt); merge(jump, current, subroutine); newControlFlowEdge(insn, jump); for (int j = 0; j < lsi.labels.size(); ++j) { LabelNode label = lsi.labels.get(j); jump = insns.indexOf(label); merge(jump, current, subroutine); newControlFlowEdge(insn, jump); int jump = insns.indexOf(tsi.dflt); merge(jump, current, subroutine); newControlFlowEdge(insn, jump);