Example usage for org.objectweb.asm Opcodes POP

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

Introduction

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

Prototype

int POP

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

Click Source Link

Usage

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;//w  w  w . jav a 2  s . co  m
    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.internal.instr.InterfaceFieldProbeArrayStrategy.java

License:Open Source License

private void createInitMethod(final ClassVisitor cv, final int probeCount) {
    final MethodVisitor mv = cv.visitMethod(InstrSupport.INITMETHOD_ACC, InstrSupport.INITMETHOD_NAME,
            InstrSupport.INITMETHOD_DESC, null, null);
    mv.visitCode();//  w  w  w. jav  a 2 s .  c o m

    // Load the value of the static data field:
    mv.visitFieldInsn(Opcodes.GETSTATIC, className, InstrSupport.DATAFIELD_NAME, InstrSupport.DATAFIELD_DESC);
    mv.visitInsn(Opcodes.DUP);

    // Stack[1]: [Z
    // Stack[0]: [Z

    // Skip initialization when we already have a data array:
    final Label alreadyInitialized = new Label();
    mv.visitJumpInsn(Opcodes.IFNONNULL, alreadyInitialized);

    // Stack[0]: [Z

    mv.visitInsn(Opcodes.POP);
    final int size = accessorGenerator.generateDataAccessor(classId, className, probeCount, mv);

    // Stack[0]: [Z

    // Return the class' probe array:
    mv.visitFrame(Opcodes.F_NEW, 0, FRAME_LOCALS_EMPTY, 1, FRAME_STACK_ARRZ);
    mv.visitLabel(alreadyInitialized);
    mv.visitInsn(Opcodes.ARETURN);

    mv.visitMaxs(Math.max(size, 2), 0); // Maximum local stack size is 2
    mv.visitEnd();
}

From source file:org.jacoco.core.runtime.AbstractRuntimeData.java

License:Open Source License

/**
 * Generates the code that calls a {@link ControlFlowRuntimeData} instance through the
 * JRE API method {@link Object#equals(Object)}. The code pops a
 * {@link Object} instance from the stack and pushes the probe array of type
 * <code>boolean[]</code> on the operand stack. The generated code requires
 * a stack size of 6.//from  w w w  .  j  av  a  2 s .  c om
 * 
 * @param classid
 *            class identifier
 * @param classname
 *            VM class name
 * @param probecount
 *            probe count for this class
 * @param mv
 *            visitor to emit generated code
 */
public static void generateAccessCall(final long classid, final String classname, final int probecount,
        final MethodVisitor mv) {
    // stack[0]: Ljava/lang/Object;

    generateArgumentArray(classid, classname, probecount, mv);

    // stack[1]: [Ljava/lang/Object;
    // stack[0]: Ljava/lang/Object;

    mv.visitInsn(Opcodes.DUP_X1);

    // stack[2]: [Ljava/lang/Object;
    // stack[1]: Ljava/lang/Object;
    // stack[0]: [Ljava/lang/Object;

    mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Object", "equals", "(Ljava/lang/Object;)Z", false);
    mv.visitInsn(Opcodes.POP);

    // stack[0]: [Ljava/lang/Object;

    mv.visitInsn(Opcodes.ICONST_0);
    mv.visitInsn(Opcodes.AALOAD);

    // stack[0]: [Z

    mv.visitTypeInsn(Opcodes.CHECKCAST, InstrSupport.DATAFIELD_DESC);
}

From source file:org.jacoco.core.runtime.ExecutionDataAccess.java

License:Open Source License

/**
 * Generates the code that calls the runtime data access through the JRE API
 * method {@link Object#equals(Object)}. The code pops a {@link Object}
 * instance from the stack and pushes the probe array of type
 * <code>boolean[]</code> on the operand stack. The generated code requires
 * a stack size of 6.// ww w .  j av a 2  s. c o m
 * 
 * @param classid
 * @param classname
 * @param probecount
 * @param mv
 */
public static void generateAccessCall(final long classid, final String classname, final int probecount,
        final MethodVisitor mv) {
    // stack[0]: Ljava/lang/Object;

    generateArgumentArray(classid, classname, probecount, mv);

    // stack[1]: [Ljava/lang/Object;
    // stack[0]: Ljava/lang/Object;

    mv.visitInsn(Opcodes.DUP_X1);

    // stack[2]: [Ljava/lang/Object;
    // stack[1]: Ljava/lang/Object;
    // stack[0]: [Ljava/lang/Object;

    mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Object", "equals", "(Ljava/lang/Object;)Z");
    mv.visitInsn(Opcodes.POP);

    // stack[0]: [Ljava/lang/Object;

    mv.visitInsn(Opcodes.ICONST_0);
    mv.visitInsn(Opcodes.AALOAD);

    // stack[0]: [Z

    mv.visitTypeInsn(Opcodes.CHECKCAST, InstrSupport.DATAFIELD_DESC);
}

From source file:org.jacoco.core.runtime.URLStreamHandlerRuntime.java

License:Open Source License

public int generateDataAccessor(final long classid, final String classname, final int probecount,
        final MethodVisitor mv) {

    // The data accessor performs the following steps:
    ////from   w  ww .ja v a2s .c o m
    // final URL url = new URL(protocol, null, "");
    // final URLConnection connection = url.openConnection();
    // final Object[] args = new Object[3];
    // args[0] = Long.valueOf(classid);
    // args[1] = classname;
    // args[2] = Integer.valueOf(probecount);
    // connection.equals(args);
    // final byte[] probedata = (byte[]) args[0];

    RuntimeData.generateArgumentArray(classid, classname, probecount, mv);
    mv.visitInsn(Opcodes.DUP);

    // Stack[1]: [Ljava/lang/Object;
    // Stack[0]: [Ljava/lang/Object;

    mv.visitTypeInsn(Opcodes.NEW, "java/net/URL");
    mv.visitInsn(Opcodes.DUP);
    mv.visitLdcInsn(protocol);
    mv.visitInsn(Opcodes.ACONST_NULL);
    mv.visitLdcInsn("");
    mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/net/URL", "<init>",
            "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");

    // Stack[2]: [Ljava/net/URL;
    // Stack[1]: [Ljava/lang/Object;
    // Stack[0]: [Ljava/lang/Object;

    mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/net/URL", "openConnection", "()Ljava/net/URLConnection;");

    // Stack[2]: [Ljava/net/URLConnection;
    // Stack[1]: [Ljava/lang/Object;
    // Stack[0]: [Ljava/lang/Object;

    mv.visitInsn(Opcodes.SWAP);

    // Stack[2]: [Ljava/lang/Object;
    // Stack[1]: [Ljava/net/URLConnection;
    // Stack[0]: [Ljava/lang/Object;

    mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Object", "equals", "(Ljava/lang/Object;)Z");

    // Stack[1]: Z;
    // Stack[0]: [Ljava/lang/Object;

    mv.visitInsn(Opcodes.POP);

    // Stack[0]: [Ljava/lang/Object;

    mv.visitInsn(Opcodes.ICONST_0);
    mv.visitInsn(Opcodes.AALOAD);
    mv.visitTypeInsn(Opcodes.CHECKCAST, InstrSupport.DATAFIELD_DESC);

    return 7;
}

From source file:org.jboss.byteman.agent.adapter.RuleGeneratorAdapter.java

License:Open Source License

/**
 * Generates a POP instruction.
 */
public void pop() {
    visitInsn(Opcodes.POP);
}

From source file:org.jboss.byteman.agent.adapter.RuleTriggerMethodAdapter.java

License:Open Source License

/**
 * plant code to copy back any updated values from the argument array to the relevant local variable slots
 */// w  w  w  . j a  v  a  2  s  .c  om
private void doArgUpdate() {
    // at entry the top of the stack contains the object array
    // for an AT EXIT rule the entry below this is the return value

    Type objectType = Type.getType(Object.class);
    int arraySize = callArrayBindings.size();
    int lastUpdated = -1;
    int returnIdx = -1;

    // identify which is the last index we will need to update. n.b. if we find a return value we will
    // update that last

    for (int i = 0; i < arraySize; i++) {
        Binding binding = callArrayBindings.get(i);
        if (binding.isUpdated()) {
            lastUpdated = i;
            if (binding.isReturn()) {
                returnIdx = i;
            }
        }
    }

    // if the return value is updated it gets done last
    if (returnIdx >= 0) {
        lastUpdated = returnIdx;
    }

    // write back all other args then stack new return value and drop old one
    for (int i = 0; i < arraySize; i++) {
        Binding binding = callArrayBindings.get(i);
        if (binding.isUpdated() && !binding.isReturn()) {
            // if this is the last update then we consume the arguments array
            // otherwise we need to copy it
            if (i != lastUpdated) {
                dup();
            }
            push(i);
            arrayLoad(objectType);
            if (binding.isParam()) {
                int idx = binding.getIndex() - 1;
                unbox(argumentTypes[idx]);
                storeArg(idx);
            } else if (binding.isLocalVar()) {
                int idx = binding.getLocalIndex();
                unbox(getLocalType(idx));
                storeLocal(idx);
            }
        }
    }

    // if we had a return value to process then the args array will still be on top of the stack above
    // the old return value

    if (returnIdx >= 0) {
        // get rid of old return value remembering to use the correct type for $!
        // which varies depending if this is an AT EXIT or AFTER CALL rule
        if (saveValueType.getSize() == 2) {
            mv.visitInsn(Opcodes.DUP_X2);
            mv.visitInsn(Opcodes.POP);
            mv.visitInsn(Opcodes.POP2);
        } else {
            mv.visitInsn(Opcodes.SWAP);
            mv.visitInsn(Opcodes.POP);
        }

        push(returnIdx);
        arrayLoad(objectType);
        // use the correct type for $! which varies depending if this is an AT EXIT or AFTER CALL rule
        unbox(saveValueType);
    }
}

From source file:org.jboss.byteman.rule.Action.java

License:Open Source License

public void compile(MethodVisitor mv, CompileContext compileContext) throws CompileException {
    int currentStack = compileContext.getStackCount();

    for (Expression expr : action) {
        expr.compile(mv, compileContext);
        Type resultType = expr.getType();
        // return and throw expressions don't actually leave a value on the stack even
        // though they may have a non-VOID value type
        boolean maybePop = !(expr instanceof ReturnExpression || expr instanceof ThrowExpression);
        if (maybePop && resultType != Type.VOID) {
            int expected = (resultType.getNBytes() > 4 ? 2 : 1);
            if (expected == 1) {
                mv.visitInsn(Opcodes.POP);
                compileContext.addStackCount(-1);
            } else if (expected == 2) {
                mv.visitInsn(Opcodes.POP2);
                compileContext.addStackCount(-2);
            }/*  w w w  . jav  a2 s .  c  o  m*/
        }
    }

    // check original stack height has been restored
    if (compileContext.getStackCount() != currentStack) {
        throw new CompileException("Action.compile : invalid stack height " + compileContext.getStackCount()
                + " expecting " + currentStack);
    }
}

From source file:org.jboss.byteman.rule.expression.ArrayExpression.java

License:Open Source License

@Override
public void compileAssign(MethodVisitor mv, CompileContext compileContext) throws CompileException {
    // make sure we are at the right source line
    compileContext.notifySourceLine(line);

    Type valueType = arrayRef.getType().getBaseType();
    int currentStack = compileContext.getStackCount();
    boolean isTwoWords = (valueType.getNBytes() > 4);
    int toPop = 0;
    int size = (isTwoWords ? 2 : 1);

    // value to be assigned is TOS and will already be coerced to the correct value type
    // copy it so we can install the copy and leave the original as a a return value on the stack
    if (isTwoWords) {
        // [... val1 val2 ==> ... val1 val2 val1 val2]
        mv.visitInsn(Opcodes.DUP2);/*w w  w.ja  v a2s  .  c om*/
    } else {
        // [... val ==> ... val val]
        mv.visitInsn(Opcodes.DUP);
    }
    compileContext.addStackCount(size);

    // compile load of array reference -- adds 1 to stack height
    arrayRef.compile(mv, compileContext);
    // for each index expression compile the expression and the do an array load
    Iterator<Expression> iterator = idxList.iterator();

    while (iterator.hasNext()) {
        Expression idxExpr = iterator.next();
        if (iterator.hasNext()) {
            // dereference the array to get an embedded array
            // compile expression index -- adds 1 to height
            idxExpr.compile(mv, compileContext);
            // make sure the index is an integer
            compileTypeConversion(idxExpr.getType(), Type.I, mv, compileContext);
            // fetch embedded array pop 2 and add 1
            mv.visitInsn(Opcodes.AALOAD);
            compileContext.addStackCount(-1);
            valueType = valueType.getBaseType();
        } else {
            if (isTwoWords) {
                // stack is [..., val1, val2, val1, val2, aref ] and we want [..., val1, val2, aref, val1, val2 ]
                mv.visitInsn(Opcodes.DUP_X2); // ==>  [..., val1, val2, aref. val1, val2, aref ]
                compileContext.addStackCount(1);
                mv.visitInsn(Opcodes.POP); // ==> [..., val1, val2, aref. val1, val2 ]
                compileContext.addStackCount(-1);
            } else {
                // stack is [..., val, val, aref ] and we want [..., val, aref, val ]
                mv.visitInsn(Opcodes.SWAP);
            }
            // compile expression index -- adds 1 to height
            idxExpr.compile(mv, compileContext);
            // make sure the index is an integer
            compileTypeConversion(idxExpr.getType(), Type.I, mv, compileContext);
            if (isTwoWords) {
                // stack is [..., val1, val2, aref, val1, val2, idx] and we want [..., val1, val2, aref, idx, val1, val2 ]
                mv.visitInsn(Opcodes.DUP_X2); // ==> [..., val1, val2, aref, idx, val1, val2, idx]
                compileContext.addStackCount(1);
                mv.visitInsn(Opcodes.POP); // ==> [..., val1, val2, aref, idx, val1, val2 ]
                compileContext.addStackCount(-1);
            } else {
                // stack is [..., val, aref, val, idx] and we want [..., val, aref, idx, val ]
                mv.visitInsn(Opcodes.SWAP);
            }
            // now we can do the array store
            if (valueType.isObject() || valueType.isArray()) {
                // compile load object - pops 3
                mv.visitInsn(Opcodes.AASTORE);
                toPop = -3;
            } else if (valueType == Type.Z || valueType == Type.B) {
                // compile load byte - pops 3
                mv.visitInsn(Opcodes.BASTORE);
                toPop = -3;
            } else if (valueType == Type.S) {
                // compile load short - pops 3
                mv.visitInsn(Opcodes.SASTORE);
                toPop = -3;
            } else if (valueType == Type.C) {
                // compile load char - pops 3
                mv.visitInsn(Opcodes.CASTORE);
                toPop = -3;
            } else if (valueType == Type.I) {
                // compile load int - pops 3
                mv.visitInsn(Opcodes.IASTORE);
                toPop = -3;
            } else if (valueType == Type.J) {
                // compile load long - pops 4
                mv.visitInsn(Opcodes.LASTORE);
                toPop = -4;
            } else if (valueType == Type.F) {
                // compile load float - pops 3
                mv.visitInsn(Opcodes.FASTORE);
                toPop = -3;
            } else if (valueType == Type.D) {
                // compile load double - pops 4
                mv.visitInsn(Opcodes.DASTORE);
                toPop = -4;
            }
            compileContext.addStackCount(toPop);
            if (iterator.hasNext()) {
                assert valueType.isArray();
                valueType = valueType.getBaseType();
            }
        }
    }

    // check stack height
    if (compileContext.getStackCount() != currentStack) {
        throw new CompileException("ArrayExpression.compile : invalid stack height "
                + compileContext.getStackCount() + " expecting " + currentStack);
    }

    // we needed room for an aray and an index or for a one or two word result
    // but the recursive evaluations will have made sure the max stack is big enough
    // so there is no need to update the maximum stack height
}

From source file:org.jboss.byteman.rule.expression.ComparisonExpression.java

License:Open Source License

public void compile(MethodVisitor mv, CompileContext compileContext) throws CompileException {
    // make sure we are at the right source line
    compileContext.notifySourceLine(line);

    Expression oper0 = getOperand(0);
    Expression oper1 = getOperand(1);

    int removed = 0;

    // evaluate the operands and ensure the reuslt is of the correct type for comparison adds 2
    oper0.compile(mv, compileContext);/*from w w  w . ja  v a 2 s.com*/
    compileTypeConversion(oper0.getType(), comparisonType, mv, compileContext);
    oper1.compile(mv, compileContext);
    compileTypeConversion(oper1.getType(), comparisonType, mv, compileContext);

    // now do the appropriate type of comparison
    if (comparisonType == type.B || comparisonType == type.S || comparisonType == type.S
            || comparisonType == type.I) {
        Label elsetarget = new Label();
        Label endtarget = new Label();
        // we remove 2 words from the stack and then add 1 back
        removed = 2;
        switch (oper) {
        case LT:
            mv.visitJumpInsn(Opcodes.IF_ICMPGE, elsetarget);
            mv.visitLdcInsn(true);
            mv.visitJumpInsn(Opcodes.GOTO, endtarget);
            mv.visitLabel(elsetarget);
            mv.visitLdcInsn(false);
            mv.visitLabel(endtarget);
            break;
        case LE:
            mv.visitJumpInsn(Opcodes.IF_ICMPGT, elsetarget);
            mv.visitLdcInsn(true);
            mv.visitJumpInsn(Opcodes.GOTO, endtarget);
            mv.visitLabel(elsetarget);
            mv.visitLdcInsn(false);
            mv.visitLabel(endtarget);
            break;
        case GT:
            mv.visitJumpInsn(Opcodes.IF_ICMPLE, elsetarget);
            mv.visitLdcInsn(true);
            mv.visitJumpInsn(Opcodes.GOTO, endtarget);
            mv.visitLabel(elsetarget);
            mv.visitLdcInsn(false);
            mv.visitLabel(endtarget);
            break;
        case GE:
            mv.visitJumpInsn(Opcodes.IF_ICMPLT, elsetarget);
            mv.visitLdcInsn(true);
            mv.visitJumpInsn(Opcodes.GOTO, endtarget);
            mv.visitLabel(elsetarget);
            mv.visitLdcInsn(false);
            mv.visitLabel(endtarget);
            break;
        case EQ:
            mv.visitJumpInsn(Opcodes.IF_ICMPNE, elsetarget);
            mv.visitLdcInsn(true);
            mv.visitJumpInsn(Opcodes.GOTO, endtarget);
            mv.visitLabel(elsetarget);
            mv.visitLdcInsn(false);
            mv.visitLabel(endtarget);
            break;
        case NE:
            mv.visitJumpInsn(Opcodes.IF_ICMPEQ, elsetarget);
            mv.visitLdcInsn(true);
            mv.visitJumpInsn(Opcodes.GOTO, endtarget);
            mv.visitLabel(elsetarget);
            mv.visitLdcInsn(false);
            mv.visitLabel(endtarget);
            break;
        }
    } else if (comparisonType == type.J || comparisonType == type.F || comparisonType == type.D) {
        if (comparisonType == type.J) {
            mv.visitInsn(Opcodes.LCMP);
            // we remove four words from the stack and add 1 back
            removed = 4;
        } else if (comparisonType == type.F) {
            // we remove two words from the stack and add 1 back
            removed = 2;
            mv.visitInsn(Opcodes.FCMPG);
        } else if (comparisonType == type.D) {
            // we remove four words from the stack and add 1 back
            removed = 4;
            mv.visitInsn(Opcodes.DCMPG);
        }
        Label elsetarget = new Label();
        Label endtarget = new Label();
        switch (oper) {
        case LT:
            mv.visitJumpInsn(Opcodes.IFGE, elsetarget);
            mv.visitLdcInsn(true);
            mv.visitJumpInsn(Opcodes.GOTO, endtarget);
            mv.visitLabel(elsetarget);
            mv.visitLdcInsn(false);
            mv.visitLabel(endtarget);
            break;
        case LE:
            mv.visitJumpInsn(Opcodes.IFGT, elsetarget);
            mv.visitLdcInsn(true);
            mv.visitJumpInsn(Opcodes.GOTO, endtarget);
            mv.visitLabel(elsetarget);
            mv.visitLdcInsn(false);
            mv.visitLabel(endtarget);
            break;
        case GT:
            mv.visitJumpInsn(Opcodes.IFLE, elsetarget);
            mv.visitLdcInsn(true);
            mv.visitJumpInsn(Opcodes.GOTO, endtarget);
            mv.visitLabel(elsetarget);
            mv.visitLdcInsn(false);
            mv.visitLabel(endtarget);
            break;
        case GE:
            mv.visitJumpInsn(Opcodes.IFLT, elsetarget);
            mv.visitLdcInsn(true);
            mv.visitJumpInsn(Opcodes.GOTO, endtarget);
            mv.visitLabel(elsetarget);
            mv.visitLdcInsn(false);
            mv.visitLabel(endtarget);
            break;
        case EQ:
            mv.visitJumpInsn(Opcodes.IFNE, elsetarget);
            mv.visitLdcInsn(true);
            mv.visitJumpInsn(Opcodes.GOTO, endtarget);
            mv.visitLabel(elsetarget);
            mv.visitLdcInsn(false);
            mv.visitLabel(endtarget);
            break;
        case NE:
            mv.visitJumpInsn(Opcodes.IFEQ, elsetarget);
            mv.visitLdcInsn(true);
            mv.visitJumpInsn(Opcodes.GOTO, endtarget);
            mv.visitLabel(elsetarget);
            mv.visitLdcInsn(false);
            mv.visitLabel(endtarget);
            break;
        }
    } else if (comparable) {
        // we add a further two words setting up the relevant test then remove them
        // and also remove the original two words replacing them with a single word
        removed = 4;
        compileContext.addStackCount(2);
        // we need to deal with null values correctly
        // if op1 == null || op2 == null
        // then
        //   EQ:
        //   push value1 == value2
        //   NE:
        //   push value1 != value2
        //   ow:
        //   push false
        // else
        //   execute compareTo or equals and test for the desired outcome
        // end if
        Label splittarget = new Label(); // else
        Label jointarget = new Label(); // end if
        mv.visitInsn(Opcodes.DUP2); // [... op1, op2 ] ==> [... op1, op2, op1,  op2]
        mv.visitInsn(Opcodes.POP); // [... op1, op2, op1, op2 ] ==> [... op1, op2, op1]
        // if op1 == null
        mv.visitJumpInsn(Opcodes.IFNULL, splittarget); // [... op1, op2, op1] ==> [... op1, op2]
        mv.visitInsn(Opcodes.DUP); // [... op1, op2 ] ==> [... op1, op2, op2]
        // || op2 == null
        mv.visitJumpInsn(Opcodes.IFNULL, splittarget); // [... op1, op2, op2] ==> [... op1, op2]
        // so, it is ok to call compareTo leaving an int or equals leaving a boolean
        if (oper != EQ && oper != NE) {
            mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/lang/Comparable", "compareTo",
                    "(Ljava/lang/Object;)I");
        } else {
            mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Object", "equals", "(Ljava/lang/Object;)Z");
        }
        // now if we did a compareTo we need to generate the required boolean
        Label elsetarget = new Label();
        Label endtarget = new Label();
        // if needed the convert the compareTo result to the required boolean outcome
        switch (oper) {
        case LT:
            mv.visitJumpInsn(Opcodes.IFGE, elsetarget);
            mv.visitLdcInsn(true);
            mv.visitJumpInsn(Opcodes.GOTO, endtarget);
            mv.visitLabel(elsetarget);
            mv.visitLdcInsn(false);
            mv.visitLabel(endtarget);
            break;
        case LE:
            mv.visitJumpInsn(Opcodes.IFGT, elsetarget);
            mv.visitLdcInsn(true);
            mv.visitJumpInsn(Opcodes.GOTO, endtarget);
            mv.visitLabel(elsetarget);
            mv.visitLdcInsn(false);
            mv.visitLabel(endtarget);
            break;
        case GT:
            mv.visitJumpInsn(Opcodes.IFLE, elsetarget);
            mv.visitLdcInsn(true);
            mv.visitJumpInsn(Opcodes.GOTO, endtarget);
            mv.visitLabel(elsetarget);
            mv.visitLdcInsn(false);
            mv.visitLabel(endtarget);
            break;
        case GE:
            mv.visitJumpInsn(Opcodes.IFLT, elsetarget);
            mv.visitLdcInsn(true);
            mv.visitJumpInsn(Opcodes.GOTO, endtarget);
            mv.visitLabel(elsetarget);
            mv.visitLdcInsn(false);
            mv.visitLabel(endtarget);
            break;
        case NE:
            mv.visitJumpInsn(Opcodes.IFEQ, elsetarget);
            mv.visitLdcInsn(false);
            mv.visitJumpInsn(Opcodes.GOTO, endtarget);
            mv.visitLabel(elsetarget);
            mv.visitLdcInsn(true);
            mv.visitLabel(endtarget);
            break;
        }
        // skip to the join point
        mv.visitJumpInsn(Opcodes.GOTO, jointarget);
        // label the split point
        mv.visitLabel(splittarget);
        if (oper == EQ) {
            elsetarget = new Label();
            endtarget = new Label();
            mv.visitJumpInsn(Opcodes.IF_ACMPEQ, elsetarget);
            mv.visitLdcInsn(false);
            mv.visitJumpInsn(Opcodes.GOTO, endtarget);
            mv.visitLabel(elsetarget);
            mv.visitLdcInsn(true);
            mv.visitLabel(endtarget);
        } else if (oper == NE) {
            elsetarget = new Label();
            endtarget = new Label();
            mv.visitJumpInsn(Opcodes.IF_ACMPNE, elsetarget);
            mv.visitLdcInsn(false);
            mv.visitJumpInsn(Opcodes.GOTO, endtarget);
            mv.visitLabel(elsetarget);
            mv.visitLdcInsn(true);
            mv.visitLabel(endtarget);
        } else {
            // pop the operands and stack false
            mv.visitInsn(Opcodes.POP2);
            mv.visitLdcInsn(false);
        }
        // label the join point
        mv.visitLabel(jointarget);
    } else if (comparisonType == Type.Z) {
        // unboxed booleans need special treatment
        // we remove two words replacing them with a single word
        removed = 2;
        Label elsetarget = new Label();
        Label endtarget = new Label();
        mv.visitJumpInsn(Opcodes.IFEQ, elsetarget);
        // on this branch for EQ the stacked value is what we need and for NE
        // the stacked value needs flipping
        if (oper == NE) {
            Label elsetarget2 = new Label();
            mv.visitJumpInsn(Opcodes.IFEQ, elsetarget2);
            mv.visitLdcInsn(false);
            mv.visitJumpInsn(Opcodes.GOTO, endtarget);
            mv.visitLabel(elsetarget2);
            mv.visitLdcInsn(true);
        }
        mv.visitJumpInsn(Opcodes.GOTO, endtarget);
        mv.visitLabel(elsetarget);
        // on this branch for NE the stacked value is what we need and for EQ
        // the stacked value needs flipping
        if (oper == EQ) {
            Label elsetarget2 = new Label();
            mv.visitJumpInsn(Opcodes.IFEQ, elsetarget2);
            mv.visitLdcInsn(false);
            mv.visitJumpInsn(Opcodes.GOTO, endtarget);
            mv.visitLabel(elsetarget2);
            mv.visitLdcInsn(true);
        }
        mv.visitLabel(endtarget);

    } else if (comparisonType == Type.BOOLEAN) {
        // boxed booleans need special treatment
        // we remove two words replacing them with a single word
        removed = 2;
        Label elsetarget = new Label();
        Label endtarget = new Label();
        mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java.lang.Boolean", "equals", "(Ljava/lang/Boolean;)Z");
        if (oper == NE) {
            mv.visitJumpInsn(Opcodes.IFEQ, elsetarget);
            mv.visitLdcInsn(true);
            mv.visitJumpInsn(Opcodes.GOTO, endtarget);
            mv.visitLabel(elsetarget);
            mv.visitLdcInsn(false);
            mv.visitLabel(endtarget);
        }
    } else {
        // we remove two words replacing them with a single word
        removed = 2;
        Label elsetarget = new Label();
        Label endtarget = new Label();
        if (oper == EQ) {
            mv.visitJumpInsn(Opcodes.IF_ACMPNE, elsetarget);
            mv.visitLdcInsn(true);
            mv.visitJumpInsn(Opcodes.GOTO, endtarget);
            mv.visitLabel(elsetarget);
            mv.visitLdcInsn(false);
            mv.visitLabel(endtarget);
        } else {
            mv.visitJumpInsn(Opcodes.IF_ACMPEQ, elsetarget);
            mv.visitLdcInsn(true);
            mv.visitJumpInsn(Opcodes.GOTO, endtarget);
            mv.visitLabel(elsetarget);
            mv.visitLdcInsn(false);
            mv.visitLabel(endtarget);
        }
    }
    compileContext.addStackCount(1 - removed);
}