List of usage examples for org.objectweb.asm Opcodes IFEQ
int IFEQ
To view the source code for org.objectweb.asm Opcodes IFEQ.
Click Source Link
From source file:org.elasticsearch.painless.node.SWhile.java
License:Apache License
@Override void write(MethodWriter writer, Globals globals) { writer.writeStatementOffset(location); Label begin = new Label(); Label end = new Label(); writer.mark(begin);/* ww w . ja v a2s. com*/ if (!continuous) { condition.write(writer, globals); writer.ifZCmp(Opcodes.IFEQ, end); } if (block != null) { if (loopCounter != null) { writer.writeLoopCounter(loopCounter.getSlot(), Math.max(1, block.statementCount), location); } block.continu = begin; block.brake = end; block.write(writer, globals); } else { if (loopCounter != null) { writer.writeLoopCounter(loopCounter.getSlot(), 1, location); } } if (block == null || !block.allEscape) { writer.goTo(begin); } writer.mark(end); }
From source file:org.elasticsearch.painless.Writer.java
License:Apache License
void checkWriteBranch(final ParserRuleContext source) { final Branch branch = getBranch(source); if (branch != null) { if (branch.tru != null) { execute.visitJumpInsn(Opcodes.IFNE, branch.tru); } else if (branch.fals != null) { execute.visitJumpInsn(Opcodes.IFEQ, branch.fals); }/*from w w w.jav a2 s.c om*/ } }
From source file:org.elasticsearch.plan.a.Adapter.java
License:Apache License
void checkWriteBranch(final MethodVisitor visitor, final ParserRuleContext source) { final Branch branch = getBranch(source); if (branch != null) { if (branch.tru != null) { visitor.visitJumpInsn(Opcodes.IFNE, branch.tru); } else if (branch.fals != null) { visitor.visitJumpInsn(Opcodes.IFEQ, branch.fals); }/*from w ww.j a v a 2 s . c o m*/ } }
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 w w . jav a2 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.coverage.BranchInstrumentation.java
License:Open Source License
/** * <p>//w ww. j a v a 2s.co m * getInstrumentation * </p> * * @param instruction * a {@link org.evosuite.graphs.cfg.BytecodeInstruction} object. * @return a {@link org.objectweb.asm.tree.InsnList} object. */ protected InsnList getInstrumentation(BytecodeInstruction instruction) { if (instruction == null) throw new IllegalArgumentException("null given"); if (!instruction.isActualBranch()) throw new IllegalArgumentException("branch instruction expected"); if (!BranchPool.getInstance(classLoader).isKnownAsNormalBranchInstruction(instruction)) throw new IllegalArgumentException( "expect given instruction to be known by the BranchPool as a normal branch instruction"); int opcode = instruction.getASMNode().getOpcode(); int instructionId = instruction.getInstructionId(); int branchId = BranchPool.getInstance(classLoader).getActualBranchIdForNormalBranchInstruction(instruction); if (branchId < 0) throw new IllegalStateException("expect BranchPool to know branchId for all branch instructions"); InsnList instrumentation = new InsnList(); switch (opcode) { case Opcodes.IFEQ: case Opcodes.IFNE: case Opcodes.IFLT: case Opcodes.IFGE: case Opcodes.IFGT: case Opcodes.IFLE: instrumentation.add(new InsnNode(Opcodes.DUP)); instrumentation.add(new LdcInsnNode(opcode)); // instrumentation.add(new LdcInsnNode(id)); instrumentation.add(new LdcInsnNode(branchId)); instrumentation.add(new LdcInsnNode(instructionId)); instrumentation.add( new MethodInsnNode(Opcodes.INVOKESTATIC, EXECUTION_TRACER, "passedBranch", "(IIII)V", false)); logger.debug("Adding passedBranch val=?, opcode=" + opcode + ", branch=" + branchId + ", bytecode_id=" + instructionId); break; case Opcodes.IF_ICMPEQ: case Opcodes.IF_ICMPNE: case Opcodes.IF_ICMPLT: case Opcodes.IF_ICMPGE: case Opcodes.IF_ICMPGT: case Opcodes.IF_ICMPLE: instrumentation.add(new InsnNode(Opcodes.DUP2)); instrumentation.add(new LdcInsnNode(opcode)); // instrumentation.add(new LdcInsnNode(id)); instrumentation.add(new LdcInsnNode(branchId)); instrumentation.add(new LdcInsnNode(instructionId)); instrumentation.add( new MethodInsnNode(Opcodes.INVOKESTATIC, EXECUTION_TRACER, "passedBranch", "(IIIII)V", false)); break; case Opcodes.IF_ACMPEQ: case Opcodes.IF_ACMPNE: instrumentation.add(new InsnNode(Opcodes.DUP2)); instrumentation.add(new LdcInsnNode(opcode)); // instrumentation.add(new LdcInsnNode(id)); instrumentation.add(new LdcInsnNode(branchId)); instrumentation.add(new LdcInsnNode(instructionId)); instrumentation.add(new MethodInsnNode(Opcodes.INVOKESTATIC, EXECUTION_TRACER, "passedBranch", "(Ljava/lang/Object;Ljava/lang/Object;III)V", false)); break; case Opcodes.IFNULL: case Opcodes.IFNONNULL: instrumentation.add(new InsnNode(Opcodes.DUP)); instrumentation.add(new LdcInsnNode(opcode)); // instrumentation.add(new LdcInsnNode(id)); instrumentation.add(new LdcInsnNode(branchId)); instrumentation.add(new LdcInsnNode(instructionId)); instrumentation.add(new MethodInsnNode(Opcodes.INVOKESTATIC, EXECUTION_TRACER, "passedBranch", "(Ljava/lang/Object;III)V", false)); break; } return instrumentation; }
From source file:org.evosuite.instrumentation.coverage.BranchInstrumentation.java
License:Open Source License
/** * <p>/*from w ww. j ava2s . c om*/ * addDefaultCaseCoveredCall * </p> * * @param v * a {@link org.evosuite.graphs.cfg.BytecodeInstruction} object. * @param instrumentation * a {@link org.objectweb.asm.tree.InsnList} object. * @param defaultCaseBranchId * a int. */ protected void addDefaultCaseCoveredCall(BytecodeInstruction v, InsnList instrumentation, int defaultCaseBranchId) { instrumentation.add(new LdcInsnNode(0)); instrumentation.add(new LdcInsnNode(Opcodes.IFEQ)); instrumentation.add(new LdcInsnNode(defaultCaseBranchId)); instrumentation.add(new LdcInsnNode(v.getInstructionId())); instrumentation .add(new MethodInsnNode(Opcodes.INVOKESTATIC, EXECUTION_TRACER, "passedBranch", "(IIII)V", false)); }
From source file:org.evosuite.instrumentation.mutation.ReplaceComparisonOperator.java
License:Open Source License
private String getOp(int opcode) { switch (opcode) { case Opcodes.IFEQ: case Opcodes.IF_ACMPEQ: case Opcodes.IF_ICMPEQ: return "=="; case Opcodes.IFNE: case Opcodes.IF_ACMPNE: case Opcodes.IF_ICMPNE: return "!="; case Opcodes.IFLT: case Opcodes.IF_ICMPLT: return "<"; case Opcodes.IFLE: case Opcodes.IF_ICMPLE: return "<="; case Opcodes.IFGT: case Opcodes.IF_ICMPGT: return ">"; case Opcodes.IFGE: case Opcodes.IF_ICMPGE: return ">="; case Opcodes.IFNULL: return "= null"; case Opcodes.IFNONNULL: return "!= null"; }//w w w . ja v a 2 s.co m throw new RuntimeException("Unknown opcode: " + opcode); }
From source file:org.evosuite.instrumentation.mutation.ReplaceComparisonOperator.java
License:Open Source License
/** * <p>getInfectionDistance</p> * * @param opcodeOrig a int.//w w w . ja va 2 s .co m * @param opcodeNew a int. * @return a {@link org.objectweb.asm.tree.InsnList} object. */ public InsnList getInfectionDistance(int opcodeOrig, int opcodeNew) { InsnList distance = new InsnList(); switch (opcodeOrig) { case Opcodes.IF_ICMPEQ: case Opcodes.IF_ICMPNE: case Opcodes.IF_ICMPLE: case Opcodes.IF_ICMPLT: case Opcodes.IF_ICMPGE: case Opcodes.IF_ICMPGT: distance.add(new InsnNode(Opcodes.DUP2)); distance.add(new LdcInsnNode(opcodeOrig)); distance.add(new LdcInsnNode(opcodeNew)); distance.add(new MethodInsnNode(Opcodes.INVOKESTATIC, PackageInfo.getNameWithSlash(ReplaceComparisonOperator.class), "getInfectionDistance", "(IIII)D", false)); break; case Opcodes.IFEQ: case Opcodes.IFNE: case Opcodes.IFLE: case Opcodes.IFLT: case Opcodes.IFGE: case Opcodes.IFGT: distance.add(new InsnNode(Opcodes.DUP)); distance.add(new LdcInsnNode(opcodeOrig)); distance.add(new LdcInsnNode(opcodeNew)); distance.add(new MethodInsnNode(Opcodes.INVOKESTATIC, PackageInfo.getNameWithSlash(ReplaceComparisonOperator.class), "getInfectionDistance", "(III)D", false)); break; default: distance.add(new LdcInsnNode(0.0)); } return distance; }
From source file:org.evosuite.instrumentation.mutation.ReplaceComparisonOperator.java
License:Open Source License
/** * <p>getInfectionDistance</p> * * @param intVal a int./*from w w w. j av a 2 s .c o m*/ * @param opcodeOrig a int. * @param opcodeNew a int. * @return a double. */ public static double getInfectionDistance(int intVal, int opcodeOrig, int opcodeNew) { long val = intVal; switch (opcodeOrig) { case Opcodes.IFLT: switch (opcodeNew) { case Opcodes.IFLE: // Only differs for val == 0 return Math.abs(val); case Opcodes.IFEQ: // Only differs for val <= 0 return val > 0 ? val : 0.0; case Opcodes.IFGT: // Only same for val == 0 return val == 0 ? 1.0 : 0.0; case Opcodes.IFGE: // Always differs return 0.0; case Opcodes.IFNE: // Only differs for val > 0 return val <= 0 ? Math.abs(val) + 1.0 : 0.0; case TRUE: return val < 0 ? 1.0 : 0.0; case FALSE: return val < 0 ? 0.0 : 1.0; } case Opcodes.IFLE: switch (opcodeNew) { case Opcodes.IFLT: // Only differs for val == 0 return Math.abs(val); case Opcodes.IFEQ: return val >= 0 ? val + 1.0 : 0.0; case Opcodes.IFGE: // Only equals for val == 0 return val == 0 ? 1.0 : 0.0; case Opcodes.IFGT: // Always differs return 0.0; case Opcodes.IFNE: // Only differs if val >= 0 return val < 0 ? Math.abs(val) : 0.0; case TRUE: return val <= 0 ? 1.0 : 0.0; case FALSE: return val <= 0 ? 0.0 : 1.0; } case Opcodes.IFGT: switch (opcodeNew) { case Opcodes.IFGE: // Only differs for val == 0 return Math.abs(val); case Opcodes.IFEQ: // Only differs for val >= 0 return val < 0 ? Math.abs(val) : 0.0; case Opcodes.IFLT: // Only same for val == 0 return val == 0 ? 1.0 : 0.0; case Opcodes.IFLE: // Always differs return 0.0; case Opcodes.IFNE: // Only differs for val < 0 return val >= 0 ? val + 1.0 : 0.0; case TRUE: return val > 0 ? 1.0 : 0.0; case FALSE: return val > 0 ? 0.0 : 1.0; } case Opcodes.IFGE: switch (opcodeNew) { case Opcodes.IFGT: // Only differs for val == 0 return Math.abs(val); case Opcodes.IFEQ: return val <= 0 ? Math.abs(val) + 1.0 : 0.0; case Opcodes.IFLE: // Only equals for val == 0 return val == 0 ? 1.0 : 0.0; case Opcodes.IFLT: // Always differs return 0.0; case Opcodes.IFNE: // Only differs if val > 0 return val > 0 ? val : 0.0; case TRUE: return val >= 0 ? 1.0 : 0.0; case FALSE: return val >= 0 ? 0.0 : 1.0; } case Opcodes.IFEQ: switch (opcodeNew) { case Opcodes.IFLT: // Only differs if val <= 0 return val > 0 ? val : 0.0; case Opcodes.IFGT: // Only differs if val >= 0 return val < 0 ? Math.abs(val) : 0.0; case Opcodes.IFNE: // Always differs return 0.0; case Opcodes.IFLE: return val >= 0 ? val + 1.0 : 0.0; case Opcodes.IFGE: return val <= 0 ? Math.abs(val) + 1.0 : 0.0; case TRUE: return val == 0 ? 1.0 : 0.0; case FALSE: return val == 0 ? 0.0 : 1.0; } case Opcodes.IFNE: switch (opcodeNew) { case Opcodes.IFEQ: return 0.0; case Opcodes.IFLT: // Only differs for val > 0 return val <= 0 ? Math.abs(val) + 1.0 : 0.0; case Opcodes.IFLE: // Only differs for val > 0 return val < 0 ? Math.abs(val) : 0.0; case Opcodes.IFGT: return val >= 0 ? val + 1.0 : 0.0; case Opcodes.IFGE: return val > 0 ? val : 0.0; case TRUE: return val != 0 ? 1.0 : 0.0; case FALSE: return val != 0 ? 0.0 : 1.0; } } throw new RuntimeException("Unknown operator replacement: " + opcodeOrig + " -> " + opcodeNew); }
From source file:org.evosuite.instrumentation.mutation.ReplaceComparisonOperator.java
License:Open Source License
private int getBooleanIntReplacement(int opcode) { logger.debug("Getting Boolean int replacement"); switch (opcode) { case Opcodes.IFEQ: return Opcodes.IFNE; case Opcodes.IFNE: return Opcodes.IFEQ; case Opcodes.IFGT: return Opcodes.IFEQ; case Opcodes.IFLE: return Opcodes.IFGT; // The rest should not occur except if our interpreter did something wrong case Opcodes.IFGE: return Opcodes.IFLT; case Opcodes.IFLT: return Opcodes.IFGE; }//from w w w . ja va2 s.c o m throw new RuntimeException("Illegal opcode received: " + opcode); }