List of usage examples for org.objectweb.asm Opcodes INVOKESTATIC
int INVOKESTATIC
To view the source code for org.objectweb.asm Opcodes INVOKESTATIC.
Click Source Link
From source file:org.evosuite.graphs.cfg.ASMWrapper.java
License:Open Source License
/** * <p>//w w w .j a v a 2s . c o m * isInvokeStatic * </p> * * @return a boolean representing whether the instruction is a static method * call. */ public boolean isInvokeStatic() { if (asmNode instanceof MethodInsnNode) { return (asmNode.getOpcode() == Opcodes.INVOKESTATIC); } return false; }
From source file:org.evosuite.graphs.cfg.BytecodeInstructionPool.java
License:Open Source License
/** * Determine how many bytes the current instruction occupies together with * its operands//from ww w.ja v a 2 s. c o m * * @return */ private int getBytecodeIncrement(AbstractInsnNode instructionNode) { int opcode = instructionNode.getOpcode(); switch (opcode) { case Opcodes.ALOAD: // index case Opcodes.ASTORE: // index case Opcodes.DLOAD: case Opcodes.DSTORE: case Opcodes.FLOAD: case Opcodes.FSTORE: case Opcodes.ILOAD: case Opcodes.ISTORE: case Opcodes.LLOAD: case Opcodes.LSTORE: VarInsnNode varNode = (VarInsnNode) instructionNode; if (varNode.var > 3) return 1; else return 0; case Opcodes.BIPUSH: // byte case Opcodes.NEWARRAY: case Opcodes.RET: return 1; case Opcodes.LDC: LdcInsnNode ldcNode = (LdcInsnNode) instructionNode; if (ldcNode.cst instanceof Double || ldcNode.cst instanceof Long) return 2; // LDC2_W else return 1; case 19: //LDC_W case 20: //LDC2_W return 2; case Opcodes.ANEWARRAY: // indexbyte1, indexbyte2 case Opcodes.CHECKCAST: // indexbyte1, indexbyte2 case Opcodes.GETFIELD: case Opcodes.GETSTATIC: case Opcodes.GOTO: case Opcodes.IF_ACMPEQ: case Opcodes.IF_ACMPNE: case Opcodes.IF_ICMPEQ: case Opcodes.IF_ICMPNE: case Opcodes.IF_ICMPGE: case Opcodes.IF_ICMPGT: case Opcodes.IF_ICMPLE: case Opcodes.IF_ICMPLT: case Opcodes.IFLE: case Opcodes.IFLT: case Opcodes.IFGE: case Opcodes.IFGT: case Opcodes.IFNE: case Opcodes.IFEQ: case Opcodes.IFNONNULL: case Opcodes.IFNULL: case Opcodes.IINC: case Opcodes.INSTANCEOF: case Opcodes.INVOKESPECIAL: case Opcodes.INVOKESTATIC: case Opcodes.INVOKEVIRTUAL: case Opcodes.JSR: case Opcodes.NEW: case Opcodes.PUTFIELD: case Opcodes.PUTSTATIC: case Opcodes.SIPUSH: // case Opcodes.LDC_W // case Opcodes.LDC2_W return 2; case Opcodes.MULTIANEWARRAY: return 3; case Opcodes.INVOKEDYNAMIC: case Opcodes.INVOKEINTERFACE: return 4; case Opcodes.LOOKUPSWITCH: case Opcodes.TABLESWITCH: // TODO: Could be more return 4; // case Opcodes.GOTO_W // case Opcodes.JSR_W } return 0; }
From source file:org.evosuite.instrumentation.BooleanTestabilityTransformation.java
License:Open Source License
/** * Insert a call to the isNull helper function * //from ww w. j a v a 2s .com * @param opcode * @param position * @param list */ public void insertPushNull(int opcode, JumpInsnNode position, InsnList list) { int branchId = getBranchID(currentMethodNode, position); logger.info("Inserting instrumentation for NULL check at branch {} in method {}", branchId, currentMethodNode.name); MethodInsnNode nullCheck = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "isNull", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.getType(Object.class), Type.INT_TYPE })); list.insertBefore(position, new InsnNode(Opcodes.DUP)); list.insertBefore(position, new LdcInsnNode(opcode)); list.insertBefore(position, nullCheck); //list.insertBefore(position, // new LdcInsnNode(getBranchID(currentMethodNode, position))); insertBranchIdPlaceholder(currentMethodNode, position, branchId); MethodInsnNode push = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "pushPredicate", Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { Type.INT_TYPE, Type.INT_TYPE })); list.insertBefore(position, push); }
From source file:org.evosuite.instrumentation.BooleanTestabilityTransformation.java
License:Open Source License
/** * Insert a call to the reference equality check helper function * //from w ww . ja v a 2 s .c o m * @param opcode * @param position * @param list */ public void insertPushEquals(int opcode, JumpInsnNode position, InsnList list) { MethodInsnNode equalCheck = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "isEqual", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.getType(Object.class), Type.getType(Object.class), Type.INT_TYPE })); list.insertBefore(position, new InsnNode(Opcodes.DUP2)); list.insertBefore(position, new LdcInsnNode(opcode)); list.insertBefore(position, equalCheck); //list.insertBefore(position, // new LdcInsnNode(getBranchID(currentMethodNode, position))); insertBranchIdPlaceholder(currentMethodNode, position); MethodInsnNode push = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "pushPredicate", Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { Type.INT_TYPE, Type.INT_TYPE })); list.insertBefore(position, push); }
From source file:org.evosuite.instrumentation.BooleanTestabilityTransformation.java
License:Open Source License
/** * Insert a call to the distance function for unary comparison * // www . j a va 2 s.c o m * @param opcode * @param position * @param list */ public void insertPush(int opcode, JumpInsnNode position, InsnList list) { list.insertBefore(position, new InsnNode(Opcodes.DUP)); // TODO: We have to put a placeholder here instead of the actual branch ID // TODO: And then later add another transformation where we replace this with // actual branch IDs //list.insertBefore(position, // new LdcInsnNode(getBranchID(currentMethodNode, position))); insertBranchIdPlaceholder(currentMethodNode, position); MethodInsnNode push = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "pushPredicate", Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { Type.INT_TYPE, Type.INT_TYPE })); list.insertBefore(position, push); }
From source file:org.evosuite.instrumentation.BooleanTestabilityTransformation.java
License:Open Source License
/** * Insert a call to the distance function for binary comparison * /*from www.j a v a 2s . c om*/ * @param opcode * @param position * @param list */ public void insertPush2(int opcode, JumpInsnNode position, InsnList list) { list.insertBefore(position, new InsnNode(Opcodes.DUP2)); //list.insertBefore(position, new InsnNode(Opcodes.ISUB)); MethodInsnNode sub = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "intSub", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.INT_TYPE, Type.INT_TYPE })); list.insertBefore(position, sub); insertBranchIdPlaceholder(currentMethodNode, position); // list.insertBefore(position, // new LdcInsnNode(getBranchID(currentMethodNode, position))); MethodInsnNode push = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "pushPredicate", Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { Type.INT_TYPE, Type.INT_TYPE })); list.insertBefore(position, push); }
From source file:org.evosuite.instrumentation.BooleanTestabilityTransformation.java
License:Open Source License
/** * Insert a call that takes a boolean from the stack, and returns the * appropriate distance//from ww w.j a va 2s .c om * * @param position * @param list */ public void insertGet(AbstractInsnNode position, InsnList list) { logger.info("Inserting get call"); // Here, branchId is the first control dependency //list.insertBefore(position, // new LdcInsnNode(getControlDependentBranchID(currentMethodNode, // position))); insertControlDependencyPlaceholder(currentMethodNode, position); MethodInsnNode get = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "getDistance", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.INT_TYPE, Type.INT_TYPE, Type.INT_TYPE })); list.insert(position, get); }
From source file:org.evosuite.instrumentation.BooleanTestabilityTransformation.java
License:Open Source License
/** * Insert a call that takes a boolean from the stack, and returns the * appropriate distance//from w ww .ja v a 2s. co m * * @param position * @param list */ public void insertGetBefore(AbstractInsnNode position, InsnList list) { logger.info("Inserting get call before"); // Here, branchId is the first control dependency //list.insertBefore(position, // new LdcInsnNode(getControlDependentBranchID(currentMethodNode, // position))); // insertControlDependencyPlaceholder(currentMethodNode, position); // branch // approx // value Label label = new Label(); LabelNode labelNode = new LabelNode(label); //BooleanTestabilityPlaceholderTransformer.addControlDependencyPlaceholder(label, // insnNode); currentMethodNode.instructions.insertBefore(position, labelNode); //instructions.insertBefore(insnNode, new LdcInsnNode(0)); //mn.instructions.insertBefore(insnNode, new LdcInsnNode(0)); currentMethodNode.instructions.insertBefore(position, new LdcInsnNode(getControlDependentBranchID(currentMethodNode, position))); currentMethodNode.instructions.insertBefore(position, new InsnNode(Opcodes.SWAP)); currentMethodNode.instructions.insertBefore(position, new LdcInsnNode(getApproximationLevel(currentMethodNode, position))); currentMethodNode.instructions.insertBefore(position, new InsnNode(Opcodes.SWAP)); MethodInsnNode get = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "getDistance", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.INT_TYPE, Type.INT_TYPE, Type.INT_TYPE })); list.insertBefore(position, get); }
From source file:org.evosuite.instrumentation.ComparisonTransformation.java
License:Open Source License
private void insertLongComparison(AbstractInsnNode position, InsnList list) { MethodInsnNode get = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "longSub", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.LONG_TYPE, Type.LONG_TYPE })); list.insert(position, get);/*from w ww . j a va 2 s. c om*/ list.remove(position); }
From source file:org.evosuite.instrumentation.ComparisonTransformation.java
License:Open Source License
private void insertFloatComparison(AbstractInsnNode position, InsnList list) { MethodInsnNode get = new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(BooleanHelper.class), "floatSub", Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.FLOAT_TYPE, Type.FLOAT_TYPE })); list.insert(position, get);//ww w . j a va2 s . c o m list.remove(position); }