List of usage examples for org.objectweb.asm Opcodes ICONST_1
int ICONST_1
To view the source code for org.objectweb.asm Opcodes ICONST_1.
Click Source Link
From source file:de.tuberlin.uebb.jbop.optimizer.array.LocalArrayValueInlinerTest.java
License:Open Source License
/** * Tests that LocalArrayValueInliner is working correctly. * // w w w. j a v a 2 s.co m * @throws Exception * the exception */ @Test public void testLocalArrayValueInliner() throws Exception { // INIT final String owner = "de.tuberlin.uebb.jbop.optimizer.array.LocalArrayValueTestClass"; final ClassNodeBuilder builder = ClassNodeBuilder.createClass(owner).// addField("doubleArray", "[[D").// withAnnotation(ImmutableArray.class).// withModifiers(Opcodes.ACC_PRIVATE, Opcodes.ACC_FINAL).// initArray(2, 2).// initMultiArrayWith(1.0, 0, 0).// initMultiArrayWith(2.0, 0, 1).// initMultiArrayWith(3.0, 1, 0).// initMultiArrayWith(4.0, 1, 1).// addMethod("getArrayValue", "()D").withAnnotation(Optimizable.class).// addGetClassField("doubleArray").// 2 -> 2 addInsn(new InsnNode(Opcodes.ICONST_0)).// 1 -> 1 addInsn(new InsnNode(Opcodes.AALOAD)).// 1 -> 1 addInsn(new VarInsnNode(Opcodes.ASTORE, 2)).// 1 -> 1 addInsn(new VarInsnNode(Opcodes.ALOAD, 2)).// 1 -> 0| addInsn(new InsnNode(Opcodes.ICONST_1)).// 1 -> 0| addInsn(new InsnNode(Opcodes.DALOAD)).// 1 -> 0| 1 addInsn(new InsnNode(Opcodes.DRETURN));// 1 -> 1 // 14 -> 12 final LocalArrayValueInliner inliner = new LocalArrayValueInliner(); inliner.setInputObject(builder.toClass().instance()); // RUN STEP 1 final MethodNode method = builder.getMethod("getArrayValue"); assertEquals(9, method.instructions.size()); final InsnList optimized = inliner.optimize(method.instructions, method); // ASSERT STEP 1 assertEquals(7, optimized.size()); assertEquals(2.0, NodeHelper.getNumberValue(optimized.get(5)).doubleValue(), .0001); // RUN STEP 2 final InsnList optimized2 = inliner.optimize(method.instructions, method); // ASSERT STEP 2 assertEquals(7, optimized2.size()); }
From source file:de.tuberlin.uebb.jbop.optimizer.controlflow.ConstantIfInlinerTest.java
License:Open Source License
/** * Tests that constantIfInliner is working correctly. * //from w ww .j a v a 2 s .c o m * Input is * * <pre> * if(1<2) * ... * </pre> * * @throws JBOPClassException * the jBOP class exception */ @Test public void testConstantIfInlinerIF_CMPEG() throws JBOPClassException { // INIT final LabelNode label = new LabelNode(); builder.addInsn(new InsnNode(Opcodes.ICONST_1)).// addInsn(new InsnNode(Opcodes.ICONST_2)).// addInsn(new JumpInsnNode(Opcodes.IF_ICMPGE, 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. * //from w w w . j a va 2 s.co m * Input is * * <pre> * if(1<=2) * ... * </pre> * * @throws JBOPClassException * the jBOP class exception */ @Test public void testConstantIfInlinerIF_ICMPGT() throws JBOPClassException { // INIT final LabelNode label = new LabelNode(); builder.addInsn(new InsnNode(Opcodes.ICONST_1)).// addInsn(new InsnNode(Opcodes.ICONST_2)).// addInsn(new JumpInsnNode(Opcodes.IF_ICMPGT, 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. * //from w w w . j a v a 2 s. co 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. * /*from w w w. j a v a 2 s .c om*/ * Input is * * <pre> * if(2>=1) * ... * </pre> * * @throws JBOPClassException * the jBOP class exception */ @Test public void testConstantIfInlinerIF_ICMPLT() 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_ICMPLT, 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. * //from w w w . j a v a 2 s. c om * Input is * * <pre> * if(1==1) * ... * </pre> * * @throws JBOPClassException * the jBOP class exception */ @Test public void testConstantIfInlinerIF_ICMPNE() throws JBOPClassException { // INIT final LabelNode label = new LabelNode(); builder.addInsn(new InsnNode(Opcodes.ICONST_1)).// addInsn(new InsnNode(Opcodes.ICONST_1)).// addInsn(new JumpInsnNode(Opcodes.IF_ICMPNE, 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. * // ww w . j a va2 s.c o m * Input is * * <pre> * if(1!=2) * ... * </pre> * * @throws JBOPClassException * the jBOP class exception */ @Test public void testConstantIfInlinerIF_ICMPEQ() throws JBOPClassException { // INIT final LabelNode label = new LabelNode(); builder.addInsn(new InsnNode(Opcodes.ICONST_1)).// addInsn(new InsnNode(Opcodes.ICONST_2)).// addInsn(new JumpInsnNode(Opcodes.IF_ICMPEQ, 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. * /*from w ww.ja v a2 s. c o m*/ * Input is * * <pre> * if(a) * ... * </pre> * * where a is true * * @throws JBOPClassException * the jBOP class exception */ @Test public void testConstantIfInlinerIFEQ() throws JBOPClassException { // INIT final LabelNode label = new LabelNode(); builder.addInsn(new InsnNode(Opcodes.ICONST_1)).// addInsn(new JumpInsnNode(Opcodes.IFEQ, label)).// addInsn(new InsnNode(Opcodes.NOP)).// addInsn(label).// addInsn(new InsnNode(Opcodes.RETURN)); // RUN assertEquals(5, 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 ww .j av a2 s . c o 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. * /* w w w .j ava 2 s . com*/ * 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()); }