Example usage for org.objectweb.asm Opcodes MONITORENTER

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

Introduction

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

Prototype

int MONITORENTER

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

Click Source Link

Usage

From source file:org.jacoco.core.internal.analysis.filter.SynchronizedFilterTest.java

License:Open Source License

@Test
public void ecj() {
    final Label start = new Label();
    final Label end = new Label();
    final Label handler = new Label();
    final Label handlerEnd = new Label();
    m.visitTryCatchBlock(start, end, handler, null);
    m.visitTryCatchBlock(handler, handlerEnd, handler, null);

    m.visitVarInsn(Opcodes.ALOAD, 0);/* w  w w.  j ava  2s .co  m*/
    m.visitFieldInsn(Opcodes.GETFIELD, "Target", "lock", "Ljava/lang/Object;");
    m.visitInsn(Opcodes.DUP);
    m.visitVarInsn(Opcodes.ASTORE, 1);
    m.visitInsn(Opcodes.MONITORENTER);
    m.visitLabel(start);
    m.visitVarInsn(Opcodes.ALOAD, 0);
    m.visitInsn(Opcodes.NOP);
    m.visitVarInsn(Opcodes.ALOAD, 1);
    m.visitInsn(Opcodes.MONITOREXIT);
    m.visitLabel(end);
    final Label exit = new Label();
    m.visitJumpInsn(Opcodes.GOTO, exit);
    m.visitLabel(handler);
    m.visitVarInsn(Opcodes.ALOAD, 1);
    m.visitInsn(Opcodes.MONITOREXIT);
    m.visitLabel(handlerEnd);
    m.visitInsn(Opcodes.ATHROW);
    m.visitLabel(exit);
    m.visitInsn(Opcodes.RETURN);

    filter.filter(m, context, output);

    assertIgnored(new Range((LabelNode) handler.info, ((LabelNode) exit.info).getPrevious()));
}

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. ja  v  a2s  . c o  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.jboss.byteman.agent.adapter.cfg.BBlock.java

License:Open Source License

/**
 * add an instruction to the sequence in the block
 * @param instruction an Opcode/*from ww  w  . j  a v a  2 s .c o  m*/
 * @return the index of the newly added instruction
 */
public int append(int instruction) {
    int index = instructions.add(instruction);
    if (instruction == Opcodes.MONITORENTER) {
        // push onto front of list
        monitorEnters.push(new CodeLocation(this, index));
    } else if (instruction == Opcodes.MONITOREXIT) {
        CodeLocation exit = new CodeLocation(this, index);
        // we need to keep track of exits for when we can collate monitor section ends
        // with try catch blocks which overlapthis block so we don't drop them here
        // even if there is a matching enter in this block
        monitorExits.add(exit);
        // however if there is an enter in this block then it belongs to this exit
        // so we pop it to ensurewe only retain active local enters
        // we also record the pairing so we can work back from the matched exit to
        //its enter. pairing with non-local enters is done at block end carry forward
        if (!monitorEnters.isEmpty()) {
            CodeLocation enter = monitorEnters.pop();
            cfg.addMonitorPair(enter, exit);
        }
    }
    return index;
}

From source file:org.jboss.byteman.agent.adapter.cfg.CFG.java

License:Open Source License

/**
 * return the index of the local var at which this monitorenter saved its lock object
 *//* w w  w  .  j a  v a 2s. com*/
public int getSavedMonitorIdx(CodeLocation open) {
    // this should identify a monitorexit instruction preceded by an aload N instruction
    BBlock block = open.getBlock();
    int instructionIdx = open.getInstructionIdx();
    if (instructionIdx <= 0) {
        System.out.println("getSavedMonitorIdx : unexpected! close pair has invalid index " + instructionIdx
                + " in method " + methodName);
    }
    int instruction = block.getInstruction(instructionIdx);
    if (instruction != Opcodes.MONITORENTER) {
        System.out.println("getSavedMonitorIdx : unexpected! close pair instruction " + instruction
                + " is not MONITOREXIT in method " + methodName);
    }
    instructionIdx--;
    instruction = block.getInstruction(instructionIdx);
    // normally the monitorenter is preceded by a DUP ASTORE pair to save the monitor object
    // however, if an AT SYNCHRONIZE trigger has been injected before the MONITORENTER then
    // there may be a call to Rule.execute between the ASTORE and the MONITORENTER
    if (instruction == Opcodes.INVOKESTATIC) {
        // we can safely skip backwards to the last ASTORE because the trigger sequence will not
        // use an ASTORE
        while (instruction != Opcodes.ASTORE && instructionIdx > 0) {
            // skip backwards until we find the required ASTORE
            instructionIdx--;
            instruction = block.getInstruction(instructionIdx);
        }
    }
    if (instruction != Opcodes.ASTORE) {
        System.out.println("getSavedMonitorIdx : unexpected! close pair preceding instruction " + instruction
                + " is not ASTORE in method " + methodName);
        return -1;
    }
    int varIdx = block.getInstructionArg(instructionIdx, 0);
    if (varIdx < 0) {
        System.out.println(
                "getSavedMonitorIdx : unexpected! close pair preceding ASTORE instruction has invalid index "
                        + varIdx + " in method " + methodName);
    }
    return varIdx;
}

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

License:Open Source License

/**
 * Generates the instruction to get the monitor of the top stack value.
 */
public void monitorEnter() {
    visitInsn(Opcodes.MONITORENTER);
}

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

License:Open Source License

@Override
public void visitInsn(int opcode) {
    super.visitInsn(opcode);
    // look for interesting instructions which need inserting into the CFG
    switch (opcode) {
    case Opcodes.IRETURN:
    case Opcodes.LRETURN:
    case Opcodes.FRETURN:
    case Opcodes.DRETURN:
    case Opcodes.ARETURN:
    case Opcodes.RETURN:
    case Opcodes.ATHROW: {
        // add this instruction to the current block and then start a new current block
        cfg.add(opcode);//from   www.  j  a  v a 2s  .  c o m
        Label newStart = super.newLabel();
        // must call split before visiting the label
        cfg.split(newStart);
        visitLabel(newStart);
    }
        break;
    case Opcodes.MONITORENTER:
    case Opcodes.MONITOREXIT: {
        // just add this instruction to the current block
        cfg.add(opcode);
    }
        break;
    default: {
        cfg.add(opcode);
    }
    }
}

From source file:org.openquark.cal.internal.javamodel.AsmJavaBytecodeGenerator.java

License:Open Source License

/**
 * Encode a method invocation that is wrapped in a synchronized block.
 *   See Sun bug id #4414101 for a discussion of this generated code.
 * //ww  w.j  a  v a2s . co m
 * @param smi - the SynchronizedMethodInvocation object.
 * @param context - the context of the code generation.
 * @return - true if the SynchronizedMethodInvocation is terminating.
 * @throws JavaGenerationException
 */
private static boolean encodeSynchronizedMethodInvocation(JavaStatement.SynchronizedMethodInvocation smi,
        GenerationContext context) throws JavaGenerationException {

    MethodVisitor mv = context.getMethodVisitor();

    // Get the JavaExpression for the object to synchronize on and generate the bytecode. 
    JavaExpression objectToSynchOn = smi.getSynchronizingObject();
    encodeExpr(objectToSynchOn, context);

    // The object to synchronize on is now on the stack.  Duplicate it, 
    // move one to storage as a local variable, and to MONITORENTER on the other. 
    mv.visitInsn(Opcodes.DUP);

    int mutexIndex = context.addLocalVar("$mutex", JavaTypeName.OBJECT);
    mv.visitVarInsn(Opcodes.ASTORE, mutexIndex);

    mv.visitInsn(Opcodes.MONITORENTER);

    // We need to wrap the method invocation in a try/catch block so 
    // the monitor can be exited properly if the method invocation throws
    // an exception.
    Label tryCatchStart = new Label();
    mv.visitLabel(tryCatchStart);

    // Note: if this is generalized to handle any synchronized statement (for example, a synchronized block), 
    //   then the scope of entries in the exception table here will have to be modified to exclude return instructions.
    //   See encodeTryCatchStatement() for how to do this.
    //   Here, the only statement in the try block is a single expressionStatement, which has no return instructions, 
    //     so we don't have to worry about handling this case.

    // Get the method invocation and generate the corresponding bytecode.
    MethodInvocation methodInvocation = smi.getMethodInvocation();
    encodeExpr(methodInvocation, context);

    // Load the mutex object back onto the stack and do MonitorExit.
    mv.visitVarInsn(Opcodes.ALOAD, mutexIndex);
    mv.visitInsn(Opcodes.MONITOREXIT);

    // Label the end of the try block around the method invocation.
    Label tryEnd = new Label();
    mv.visitLabel(tryEnd);

    // At this point we want to code an instruction to jump past the exception handling
    // code.
    Label tryCatchEnd = new Label();
    mv.visitJumpInsn(Opcodes.GOTO, tryCatchEnd);

    // Label the start of the exception handling code.
    Label catchStart = new Label();
    mv.visitLabel(catchStart);

    // The exception is on the stack.  Store it as a local.
    int exceptionIndex = context.addLocalVar("exception", JavaTypeName.OBJECT);
    mv.visitVarInsn(Opcodes.ASTORE, exceptionIndex);

    // Retrieve the mutex object and do MONITOREXIT.
    mv.visitVarInsn(Opcodes.ALOAD, mutexIndex);
    mv.visitInsn(Opcodes.MONITOREXIT);

    // Label the end of the exception handling code that deals with the monitor.
    Label exceptionMonitorExitEnd = new Label();
    mv.visitLabel(exceptionMonitorExitEnd);

    // Retrieve the exception and throw it.
    mv.visitVarInsn(Opcodes.ALOAD, exceptionIndex);
    mv.visitInsn(Opcodes.ATHROW);

    // Vist the label to mark the end of the try/catch.
    mv.visitLabel(tryCatchEnd);

    // Set up the try/catch block to catch exceptions thrown by the method invocation
    // and handle exiting the monitor.
    mv.visitTryCatchBlock(tryCatchStart, tryEnd, catchStart, null);

    // Set up a try catch block so that if an exception is thrown by trying to exit 
    // the monitor in the case of an exception from the method invocation we will keep trying to 
    // exit the monitor.
    mv.visitTryCatchBlock(catchStart, exceptionMonitorExitEnd, catchStart, null);

    return false;
}

From source file:org.sonar.java.bytecode.se.BytecodeEGWalkerExecuteTest.java

License:Open Source License

@Test
public void test_monitor_enter_exit() throws Exception {
    int opcodes[] = { Opcodes.MONITORENTER, Opcodes.MONITOREXIT };

    for (int opcode : opcodes) {
        ProgramState programState = execute(new Instruction(opcode),
                ProgramState.EMPTY_STATE.stackValue(new SymbolicValue()));
        assertEmptyStack(programState);/*from w  w  w .j  a  v  a  2  s  .c  om*/

        assertThatThrownBy(() -> execute(new Instruction(opcode)))
                .hasMessage(Printer.OPCODES[opcode] + " needs 1 values on stack");
    }
}

From source file:pt.minha.kernel.instrument.SyncToMonitorClassVisitor.java

License:Open Source License

public void makeStub(int access, String name, String desc, String signature, String[] exceptions) {
    Method m = new Method(name, desc);

    MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
    mv.visitCode();/* w  w w  .  ja v a  2 s.  c  om*/

    Label begin = new Label();
    Label pre_invoke = new Label();
    Label pos_leave = new Label();
    Label in_catch = new Label();
    Label pre_rethrow = new Label();
    Label end = new Label();

    mv.visitTryCatchBlock(pre_invoke, pos_leave, in_catch, null);
    mv.visitTryCatchBlock(in_catch, pre_rethrow, in_catch, null);

    mv.visitLabel(begin);

    int offset;
    if ((access & Opcodes.ACC_STATIC) == 0) {
        mv.visitVarInsn(Opcodes.ALOAD, 0);
        offset = 1;
    } else {
        mv.visitFieldInsn(Opcodes.GETSTATIC, clz, "_fake_class",
                "L" + ClassConfig.fake_prefix + "java/lang/Object;");
        offset = 0;
    }

    int length = 0;
    for (Type t : m.getArgumentTypes())
        length += t.getSize();

    mv.visitInsn(Opcodes.DUP);
    mv.visitVarInsn(Opcodes.ASTORE, offset + length);
    mv.visitInsn(Opcodes.MONITORENTER);

    mv.visitLabel(pre_invoke);

    if ((access & Opcodes.ACC_STATIC) == 0)
        mv.visitVarInsn(Opcodes.ALOAD, 0);

    int i = offset;
    for (Type t : m.getArgumentTypes()) {
        // t.getOpcode() should work for long and double too... :-( 
        if (t.getClassName().equals("long"))
            mv.visitVarInsn(Opcodes.LLOAD, i);
        else if (t.getClassName().equals("double"))
            mv.visitVarInsn(Opcodes.DLOAD, i);
        else
            mv.visitVarInsn(t.getOpcode(Opcodes.ILOAD), i);
        i += t.getSize();
    }

    boolean itf = (access & Opcodes.ACC_INTERFACE) != 0;
    if ((access & Opcodes.ACC_STATIC) == 0)
        mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, clz, "_" + name, desc, itf);
    else
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, clz, "_" + name, desc, itf);

    mv.visitVarInsn(Opcodes.ALOAD, offset + length);
    mv.visitInsn(Opcodes.MONITOREXIT);

    mv.visitLabel(pos_leave);

    if (m.getReturnType().equals(Type.VOID_TYPE))
        mv.visitInsn(Opcodes.RETURN);
    else
        mv.visitInsn(m.getReturnType().getOpcode(Opcodes.IRETURN));

    mv.visitLabel(in_catch);

    mv.visitVarInsn(Opcodes.ALOAD, offset + length);
    mv.visitInsn(Opcodes.MONITOREXIT);

    mv.visitLabel(pre_rethrow);
    mv.visitInsn(Opcodes.ATHROW);

    mv.visitLabel(end);

    i = 0;
    if ((access & Opcodes.ACC_STATIC) == 0)
        mv.visitLocalVariable("this", "L" + clz + ";", null, begin, end, i++);
    for (Type t : m.getArgumentTypes())
        mv.visitLocalVariable("arg" + i, t.getDescriptor(), null, begin, end, i++);

    mv.visitMaxs(0, 0);
    mv.visitEnd();
}

From source file:serianalyzer.JVMImpl.java

License:Open Source License

/**
 * @param opcode//  w w w.j a va2s  .c  o m
 * @param s
 */
static void handleJVMInsn(int opcode, JVMStackState s) {
    BaseType o1;
    BaseType o2;
    BaseType o3;
    List<BaseType> l1;
    List<BaseType> l2;
    switch (opcode) {
    case Opcodes.NOP:
        break;

    case Opcodes.ARRAYLENGTH:
        o1 = s.pop();
        s.push(new BasicConstant(Type.INT_TYPE, 0, !(o1 != null && !o1.isTainted())));
        break;
    case Opcodes.ACONST_NULL:
        s.push(new BasicConstant(Type.VOID_TYPE, "<null>")); //$NON-NLS-1$
        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:
        s.push(new BasicConstant(Type.INT_TYPE, opcode - 3));
        break;
    case Opcodes.LCONST_0:
    case Opcodes.LCONST_1:
        s.push(new BasicConstant(Type.LONG_TYPE, opcode - 9L));
        break;
    case Opcodes.FCONST_0:
    case Opcodes.FCONST_1:
    case Opcodes.FCONST_2:
        s.push(new BasicConstant(Type.FLOAT_TYPE, opcode - 11f));
        break;
    case Opcodes.DCONST_0:
    case Opcodes.DCONST_1:
        s.push(new BasicConstant(Type.DOUBLE_TYPE, opcode - 14d));
        break;
    case Opcodes.IALOAD:
    case Opcodes.LALOAD:
    case Opcodes.FALOAD:
    case Opcodes.DALOAD:
    case Opcodes.BALOAD:
    case Opcodes.CALOAD:
    case Opcodes.SALOAD:
        o1 = s.pop();
        o2 = s.pop();
        s.push(new BasicVariable(toType(opcode), "primitive array elem", //$NON-NLS-1$
                (o1 == null || o1.isTainted()) | (o2 == null || o2.isTainted())));
        break;

    case Opcodes.AALOAD:
        o1 = s.pop();
        o2 = s.pop();
        if (o1 != null && o2 instanceof SimpleType && ((SimpleType) o2).getType().toString().startsWith("[")) { //$NON-NLS-1$
            Type atype = Type.getType(((SimpleType) o2).getType().toString().substring(1));
            if (o2.getAlternativeTypes() != null && !o2.getAlternativeTypes().isEmpty()) {
                s.clear();
                break;
            }
            s.push(new BasicVariable(atype, "array elem " + atype, o1.isTainted() | o2.isTainted())); //$NON-NLS-1$
        } else {
            s.clear();
        }
        break;

    case Opcodes.IASTORE:
    case Opcodes.LASTORE:
    case Opcodes.FASTORE:
    case Opcodes.DASTORE:
    case Opcodes.AASTORE:
    case Opcodes.BASTORE:
    case Opcodes.CASTORE:
    case Opcodes.SASTORE:
        s.pop(3);
        break;

    case Opcodes.POP2:
        s.pop();
    case Opcodes.MONITORENTER:
    case Opcodes.MONITOREXIT:
    case Opcodes.POP:
        s.pop();
        break;

    case Opcodes.DUP:
        if (!s.isEmpty()) {
            o1 = s.pop();
            s.push(o1);
            s.push(o1);
        }
        break;
    case Opcodes.DUP_X1:
        o1 = s.pop();
        o2 = s.pop();
        s.push(o1);
        s.push(o2);
        s.push(o1);
        break;
    case Opcodes.DUP_X2:
        o1 = s.pop();
        o2 = s.pop();
        o3 = s.pop();
        s.push(o1);
        s.push(o3);
        s.push(o2);
        s.push(o1);
        break;
    case Opcodes.DUP2:
        l1 = s.popWord();
        if (l1.isEmpty()) {
            log.trace("DUP2 with unknown operand"); //$NON-NLS-1$
            s.clear();
        } else {
            s.pushWord(l1);
            s.pushWord(l1);
        }
        break;
    case Opcodes.DUP2_X1:
        l1 = s.popWord();
        o1 = s.pop();
        if (l1.isEmpty()) {
            log.trace("DUP2 with unknown operand"); //$NON-NLS-1$
            s.clear();
        } else {
            s.pushWord(l1);
            s.push(o1);
            s.pushWord(l1);
        }
        break;
    case Opcodes.DUP2_X2:
        l1 = s.popWord();
        l2 = s.popWord();
        if (l1.isEmpty() || l2.isEmpty()) {
            log.trace("DUP2 with unknown operand"); //$NON-NLS-1$
            s.clear();
        } else {
            s.pushWord(l1);
            s.pushWord(l2);
            s.pushWord(l1);
        }
        break;

    case Opcodes.SWAP:
        o1 = s.pop();
        o2 = s.pop();
        s.push(o1);
        s.push(o2);
        break;

    case Opcodes.IADD:
    case Opcodes.LADD:
    case Opcodes.FADD:
    case Opcodes.DADD:
    case Opcodes.ISUB:
    case Opcodes.LSUB:
    case Opcodes.FSUB:
    case Opcodes.DSUB:
    case Opcodes.IMUL:
    case Opcodes.LMUL:
    case Opcodes.FMUL:
    case Opcodes.DMUL:
    case Opcodes.IDIV:
    case Opcodes.LDIV:
    case Opcodes.FDIV:
    case Opcodes.DDIV:
    case Opcodes.IREM:
    case Opcodes.LREM:
    case Opcodes.FREM:
    case Opcodes.DREM:
    case Opcodes.IAND:
    case Opcodes.LAND:
    case Opcodes.IOR:
    case Opcodes.LOR:
    case Opcodes.IXOR:
    case Opcodes.LXOR:
    case Opcodes.LCMP:
    case Opcodes.FCMPL:
    case Opcodes.FCMPG:
    case Opcodes.DCMPL:
    case Opcodes.DCMPG:
        s.merge(2);
        break;

    case Opcodes.ISHL:
    case Opcodes.LSHL:
    case Opcodes.ISHR:
    case Opcodes.LSHR:
    case Opcodes.IUSHR:
    case Opcodes.LUSHR:
        s.pop(); // amount
        // ignore value
        break;

    case Opcodes.INEG:
    case Opcodes.F2I:
    case Opcodes.D2I:
    case Opcodes.L2I:
        s.push(cast(s.pop(), Type.INT_TYPE));
        break;

    case Opcodes.LNEG:
    case Opcodes.I2L:
    case Opcodes.F2L:
    case Opcodes.D2L:
        s.push(cast(s.pop(), Type.LONG_TYPE));
        break;

    case Opcodes.FNEG:
    case Opcodes.I2F:
    case Opcodes.L2F:
    case Opcodes.D2F:
        s.push(cast(s.pop(), Type.FLOAT_TYPE));

    case Opcodes.DNEG:
    case Opcodes.I2D:
    case Opcodes.L2D:
    case Opcodes.F2D:
        s.push(cast(s.pop(), Type.DOUBLE_TYPE));

    case Opcodes.I2B:
        s.push(cast(s.pop(), Type.BYTE_TYPE));
        break;
    case Opcodes.I2C:
        s.push(cast(s.pop(), Type.CHAR_TYPE));
        break;
    case Opcodes.I2S:
        s.push(cast(s.pop(), Type.SHORT_TYPE));
        break;

    case Opcodes.ARETURN:
        s.clear();
        break;

    case Opcodes.IRETURN:
    case Opcodes.LRETURN:
    case Opcodes.FRETURN:
    case Opcodes.DRETURN:
    case Opcodes.RETURN:
        if (log.isTraceEnabled()) {
            log.trace("Found return " + s.pop()); //$NON-NLS-1$
        }
        s.clear();
        break;

    case Opcodes.ATHROW:
        Object thrw = s.pop();
        log.trace("Found throw " + thrw); //$NON-NLS-1$
        s.clear();
        break;

    default:
        log.warn("Unsupported instruction code " + opcode); //$NON-NLS-1$
    }
}