List of usage examples for org.objectweb.asm Opcodes ILOAD
int ILOAD
To view the source code for org.objectweb.asm Opcodes ILOAD.
Click Source Link
From source file:org.evosuite.graphs.cfg.ASMWrapper.java
License:Open Source License
/** * <p>//from w w w . j a va 2 s. c o m * isLocalVarUse * </p> * * @return a boolean. */ public boolean isLocalVariableUse() { return asmNode.getOpcode() == Opcodes.ILOAD || asmNode.getOpcode() == Opcodes.LLOAD || asmNode.getOpcode() == Opcodes.FLOAD || asmNode.getOpcode() == Opcodes.DLOAD || asmNode.getOpcode() == Opcodes.IINC || (asmNode.getOpcode() == Opcodes.ALOAD && !loadsReferenceToThis()); }
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// w ww . ja va 2 s. c om * * @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.BooleanValueInterpreter.java
License:Open Source License
/** {@inheritDoc} */ @Override/* www . j a v a 2 s .c o m*/ public BasicValue copyOperation(AbstractInsnNode insn, BasicValue value) throws AnalyzerException { if (insn.getOpcode() == Opcodes.ILOAD) { VarInsnNode varNode = (VarInsnNode) insn; if (isStatic) { if (varNode.var < types.length) { if (types[varNode.var] == Type.BOOLEAN_TYPE) { return BOOLEAN_VALUE; } } } else { if (varNode.var > 0 && varNode.var - 1 < types.length) { if (types[varNode.var - 1] == Type.BOOLEAN_TYPE) { return BOOLEAN_VALUE; } } } } return super.copyOperation(insn, value); }
From source file:org.evosuite.instrumentation.coverage.DefUseInstrumentation.java
License:Open Source License
private InsnList getMethodInstrumentation(BytecodeInstruction call, boolean staticContext, InsnList instrumentation, MethodNode mn) { String descriptor = call.getMethodCallDescriptor(); Type[] args = Type.getArgumentTypes(descriptor); int loc = getNextLocalNum(mn); Map<Integer, Integer> to = new HashMap<Integer, Integer>(); for (int i = args.length - 1; i >= 0; i--) { Type type = args[i];//from www . j av a2 s. co m instrumentation.add(new VarInsnNode(type.getOpcode(Opcodes.ISTORE), loc)); to.put(i, loc); loc++; } // instrumentation.add(new InsnNode(Opcodes.DUP));//callee addObjectInstrumentation(call, instrumentation, mn); addCallingObjectInstrumentation(staticContext, instrumentation); // field method calls get special treatment: // during instrumentation it is not clear whether a field method // call constitutes a definition or a use. So the instrumentation // will call a special function of the ExecutionTracer which will // redirect the call to either passedUse() or passedDefinition() // using the information available during runtime (the CCFGs) instrumentation.add(new LdcInsnNode(DefUsePool.getDefUseCounter())); instrumentation .add(new MethodInsnNode(Opcodes.INVOKESTATIC, PackageInfo.getNameWithSlash(ExecutionTracer.class), "passedFieldMethodCall", "(Ljava/lang/Object;Ljava/lang/Object;I)V")); for (int i = 0; i < args.length; i++) { Type type = args[i]; instrumentation.add(new VarInsnNode(type.getOpcode(Opcodes.ILOAD), to.get(i))); } return instrumentation; }
From source file:org.evosuite.instrumentation.mutation.InsertUnaryOperator.java
License:Open Source License
/** {@inheritDoc} */ @Override//from w w w. ja v a 2 s . co m public List<Mutation> apply(MethodNode mn, String className, String methodName, BytecodeInstruction instruction, Frame frame) { // TODO - need to keep InsnList in Mutation, not only Instruction? // Mutation: Insert an INEG _after_ an iload List<Mutation> mutations = new LinkedList<Mutation>(); List<InsnList> mutationCode = new LinkedList<InsnList>(); List<String> descriptions = new LinkedList<String>(); if (instruction.getASMNode() instanceof VarInsnNode) { try { InsnList mutation = new InsnList(); VarInsnNode node = (VarInsnNode) instruction.getASMNode(); // insert mutation into bytecode with conditional mutation.add(new VarInsnNode(node.getOpcode(), node.var)); mutation.add(new InsnNode(getNegation(node.getOpcode()))); mutationCode.add(mutation); if (!mn.localVariables.isEmpty()) descriptions.add("Negation of " + getName(mn, node)); else descriptions.add("Negation"); if (node.getOpcode() == Opcodes.ILOAD) { if (frame.getStack(frame.getStackSize() - 1) != BooleanValueInterpreter.BOOLEAN_VALUE) { mutation = new InsnList(); mutation.add(new IincInsnNode(node.var, 1)); mutation.add(new VarInsnNode(node.getOpcode(), node.var)); if (!mn.localVariables.isEmpty()) descriptions.add("IINC 1 " + getName(mn, node)); else descriptions.add("IINC 1"); mutationCode.add(mutation); mutation = new InsnList(); mutation.add(new IincInsnNode(node.var, -1)); mutation.add(new VarInsnNode(node.getOpcode(), node.var)); if (!mn.localVariables.isEmpty()) descriptions.add("IINC -1 " + getName(mn, node)); else descriptions.add("IINC -1"); mutationCode.add(mutation); } } } catch (VariableNotFoundException e) { logger.info("Could not find variable: " + e); return new ArrayList<Mutation>(); } } else { InsnList mutation = new InsnList(); FieldInsnNode node = (FieldInsnNode) instruction.getASMNode(); Type type = Type.getType(node.desc); mutation.add(new FieldInsnNode(node.getOpcode(), node.owner, node.name, node.desc)); mutation.add(new InsnNode(getNegation(type))); descriptions.add("Negation"); mutationCode.add(mutation); if (type == Type.INT_TYPE) { mutation = new InsnList(); mutation.add(new FieldInsnNode(node.getOpcode(), node.owner, node.name, node.desc)); mutation.add(new InsnNode(Opcodes.ICONST_1)); mutation.add(new InsnNode(Opcodes.IADD)); descriptions.add("+1"); mutationCode.add(mutation); mutation = new InsnList(); mutation.add(new FieldInsnNode(node.getOpcode(), node.owner, node.name, node.desc)); mutation.add(new InsnNode(Opcodes.ICONST_M1)); mutation.add(new InsnNode(Opcodes.IADD)); descriptions.add("-1"); mutationCode.add(mutation); } } int i = 0; for (InsnList mutation : mutationCode) { // insert mutation into pool Mutation mutationObject = MutationPool.addMutation(className, methodName, NAME + " " + descriptions.get(i++), instruction, mutation, Mutation.getDefaultInfectionDistance()); mutations.add(mutationObject); } return mutations; }
From source file:org.evosuite.instrumentation.mutation.InsertUnaryOperator.java
License:Open Source License
/** {@inheritDoc} */ @Override//from w ww . j a v a 2 s.c o m public boolean isApplicable(BytecodeInstruction instruction) { AbstractInsnNode node = instruction.getASMNode(); switch (node.getOpcode()) { case Opcodes.ILOAD: case Opcodes.LLOAD: case Opcodes.FLOAD: case Opcodes.DLOAD: return true; case Opcodes.GETFIELD: case Opcodes.GETSTATIC: FieldInsnNode fieldNode = (FieldInsnNode) instruction.getASMNode(); Type type = Type.getType(fieldNode.desc); if (type == Type.BYTE_TYPE || type == Type.SHORT_TYPE || type == Type.LONG_TYPE || type == Type.FLOAT_TYPE || type == Type.DOUBLE_TYPE || type == Type.BOOLEAN_TYPE || type == Type.INT_TYPE) { return true; } default: return false; } }
From source file:org.evosuite.instrumentation.mutation.InsertUnaryOperator.java
License:Open Source License
private int getNegation(int opcode) { switch (opcode) { case Opcodes.ILOAD: return Opcodes.INEG; case Opcodes.LLOAD: return Opcodes.LNEG; case Opcodes.FLOAD: return Opcodes.FNEG; case Opcodes.DLOAD: return Opcodes.DNEG; default://from ww w . jav a2 s .c o m throw new RuntimeException("Invalid opcode for negation: " + opcode); } }
From source file:org.evosuite.instrumentation.mutation.ReplaceArithmeticOperator.java
License:Open Source License
@SuppressWarnings("rawtypes") private static int getNextIndexFromLoad(MethodNode mn) { Iterator it = mn.instructions.iterator(); int index = 0; while (it.hasNext()) { AbstractInsnNode node = (AbstractInsnNode) it.next(); if (node instanceof VarInsnNode) { VarInsnNode varNode = (VarInsnNode) node; int varIndex = varNode.var; switch (varNode.getOpcode()) { case Opcodes.ALOAD: case Opcodes.ILOAD: case Opcodes.FLOAD: case Opcodes.IALOAD: case Opcodes.BALOAD: case Opcodes.CALOAD: case Opcodes.AALOAD: case Opcodes.ASTORE: case Opcodes.ISTORE: case Opcodes.FSTORE: case Opcodes.IASTORE: case Opcodes.BASTORE: case Opcodes.CASTORE: case Opcodes.AASTORE: index = Math.max(index, varIndex + 1); break; case Opcodes.DLOAD: case Opcodes.DSTORE: case Opcodes.LLOAD: case Opcodes.LSTORE: case Opcodes.DALOAD: case Opcodes.DASTORE: case Opcodes.LALOAD: case Opcodes.LASTORE: index = Math.max(index, varIndex + 2); break; }//w w w . j a va 2 s . c o m } } return index; }
From source file:org.evosuite.instrumentation.mutation.ReplaceBitwiseOperator.java
License:Open Source License
/** * <p>getInfectionDistance</p> * * @param opcodeOrig a int.//from w ww. j av a 2 s . c om * @param opcodeNew a int. * @return a {@link org.objectweb.asm.tree.InsnList} object. */ public InsnList getInfectionDistance(int opcodeOrig, int opcodeNew) { InsnList distance = new InsnList(); if (opcodesInt.contains(opcodeOrig)) { distance.add(new InsnNode(Opcodes.DUP2)); distance.add(new LdcInsnNode(opcodeOrig)); distance.add(new LdcInsnNode(opcodeNew)); distance.add(new MethodInsnNode(Opcodes.INVOKESTATIC, PackageInfo.getNameWithSlash(ReplaceBitwiseOperator.class), "getInfectionDistanceInt", "(IIII)D", false)); } else if (opcodesIntShift.contains(opcodeOrig)) { distance.add(new InsnNode(Opcodes.DUP2)); distance.add(new LdcInsnNode(opcodeOrig)); distance.add(new LdcInsnNode(opcodeNew)); distance.add(new MethodInsnNode(Opcodes.INVOKESTATIC, PackageInfo.getNameWithSlash(ReplaceBitwiseOperator.class), "getInfectionDistanceInt", "(IIII)D", false)); } else if (opcodesLong.contains(opcodeOrig)) { distance.add(new VarInsnNode(Opcodes.LSTORE, numVariable)); distance.add(new InsnNode(Opcodes.DUP2)); distance.add(new VarInsnNode(Opcodes.LLOAD, numVariable)); distance.add(new InsnNode(Opcodes.DUP2_X2)); distance.add(new LdcInsnNode(opcodeOrig)); distance.add(new LdcInsnNode(opcodeNew)); distance.add(new MethodInsnNode(Opcodes.INVOKESTATIC, PackageInfo.getNameWithSlash(ReplaceBitwiseOperator.class), "getInfectionDistanceLong", "(JJII)D", false)); numVariable += 2; } else if (opcodesLongShift.contains(opcodeOrig)) { distance.add(new VarInsnNode(Opcodes.ISTORE, numVariable)); distance.add(new InsnNode(Opcodes.DUP2)); distance.add(new VarInsnNode(Opcodes.ILOAD, numVariable)); distance.add(new InsnNode(Opcodes.DUP_X2)); distance.add(new LdcInsnNode(opcodeOrig)); distance.add(new LdcInsnNode(opcodeNew)); distance.add(new MethodInsnNode(Opcodes.INVOKESTATIC, PackageInfo.getNameWithSlash(ReplaceBitwiseOperator.class), "getInfectionDistanceLong", "(JIII)D", false)); numVariable += 1; } return distance; }
From source file:org.evosuite.instrumentation.mutation.ReplaceVariable.java
License:Open Source License
private int getLoadOpcode(LocalVariableNode var) { Type type = Type.getType(var.desc); return type.getOpcode(Opcodes.ILOAD); }