List of usage examples for org.objectweb.asm Opcodes IFNULL
int IFNULL
To view the source code for org.objectweb.asm Opcodes IFNULL.
Click Source Link
From source file:de.unisb.cs.st.javaslicer.common.classRepresentation.instructions.JumpInstruction.java
License:Open Source License
@Override public String toString() { String condition;//from w w w. ja v a 2 s.co m switch (getOpcode()) { case Opcodes.IFEQ: condition = "IFEQ"; break; case Opcodes.IFNE: condition = "IFNE"; break; case Opcodes.IFLT: condition = "IFLT"; break; case Opcodes.IFGE: condition = "IFGE"; break; case Opcodes.IFGT: condition = "IFGT"; break; case Opcodes.IFLE: condition = "IFLE"; break; case Opcodes.IF_ICMPEQ: condition = "IF_ICMPEQ"; break; case Opcodes.IF_ICMPNE: condition = "IF_ICMPNE"; break; case Opcodes.IF_ICMPLT: condition = "IF_ICMPLT"; break; case Opcodes.IF_ICMPGE: condition = "IF_ICMPGE"; break; case Opcodes.IF_ICMPGT: condition = "IF_ICMPGT"; break; case Opcodes.IF_ICMPLE: condition = "IF_ICMPLE"; break; case Opcodes.IF_ACMPEQ: condition = "IF_ACMPEQ"; break; case Opcodes.IF_ACMPNE: condition = "IF_ACMPNE"; break; case Opcodes.GOTO: condition = "GOTO"; break; case Opcodes.JSR: condition = "JSR"; break; case Opcodes.IFNULL: condition = "IFNULL"; break; case Opcodes.IFNONNULL: condition = "IFNONNULL"; break; default: assert false; condition = "--ERROR--"; break; } return condition + " " + this.label; }
From source file:de.unisb.cs.st.javaslicer.common.classRepresentation.instructions.JumpInstruction2.java
License:Open Source License
@Override public String toString() { String condition;/*from w w w . ja v a 2s . c om*/ switch (getOpcode()) { case Opcodes.IFEQ: condition = "IFEQ"; break; case Opcodes.IFNE: condition = "IFNE"; break; case Opcodes.IFLT: condition = "IFLT"; break; case Opcodes.IFGE: condition = "IFGE"; break; case Opcodes.IFGT: condition = "IFGT"; break; case Opcodes.IFLE: condition = "IFLE"; break; case Opcodes.IF_ICMPEQ: condition = "IF_ICMPEQ"; break; case Opcodes.IF_ICMPNE: condition = "IF_ICMPNE"; break; case Opcodes.IF_ICMPLT: condition = "IF_ICMPLT"; break; case Opcodes.IF_ICMPGE: condition = "IF_ICMPGE"; break; case Opcodes.IF_ICMPGT: condition = "IF_ICMPGT"; break; case Opcodes.IF_ICMPLE: condition = "IF_ICMPLE"; break; case Opcodes.IF_ACMPEQ: condition = "IF_ACMPEQ"; break; case Opcodes.IF_ACMPNE: condition = "IF_ACMPNE"; break; case Opcodes.GOTO: condition = "GOTO"; break; case Opcodes.JSR: condition = "JSR"; break; case Opcodes.IFNULL: condition = "IFNULL"; break; case Opcodes.IFNONNULL: condition = "IFNONNULL"; break; default: assert false; condition = "--ERROR--"; break; } return condition + " " + this.target; }
From source file:dodola.anole.lib.Redirection.java
License:Apache License
/** * Adds the instructions to do a generic redirection. * <p/>/*from w w w.j a v a 2s . c o m*/ * Note that the generated bytecode does not have a direct translation to code, but as an * example, the following code block gets inserted. * <code> * if ($change != null) { * $change.access$dispatch($name, new object[] { arg0, ... argsN }) * $anyCodeInsertedbyRestore * } * $originalMethodBody * </code> * * @param mv the method visitor to add the instructions to. * @param change the local variable containing the alternate implementation. * @param args the type of the local variable that need to be forwarded. */ void redirect(GeneratorAdapter mv, int change, List<Type> args) { // code to check if a new implementation of the current class is available. Label l0 = new Label(); mv.loadLocal(change); mv.visitJumpInsn(Opcodes.IFNULL, l0); mv.loadLocal(change); mv.push(name); // create an array of objects capable of containing all the parameters and optionally the "this" createLocals(mv, args); // we need to maintain the stack index when loading parameters from, as for long and double // values, it uses 2 stack elements, all others use only 1 stack element. int stackIndex = 0; for (int arrayIndex = 0; arrayIndex < args.size(); arrayIndex++) { Type arg = args.get(arrayIndex); // duplicate the array of objects reference, it will be used to store the value in. mv.dup(); // index in the array of objects to store the boxed parameter. mv.push(arrayIndex); // Pushes the appropriate local variable on the stack redirectLocal(mv, stackIndex, arg); // potentially box up intrinsic types. mv.box(arg); mv.arrayStore(Type.getType(Object.class)); // stack index must progress according to the parameter type we just processed. stackIndex += arg.getSize(); } // now invoke the generic dispatch method. mv.invokeInterface(IncrementalVisitor.CHANGE_TYPE, Method.getMethod("Object access$dispatch(String, Object[])")); // Restore the state after the redirection restore(mv, args); // jump label for classes without any new implementation, just invoke the original // method implementation. mv.visitLabel(l0); }
From source file:dyco4j.instrumentation.internals.InitTracingMethodVisitor.java
License:BSD License
@Override public void visitJumpInsn(final int opcode, final Label label) { mv.visitJumpInsn(opcode, label);// w w w . j ava2s . c o m switch (opcode) { case Opcodes.IFEQ: case Opcodes.IFNE: case Opcodes.IFLT: case Opcodes.IFGE: case Opcodes.IFGT: case Opcodes.IFLE: case Opcodes.IFNULL: case Opcodes.IFNONNULL: this.stackFrame.pop(); 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: case Opcodes.IF_ACMPEQ: case Opcodes.IF_ACMPNE: this.stackFrame.pop(); this.stackFrame.pop(); break; case Opcodes.JSR: this.stackFrame.push(OTHER); break; } addBranch(label); }
From source file:edu.illinois.nondex.instr.ConcurrentHashMapShufflingAdder.java
License:Open Source License
@Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { if ("<init>".equals(name)) { return new MethodVisitor(Opcodes.ASM5, super.visitMethod(access, name, desc, signature, exceptions)) { @Override//from w ww . j a v a 2s . co m public void visitInsn(int opcode) { if (opcode == Opcodes.RETURN) { mv.visitVarInsn(Opcodes.ALOAD, 1); Label l0 = new Label(); mv.visitJumpInsn(Opcodes.IFNULL, l0); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitVarInsn(Opcodes.ALOAD, 1); mv.visitVarInsn(Opcodes.ALOAD, 1); mv.visitInsn(Opcodes.ARRAYLENGTH); mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/util/Arrays", "copyOf", "([Ljava/lang/Object;I)[Ljava/lang/Object;", false); mv.visitMethodInsn(Opcodes.INVOKESTATIC, "edu/illinois/nondex/shuffling/ControlNondeterminism", "shuffle", "([Ljava/lang/Object;)[Ljava/lang/Object;", false); mv.visitTypeInsn(Opcodes.CHECKCAST, "[Ljava/util/concurrent/ConcurrentHashMap$Node;"); mv.visitFieldInsn(Opcodes.PUTFIELD, "java/util/concurrent/ConcurrentHashMap$Traverser", "tab", "[Ljava/util/concurrent/ConcurrentHashMap$Node;"); mv.visitLabel(l0); mv.visitFrame(Opcodes.F_FULL, 5, new Object[] { "java/util/concurrent/ConcurrentHashMap$Traverser", "[Ljava/util/concurrent/ConcurrentHashMap$Node;", Opcodes.INTEGER, Opcodes.INTEGER, Opcodes.INTEGER }, 0, new Object[] {}); mv.visitInsn(Opcodes.RETURN); } super.visitInsn(opcode); } }; } return super.visitMethod(access, name, desc, signature, exceptions); }
From source file:edu.mit.streamjit.util.bytecode.MethodResolver.java
License:Open Source License
private void interpret(JumpInsnNode insn, FrameState frame, BBInfo block) { //All JumpInsnNodes have a target. Find it. BBInfo target = blockByInsn(insn.label); assert target != null; if (insn.getOpcode() == Opcodes.GOTO) { block.block.instructions().add(new JumpInst(target.block)); return;/* w ww. j a v a 2 s.c o m*/ } else if (insn.getOpcode() == Opcodes.JSR) throw new UnsupportedOperationException("jsr not supported; upgrade to Java 6-era class files"); //Remaining opcodes are branches. BBInfo fallthrough = blocks.get(blocks.indexOf(block) + 1); BranchInst.Sense sense = OPCODE_TO_SENSE.get(insn.getOpcode()); //The second operand may come from the stack or may be a constant 0 or null. Value right; switch (insn.getOpcode()) { case Opcodes.IFEQ: case Opcodes.IFNE: case Opcodes.IFLT: case Opcodes.IFGE: case Opcodes.IFGT: case Opcodes.IFLE: right = module.constants().getConstant(0); break; case Opcodes.IFNULL: case Opcodes.IFNONNULL: right = module.constants().getNullConstant(); 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: case Opcodes.IF_ACMPEQ: case Opcodes.IF_ACMPNE: right = frame.stack.pop(); break; default: throw new AssertionError("Can't happen! Branch opcode missing? " + insn.getOpcode()); } //First operand always comes from the stack. Value left = frame.stack.pop(); block.block.instructions().add(new BranchInst(left, sense, right, target.block, fallthrough.block)); }
From source file:edu.umd.cs.guitar.testcase.plugin.edg.ClassDBVisitor.java
License:Open Source License
@Override public void visitJumpInsn(int opcode, Label label) { currentMethod.setEmpty(false);/*from ww w. j ava 2 s .c o m*/ currentMethod.setEmpty(false); switch (opcode) { case Opcodes.IFEQ: case Opcodes.IFNE: case Opcodes.IFLT: case Opcodes.IFGE: case Opcodes.IFGT: case Opcodes.IFLE: case Opcodes.IF_ICMPEQ: case Opcodes.IF_ICMPNE: case Opcodes.IF_ICMPLT: case Opcodes.IF_ICMPGE: case Opcodes.IF_ICMPGT: case Opcodes.IF_ICMPLE: case Opcodes.IF_ACMPEQ: case Opcodes.IF_ACMPNE: // case Opcodes.GOTO: // case Opcodes.JSR: case Opcodes.IFNULL: case Opcodes.IFNONNULL: // add all label reads/writes as condition reads/writes currentMethod.getConditionReads().addAll(labelReads); currentMethod.getConditionWrites().addAll(labelWrites); break; } }
From source file:jpcsp.Allegrex.compiler.CompilerContext.java
License:Open Source License
private void startInternalMethod() { // if (e != null) Label notReplacedLabel = new Label(); mv.visitFieldInsn(Opcodes.GETSTATIC, codeBlock.getClassName(), getReplaceFieldName(), executableDescriptor); mv.visitJumpInsn(Opcodes.IFNULL, notReplacedLabel); {// w w w . j ava2 s . c om // return e.exec(returnAddress, alternativeReturnAddress, isJump); mv.visitFieldInsn(Opcodes.GETSTATIC, codeBlock.getClassName(), getReplaceFieldName(), executableDescriptor); mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, executableInternalName, getExecMethodName(), getExecMethodDesc()); mv.visitInsn(Opcodes.IRETURN); } mv.visitLabel(notReplacedLabel); if (Profiler.isProfilerEnabled()) { loadImm(getCodeBlock().getStartAddress()); mv.visitMethodInsn(Opcodes.INVOKESTATIC, profilerInternalName, "addCall", "(I)V"); } if (RuntimeContext.debugCodeBlockCalls) { loadImm(getCodeBlock().getStartAddress()); mv.visitMethodInsn(Opcodes.INVOKESTATIC, runtimeContextInternalName, RuntimeContext.debugCodeBlockStart, "(I)V"); } }
From source file:name.martingeisse.minimal.compiler.Compiler.java
License:Open Source License
/** * Compiles a {@link MethodNode} to MCode. * /*w w w . ja v a 2s. c o m*/ * @param methodNode the method node to compile * @return the compiled code */ public ImmutableList<MCodeEntry> compile(final MethodNode methodNode) { for (int i = 0; i < methodNode.instructions.size(); i++) { final AbstractInsnNode instruction = methodNode.instructions.get(i); if (instruction instanceof LineNumberNode) { // ignored } else if (instruction instanceof FrameNode) { // this could be useful in the future } else if (instruction instanceof LabelNode) { label(((LabelNode) instruction).getLabel()); } else if (instruction instanceof InsnNode) { switch (instruction.getOpcode()) { case Opcodes.ICONST_M1: iconst(-1); break; case Opcodes.ICONST_0: iconst(0); break; case Opcodes.ICONST_1: iconst(1); break; case Opcodes.ICONST_2: iconst(2); break; case Opcodes.ICONST_3: iconst(3); break; case Opcodes.ICONST_4: iconst(4); break; case Opcodes.ICONST_5: iconst(5); break; default: unsupported(instruction); break; } } else if (instruction instanceof VarInsnNode) { final VarInsnNode varInsnNode = (VarInsnNode) instruction; switch (varInsnNode.getOpcode()) { case Opcodes.ILOAD: iload(varInsnNode.var); break; case Opcodes.ISTORE: istore(varInsnNode.var); break; default: unsupported(instruction); break; } } else if (instruction instanceof IincInsnNode) { final IincInsnNode iincInsnNode = (IincInsnNode) instruction; iinc(iincInsnNode.var, iincInsnNode.incr); } else if (instruction instanceof JumpInsnNode) { final JumpInsnNode jumpInsnNode = (JumpInsnNode) instruction; switch (jumpInsnNode.getOpcode()) { case Opcodes.IFEQ: case Opcodes.IFNE: case Opcodes.IFLT: case Opcodes.IFGE: case Opcodes.IFGT: case Opcodes.IFLE: branch1(jumpInsnNode.label.getLabel(), jumpInsnNode.getOpcode()); 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: branch2(jumpInsnNode.label.getLabel(), jumpInsnNode.getOpcode()); break; case Opcodes.IFNULL: case Opcodes.IFNONNULL: // unsupported: one-argument reference comparison operator unsupported(instruction); break; case Opcodes.IF_ACMPEQ: case Opcodes.IF_ACMPNE: // unsupported: two-argument reference comparison operator unsupported(instruction); break; case Opcodes.GOTO: jump(jumpInsnNode.label.getLabel()); break; case Opcodes.JSR: jsr(jumpInsnNode.label.getLabel()); break; default: unsupported(instruction); break; } } else if (instruction instanceof IntInsnNode) { final IntInsnNode intInsnNode = (IntInsnNode) instruction; if (instruction.getOpcode() == Opcodes.BIPUSH || instruction.getOpcode() == Opcodes.SIPUSH) { iconst(intInsnNode.operand); } else { // NEWARRAY unsupported(instruction); } } else if (instruction instanceof MethodInsnNode) { final MethodInsnNode methodInsnNode = (MethodInsnNode) instruction; if (methodInsnNode.getOpcode() == Opcodes.INVOKESTATIC) { if (methodInsnNode.owner.replace('/', '.').equals(Native.class.getName())) { nativeCall(methodInsnNode.name, methodInsnNode.desc); } else { unsupported(instruction); } } else { unsupported(instruction); } } else { unsupported(instruction); } } return builder.build(); }
From source file:org.adjective.stout.loop.IsNullCondition.java
License:Apache License
public Operation jumpWhenTrue(Label label) { return new JumpOperation(Opcodes.IFNULL, _expression, label); }