List of usage examples for org.objectweb.asm Opcodes IMUL
int IMUL
To view the source code for org.objectweb.asm Opcodes IMUL.
Click Source Link
From source file:org.decojer.cavaj.readers.asm.ReadMethodVisitor.java
License:Open Source License
@Override public void visitInsn(final int opcode) { T t = null;//from w ww .j a v a 2 s. c o m int iValue = Integer.MIN_VALUE; Object oValue = null; switch (opcode) { case Opcodes.NOP: // nothing to do, ignore break; /******* * ADD * *******/ case Opcodes.DADD: t = T.DOUBLE; // fall through case Opcodes.FADD: if (t == null) { t = T.FLOAT; } // fall through case Opcodes.IADD: if (t == null) { t = T.INT; } // fall through case Opcodes.LADD: if (t == null) { t = T.LONG; } add(new ADD(this.ops.size(), opcode, this.line, t)); break; /********* * ALOAD * *********/ case Opcodes.AALOAD: t = T.REF; // fall through case Opcodes.BALOAD: if (t == null) { t = T.SMALL; } // fall through case Opcodes.CALOAD: if (t == null) { t = T.CHAR; } // fall through case Opcodes.DALOAD: if (t == null) { t = T.DOUBLE; } // fall through case Opcodes.FALOAD: if (t == null) { t = T.FLOAT; } // fall through case Opcodes.IALOAD: if (t == null) { t = T.INT; } // fall through case Opcodes.LALOAD: if (t == null) { t = T.LONG; } // fall through case Opcodes.SALOAD: if (t == null) { t = T.SHORT; } add(new ALOAD(this.ops.size(), opcode, this.line, t)); break; /******* * AND * *******/ case Opcodes.IAND: t = T.AINT; // fall through case Opcodes.LAND: if (t == null) { t = T.LONG; } add(new AND(this.ops.size(), opcode, this.line, t)); break; /*************** * ARRAYLENGTH * ***************/ case Opcodes.ARRAYLENGTH: add(new ARRAYLENGTH(this.ops.size(), opcode, this.line)); break; /********** * ASTORE * **********/ case Opcodes.AASTORE: t = T.REF; // fall through case Opcodes.BASTORE: if (t == null) { t = T.SMALL; } // fall through case Opcodes.CASTORE: if (t == null) { t = T.CHAR; } // fall through case Opcodes.DASTORE: if (t == null) { t = T.DOUBLE; } // fall through case Opcodes.FASTORE: if (t == null) { t = T.FLOAT; } // fall through case Opcodes.IASTORE: if (t == null) { t = T.INT; } // fall through case Opcodes.LASTORE: if (t == null) { t = T.LONG; } // fall through case Opcodes.SASTORE: if (t == null) { t = T.SHORT; } add(new ASTORE(this.ops.size(), opcode, this.line, t)); break; /******** * CAST * ********/ case Opcodes.D2F: t = T.DOUBLE; oValue = T.FLOAT; // fall through case Opcodes.D2I: if (t == null) { t = T.DOUBLE; oValue = T.INT; } // fall through case Opcodes.D2L: if (t == null) { t = T.DOUBLE; oValue = T.LONG; } // fall through case Opcodes.F2D: if (t == null) { t = T.FLOAT; oValue = T.DOUBLE; } // fall through case Opcodes.F2I: if (t == null) { t = T.FLOAT; oValue = T.INT; } // fall through case Opcodes.F2L: if (t == null) { t = T.FLOAT; oValue = T.LONG; } // fall through case Opcodes.I2B: if (t == null) { t = T.INT; oValue = T.BYTE; } // fall through case Opcodes.I2C: if (t == null) { t = T.INT; oValue = T.CHAR; } // fall through case Opcodes.I2D: if (t == null) { t = T.INT; oValue = T.DOUBLE; } // fall through case Opcodes.I2F: if (t == null) { t = T.INT; oValue = T.FLOAT; } // fall through case Opcodes.I2L: if (t == null) { t = T.INT; oValue = T.LONG; } // fall through case Opcodes.I2S: if (t == null) { t = T.INT; oValue = T.SHORT; } // fall through case Opcodes.L2D: if (t == null) { t = T.LONG; oValue = T.DOUBLE; } // fall through case Opcodes.L2F: if (t == null) { t = T.LONG; oValue = T.FLOAT; } // fall through case Opcodes.L2I: if (t == null) { t = T.LONG; oValue = T.INT; } assert oValue instanceof T; add(new CAST(this.ops.size(), opcode, this.line, t, (T) oValue)); break; /******* * CMP * *******/ case Opcodes.DCMPG: t = T.DOUBLE; iValue = CMP.T_G; // fall through case Opcodes.DCMPL: if (t == null) { t = T.DOUBLE; iValue = CMP.T_L; } // fall through case Opcodes.FCMPG: if (t == null) { t = T.FLOAT; iValue = CMP.T_G; } // fall through case Opcodes.FCMPL: if (t == null) { t = T.FLOAT; iValue = CMP.T_L; } // fall through case Opcodes.LCMP: if (t == null) { t = T.LONG; iValue = CMP.T_0; } add(new CMP(this.ops.size(), opcode, this.line, t, iValue)); break; /******* * DIV * *******/ case Opcodes.DDIV: t = T.DOUBLE; // fall through case Opcodes.FDIV: if (t == null) { t = T.FLOAT; } // fall through case Opcodes.IDIV: if (t == null) { t = T.INT; } // fall through case Opcodes.LDIV: if (t == null) { t = T.LONG; } add(new DIV(this.ops.size(), opcode, this.line, t)); break; /******* * DUP * *******/ case Opcodes.DUP: oValue = DUP.Kind.DUP; // fall through case Opcodes.DUP_X1: if (oValue == null) { oValue = DUP.Kind.DUP_X1; } // fall through case Opcodes.DUP_X2: if (oValue == null) { oValue = DUP.Kind.DUP_X2; } // fall through case Opcodes.DUP2: if (oValue == null) { oValue = DUP.Kind.DUP2; } // fall through case Opcodes.DUP2_X1: if (oValue == null) { oValue = DUP.Kind.DUP2_X1; } // fall through case Opcodes.DUP2_X2: if (oValue == null) { oValue = DUP.Kind.DUP2_X2; } add(new DUP(this.ops.size(), opcode, this.line, (DUP.Kind) oValue)); break; /*********** * MONITOR * ***********/ case Opcodes.MONITORENTER: oValue = MONITOR.Kind.ENTER; // fall through case Opcodes.MONITOREXIT: if (oValue == null) { oValue = MONITOR.Kind.EXIT; } add(new MONITOR(this.ops.size(), opcode, this.line, (MONITOR.Kind) oValue)); break; /******* * MUL * *******/ case Opcodes.DMUL: t = T.DOUBLE; // fall through case Opcodes.FMUL: if (t == null) { t = T.FLOAT; } // fall through case Opcodes.IMUL: if (t == null) { t = T.INT; } // fall through case Opcodes.LMUL: if (t == null) { t = T.LONG; } add(new MUL(this.ops.size(), opcode, this.line, t)); break; /******* * NEG * *******/ case Opcodes.DNEG: t = T.DOUBLE; // fall through case Opcodes.FNEG: if (t == null) { t = T.FLOAT; } // fall through case Opcodes.INEG: if (t == null) { t = T.INT; } // fall through case Opcodes.LNEG: if (t == null) { t = T.LONG; } add(new NEG(this.ops.size(), opcode, this.line, t)); break; /****** * OR * ******/ case Opcodes.IOR: t = T.AINT; // fall through case Opcodes.LOR: if (t == null) { t = T.LONG; } add(new OR(this.ops.size(), opcode, this.line, t)); break; /******* * POP * *******/ case Opcodes.POP: oValue = POP.Kind.POP; // fall through case Opcodes.POP2: if (oValue == null) { oValue = POP.Kind.POP2; } add(new POP(this.ops.size(), opcode, this.line, (POP.Kind) oValue)); break; /******** * PUSH * ********/ case Opcodes.ACONST_NULL: t = T.REF; // fall through case Opcodes.DCONST_0: if (t == null) { oValue = 0D; t = T.DOUBLE; } // fall through case Opcodes.FCONST_0: if (t == null) { oValue = 0F; t = T.FLOAT; } // fall through case Opcodes.ICONST_0: if (t == null) { oValue = 0; t = T.getJvmIntT(0); } // fall through case Opcodes.LCONST_0: if (t == null) { oValue = 0L; t = T.LONG; } // fall through case Opcodes.DCONST_1: if (t == null) { oValue = 1D; t = T.DOUBLE; } // fall through case Opcodes.FCONST_1: if (t == null) { oValue = 1F; t = T.FLOAT; } // fall through case Opcodes.ICONST_1: if (t == null) { oValue = 1; t = T.getJvmIntT(1); } // fall through case Opcodes.LCONST_1: if (t == null) { oValue = 1L; t = T.LONG; } // fall through case Opcodes.FCONST_2: if (t == null) { oValue = 2F; t = T.FLOAT; } // fall through case Opcodes.ICONST_2: if (t == null) { oValue = 2; t = T.getJvmIntT(2); } // fall through case Opcodes.ICONST_3: if (t == null) { oValue = 3; t = T.getJvmIntT(3); } // fall through case Opcodes.ICONST_4: if (t == null) { oValue = 4; t = T.getJvmIntT(4); } // fall through case Opcodes.ICONST_5: if (t == null) { oValue = 5; t = T.getJvmIntT(5); } // fall through case Opcodes.ICONST_M1: if (t == null) { oValue = -1; t = T.getJvmIntT(-1); } add(new PUSH(this.ops.size(), opcode, this.line, t, oValue)); break; /******* * REM * *******/ case Opcodes.DREM: t = T.DOUBLE; // fall through case Opcodes.FREM: if (t == null) { t = T.FLOAT; } // fall through case Opcodes.IREM: if (t == null) { t = T.INT; } // fall through case Opcodes.LREM: if (t == null) { t = T.LONG; } add(new REM(this.ops.size(), opcode, this.line, t)); break; /********** * RETURN * **********/ case Opcodes.ARETURN: t = T.REF; // fall through case Opcodes.DRETURN: if (t == null) { t = T.DOUBLE; } // fall through case Opcodes.FRETURN: if (t == null) { t = T.FLOAT; } // fall through case Opcodes.IRETURN: if (t == null) { t = T.AINT; } // fall through case Opcodes.LRETURN: if (t == null) { t = T.LONG; } // fall through case Opcodes.RETURN: if (t == null) { t = T.VOID; } add(new RETURN(this.ops.size(), opcode, this.line, t)); break; /******* * SHL * *******/ case Opcodes.ISHL: t = T.INT; // fall through case Opcodes.LSHL: if (t == null) { t = T.LONG; } add(new SHL(this.ops.size(), opcode, this.line, t, T.INT)); break; /******* * SHR * *******/ case Opcodes.ISHR: case Opcodes.IUSHR: t = T.INT; // fall through case Opcodes.LSHR: case Opcodes.LUSHR: if (t == null) { t = T.LONG; } add(new SHR(this.ops.size(), opcode, this.line, t, T.INT, opcode == Opcodes.IUSHR || opcode == Opcodes.LUSHR)); break; /******* * SUB * *******/ case Opcodes.DSUB: t = T.DOUBLE; // fall through case Opcodes.FSUB: if (t == null) { t = T.FLOAT; } // fall through case Opcodes.ISUB: if (t == null) { t = T.INT; } // fall through case Opcodes.LSUB: if (t == null) { t = T.LONG; } add(new SUB(this.ops.size(), opcode, this.line, t)); break; /******** * SWAP * ********/ case Opcodes.SWAP: add(new SWAP(this.ops.size(), opcode, this.line)); break; /********* * THROW * *********/ case Opcodes.ATHROW: add(new THROW(this.ops.size(), opcode, this.line)); break; /******* * XOR * *******/ case Opcodes.IXOR: t = T.AINT; // fall through case Opcodes.LXOR: { if (t == null) { t = T.LONG; } add(new XOR(this.ops.size(), opcode, this.line, t)); break; } default: log.warn(getM() + ": Unknown insn opcode '" + opcode + "'!"); } }
From source file:org.evosuite.instrumentation.error.ErrorConditionChecker.java
License:Open Source License
/** * <p>//from w ww. j a va 2 s. c o m * overflowDistance * </p> * * @param op1 * a int. * @param op2 * a int. * @param opcode * a int. * @return a int. */ public static int overflowDistance(int op1, int op2, int opcode) { switch (opcode) { case Opcodes.IADD: int result = overflowDistanceAdd(op1, op2); logger.debug("O: " + op1 + " + " + op2 + " = " + (op1 + op2) + " -> " + result); return result; case Opcodes.ISUB: return overflowDistanceSub(op1, op2); case Opcodes.IMUL: return overflowDistanceMul(op1, op2); case Opcodes.IDIV: return overflowDistanceDiv(op1, op2); } return Integer.MAX_VALUE; }
From source file:org.evosuite.instrumentation.error.ErrorConditionChecker.java
License:Open Source License
public static int underflowDistance(int op1, int op2, int opcode) { switch (opcode) { case Opcodes.IADD: int result = underflowDistanceAdd(op1, op2); logger.debug("U: " + op1 + " + " + op2 + " = " + (op1 + op2) + " -> " + result); return result; case Opcodes.ISUB: return underflowDistanceSub(op1, op2); case Opcodes.IMUL: return underflowDistanceMul(op1, op2); }/*from ww w .j av a2 s . c om*/ return Integer.MAX_VALUE; }
From source file:org.evosuite.instrumentation.error.OverflowInstrumentation.java
License:Open Source License
@Override public void visitInsn(int opcode) { // Overflow checks switch (opcode) { case Opcodes.IADD: case Opcodes.ISUB: case Opcodes.IMUL: mv.visitInsn(Opcodes.DUP2);/*from ww w . j a v a 2 s . co m*/ mv.visitLdcInsn(opcode); mv.visitMethodInsn(Opcodes.INVOKESTATIC, CHECKER, "underflowDistance", "(III)I", false); insertBranchWithoutException(Opcodes.IFGT); case Opcodes.IDIV: mv.visitInsn(Opcodes.DUP2); mv.visitLdcInsn(opcode); mv.visitMethodInsn(Opcodes.INVOKESTATIC, CHECKER, "overflowDistance", "(III)I", false); insertBranchWithoutException(Opcodes.IFGT); break; case Opcodes.FADD: case Opcodes.FSUB: case Opcodes.FMUL: mv.visitInsn(Opcodes.DUP2); mv.visitLdcInsn(opcode); mv.visitMethodInsn(Opcodes.INVOKESTATIC, CHECKER, "underflowDistance", "(FFI)I", false); insertBranchWithoutException(Opcodes.IFGE); case Opcodes.FDIV: mv.visitInsn(Opcodes.DUP2); mv.visitLdcInsn(opcode); mv.visitMethodInsn(Opcodes.INVOKESTATIC, CHECKER, "overflowDistance", "(FFI)I", false); insertBranchWithoutException(Opcodes.IFGE); break; case Opcodes.DADD: case Opcodes.DSUB: case Opcodes.DMUL: int loc = mv.newLocal(Type.DOUBLE_TYPE); mv.storeLocal(loc); mv.visitInsn(Opcodes.DUP2); mv.loadLocal(loc); mv.visitInsn(Opcodes.DUP2_X2); mv.visitLdcInsn(opcode); mv.visitMethodInsn(Opcodes.INVOKESTATIC, CHECKER, "underflowDistance", "(DDI)I", false); insertBranchWithoutException(Opcodes.IFGE); case Opcodes.DDIV: loc = mv.newLocal(Type.DOUBLE_TYPE); mv.storeLocal(loc); mv.visitInsn(Opcodes.DUP2); mv.loadLocal(loc); mv.visitInsn(Opcodes.DUP2_X2); mv.visitLdcInsn(opcode); mv.visitMethodInsn(Opcodes.INVOKESTATIC, CHECKER, "overflowDistance", "(DDI)I", false); insertBranchWithoutException(Opcodes.IFGE); break; case Opcodes.LADD: case Opcodes.LSUB: case Opcodes.LMUL: int loc2 = mv.newLocal(Type.LONG_TYPE); mv.storeLocal(loc2); mv.visitInsn(Opcodes.DUP2); mv.loadLocal(loc2); mv.visitInsn(Opcodes.DUP2_X2); mv.visitLdcInsn(opcode); mv.visitMethodInsn(Opcodes.INVOKESTATIC, CHECKER, "underflowDistance", "(JJI)I", false); insertBranchWithoutException(Opcodes.IFGE); case Opcodes.LDIV: loc2 = mv.newLocal(Type.LONG_TYPE); mv.storeLocal(loc2); mv.visitInsn(Opcodes.DUP2); mv.loadLocal(loc2); mv.visitInsn(Opcodes.DUP2_X2); mv.visitLdcInsn(opcode); mv.visitMethodInsn(Opcodes.INVOKESTATIC, CHECKER, "overflowDistance", "(JJI)I", false); insertBranchWithoutException(Opcodes.IFGE); break; } }
From source file:org.evosuite.instrumentation.error.TestIntOverflow.java
License:Open Source License
@Test public void testMulOverflow() { int result = ErrorConditionChecker.overflowDistance(x, y, Opcodes.IMUL); assertOverflow((long) x * (long) y, result); }
From source file:org.evosuite.instrumentation.error.TestIntUnderflow.java
License:Open Source License
@Test public void testMulUnderflow() { int result = ErrorConditionChecker.underflowDistance(x, y, Opcodes.IMUL); assertUnderflow((long) x * (long) y, result); }
From source file:org.evosuite.instrumentation.ErrorConditionChecker.java
License:Open Source License
/** * <p>// w w w .ja va 2s . c o m * overflowDistance * </p> * * @param op1 * a int. * @param op2 * a int. * @param opcode * a int. * @return a int. */ public static int overflowDistance(int op1, int op2, int opcode) { switch (opcode) { case Opcodes.IADD: int result = overflowDistanceAdd(op1, op2); logger.debug("O: {} + {} = {} -> {}", op1, op2, op1 + op2, result); return result; case Opcodes.ISUB: return overflowDistanceSub(op1, op2); case Opcodes.IMUL: return overflowDistanceMul(op1, op2); case Opcodes.IDIV: return overflowDistanceDiv(op1, op2); } return Integer.MAX_VALUE; }
From source file:org.evosuite.instrumentation.ErrorConditionChecker.java
License:Open Source License
public static int underflowDistance(int op1, int op2, int opcode) { switch (opcode) { case Opcodes.IADD: int result = underflowDistanceAdd(op1, op2); logger.debug("U: {} + {} = {} -> {}", op1, op2, op1 + op2, result); return result; case Opcodes.ISUB: return underflowDistanceSub(op1, op2); case Opcodes.IMUL: return underflowDistanceMul(op1, op2); }/*from www .j a v a 2 s. c o m*/ return Integer.MAX_VALUE; }
From source file:org.evosuite.instrumentation.mutation.ReplaceArithmeticOperator.java
License:Open Source License
/** * <p>calculate</p>//from w w w . j a v a 2s . c o m * * @param x a int. * @param y a int. * @param opcode a int. * @return a int. */ public static int calculate(int x, int y, int opcode) { switch (opcode) { case Opcodes.IADD: return x + y; case Opcodes.ISUB: return x - y; case Opcodes.IMUL: return x * y; case Opcodes.IDIV: return x / y; case Opcodes.IREM: return x % y; } throw new RuntimeException("Unknown integer opcode: " + opcode); }
From source file:org.evosuite.javaagent.ErrorConditionCheckerTest.java
License:Open Source License
@Test public void testIntMulOverflow() { int distance = ErrorConditionChecker.overflowDistance(Integer.MAX_VALUE, 2, Opcodes.IMUL); assertTrue(distance <= 0);/*from w ww. j a v a 2 s. c o m*/ distance = ErrorConditionChecker.overflowDistance(Integer.MAX_VALUE / 2, 3, Opcodes.IMUL); assertTrue(distance <= 0); distance = ErrorConditionChecker.overflowDistance(Integer.MIN_VALUE, -2, Opcodes.IMUL); assertTrue(distance <= 0); distance = ErrorConditionChecker.overflowDistance(Integer.MIN_VALUE, -1, Opcodes.IMUL); assertTrue(distance <= 0); distance = ErrorConditionChecker.overflowDistance(-15000000, -15000000, Opcodes.IMUL); assertTrue(distance <= 0); int distance1 = ErrorConditionChecker.overflowDistance(10, 10, Opcodes.IMUL); assertTrue("Expected value greater 0 but got " + distance1, distance1 > 0); int distance2 = ErrorConditionChecker.overflowDistance(10, 1000, Opcodes.IMUL); assertTrue("Expected value greater 0 but got " + distance2, distance2 > 0); assertTrue("Invalid ranking: " + distance1 + ", " + distance2, distance2 < distance1); distance2 = ErrorConditionChecker.overflowDistance(-10, 1000, Opcodes.IMUL); assertTrue("Expected value greater 0 but got " + distance2, distance2 > 0); assertTrue("Invalid ranking: " + distance1 + ", " + distance2, distance2 > distance1); int distance3 = ErrorConditionChecker.overflowDistance(-100, 1000, Opcodes.IMUL); assertTrue("Expected value greater 0 but got " + distance3, distance3 > 0); assertTrue("Invalid ranking: " + distance1 + ", " + distance2, distance3 > distance2); distance1 = ErrorConditionChecker.overflowDistance(-100, -100, Opcodes.IMUL); assertTrue("Expected value greater 0 but got " + distance1, distance1 > 0); distance2 = ErrorConditionChecker.overflowDistance(100, 1000, Opcodes.IMUL); assertTrue("Expected value greater 0 but got " + distance2, distance2 > 0); assertTrue("Invalid ranking: " + distance1 + ", " + distance2, distance2 < distance1); }