List of usage examples for org.objectweb.asm Opcodes LSUB
int LSUB
To view the source code for org.objectweb.asm Opcodes LSUB.
Click Source Link
From source file:io.awacs.plugin.springmvc.ServiceWrapper.java
License:Apache License
/** * origin method: (XXX)X//from w ww .j a va 2 s . c o m * <p> * proxy method: (XXXLjavax/servlet/http/HttpServletRequest;)X * req -> localIndex - 1 * * @param cn * @param origin * @return */ private MethodNode doProxy(ClassNode cn, MethodNode origin) { MethodNode newNode = copyMethod(origin); //move annotations hideAnnotations(origin); LabelNode l0 = new LabelNode(); LabelNode l1 = new LabelNode(); LabelNode l2 = new LabelNode(); String returnType = origin.desc.substring(origin.desc.indexOf(')') + 1); int localIndex = copyParameters(origin, newNode, l0, l2); newNode.tryCatchBlocks.add(new TryCatchBlockNode(l0, l1, l2, "java/lang/Exception")); //localIndex -> elapsedTime newNode.localVariables.add(new LocalVariableNode("elapsedTime", "J", null, l0, l1, localIndex)); // newNode.instructions.add(l0); // long elapsedTime = System.currentTimeMillis(); newNode.instructions .add(new MethodInsnNode(Opcodes.INVOKESTATIC, "java/lang/System", "currentTimeMillis", "()J")); newNode.instructions.add(new VarInsnNode(Opcodes.LSTORE, localIndex)); int paramCount = getParamCount(origin.desc, origin.access); //load? for (int i = 0; i < paramCount; i++) { LocalVariableNode node = (LocalVariableNode) newNode.localVariables.get(i); switch (node.desc) { case "J": newNode.instructions.add(new VarInsnNode(Opcodes.LLOAD, node.index)); break; case "D": newNode.instructions.add(new VarInsnNode(Opcodes.DLOAD, node.index)); break; case "F": newNode.instructions.add(new VarInsnNode(Opcodes.FLOAD, node.index)); break; case "I": newNode.instructions.add(new VarInsnNode(Opcodes.ILOAD, node.index)); break; case "S": newNode.instructions.add(new VarInsnNode(Opcodes.ILOAD, node.index)); break; case "Z": newNode.instructions.add(new VarInsnNode(Opcodes.ILOAD, node.index)); break; case "B": newNode.instructions.add(new VarInsnNode(Opcodes.ILOAD, node.index)); break; case "C": newNode.instructions.add(new VarInsnNode(Opcodes.ILOAD, node.index)); break; default: newNode.instructions.add(new VarInsnNode(Opcodes.ALOAD, node.index)); break; } } // newNode.instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, cn.name, origin.name, origin.desc)); // newNode.instructions .add(new MethodInsnNode(Opcodes.INVOKESTATIC, "java/lang/System", "currentTimeMillis", "()J")); newNode.instructions.add(new VarInsnNode(Opcodes.LLOAD, localIndex)); newNode.instructions.add(new InsnNode(Opcodes.LSUB)); newNode.instructions.add(new VarInsnNode(Opcodes.LSTORE, localIndex)); newNode.instructions.add(new VarInsnNode(Opcodes.ALOAD, localIndex - 1)); newNode.instructions.add(new MethodInsnNode(Opcodes.INVOKEINTERFACE, "javax/servlet/http/HttpServletRequest", "getRequestURI", "()Ljava/lang/String;")); //? newNode.instructions.add(new VarInsnNode(Opcodes.LLOAD, localIndex)); //SpringmvcPlugin.incrAccess(uri, elapsedTime); newNode.instructions.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "io/awacs/plugin/springmvc/SpringmvcPlugin", "incrAccess", "(Ljava/lang/String;J)V")); // newNode.instructions.add(l1); switch (returnType) { case "J": newNode.instructions.add(new InsnNode(Opcodes.LRETURN)); break; case "D": newNode.instructions.add(new InsnNode(Opcodes.DRETURN)); break; case "F": newNode.instructions.add(new InsnNode(Opcodes.FRETURN)); break; case "I": newNode.instructions.add(new InsnNode(Opcodes.IRETURN)); break; case "S": newNode.instructions.add(new InsnNode(Opcodes.IRETURN)); break; case "C": newNode.instructions.add(new InsnNode(Opcodes.IRETURN)); break; case "B": newNode.instructions.add(new InsnNode(Opcodes.IRETURN)); break; case "Z": newNode.instructions.add(new InsnNode(Opcodes.IRETURN)); break; default: newNode.instructions.add(new InsnNode(Opcodes.ARETURN)); break; } newNode.instructions.add(l2); newNode.instructions .add(new FrameNode(Opcodes.F_SAME1, 0, null, 1, new Object[] { "java/lang/Exception" })); newNode.instructions.add(new VarInsnNode(Opcodes.ASTORE, localIndex)); newNode.instructions.add(new VarInsnNode(Opcodes.ALOAD, localIndex - 1)); newNode.instructions.add(new MethodInsnNode(Opcodes.INVOKEINTERFACE, "javax/servlet/http/HttpServletRequest", "getRequestURI", "()Ljava/lang/String;")); newNode.instructions.add(new VarInsnNode(Opcodes.ALOAD, localIndex)); newNode.instructions .add(new MethodInsnNode(Opcodes.INVOKESTATIC, "io/awacs/plugin/springmvc/SpringmvcPlugin", "incrFailure", "(Ljava/lang/String;Ljava/lang/Throwable;)V")); newNode.instructions.add(new VarInsnNode(Opcodes.ALOAD, localIndex)); newNode.instructions.add(new InsnNode(Opcodes.ATHROW)); newNode.maxLocals = origin.maxLocals + 3; newNode.maxStack = Math.max(localIndex + 2, 6); return newNode; }
From source file:org.adjective.stout.tools.StackVisualiserMethodVisitor.java
License:Apache License
public void visitInsn(int opcode) { switch (opcode) { case Opcodes.NOP: break;/*from w w w .ja v a 2 s.c o m*/ case Opcodes.ACONST_NULL: push("null", Object.class); break; case Opcodes.ICONST_M1: case Opcodes.ICONST_0: case Opcodes.ICONST_1: case Opcodes.ICONST_2: case Opcodes.ICONST_3: case Opcodes.ICONST_4: case Opcodes.ICONST_5: push(Integer.toString(opcode - Opcodes.ICONST_0), Type.INT_TYPE); break; case Opcodes.LCONST_0: case Opcodes.LCONST_1: push(Integer.toString(opcode - Opcodes.LCONST_0), Type.LONG_TYPE); break; case Opcodes.FCONST_0: case Opcodes.FCONST_1: case Opcodes.FCONST_2: push(Integer.toString(opcode - Opcodes.FCONST_0), Type.FLOAT_TYPE); break; case Opcodes.DCONST_0: case Opcodes.DCONST_1: push(Integer.toString(opcode - Opcodes.DCONST_0), Type.DOUBLE_TYPE); break; case Opcodes.IALOAD: case Opcodes.LALOAD: case Opcodes.FALOAD: case Opcodes.DALOAD: case Opcodes.AALOAD: case Opcodes.BALOAD: case Opcodes.CALOAD: case Opcodes.SALOAD: { Type opType = getType(Opcodes.IALOAD, opcode); StackValue idx = pop(Type.INT_TYPE); StackValue arr = popArray(opType); push(arr.description + "[" + idx.description + "]", opType); } break; case Opcodes.IASTORE: case Opcodes.LASTORE: case Opcodes.FASTORE: case Opcodes.DASTORE: case Opcodes.AASTORE: case Opcodes.BASTORE: case Opcodes.CASTORE: case Opcodes.SASTORE: { Type opType = getType(Opcodes.IASTORE, opcode); pop(opType); pop(Type.INT_TYPE); popArray(opType); } break; case Opcodes.POP: pop(); break; case Opcodes.POP2: pop(2); break; case Opcodes.DUP: push(peek()); break; case Opcodes.DUP2: push(peek(2)); push(peek(1)); break; case Opcodes.DUP_X1: { StackValue a = pop(); StackValue b = pop(); push(a); push(b); push(a); } break; case Opcodes.DUP_X2: { StackValue a = pop(); StackValue b = pop(); StackValue c = pop(); push(a); push(c); push(b); push(a); } break; case Opcodes.DUP2_X1: { StackValue a = popValue(false); StackValue b = pop(); StackValue c = pop(); push(b); push(a); push(c); push(b); push(a); } case Opcodes.DUP2_X2: { StackValue a = popValue(false); StackValue b = pop(); StackValue c = popValue(false); StackValue d = pop(); push(b); push(a); push(d); push(c); push(b); push(a); } break; case Opcodes.SWAP: { StackValue a = pop(); StackValue b = pop(); push(a); push(b); } break; case Opcodes.IADD: case Opcodes.LADD: case Opcodes.FADD: case Opcodes.DADD: math(Opcodes.IADD, opcode, "+"); break; case Opcodes.ISUB: case Opcodes.LSUB: case Opcodes.FSUB: case Opcodes.DSUB: math(Opcodes.ISUB, opcode, "-"); break; case Opcodes.IMUL: case Opcodes.LMUL: case Opcodes.FMUL: case Opcodes.DMUL: math(Opcodes.IMUL, opcode, "*"); break; case Opcodes.IDIV: case Opcodes.LDIV: case Opcodes.FDIV: case Opcodes.DDIV: math(Opcodes.IDIV, opcode, "/"); break; case Opcodes.IREM: case Opcodes.LREM: case Opcodes.FREM: case Opcodes.DREM: math(Opcodes.IREM, opcode, "%"); break; case Opcodes.IAND: case Opcodes.LAND: math(Opcodes.IAND, opcode, "&"); break; case Opcodes.IOR: case Opcodes.LOR: math(Opcodes.IOR, opcode, "|"); break; case Opcodes.IXOR: case Opcodes.LXOR: math(Opcodes.IXOR, opcode, "^"); break; case Opcodes.INEG: case Opcodes.LNEG: case Opcodes.FNEG: case Opcodes.DNEG: { Type type = getType(Opcodes.INEG, opcode); StackValue a = pop(type); push("-" + a.description, type); } break; case Opcodes.ISHL: case Opcodes.LSHL: { Type type = getType(Opcodes.ISHL, opcode); StackValue n = pop(Type.INT_TYPE); StackValue a = pop(type); push(a.description + "<<" + n.description, type); } break; case Opcodes.ISHR: case Opcodes.LSHR: { Type type = getType(Opcodes.ISHR, opcode); StackValue n = pop(Type.INT_TYPE); StackValue a = pop(type); push(a.description + ">>" + n.description, type); } break; case Opcodes.IUSHR: case Opcodes.LUSHR: { Type type = getType(Opcodes.IUSHR, opcode); StackValue n = pop(Type.INT_TYPE); StackValue a = pop(type); push(a.description + ">>>" + n.description, type); } case Opcodes.LCMP: { StackValue a = pop(Type.LONG_TYPE); StackValue b = pop(Type.LONG_TYPE); push(a.description + " cmp " + b.description + " {-1|0|1}", Type.LONG_TYPE); } break; case Opcodes.I2L: case Opcodes.I2F: case Opcodes.I2D: case Opcodes.L2I: case Opcodes.L2F: case Opcodes.L2D: case Opcodes.F2I: case Opcodes.F2L: case Opcodes.F2D: case Opcodes.D2I: case Opcodes.D2L: case Opcodes.D2F: case Opcodes.I2B: case Opcodes.I2C: case Opcodes.I2S: cast(opcode); break; case Opcodes.ARETURN: case Opcodes.ATHROW: popObject(); break; case Opcodes.RETURN: break; default: throw new IllegalArgumentException("Unsupported opcode " + opcode + " - " + OPCODES[opcode]); } print(opcode, ""); /* * FCMPL, FCMPG, DCMPL, DCMPG, IRETURN, LRETURN, * FRETURN, DRETURN, ARETURN, RETURN, ARRAYLENGTH, ATHROW, * MONITORENTER, or MONITOREXIT */ }
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 w w .jav a2 s .com 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
public static int overflowDistance(long op1, long op2, int opcode) { switch (opcode) { case Opcodes.LADD: return overflowDistanceAdd(op1, op2); case Opcodes.LSUB: return overflowDistanceSub(op1, op2); case Opcodes.LMUL: return overflowDistanceMul(op1, op2); case Opcodes.LDIV: return overflowDistanceDiv(op1, op2); }/*from w w w. jav a 2 s . c o m*/ return Integer.MAX_VALUE; }
From source file:org.evosuite.instrumentation.error.ErrorConditionChecker.java
License:Open Source License
public static int underflowDistance(long op1, long op2, int opcode) { switch (opcode) { case Opcodes.LADD: return underflowDistanceAdd(op1, op2); case Opcodes.LSUB: return underflowDistanceSub(op1, op2); case Opcodes.LMUL: return underflowDistanceMul(op1, op2); }/*from www.ja v a2 s. co m*/ 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 w w w . j a va 2s. c o 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.TestLongOverflow.java
License:Open Source License
@Test public void testSubOverflow() { int result = ErrorConditionChecker.overflowDistance(x, y, Opcodes.LSUB); assertOverflow(new BigDecimal(x).subtract(new BigDecimal(y)), result, x - y); }
From source file:org.evosuite.instrumentation.error.TestLongUnderflow.java
License:Open Source License
@Test public void testSubUnderflow() { int result = ErrorConditionChecker.underflowDistance(x, y, Opcodes.LSUB); assertUnderflow(new BigDecimal(x).subtract(new BigDecimal(y)), result, x - y); }
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 . co m*/ * * @param x a long. * @param y a long. * @param opcode a int. * @return a long. */ public static long calculate(long x, long y, int opcode) { switch (opcode) { case Opcodes.LADD: return x + y; case Opcodes.LSUB: return x - y; case Opcodes.LMUL: return x * y; case Opcodes.LDIV: return x / y; case Opcodes.LREM: return x % y; } throw new RuntimeException("Unknown integer opcode: " + opcode); }
From source file:org.jacoco.core.internal.instr.FrameTracker.java
License:Open Source License
@Override public void visitInsn(final int opcode) { final Object t1, t2, t3, t4; switch (opcode) { case Opcodes.NOP: case Opcodes.RETURN: break;/* w w w. ja va 2 s . co m*/ case Opcodes.ARETURN: case Opcodes.ATHROW: case Opcodes.FRETURN: case Opcodes.IRETURN: case Opcodes.MONITORENTER: case Opcodes.MONITOREXIT: case Opcodes.POP: pop(1); break; case Opcodes.DRETURN: case Opcodes.LRETURN: case Opcodes.POP2: pop(2); break; case Opcodes.AASTORE: case Opcodes.BASTORE: case Opcodes.CASTORE: case Opcodes.FASTORE: case Opcodes.IASTORE: case Opcodes.SASTORE: pop(3); break; case Opcodes.LASTORE: case Opcodes.DASTORE: pop(4); break; case Opcodes.ICONST_M1: case Opcodes.ICONST_0: case Opcodes.ICONST_1: case Opcodes.ICONST_2: case Opcodes.ICONST_3: case Opcodes.ICONST_4: case Opcodes.ICONST_5: push(Opcodes.INTEGER); break; case Opcodes.ARRAYLENGTH: case Opcodes.F2I: case Opcodes.I2B: case Opcodes.I2C: case Opcodes.I2S: case Opcodes.INEG: pop(1); push(Opcodes.INTEGER); break; case Opcodes.BALOAD: case Opcodes.CALOAD: case Opcodes.D2I: case Opcodes.FCMPG: case Opcodes.FCMPL: case Opcodes.IADD: case Opcodes.IALOAD: case Opcodes.IAND: case Opcodes.IDIV: case Opcodes.IMUL: case Opcodes.IOR: case Opcodes.IREM: case Opcodes.ISHL: case Opcodes.ISHR: case Opcodes.ISUB: case Opcodes.IUSHR: case Opcodes.IXOR: case Opcodes.L2I: case Opcodes.SALOAD: pop(2); push(Opcodes.INTEGER); break; case Opcodes.DCMPG: case Opcodes.DCMPL: case Opcodes.LCMP: pop(4); push(Opcodes.INTEGER); break; case Opcodes.FCONST_0: case Opcodes.FCONST_1: case Opcodes.FCONST_2: push(Opcodes.FLOAT); break; case Opcodes.FNEG: case Opcodes.I2F: pop(1); push(Opcodes.FLOAT); break; case Opcodes.D2F: case Opcodes.FADD: case Opcodes.FALOAD: case Opcodes.FDIV: case Opcodes.FMUL: case Opcodes.FREM: case Opcodes.FSUB: case Opcodes.L2F: pop(2); push(Opcodes.FLOAT); break; case Opcodes.LCONST_0: case Opcodes.LCONST_1: push(Opcodes.LONG); push(Opcodes.TOP); break; case Opcodes.F2L: case Opcodes.I2L: pop(1); push(Opcodes.LONG); push(Opcodes.TOP); break; case Opcodes.D2L: case Opcodes.LALOAD: case Opcodes.LNEG: pop(2); push(Opcodes.LONG); push(Opcodes.TOP); break; case Opcodes.LSHL: case Opcodes.LSHR: case Opcodes.LUSHR: pop(3); push(Opcodes.LONG); push(Opcodes.TOP); break; case Opcodes.LADD: case Opcodes.LAND: case Opcodes.LDIV: case Opcodes.LMUL: case Opcodes.LOR: case Opcodes.LREM: case Opcodes.LSUB: case Opcodes.LXOR: pop(4); push(Opcodes.LONG); push(Opcodes.TOP); break; case Opcodes.DCONST_0: case Opcodes.DCONST_1: push(Opcodes.DOUBLE); push(Opcodes.TOP); break; case Opcodes.F2D: case Opcodes.I2D: pop(1); push(Opcodes.DOUBLE); push(Opcodes.TOP); break; case Opcodes.DALOAD: case Opcodes.DNEG: case Opcodes.L2D: pop(2); push(Opcodes.DOUBLE); push(Opcodes.TOP); break; case Opcodes.DADD: case Opcodes.DDIV: case Opcodes.DMUL: case Opcodes.DREM: case Opcodes.DSUB: pop(4); push(Opcodes.DOUBLE); push(Opcodes.TOP); break; case Opcodes.ACONST_NULL: push(Opcodes.NULL); break; case Opcodes.AALOAD: pop(1); t1 = pop(); push(Type.getType(((String) t1).substring(1))); break; case Opcodes.DUP: t1 = pop(); push(t1); push(t1); break; case Opcodes.DUP_X1: t1 = pop(); t2 = pop(); push(t1); push(t2); push(t1); break; case Opcodes.DUP_X2: t1 = pop(); t2 = pop(); t3 = pop(); push(t1); push(t3); push(t2); push(t1); break; case Opcodes.DUP2: t1 = pop(); t2 = pop(); push(t2); push(t1); push(t2); push(t1); break; case Opcodes.DUP2_X1: t1 = pop(); t2 = pop(); t3 = pop(); push(t2); push(t1); push(t3); push(t2); push(t1); break; case Opcodes.DUP2_X2: t1 = pop(); t2 = pop(); t3 = pop(); t4 = pop(); push(t2); push(t1); push(t4); push(t3); push(t2); push(t1); break; case Opcodes.SWAP: t1 = pop(); t2 = pop(); push(t1); push(t2); break; default: throw new IllegalArgumentException(); } mv.visitInsn(opcode); }