Example usage for org.objectweb.asm Opcodes ICONST_0

List of usage examples for org.objectweb.asm Opcodes ICONST_0

Introduction

In this page you can find the example usage for org.objectweb.asm Opcodes ICONST_0.

Prototype

int ICONST_0

To view the source code for org.objectweb.asm Opcodes ICONST_0.

Click Source Link

Usage

From source file:de.tuberlin.uebb.jbop.optimizer.loop.ForLoopUnrollerTest.java

License:Open Source License

/**
 * Tests that ForLoopUnroller is working correctly.
 * //from ww  w .j  av a2s  .  c o m
 * Used is a loop of the kind:
 * 
 * for(int i=0; i< 3; ++i)
 */
@Test
public void testForLoopUnrollerStrictForward() {
    // INIT
    final LabelNode label1 = new LabelNode();
    final LabelNode label2 = new LabelNode();
    builder.addInsn(new InsnNode(Opcodes.ICONST_0)).//
            addInsn(new VarInsnNode(Opcodes.ISTORE, 1)).//
            addInsn(new JumpInsnNode(Opcodes.GOTO, label1)).//
            addInsn(label2).//
            addInsn(new VarInsnNode(Opcodes.ILOAD, 1)).//
            addInsn(new VarInsnNode(Opcodes.ILOAD, 1)).//
            addInsn(new InsnNode(Opcodes.IADD)).//
            addInsn(new IincInsnNode(1, 1)).//
            addInsn(label1).//
            addInsn(NodeHelper.getInsnNodeFor(3)).//
            addInsn(new VarInsnNode(Opcodes.ILOAD, 1)).//
            addInsn(new JumpInsnNode(Opcodes.IF_ICMPLT, label2)).//
            addInsn(new InsnNode(Opcodes.RETURN));

    // RUN
    assertEquals(13, method.instructions.size());
    final InsnList optimized = optimizer.optimize(method.instructions, method);

    // ASSERT
    assertEquals(19, optimized.size());

    int node = 0;
    for (int i = 0; i < 3; ++i) {
        assertEquals(i, NodeHelper.getNumberValue(optimized.get(node)).intValue());
        node++;
        assertEquals(Opcodes.ISTORE, optimized.get(node).getOpcode());
        node++;
        assertEquals(Opcodes.ILOAD, optimized.get(node).getOpcode());
        node++;
        assertEquals(Opcodes.ILOAD, optimized.get(node).getOpcode());
        node++;
        assertEquals(Opcodes.IADD, optimized.get(node).getOpcode());
        node++;
        assertEquals(Opcodes.NOP, optimized.get(node).getOpcode()); // this is the SkipMarkNode
        node++;
    }
}

From source file:de.tuberlin.uebb.jbop.optimizer.methodsplitter.BlockTest.java

License:Open Source License

/**
 * Tests the type erasure./*w ww .j  a va  2  s  .c o m*/
 */
@Test
public void testTypeErasure() {
    final InsnList list = new InsnList();
    list.add(new InsnNode(Opcodes.ICONST_5));
    list.add(new IntInsnNode(Opcodes.NEWARRAY, Opcodes.T_INT));
    list.add(new VarInsnNode(Opcodes.ASTORE, 3));
    list.add(new VarInsnNode(Opcodes.ILOAD, 1));
    list.add(new VarInsnNode(Opcodes.ILOAD, 2));
    list.add(new InsnNode(Opcodes.IADD));
    list.add(new InsnNode(Opcodes.ICONST_0));
    list.add(new VarInsnNode(Opcodes.ALOAD, 3));
    list.add(new InsnNode(Opcodes.IASTORE));
    list.add(new InsnNode(Opcodes.ICONST_5));
    list.add(new IntInsnNode(Opcodes.NEWARRAY, Opcodes.T_INT));
    list.add(new VarInsnNode(Opcodes.ASTORE, 4));
    list.add(new VarInsnNode(Opcodes.ILOAD, 1));
    list.add(new VarInsnNode(Opcodes.ILOAD, 2));
    list.add(new InsnNode(Opcodes.IADD));
    list.add(new InsnNode(Opcodes.ICONST_1));
    final VarInsnNode insn = new VarInsnNode(Opcodes.ALOAD, 3);
    list.add(insn);
    list.add(new InsnNode(Opcodes.IASTORE));
    list.add(new InsnNode(Opcodes.RETURN));

    final ListIterator<AbstractInsnNode> iterator = list.iterator();

    final Block block = new Block(1, new Type[] { Type.INT_TYPE, Type.INT_TYPE }, Type.INT_TYPE);
    while (iterator.hasNext()) {
        block.addInsn(iterator.next(), true);
    }

    final Type findType = block.findType(insn);
    assertEquals(Type.getType("[I"), findType);
}

From source file:de.tuberlin.uebb.jbop.optimizer.utils.NodeHelper.java

License:Open Source License

private static AbstractInsnNode getIntInsnNode(final Number newNumber) {
    switch (newNumber.intValue()) {
    case CONST_M1:
        return new InsnNode(Opcodes.ICONST_M1);
    case CONST_0:
        return new InsnNode(Opcodes.ICONST_0);
    case CONST_1:
        return new InsnNode(Opcodes.ICONST_1);
    case CONST_2:
        return new InsnNode(Opcodes.ICONST_2);
    case CONST_3:
        return new InsnNode(Opcodes.ICONST_3);
    case CONST_4:
        return new InsnNode(Opcodes.ICONST_4);
    case CONST_5:
        return new InsnNode(Opcodes.ICONST_5);
    default:/*from ww w .  ja v  a 2 s  .  com*/
        if (newNumber.intValue() >= CONST_LOW_INT && newNumber.intValue() <= CONST_HIGH_INT) {
            return new IntInsnNode(getopcodePush(newNumber.intValue()), newNumber.intValue());
        }
        return new LdcInsnNode(newNumber);
    }
}

From source file:de.tuberlin.uebb.jbop.optimizer.utils.NodeHelper.java

License:Open Source License

/**
 * Checks if node is iconst_i.//w  ww  . j  av  a  2  s  .  c om
 * 
 * @param node
 *          the node
 * @param i
 *          the i
 * @return true, if is iconst_i
 */
public static boolean isIconst(final AbstractInsnNode node, final int i) {
    if (node == null) {
        return false;
    }
    if (node instanceof InsnNode) {
        return node.getOpcode() == Opcodes.ICONST_0 + i;
    }
    return false;
}

From source file:de.tuberlin.uebb.jbop.optimizer.utils.NodeHelper.java

License:Open Source License

/**
 * Gets the value./*from ww w  . ja v a  2s.c  o  m*/
 * 
 * @param node
 *          the node
 * @return the value
 * @throws NotANumberException
 *           if node is not a number-Node
 */
public static Number getNumberValue(final AbstractInsnNode node) throws NotANumberException {
    if (node == null) {
        throw new NotANumberException();
    }
    AbstractInsnNode checkNode = node;
    if (isCast(node)) {
        checkNode = node.getPrevious();
    }
    if (isIconst(checkNode)) {
        return cast(Integer.valueOf(checkNode.getOpcode() - Opcodes.ICONST_0), checkNode, node);
    }
    if (checkNode.getOpcode() == Opcodes.LCONST_0) {
        return cast(Long.valueOf(0), checkNode, node);
    }
    if (checkNode.getOpcode() == Opcodes.LCONST_1) {
        return cast(Long.valueOf(1), checkNode, node);
    }
    if (checkNode.getOpcode() == Opcodes.FCONST_0) {
        return cast(Float.valueOf(0), checkNode, node);
    }
    if (checkNode.getOpcode() == Opcodes.FCONST_1) {
        return cast(Float.valueOf(1), checkNode, node);
    }
    if (checkNode.getOpcode() == Opcodes.FCONST_2) {
        return cast(Float.valueOf(1), checkNode, node);
    }
    if (checkNode.getOpcode() == Opcodes.DCONST_0) {
        return cast(Double.valueOf(0), checkNode, node);
    }
    if (checkNode.getOpcode() == Opcodes.DCONST_1) {
        return cast(Double.valueOf(1), checkNode, node);
    }
    if (checkNode instanceof IntInsnNode) {
        return cast(Integer.valueOf(((IntInsnNode) checkNode).operand), checkNode, node);
    }
    return cast(getConstantValue(checkNode, Number.class), checkNode, node);
}

From source file:de.unisb.cs.st.javalanche.mutation.bytecodeMutations.replaceIntegerConstant.AbstractRicMethodAdapter.java

License:Open Source License

@Override
public void visitInsn(int opcode) {
    if (mutationCode) {
        super.visitInsn(opcode);
        return;//ww w  .j a  v  a2  s.c  o  m
    }

    switch (opcode) {
    case Opcodes.ICONST_M1:
        intConstant(-1);
        break;
    case Opcodes.ICONST_0:
        intConstant(0);
        break;
    case Opcodes.ICONST_1:
        intConstant(1);
        break;
    case Opcodes.ICONST_2:
        intConstant(2);
        break;
    case Opcodes.ICONST_3:
        intConstant(3);
        break;
    case Opcodes.ICONST_4:
        intConstant(4);
        break;
    case Opcodes.ICONST_5:
        intConstant(5);
        break;
    case Opcodes.LCONST_0:
        longConstant(0);
        break;
    case Opcodes.LCONST_1:
        longConstant(1);
        break;
    case Opcodes.FCONST_0:
        floatConstant(0);
        break;
    case Opcodes.FCONST_1:
        floatConstant(1);
        break;
    case Opcodes.FCONST_2:
        floatConstant(2);
        break;
    case Opcodes.DCONST_0:
        doubleConstant(0);
        break;
    case Opcodes.DCONST_1:
        doubleConstant(1);
        break;
    default:
        break;
    }
    if (forwardCalls) {
        super.visitInsn(opcode);
    }
}

From source file:de.unisb.cs.st.javalanche.mutation.bytecodeMutations.replaceIntegerConstant.RicMethodAdapter.java

License:Open Source License

@Override
public void visitInsn(int opcode) {
    if (mutationCode) {
        super.visitInsn(opcode);
        return;/*  www .  j  av  a 2  s . co  m*/
    }
    switch (opcode) {
    case Opcodes.ICONST_M1:
        intConstant(-1);
        break;
    case Opcodes.ICONST_0:
        intConstant(0);
        break;
    case Opcodes.ICONST_1:
        intConstant(1);
        break;
    case Opcodes.ICONST_2:
        intConstant(2);
        break;
    case Opcodes.ICONST_3:
        intConstant(3);
        break;
    case Opcodes.ICONST_4:
        intConstant(4);
        break;
    case Opcodes.ICONST_5:
        intConstant(5);
        break;
    case Opcodes.LCONST_0:
        longConstant(0);
        break;
    case Opcodes.LCONST_1:
        longConstant(1);
        break;
    case Opcodes.FCONST_0:
        floatConstant(0);
        break;
    case Opcodes.FCONST_1:
        floatConstant(1);
        break;
    case Opcodes.FCONST_2:
        floatConstant(2);
        break;
    case Opcodes.DCONST_0:
        doubleConstant(0);
        break;
    case Opcodes.DCONST_1:
        doubleConstant(1);
        break;

    default:
        super.visitInsn(opcode);
        break;
    }
}

From source file:de.unisb.cs.st.javaslicer.common.classRepresentation.instructions.SimpleInstruction.java

License:Open Source License

@Override
public String toString() {
    switch (getOpcode()) {
    // the not interesting ones:
    case Opcodes.NOP:
        return "NOP";
    // constants:
    case Opcodes.ACONST_NULL:
        return "ACONST_NULL";
    case Opcodes.ICONST_M1:
        return "ICONST_M1";
    case Opcodes.ICONST_0:
        return "ICONST_0";
    case Opcodes.ICONST_1:
        return "ICONST_1";
    case Opcodes.ICONST_2:
        return "ICONST_2";
    case Opcodes.ICONST_3:
        return "ICONST_3";
    case Opcodes.ICONST_4:
        return "ICONST_4";
    case Opcodes.ICONST_5:
        return "ICONST_5";
    case Opcodes.LCONST_0:
        return "LCONST_0";
    case Opcodes.LCONST_1:
        return "LCONST_1";
    case Opcodes.FCONST_0:
        return "FCONST_0";
    case Opcodes.FCONST_1:
        return "FCONST_1";
    case Opcodes.FCONST_2:
        return "FCONST_2";
    case Opcodes.DCONST_0:
        return "DCONST_0";
    case Opcodes.DCONST_1:
        return "DCONST_1";

    // array load:
    case Opcodes.IALOAD:
        return "IALOAD";
    case Opcodes.LALOAD:
        return "LALOAD";
    case Opcodes.FALOAD:
        return "FALOAD";
    case Opcodes.DALOAD:
        return "DALOAD";
    case Opcodes.AALOAD:
        return "AALOAD";
    case Opcodes.BALOAD:
        return "BALOAD";
    case Opcodes.CALOAD:
        return "CALOAD";
    case Opcodes.SALOAD:
        return "SALOAD";

    // array store:
    case Opcodes.IASTORE:
        return "IASTORE";
    case Opcodes.LASTORE:
        return "LASTORE";
    case Opcodes.FASTORE:
        return "FASTORE";
    case Opcodes.DASTORE:
        return "DASTORE";
    case Opcodes.AASTORE:
        return "AASTORE";
    case Opcodes.BASTORE:
        return "BASTORE";
    case Opcodes.CASTORE:
        return "CASTORE";
    case Opcodes.SASTORE:
        return "SASTORE";

    // stack manipulation:
    case Opcodes.POP:
        return "POP";
    case Opcodes.POP2:
        return "POP2";
    case Opcodes.DUP:
        return "DUP";
    case Opcodes.DUP_X1:
        return "DUP_X1";
    case Opcodes.DUP_X2:
        return "DUP_X2";
    case Opcodes.DUP2:
        return "DUP2";
    case Opcodes.DUP2_X1:
        return "DUP2_X1";
    case Opcodes.DUP2_X2:
        return "DUP2_X2";
    case Opcodes.SWAP:
        return "SWAP";

    // arithmetic:
    case Opcodes.IADD:
        return "IADD";
    case Opcodes.LADD:
        return "LADD";
    case Opcodes.FADD:
        return "FADD";
    case Opcodes.DADD:
        return "DADD";
    case Opcodes.ISUB:
        return "ISUB";
    case Opcodes.LSUB:
        return "LSUB";
    case Opcodes.FSUB:
        return "FSUB";
    case Opcodes.DSUB:
        return "DSUB";
    case Opcodes.IMUL:
        return "IMUL";
    case Opcodes.LMUL:
        return "LMUL";
    case Opcodes.FMUL:
        return "FMUL";
    case Opcodes.DMUL:
        return "DMUL";
    case Opcodes.IDIV:
        return "IDIV";
    case Opcodes.LDIV:
        return "LDIV";
    case Opcodes.FDIV:
        return "FDIV";
    case Opcodes.DDIV:
        return "DDIV";
    case Opcodes.IREM:
        return "IREM";
    case Opcodes.LREM:
        return "LREM";
    case Opcodes.FREM:
        return "FREM";
    case Opcodes.DREM:
        return "DREM";
    case Opcodes.INEG:
        return "INEG";
    case Opcodes.LNEG:
        return "LNEG";
    case Opcodes.FNEG:
        return "FNEG";
    case Opcodes.DNEG:
        return "DNEG";
    case Opcodes.ISHL:
        return "ISHL";
    case Opcodes.LSHL:
        return "LSHL";
    case Opcodes.ISHR:
        return "ISHR";
    case Opcodes.LSHR:
        return "LSHR";
    case Opcodes.IUSHR:
        return "IUSHR";
    case Opcodes.LUSHR:
        return "LUSHR";
    case Opcodes.IAND:
        return "IAND";
    case Opcodes.LAND:
        return "LAND";
    case Opcodes.IOR:
        return "IOR";
    case Opcodes.LOR:
        return "LOR";
    case Opcodes.IXOR:
        return "IXOR";
    case Opcodes.LXOR:
        return "LXOR";

    // type conversions:
    case Opcodes.I2L:
        return "I2L";
    case Opcodes.I2F:
        return "I2F";
    case Opcodes.I2D:
        return "I2D";
    case Opcodes.L2I:
        return "L2I";
    case Opcodes.L2F:
        return "L2F";
    case Opcodes.L2D:
        return "L2D";
    case Opcodes.F2I:
        return "F2I";
    case Opcodes.F2L:
        return "F2L";
    case Opcodes.F2D:
        return "F2D";
    case Opcodes.D2I:
        return "D2I";
    case Opcodes.D2L:
        return "D2L";
    case Opcodes.D2F:
        return "D2F";
    case Opcodes.I2B:
        return "I2B";
    case Opcodes.I2C:
        return "I2C";
    case Opcodes.I2S:
        return "I2S";

    // comparison:
    case Opcodes.LCMP:
        return "LCMP";
    case Opcodes.FCMPL:
        return "FCMPL";
    case Opcodes.FCMPG:
        return "FCMPG";
    case Opcodes.DCMPL:
        return "DCMPL";
    case Opcodes.DCMPG:
        return "DCMPG";

    // control-flow statements:
    case Opcodes.IRETURN:
        return "IRETURN";
    case Opcodes.LRETURN:
        return "LRETURN";
    case Opcodes.FRETURN:
        return "FRETURN";
    case Opcodes.DRETURN:
        return "DRETURN";
    case Opcodes.ARETURN:
        return "ARETURN";
    case Opcodes.RETURN:
        return "RETURN";

    // special things
    case Opcodes.ARRAYLENGTH:
        return "ARRAYLENGTH";
    case Opcodes.ATHROW:
        return "ATHROW";
    case Opcodes.MONITORENTER:
        return "MONITORENTER";
    case Opcodes.MONITOREXIT:
        return "MONITOREXIT";

    default://w ww.j  a  va 2  s. c  om
        assert false;
        return "--ERROR--";
    }
}

From source file:de.zib.sfs.instrument.AbstractSfsAdapter.java

License:BSD License

protected void setInstrumentationActive(MethodVisitor mv, boolean instrumentationActive) {
    // setInstrumentationActive(<instrumentationActive>);
    mv.visitVarInsn(Opcodes.ALOAD, 0);/*from w ww  . j a va2 s  . c  o  m*/
    mv.visitInsn(instrumentationActive ? Opcodes.ICONST_1 : Opcodes.ICONST_0);
    mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, this.instrumentedTypeInternalName, "setInstrumentationActive",
            Type.getMethodDescriptor(Type.VOID_TYPE, Type.BOOLEAN_TYPE), false);
}

From source file:de.zib.sfs.instrument.DirectByteBufferAdapter.java

License:BSD License

@Override
protected void appendWrappedMethods(ClassVisitor visitor) {
    // override from MappedByteBuffer so we can re-init the callback
    // properly//from   w  ww.ja va  2  s. c o  m

    // public void setFileDescriptor(FileDescriptor fileDescriptor) {
    MethodVisitor settFileDescriptorMV = visitor.visitMethod(Opcodes.ACC_PUBLIC, "setFileDescriptor",
            Type.getMethodDescriptor(Type.VOID_TYPE, Type.getType(FileDescriptor.class)), null, null);
    settFileDescriptorMV.visitCode();

    // this.fileDescriptor = fileDescriptor;
    settFileDescriptorMV.visitVarInsn(Opcodes.ALOAD, 0);
    settFileDescriptorMV.visitVarInsn(Opcodes.ALOAD, 1);
    settFileDescriptorMV.visitFieldInsn(Opcodes.PUTFIELD, Type.getInternalName(MappedByteBuffer.class),
            "fileDescriptor", Type.getDescriptor(FileDescriptor.class));

    // callback.openCallback(this.fileDescriptor);
    settFileDescriptorMV.visitVarInsn(Opcodes.ALOAD, 0);
    settFileDescriptorMV.visitFieldInsn(Opcodes.GETFIELD, this.instrumentedTypeInternalName, "callback",
            this.callbackTypeDescriptor);
    settFileDescriptorMV.visitVarInsn(Opcodes.ALOAD, 0);
    settFileDescriptorMV.visitFieldInsn(Opcodes.GETFIELD, Type.getInternalName(MappedByteBuffer.class),
            "fileDescriptor", Type.getDescriptor(FileDescriptor.class));
    settFileDescriptorMV.visitMethodInsn(Opcodes.INVOKEVIRTUAL, this.callbackTypeInternalName, "openCallback",
            Type.getMethodDescriptor(Type.VOID_TYPE, Type.getType(FileDescriptor.class)), false);

    // }
    settFileDescriptorMV.visitInsn(Opcodes.RETURN);
    settFileDescriptorMV.visitMaxs(0, 0);
    settFileDescriptorMV.visitEnd();

    // also override from MappedByteBuffer

    // protected FileDescriptor getFileDescriptorImpl() {
    MethodVisitor getFileDescriptorImplMV = visitor.visitMethod(Opcodes.ACC_PROTECTED, "getFileDescriptorImpl",
            Type.getMethodDescriptor(Type.getType(FileDescriptor.class)), null, null);
    getFileDescriptorImplMV.visitCode();

    // return fileDescriptor;
    // }
    getFileDescriptorImplMV.visitVarInsn(Opcodes.ALOAD, 0);
    getFileDescriptorImplMV.visitFieldInsn(Opcodes.GETFIELD, Type.getInternalName(MappedByteBuffer.class),
            "fileDescriptor", Type.getDescriptor(FileDescriptor.class));
    getFileDescriptorImplMV.visitInsn(Opcodes.ARETURN);
    getFileDescriptorImplMV.visitMaxs(0, 0);
    getFileDescriptorImplMV.visitEnd();

    if (!skipReads()) {
        wrapMethod(Opcodes.ACC_PUBLIC, "get", Type.getType(ByteBuffer.class),
                new Type[] { Type.getType(byte[].class), Type.INT_TYPE, Type.INT_TYPE }, null, null,
                "getCallback", Type.INT_TYPE, new ParameterResultPasser(3));
    }

    if (!skipWrites()) {
        wrapMethod(Opcodes.ACC_PUBLIC, "put", Type.getType(ByteBuffer.class),
                new Type[] { Type.getType(byte[].class), Type.INT_TYPE, Type.INT_TYPE }, null, null,
                "putCallback", Type.INT_TYPE, new ParameterResultPasser(3));
    }

    if (!skipWrites()) {
        // public ByteBuffer put(ByteBuffer src) {
        MethodVisitor bulkPutMV = visitor.visitMethod(Opcodes.ACC_PUBLIC, "put",
                Type.getMethodDescriptor(Type.getType(ByteBuffer.class), Type.getType(ByteBuffer.class)), null,
                null);
        bulkPutMV.visitCode();

        // if (isInstrumentationActive()) {
        isInstrumentationActive(bulkPutMV);
        Label instrumentationActiveLabel = new Label();
        bulkPutMV.visitJumpInsn(Opcodes.IFEQ, instrumentationActiveLabel);

        // return nativeMethodPrefixput(src);
        bulkPutMV.visitVarInsn(Opcodes.ALOAD, 0);
        bulkPutMV.visitVarInsn(Opcodes.ALOAD, 1);
        bulkPutMV.visitMethodInsn(Opcodes.INVOKESPECIAL, this.instrumentedTypeInternalName,
                this.methodPrefix + "put",
                Type.getMethodDescriptor(Type.getType(ByteBuffer.class), Type.getType(ByteBuffer.class)),
                false);
        bulkPutMV.visitInsn(Opcodes.ARETURN);

        // }
        bulkPutMV.visitLabel(instrumentationActiveLabel);

        // setInstrumentationActive(fromFileChannel);
        bulkPutMV.visitVarInsn(Opcodes.ALOAD, 0);
        bulkPutMV.visitVarInsn(Opcodes.ALOAD, 0);
        bulkPutMV.visitFieldInsn(Opcodes.GETFIELD, this.instrumentedTypeInternalName, "fromFileChannel",
                Type.getDescriptor(Boolean.TYPE));
        bulkPutMV.visitMethodInsn(Opcodes.INVOKEVIRTUAL, this.instrumentedTypeInternalName,
                "setInstrumentationActive", Type.getMethodDescriptor(Type.VOID_TYPE, Type.BOOLEAN_TYPE), false);

        // boolean srcInstrumentationActive = false;
        bulkPutMV.visitInsn(Opcodes.ICONST_0);
        bulkPutMV.visitVarInsn(Opcodes.ISTORE, 2);

        // if (src instanceof MappedByteBuffer) {
        bulkPutMV.visitVarInsn(Opcodes.ALOAD, 1);
        bulkPutMV.visitTypeInsn(Opcodes.INSTANCEOF, Type.getInternalName(MappedByteBuffer.class));
        Label srcInstanceofMappedByteBufferLabel = new Label();
        bulkPutMV.visitJumpInsn(Opcodes.IFEQ, srcInstanceofMappedByteBufferLabel);

        // srcInstrumentationActive = src.isFromFileChannel();
        bulkPutMV.visitVarInsn(Opcodes.ALOAD, 1);
        bulkPutMV.visitMethodInsn(Opcodes.INVOKEVIRTUAL, Type.getInternalName(MappedByteBuffer.class),
                "isFromFileChannel", Type.getMethodDescriptor(Type.BOOLEAN_TYPE), false);
        bulkPutMV.visitVarInsn(Opcodes.ISTORE, 2);

        // src.setInstrumentationActive(true);
        bulkPutMV.visitVarInsn(Opcodes.ALOAD, 1);
        bulkPutMV.visitInsn(Opcodes.ICONST_1);
        bulkPutMV.visitMethodInsn(Opcodes.INVOKEVIRTUAL, Type.getInternalName(MappedByteBuffer.class),
                "setInstrumentationActive", Type.getMethodDescriptor(Type.VOID_TYPE, Type.BOOLEAN_TYPE), false);

        // }
        bulkPutMV.visitLabel(srcInstanceofMappedByteBufferLabel);

        // int length = src.remaining();
        bulkPutMV.visitVarInsn(Opcodes.ALOAD, 1);
        bulkPutMV.visitMethodInsn(Opcodes.INVOKEVIRTUAL, Type.getInternalName(Buffer.class), "remaining",
                Type.getMethodDescriptor(Type.INT_TYPE), false);
        bulkPutMV.visitVarInsn(Opcodes.ISTORE, 4);

        // long startTime = System.nanoTime();
        bulkPutMV.visitMethodInsn(Opcodes.INVOKESTATIC, this.systemInternalName, "nanoTime",
                this.nanoTimeDescriptor, false);
        bulkPutMV.visitVarInsn(Opcodes.LSTORE, 5);

        // ByteBuffer result = nativeMethodPrefixput(src);
        bulkPutMV.visitVarInsn(Opcodes.ALOAD, 0);
        bulkPutMV.visitVarInsn(Opcodes.ALOAD, 1);
        bulkPutMV.visitMethodInsn(Opcodes.INVOKESPECIAL, this.instrumentedTypeInternalName,
                this.methodPrefix + "put",
                Type.getMethodDescriptor(Type.getType(ByteBuffer.class), Type.getType(ByteBuffer.class)),
                false);
        bulkPutMV.visitVarInsn(Opcodes.ASTORE, 7);

        // long endTime = System.nanoTime();
        bulkPutMV.visitMethodInsn(Opcodes.INVOKESTATIC, this.systemInternalName, "nanoTime",
                this.nanoTimeDescriptor, false);
        bulkPutMV.visitVarInsn(Opcodes.LSTORE, 8);

        // if (isInstrumentationActive()) {
        isInstrumentationActive(bulkPutMV);
        Label instrumentationStillActiveLabel = new Label();
        bulkPutMV.visitJumpInsn(Opcodes.IFEQ, instrumentationStillActiveLabel);

        // callback.putCallback(startTime, endTime, length);
        bulkPutMV.visitVarInsn(Opcodes.ALOAD, 0);
        bulkPutMV.visitFieldInsn(Opcodes.GETFIELD, this.instrumentedTypeInternalName, "callback",
                this.callbackTypeDescriptor);
        bulkPutMV.visitVarInsn(Opcodes.LLOAD, 5);
        bulkPutMV.visitVarInsn(Opcodes.LLOAD, 8);
        bulkPutMV.visitVarInsn(Opcodes.ILOAD, 4);
        bulkPutMV.visitMethodInsn(Opcodes.INVOKEVIRTUAL, this.callbackTypeInternalName, "putCallback",
                Type.getMethodDescriptor(Type.VOID_TYPE, Type.LONG_TYPE, Type.LONG_TYPE, Type.INT_TYPE), false);

        // setInstrumentationActive(false);
        setInstrumentationActive(bulkPutMV, false);

        // }
        bulkPutMV.visitLabel(instrumentationStillActiveLabel);

        // if (srcInstrumentationActive) {
        bulkPutMV.visitVarInsn(Opcodes.ILOAD, 2);
        Label srcInstrumentationActiveLabel = new Label();
        bulkPutMV.visitJumpInsn(Opcodes.IFEQ, srcInstrumentationActiveLabel);

        // callback.onGetEnd(src.getFileDescriptor(), startTime, endTime,
        // length);
        bulkPutMV.visitVarInsn(Opcodes.ALOAD, 1);
        bulkPutMV.visitMethodInsn(Opcodes.INVOKEVIRTUAL, Type.getInternalName(MappedByteBuffer.class),
                "getFileDescriptor", Type.getMethodDescriptor(Type.getType(FileDescriptor.class)), false);
        bulkPutMV.visitVarInsn(Opcodes.LLOAD, 5);
        bulkPutMV.visitVarInsn(Opcodes.LLOAD, 8);
        bulkPutMV.visitVarInsn(Opcodes.ILOAD, 4);
        bulkPutMV.visitMethodInsn(Opcodes.INVOKESTATIC, this.callbackTypeInternalName, "getCallback",
                Type.getMethodDescriptor(Type.VOID_TYPE, Type.getType(FileDescriptor.class), Type.LONG_TYPE,
                        Type.LONG_TYPE, Type.INT_TYPE),
                false);

        // src.setInstrumentationActive(false);
        bulkPutMV.visitVarInsn(Opcodes.ALOAD, 1);
        bulkPutMV.visitInsn(Opcodes.ICONST_0);
        bulkPutMV.visitMethodInsn(Opcodes.INVOKEVIRTUAL, Type.getInternalName(MappedByteBuffer.class),
                "setInstrumentationActive", Type.getMethodDescriptor(Type.VOID_TYPE, Type.BOOLEAN_TYPE), false);

        // }
        bulkPutMV.visitLabel(srcInstrumentationActiveLabel);

        // return result;
        // }
        bulkPutMV.visitVarInsn(Opcodes.ALOAD, 7);
        bulkPutMV.visitInsn(Opcodes.ARETURN);
        bulkPutMV.visitMaxs(0, 0);
        bulkPutMV.visitEnd();
    }

    ResultPasser resultDiscarder = new DiscardResultPasser();

    // regular gets and puts
    for (Map.Entry<String, Type> type : TYPES.entrySet()) {
        if (!skipReads()) {
            // public TYPE getTYPE() { ... }
            wrapMethod(Opcodes.ACC_PUBLIC, "get" + type.getKey(), type.getValue(), null, null, null,
                    "get" + type.getKey() + "Callback", null, resultDiscarder);

            // public TYPE getTYPE(int index) { ... }
            wrapMethod(Opcodes.ACC_PUBLIC, "get" + type.getKey(), type.getValue(), new Type[] { Type.INT_TYPE },
                    null, null, "get" + type.getKey() + "Callback", null, resultDiscarder);
        }

        if (!skipWrites()) {
            // public ByteBuffer putTYPE(TYPE value) { ... }
            wrapMethod(Opcodes.ACC_PUBLIC, "put" + type.getKey(), Type.getType(ByteBuffer.class),
                    new Type[] { type.getValue() }, null, null, "put" + type.getKey() + "Callback", null,
                    resultDiscarder);

            // public ByteBuffer putTYPE(int index, TYPE value) { ... }
            wrapMethod(Opcodes.ACC_PUBLIC, "put" + type.getKey(), Type.getType(ByteBuffer.class),
                    new Type[] { Type.INT_TYPE, type.getValue() }, null, null,
                    "put" + type.getKey() + "Callback", null, resultDiscarder);
        }
    }

    visitor.visitEnd();
}