List of usage examples for org.objectweb.asm Opcodes IF_ICMPLE
int IF_ICMPLE
To view the source code for org.objectweb.asm Opcodes IF_ICMPLE.
Click Source Link
From source file:de.tuberlin.uebb.jbop.optimizer.controlflow.ConstantIfInlinerTest.java
License:Open Source License
/** * Tests that constantIfInliner is working correctly. * /*w ww. j a va2 s . c o m*/ * Input is * * <pre> * if(2>1) * ... * </pre> * * @throws JBOPClassException * the jBOP class exception */ @Test public void testConstantIfInlinerIF_ICMPLE() throws JBOPClassException { // INIT final LabelNode label = new LabelNode(); builder.addInsn(new InsnNode(Opcodes.ICONST_2)).// addInsn(new InsnNode(Opcodes.ICONST_1)).// addInsn(new JumpInsnNode(Opcodes.IF_ICMPLE, label)).// addInsn(new InsnNode(Opcodes.NOP)).// addInsn(label).// addInsn(new InsnNode(Opcodes.RETURN)); // RUN assertEquals(6, method.instructions.size()); final InsnList optimized = constantIfInliner.optimize(method.instructions, method); // ASSERT assertEquals(3, optimized.size()); assertEquals(Opcodes.NOP, optimized.get(0).getOpcode()); }
From source file:de.tuberlin.uebb.jbop.optimizer.controlflow.ConstantIfInlinerTest.java
License:Open Source License
/** * Tests that constantIfInliner is working correctly. * //w w w . ja v a 2 s . co m * Input is * * <pre> * if(1>2) * ... * else * ... * </pre> * * @throws JBOPClassException * the jBOP class exception */ @Test public void testConstantIfInlinerIF_ICMPLEWithElseChooseIf() throws JBOPClassException { // INIT final LabelNode label = new LabelNode(); final LabelNode label2 = new LabelNode(); builder.addInsn(new InsnNode(Opcodes.ICONST_2)).// addInsn(new InsnNode(Opcodes.ICONST_1)).// addInsn(new JumpInsnNode(Opcodes.IF_ICMPLE, label)).// addInsn(new InsnNode(Opcodes.NOP)).// addInsn(new InsnNode(Opcodes.NOP)).// addInsn(new JumpInsnNode(Opcodes.GOTO, label2)).// addInsn(label).// addInsn(new InsnNode(Opcodes.NOP)).// addInsn(label2).// addInsn(new InsnNode(Opcodes.RETURN)); // RUN assertEquals(10, method.instructions.size()); final InsnList optimized = constantIfInliner.optimize(method.instructions, method); // ASSERT assertEquals(4, optimized.size()); assertEquals(Opcodes.NOP, optimized.get(0).getOpcode()); assertEquals(Opcodes.NOP, optimized.get(1).getOpcode()); }
From source file:de.tuberlin.uebb.jbop.optimizer.controlflow.ConstantIfInlinerTest.java
License:Open Source License
/** * Tests that constantIfInliner is working correctly. * /*from w w w . ja v a 2s .co m*/ * Input is * * <pre> * if(2>1) * ... * else * ... * </pre> * * @throws JBOPClassException * the jBOP class exception */ @Test public void testConstantIfInlinerIF_ICMPLEWithElseChooseElse() throws JBOPClassException { // INIT final LabelNode label = new LabelNode(); final LabelNode label2 = new LabelNode(); builder.addInsn(new InsnNode(Opcodes.ICONST_2)).// addInsn(new InsnNode(Opcodes.ICONST_1)).// addInsn(new JumpInsnNode(Opcodes.IF_ICMPLE, label)).// addInsn(new InsnNode(Opcodes.NOP)).// addInsn(new JumpInsnNode(Opcodes.GOTO, label2)).// addInsn(label).// addInsn(new InsnNode(Opcodes.NOP)).// addInsn(new InsnNode(Opcodes.NOP)).// addInsn(label2).// addInsn(new InsnNode(Opcodes.RETURN)); // RUN assertEquals(10, method.instructions.size()); final InsnList optimized = constantIfInliner.optimize(method.instructions, method); // ASSERT assertEquals(3, optimized.size()); assertEquals(Opcodes.NOP, optimized.get(0).getOpcode()); assertEquals(-1, optimized.get(1).getOpcode()); }
From source file:de.tuberlin.uebb.jbop.optimizer.loop.ForLoop.java
License:Open Source License
private boolean eval(final int i, final int loopCount, final int ifNode) { if (ifNode == Opcodes.IF_ICMPLE) { return i <= loopCount; }/* w w w. j av a 2s .c o m*/ if (ifNode == Opcodes.IF_ICMPEQ) { return i == loopCount; } if (ifNode == Opcodes.IF_ICMPGE) { return i >= loopCount; } if (ifNode == Opcodes.IF_ICMPGT) { return i > loopCount; } if (ifNode == Opcodes.IF_ICMPLT) { return i < loopCount; } if (ifNode == Opcodes.IF_ICMPNE) { return i != loopCount; } if (ifNode == Opcodes.IFGE) { return i >= 0; } if (ifNode == Opcodes.IFEQ) { return i == 0; } if (ifNode == Opcodes.IFGT) { return i > 0; } if (ifNode == Opcodes.IFLE) { return i <= 0; } if (ifNode == Opcodes.IFLT) { return i < 0; } if (ifNode == Opcodes.IFNE) { return i != 0; } return false; }
From source file:de.unisb.cs.st.javaslicer.common.classRepresentation.instructions.JumpInstruction.java
License:Open Source License
@Override public String toString() { String condition;// w ww . jav a 2s .c o m switch (getOpcode()) { case Opcodes.IFEQ: condition = "IFEQ"; break; case Opcodes.IFNE: condition = "IFNE"; break; case Opcodes.IFLT: condition = "IFLT"; break; case Opcodes.IFGE: condition = "IFGE"; break; case Opcodes.IFGT: condition = "IFGT"; break; case Opcodes.IFLE: condition = "IFLE"; break; case Opcodes.IF_ICMPEQ: condition = "IF_ICMPEQ"; break; case Opcodes.IF_ICMPNE: condition = "IF_ICMPNE"; break; case Opcodes.IF_ICMPLT: condition = "IF_ICMPLT"; break; case Opcodes.IF_ICMPGE: condition = "IF_ICMPGE"; break; case Opcodes.IF_ICMPGT: condition = "IF_ICMPGT"; break; case Opcodes.IF_ICMPLE: condition = "IF_ICMPLE"; break; case Opcodes.IF_ACMPEQ: condition = "IF_ACMPEQ"; break; case Opcodes.IF_ACMPNE: condition = "IF_ACMPNE"; break; case Opcodes.GOTO: condition = "GOTO"; break; case Opcodes.JSR: condition = "JSR"; break; case Opcodes.IFNULL: condition = "IFNULL"; break; case Opcodes.IFNONNULL: condition = "IFNONNULL"; break; default: assert false; condition = "--ERROR--"; break; } return condition + " " + this.label; }
From source file:de.unisb.cs.st.javaslicer.common.classRepresentation.instructions.JumpInstruction2.java
License:Open Source License
@Override public String toString() { String condition;//from w w w . j av a 2 s. co m switch (getOpcode()) { case Opcodes.IFEQ: condition = "IFEQ"; break; case Opcodes.IFNE: condition = "IFNE"; break; case Opcodes.IFLT: condition = "IFLT"; break; case Opcodes.IFGE: condition = "IFGE"; break; case Opcodes.IFGT: condition = "IFGT"; break; case Opcodes.IFLE: condition = "IFLE"; break; case Opcodes.IF_ICMPEQ: condition = "IF_ICMPEQ"; break; case Opcodes.IF_ICMPNE: condition = "IF_ICMPNE"; break; case Opcodes.IF_ICMPLT: condition = "IF_ICMPLT"; break; case Opcodes.IF_ICMPGE: condition = "IF_ICMPGE"; break; case Opcodes.IF_ICMPGT: condition = "IF_ICMPGT"; break; case Opcodes.IF_ICMPLE: condition = "IF_ICMPLE"; break; case Opcodes.IF_ACMPEQ: condition = "IF_ACMPEQ"; break; case Opcodes.IF_ACMPNE: condition = "IF_ACMPNE"; break; case Opcodes.GOTO: condition = "GOTO"; break; case Opcodes.JSR: condition = "JSR"; break; case Opcodes.IFNULL: condition = "IFNULL"; break; case Opcodes.IFNONNULL: condition = "IFNONNULL"; break; default: assert false; condition = "--ERROR--"; break; } return condition + " " + this.target; }
From source file:dyco4j.instrumentation.internals.InitTracingMethodVisitor.java
License:BSD License
@Override public void visitJumpInsn(final int opcode, final Label label) { mv.visitJumpInsn(opcode, label);// ww w . j ava 2 s .co m switch (opcode) { case Opcodes.IFEQ: case Opcodes.IFNE: case Opcodes.IFLT: case Opcodes.IFGE: case Opcodes.IFGT: case Opcodes.IFLE: case Opcodes.IFNULL: case Opcodes.IFNONNULL: this.stackFrame.pop(); break; case Opcodes.IF_ICMPEQ: case Opcodes.IF_ICMPNE: case Opcodes.IF_ICMPLT: case Opcodes.IF_ICMPGE: case Opcodes.IF_ICMPGT: case Opcodes.IF_ICMPLE: case Opcodes.IF_ACMPEQ: case Opcodes.IF_ACMPNE: this.stackFrame.pop(); this.stackFrame.pop(); break; case Opcodes.JSR: this.stackFrame.push(OTHER); break; } addBranch(label); }
From source file:edu.mit.streamjit.util.bytecode.MethodResolver.java
License:Open Source License
private void interpret(JumpInsnNode insn, FrameState frame, BBInfo block) { //All JumpInsnNodes have a target. Find it. BBInfo target = blockByInsn(insn.label); assert target != null; if (insn.getOpcode() == Opcodes.GOTO) { block.block.instructions().add(new JumpInst(target.block)); return;/*from w w w. j a v a 2 s . co m*/ } else if (insn.getOpcode() == Opcodes.JSR) throw new UnsupportedOperationException("jsr not supported; upgrade to Java 6-era class files"); //Remaining opcodes are branches. BBInfo fallthrough = blocks.get(blocks.indexOf(block) + 1); BranchInst.Sense sense = OPCODE_TO_SENSE.get(insn.getOpcode()); //The second operand may come from the stack or may be a constant 0 or null. Value right; switch (insn.getOpcode()) { case Opcodes.IFEQ: case Opcodes.IFNE: case Opcodes.IFLT: case Opcodes.IFGE: case Opcodes.IFGT: case Opcodes.IFLE: right = module.constants().getConstant(0); break; case Opcodes.IFNULL: case Opcodes.IFNONNULL: right = module.constants().getNullConstant(); break; case Opcodes.IF_ICMPEQ: case Opcodes.IF_ICMPNE: case Opcodes.IF_ICMPLT: case Opcodes.IF_ICMPGE: case Opcodes.IF_ICMPGT: case Opcodes.IF_ICMPLE: case Opcodes.IF_ACMPEQ: case Opcodes.IF_ACMPNE: right = frame.stack.pop(); break; default: throw new AssertionError("Can't happen! Branch opcode missing? " + insn.getOpcode()); } //First operand always comes from the stack. Value left = frame.stack.pop(); block.block.instructions().add(new BranchInst(left, sense, right, target.block, fallthrough.block)); }
From source file:edu.mit.streamjit.util.bytecode.MethodUnresolver.java
License:Open Source License
private void emit(BranchInst i, InsnList insns) { //TODO: accessor methods on BranchInst Value left = i.getOperand(0), right = i.getOperand(1); BasicBlock target = (BasicBlock) i.getOperand(2), fallthrough = (BasicBlock) i.getOperand(3); if (!method.basicBlocks().contains(target)) throw new IllegalArgumentException("Branch targets block not in method: " + i); if (!method.basicBlocks().contains(fallthrough)) throw new IllegalArgumentException("Branch falls through to block not in method: " + i); load(i.getOperand(0), insns);/*from w w w . j a v a 2 s.c om*/ load(i.getOperand(1), insns); //TODO: long, float, doubles need to go through CMP inst first int opcode; if (left.getType() instanceof ReferenceType || left.getType() instanceof VoidType) { switch (i.getSense()) { case EQ: opcode = Opcodes.IF_ACMPEQ; break; case NE: opcode = Opcodes.IF_ACMPNE; break; default: throw new AssertionError(i); } } else if (left.getType().isSubtypeOf(intType)) { switch (i.getSense()) { case EQ: opcode = Opcodes.IF_ICMPEQ; break; case NE: opcode = Opcodes.IF_ICMPNE; break; case LT: opcode = Opcodes.IF_ICMPLT; break; case GT: opcode = Opcodes.IF_ICMPGT; break; case LE: opcode = Opcodes.IF_ICMPLE; break; case GE: opcode = Opcodes.IF_ICMPGE; break; default: throw new AssertionError(i); } } else throw new AssertionError(i); insns.add(new JumpInsnNode(opcode, labels.get(target))); insns.add(new JumpInsnNode(Opcodes.GOTO, labels.get(fallthrough))); }
From source file:edu.umd.cs.guitar.testcase.plugin.edg.ClassDBVisitor.java
License:Open Source License
@Override public void visitJumpInsn(int opcode, Label label) { currentMethod.setEmpty(false);/*from w ww . j a v a 2 s.co m*/ currentMethod.setEmpty(false); switch (opcode) { case Opcodes.IFEQ: case Opcodes.IFNE: case Opcodes.IFLT: case Opcodes.IFGE: case Opcodes.IFGT: case Opcodes.IFLE: case Opcodes.IF_ICMPEQ: case Opcodes.IF_ICMPNE: case Opcodes.IF_ICMPLT: case Opcodes.IF_ICMPGE: case Opcodes.IF_ICMPGT: case Opcodes.IF_ICMPLE: case Opcodes.IF_ACMPEQ: case Opcodes.IF_ACMPNE: // case Opcodes.GOTO: // case Opcodes.JSR: case Opcodes.IFNULL: case Opcodes.IFNONNULL: // add all label reads/writes as condition reads/writes currentMethod.getConditionReads().addAll(labelReads); currentMethod.getConditionWrites().addAll(labelWrites); break; } }