List of usage examples for org.objectweb.asm Opcodes LRETURN
int LRETURN
To view the source code for org.objectweb.asm Opcodes LRETURN.
Click Source Link
From source file:org.evosuite.instrumentation.ReturnValueAdapter.java
License:Open Source License
/** {@inheritDoc} */ @Override//from w ww . java 2 s. co m public void visitInsn(int opcode) { if (!methodName.equals("<clinit>")) { switch (opcode) { case Opcodes.IRETURN: callLogIReturn(); break; case Opcodes.ARETURN: callLogAReturn(); break; case Opcodes.ATHROW: break; case Opcodes.DRETURN: callLogDReturn(); break; case Opcodes.FRETURN: callLogFReturn(); break; case Opcodes.LRETURN: callLogLReturn(); break; case Opcodes.RETURN: break; default: break; } } super.visitInsn(opcode); }
From source file:org.evosuite.testcarver.instrument.Instrumenter.java
License:Open Source License
private void addReturnInsn(final InsnList il, final Type type) { if (type.equals(Type.BOOLEAN_TYPE)) { il.add(new InsnNode(Opcodes.IRETURN)); } else if (type.equals(Type.CHAR_TYPE)) { il.add(new InsnNode(Opcodes.IRETURN)); } else if (type.equals(Type.BYTE_TYPE)) { il.add(new InsnNode(Opcodes.IRETURN)); } else if (type.equals(Type.SHORT_TYPE)) { il.add(new InsnNode(Opcodes.IRETURN)); } else if (type.equals(Type.INT_TYPE)) { il.add(new InsnNode(Opcodes.IRETURN)); } else if (type.equals(Type.FLOAT_TYPE)) { il.add(new InsnNode(Opcodes.FRETURN)); } else if (type.equals(Type.LONG_TYPE)) { il.add(new InsnNode(Opcodes.LRETURN)); } else if (type.equals(Type.DOUBLE_TYPE)) { il.add(new InsnNode(Opcodes.DRETURN)); } else {// www . j a v a 2 s .c o m il.add(new InsnNode(Opcodes.ARETURN)); } }
From source file:org.fabric3.implementation.bytecode.proxy.common.ProxyFactoryImpl.java
License:Open Source License
private void writeReturn(Method method, Label endLabel, MethodVisitor mv) { Class<?> returnType = method.getReturnType(); if (Void.TYPE.equals(returnType)) { mv.visitInsn(Opcodes.POP);/* w w w . j a va2s.c om*/ mv.visitLabel(endLabel); mv.visitInsn(RETURN); } else if (returnType.isPrimitive()) { if (Double.TYPE.equals(returnType)) { mv.visitTypeInsn(CHECKCAST, "java/lang/Double"); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Double", "doubleValue", "()D"); mv.visitLabel(endLabel); mv.visitInsn(Opcodes.DRETURN); } else if (Long.TYPE.equals(returnType)) { mv.visitTypeInsn(CHECKCAST, "java/lang/Long"); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Long", "longValue", "()J"); mv.visitLabel(endLabel); mv.visitInsn(Opcodes.LRETURN); } else if (Integer.TYPE.equals(returnType)) { mv.visitTypeInsn(CHECKCAST, "java/lang/Integer"); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Integer", "intValue", "()I"); mv.visitLabel(endLabel); mv.visitInsn(Opcodes.IRETURN); } else if (Float.TYPE.equals(returnType)) { mv.visitTypeInsn(CHECKCAST, "java/lang/Float"); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Float", "floatValue", "()F"); mv.visitLabel(endLabel); mv.visitInsn(Opcodes.FRETURN); } else if (Short.TYPE.equals(returnType)) { mv.visitTypeInsn(CHECKCAST, "java/lang/Short"); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Short", "shortValue", "()S"); mv.visitLabel(endLabel); mv.visitInsn(Opcodes.IRETURN); } else if (Byte.TYPE.equals(returnType)) { mv.visitTypeInsn(CHECKCAST, "java/lang/Byte"); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Byte", "byteValue", "()B"); mv.visitLabel(endLabel); mv.visitInsn(Opcodes.IRETURN); } else if (Boolean.TYPE.equals(returnType)) { mv.visitTypeInsn(CHECKCAST, "java/lang/Boolean"); mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Boolean", "booleanValue", "()Z"); mv.visitLabel(endLabel); mv.visitInsn(Opcodes.IRETURN); } } else { String internalTypeName = Type.getInternalName(returnType); mv.visitTypeInsn(CHECKCAST, internalTypeName); mv.visitLabel(endLabel); mv.visitInsn(ARETURN); } }
From source file:org.glassfish.pfl.tf.spi.Util.java
License:Open Source License
public void storeFromXReturn(MethodVisitor mv, int returnOpcode, LocalVariableNode holder) { switch (returnOpcode) { case Opcodes.RETURN: // NOP// w ww . j a v a 2s . c o m break; case Opcodes.ARETURN: mv.visitVarInsn(Opcodes.ASTORE, holder.index); break; case Opcodes.IRETURN: mv.visitVarInsn(Opcodes.ISTORE, holder.index); break; case Opcodes.LRETURN: mv.visitVarInsn(Opcodes.LSTORE, holder.index); break; case Opcodes.FRETURN: mv.visitVarInsn(Opcodes.FSTORE, holder.index); break; case Opcodes.DRETURN: mv.visitVarInsn(Opcodes.DSTORE, holder.index); break; } }
From source file:org.glassfish.pfl.tf.spi.Util.java
License:Open Source License
public void loadFromXReturn(MethodVisitor mv, int returnOpcode, LocalVariableNode holder) { switch (returnOpcode) { case Opcodes.RETURN: // NOP// ww w .j a v a 2 s . c o m break; case Opcodes.ARETURN: mv.visitVarInsn(Opcodes.ALOAD, holder.index); break; case Opcodes.IRETURN: mv.visitVarInsn(Opcodes.ILOAD, holder.index); break; case Opcodes.LRETURN: mv.visitVarInsn(Opcodes.LLOAD, holder.index); break; case Opcodes.FRETURN: mv.visitVarInsn(Opcodes.FLOAD, holder.index); break; case Opcodes.DRETURN: mv.visitVarInsn(Opcodes.DLOAD, holder.index); break; } }
From source file:org.jacoco.core.internal.analysis.filter.FinallyFilter.java
License:Open Source License
private static void filter(final IFilterOutput output, final List<TryCatchBlockNode> tryCatchBlocks, final TryCatchBlockNode catchAnyBlock) { final AbstractInsnNode e = next(catchAnyBlock.handler); final int size = size(e); if (size <= 0) { return;// ww w . ja v a 2s . c o m } // Determine instructions inside regions final Set<AbstractInsnNode> inside = new HashSet<AbstractInsnNode>(); for (final TryCatchBlockNode t : tryCatchBlocks) { if (t.handler == catchAnyBlock.handler) { AbstractInsnNode i = t.start; while (i != t.end) { inside.add(i); i = i.getNext(); } } } // Find and merge duplicates at exits of regions for (final TryCatchBlockNode t : tryCatchBlocks) { if (t.handler == catchAnyBlock.handler) { boolean continues = false; AbstractInsnNode i = t.start; while (i != t.end) { switch (i.getType()) { case AbstractInsnNode.FRAME: case AbstractInsnNode.LINE: case AbstractInsnNode.LABEL: break; case AbstractInsnNode.JUMP_INSN: final AbstractInsnNode jumpTarget = next(((JumpInsnNode) i).label); if (!inside.contains(jumpTarget)) { merge(output, size, e, jumpTarget); } continues = i.getOpcode() != Opcodes.GOTO; break; default: switch (i.getOpcode()) { case Opcodes.IRETURN: case Opcodes.LRETURN: case Opcodes.FRETURN: case Opcodes.DRETURN: case Opcodes.ARETURN: case Opcodes.RETURN: case Opcodes.ATHROW: continues = false; break; default: continues = true; break; } break; } i = i.getNext(); } i = next(i); if (continues && !inside.contains(i)) { merge(output, size, e, i); } } if (t != catchAnyBlock && t.start == catchAnyBlock.start && t.end == catchAnyBlock.end) { final AbstractInsnNode i = next(next(t.handler)); if (!inside.contains(i)) { // javac's empty catch - merge after ASTORE merge(output, size, e, i); } } } }
From source file:org.jacoco.core.internal.flow.LabelFlowAnalyzer.java
License:Open Source License
@Override public void visitInsn(final int opcode) { switch (opcode) { case Opcodes.RET: throw new AssertionError("Subroutines not supported."); case Opcodes.IRETURN: case Opcodes.LRETURN: case Opcodes.FRETURN: case Opcodes.DRETURN: case Opcodes.ARETURN: case Opcodes.RETURN: case Opcodes.ATHROW: successor = false;//w w w . j av a2 s .c o m break; default: successor = true; break; } first = false; }
From source file:org.jacoco.core.internal.flow.MethodProbesAdapter.java
License:Open Source License
@Override public void visitInsn(final int opcode) { switch (opcode) { case Opcodes.IRETURN: case Opcodes.LRETURN: case Opcodes.FRETURN: case Opcodes.DRETURN: case Opcodes.ARETURN: case Opcodes.RETURN: case Opcodes.ATHROW: probesVisitor.visitInsnWithProbe(opcode, idGenerator.nextId()); break;// w ww . j a va2 s.com default: probesVisitor.visitInsn(opcode); break; } }
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;//from w w w . ja va 2 s.c om 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); }
From source file:org.jacoco.core.test.validation.java5.StructuredLockingTest.java
License:Open Source License
private void assertStructuredLocking(String owner, MethodNode mn) throws Exception { Analyzer<BasicValue> analyzer = new Analyzer<BasicValue>(new BasicInterpreter()) { @Override//ww w . java 2 s .c om protected Frame<BasicValue> newFrame(int nLocals, int nStack) { return new LockFrame(nLocals, nStack); } @Override protected Frame<BasicValue> newFrame(Frame<? extends BasicValue> src) { return new LockFrame(src); } }; Frame<BasicValue>[] frames = analyzer.analyze(owner, mn); // Make sure no locks are left when method exits: for (int i = 0; i < frames.length; i++) { AbstractInsnNode insn = mn.instructions.get(i); switch (insn.getOpcode()) { case Opcodes.IRETURN: case Opcodes.LRETURN: case Opcodes.FRETURN: case Opcodes.DRETURN: case Opcodes.ARETURN: case Opcodes.RETURN: ((LockFrame) frames[i]).assertNoLock("Exit with lock"); break; case Opcodes.ATHROW: List<TryCatchBlockNode> handlers = analyzer.getHandlers(i); if (handlers == null || handlers.isEmpty()) { ((LockFrame) frames[i]).assertNoLock("Exit with lock"); } break; } } // Only instructions protected by a catch-all handler can hold locks: for (int i = 0; i < frames.length; i++) { AbstractInsnNode insn = mn.instructions.get(i); if (insn.getOpcode() > 0) { boolean catchAll = false; List<TryCatchBlockNode> handlers = analyzer.getHandlers(i); if (handlers != null) { for (TryCatchBlockNode node : handlers) { catchAll |= node.type == null; } } if (!catchAll) { ((LockFrame) frames[i]).assertNoLock("No handlers for insn with lock"); } } } }