if (!l.inSameSubroutine(JSR)) { Edge e = new Edge(); e.info = l.inputStackTop; if (l.inSubroutine(id)) { continue; l.addToSubroutine(id, nbSubroutines);
/** * Ends the current basic block. This method must be used in the case where * the current basic block does not have any successor. */ private void noSuccessor() { if (compute == FRAMES) { Label l = new Label(); l.frame = new Frame(); l.frame.owner = l; l.resolve(this, code.length, code.data); previousBlock.successor = l; previousBlock = l; } else { currentBlock.outputStackMax = maxStackSize; } currentBlock = null; }
currentBlock.frame.execute(opcode, 0, null, null); label.getFirst().status |= Label.TARGET; nextInsn = new Label(); addSuccessor(stackSize + 1, label); nextInsn = new Label(); code.putByte(200); // GOTO_W label.put(this, code, code.length - 1, true); } else { label.put(this, code, code.length - 1, false);
Label l = handler.start.getFirst(); Label h = handler.handler.getFirst(); Label e = handler.end.getFirst(); Label n = e.successor.getFirst(); boolean change = f.merge(cw, n.frame, e.info); if (change && n.next == null) { labels.visitSubroutine(null, 1, subroutines); subroutine.visitSubroutine(null, (id / 32L) << 32 | (1L << (id % 32)), subroutines); subroutine.visitSubroutine(l, 0, subroutines);
@Override public void visitTableSwitchInsn(final int min, final int max, final Label dflt, final Label... labels) { lastCodeOffset = code.length; // adds the instruction to the bytecode of the method int source = code.length; code.putByte(Opcodes.TABLESWITCH); code.putByteArray(null, 0, (4 - code.length % 4) % 4); dflt.put(this, code, source, true); code.putInt(min).putInt(max); for (int i = 0; i < labels.length; ++i) { labels[i].put(this, code, source, true); } // updates currentBlock visitSwitchInsn(dflt, labels); }
if ((status & RESOLVED) == 0) { if (wideOffset) { addReference(-1 - source, out.length); out.putInt(-1); } else { addReference(source, out.length); out.putShort(-1);
private void visitSwitchInsn(final Label dflt, final Label[] labels) { // Label currentBlock = this.currentBlock; if (currentBlock != null) { if (compute == FRAMES) { currentBlock.frame.execute(Opcodes.LOOKUPSWITCH, 0, null, null); // adds current block successors addSuccessor(Edge.NORMAL, dflt); dflt.getFirst().status |= Label.TARGET; for (int i = 0; i < labels.length; ++i) { addSuccessor(Edge.NORMAL, labels[i]); labels[i].getFirst().status |= Label.TARGET; } } else { // updates current stack size (max stack size unchanged) --stackSize; // adds current block successors addSuccessor(stackSize, dflt); for (int i = 0; i < labels.length; ++i) { addSuccessor(stackSize, labels[i]); } } // ends current block noSuccessor(); } }
@Override public void visitLabel(final Label label) { resize |= label.resolve(this, code.length, code.data);
@Override public void doExecute(MethodExecuteContext context) { AMethod method = getMethod(); if (LOG.isPrintEnabled()) { StringBuilder str = new StringBuilder("Create method: ------------"); str.append(method.getMeta().getMethodString()); LOG.print(str); } for (LifeCycle exe : getChildren()) { exe.execute(context); } for (ExceptionTableEntry tci : exceptions) { if (tci.getEnd().getOffset() - tci.getStart().getOffset() > 0) { Type type = tci.getException(); context.getInstructions().tryCatchBlock(tci.getStart(), tci.getEnd(), tci.getHandler(), (type == null || type == Type.ANY_EXP_TYPE) ? null : type); } } }
@Override public void visitLookupSwitchInsn(final Label dflt, final int[] keys, final Label[] labels) { lastCodeOffset = code.length; // adds the instruction to the bytecode of the method int source = code.length; code.putByte(Opcodes.LOOKUPSWITCH); code.putByteArray(null, 0, (4 - code.length % 4) % 4); dflt.put(this, code, source, true); code.putInt(labels.length); for (int i = 0; i < labels.length; ++i) { code.putInt(keys[i]); labels[i].put(this, code, source, true); } // updates currentBlock visitSwitchInsn(dflt, labels); }
/** * Returns the label corresponding to the given offset. The default * implementation of this method creates a label for the given offset if it * has not been already created. * * @param offset * a bytecode offset in a method. * @param labels * the already created labels, indexed by their offset. If a * label already exists for offset this method must not create a * new one. Otherwise it must store the new label in this array. * @return a non null Label, which must be equal to labels[offset]. */ protected Label readLabel(int offset, Label[] labels) { if (labels[offset] == null) { labels[offset] = new Label(); } return labels[offset]; }
@Override public void generate() { DUP dup = OperatorFactory.newOperator(DUP.class, new Class<?>[]{KernelProgramBlock.class, IClass.class}, this, lock.getResultType()); dupSynArgument = var(lock.getResultType(), dup); flag1 = OperatorFactory.newOperator(Marker.class, new Class<?>[]{KernelProgramBlock.class, Label.class}, this, new Label()); body(lock); }
@Override protected void doExecute(MethodExecuteContext context) { Instructions instructions = context.getInstructions(); Label posLbl = new Label(); Label l1 = new Label(); Label l2 = new Label(); if(exp1 instanceof Jumpable){ Jumpable jmp = (Jumpable) exp1; jmp.jumpNegative(context, this, posLbl, l1);//.executeJump(Opcodes.JUMP_NEGATIVE, l1); }else{ exp1.push(context); instructions.unbox(exp1.getResultType().getType()); instructions.ifZCmp(Instructions.EQ, l1); } instructions.mark(posLbl); exp2.push(context); context.getInstructions().getOperandStack().pop(); instructions.goTo(l2); instructions.mark(l1); exp3.push(context); instructions.mark(l2); }
@Override protected void executing(MethodExecuteContext context) { Label andEndLbl = new Label(); Label falseLbl = new Label(); MethodVisitor mv = context.getInstructions().getMv(); OperandStack stack = context.getInstructions().getOperandStack(); jumpNegative(context, this, andEndLbl, falseLbl); mv.visitInsn(Opcodes.ICONST_1); mv.visitJumpInsn(Opcodes.GOTO, andEndLbl); mv.visitLabel(falseLbl); mv.visitInsn(Opcodes.ICONST_0); mv.visitLabel(andEndLbl); stack.pop(); stack.pop(); stack.push(Type.BOOLEAN_TYPE); }