Example usage for org.objectweb.asm Opcodes LLOAD

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

Introduction

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

Prototype

int LLOAD

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

Click Source Link

Usage

From source file:org.pitest.mutationtest.engine.gregor.mutators.experimental.extended.AODMutator2.java

License:Apache License

@Override
public void visitInsn(int opcode) {
    switch (opcode) {
    case Opcodes.IADD:
    case Opcodes.ISUB:
    case Opcodes.IMUL:
    case Opcodes.IDIV:
    case Opcodes.IREM:
        if (this.shouldMutate(OpcodeToType.typeOfOpcode(opcode))) {
            int storage = this.newLocal(Type.INT_TYPE);
            mv.visitVarInsn(Opcodes.ISTORE, storage);
            mv.visitInsn(Opcodes.POP);//from  w  ww  .  ja v a 2 s.  c o  m
            mv.visitVarInsn(Opcodes.ILOAD, storage);
            /*
             * Alternative : mv.visitInsn(Opcodes.SWAP);
             * mv.visitInsn(Opcodes.POP);
             * mv.visitVarInsn(Opcodes.ILOAD,storage);
             */
        } else {
            mv.visitInsn(opcode);
        }
        break;
    case Opcodes.FADD:
    case Opcodes.FSUB:
    case Opcodes.FMUL:
    case Opcodes.FDIV:
    case Opcodes.FREM:
        if (this.shouldMutate(OpcodeToType.typeOfOpcode(opcode))) {
            int storage = this.newLocal(Type.FLOAT_TYPE);
            mv.visitVarInsn(Opcodes.FSTORE, storage);
            mv.visitInsn(Opcodes.POP);
            mv.visitVarInsn(Opcodes.FLOAD, storage);
        } else {
            mv.visitInsn(opcode);
        }
        break;
    case Opcodes.LADD:
    case Opcodes.LSUB:
    case Opcodes.LMUL:
    case Opcodes.LDIV:
    case Opcodes.LREM:
        if (this.shouldMutate(OpcodeToType.typeOfOpcode(opcode))) {
            int storage = this.newLocal(Type.LONG_TYPE);
            mv.visitVarInsn(Opcodes.LSTORE, storage);
            mv.visitInsn(Opcodes.POP2);
            mv.visitVarInsn(Opcodes.LLOAD, storage);
        } else {
            mv.visitInsn(opcode);
        }
        break;
    case Opcodes.DADD:
    case Opcodes.DSUB:
    case Opcodes.DMUL:
    case Opcodes.DDIV:
    case Opcodes.DREM:
        if (this.shouldMutate(OpcodeToType.typeOfOpcode(opcode))) {
            int storage = this.newLocal(Type.DOUBLE_TYPE);
            mv.visitVarInsn(Opcodes.DSTORE, storage);
            mv.visitInsn(Opcodes.POP2);
            mv.visitVarInsn(Opcodes.DLOAD, storage);
        } else {
            mv.visitInsn(opcode);
        }
        break;
    default:
        mv.visitInsn(opcode);
        break;
    }
}

From source file:org.pitest.mutationtest.engine.gregor.mutators.experimental.extended.OBBNMutator3.java

License:Apache License

@Override
public void visitInsn(int opcode) {
    switch (opcode) {
    case Opcodes.IAND:
    case Opcodes.IOR:
        if (this.shouldMutate(OpcodeToType.typeOfOpcode(opcode))) {
            int storage = this.newLocal(Type.INT_TYPE);
            mv.visitVarInsn(Opcodes.ISTORE, storage);
            mv.visitInsn(Opcodes.POP);//w w  w. j a v  a 2 s .c  o m
            mv.visitVarInsn(Opcodes.ILOAD, storage);
        } else {
            mv.visitInsn(opcode);
        }
        break;
    case Opcodes.LAND:
    case Opcodes.LOR:
        if (this.shouldMutate(OpcodeToType.typeOfOpcode(opcode))) {
            int storage = this.newLocal(Type.LONG_TYPE);
            mv.visitVarInsn(Opcodes.LSTORE, storage);
            mv.visitInsn(Opcodes.POP2);
            mv.visitVarInsn(Opcodes.LLOAD, storage);
        } else {
            mv.visitInsn(opcode);
        }
        break;
    default:
        mv.visitInsn(opcode);
        break;
    }
}

From source file:org.pitest.mutationtest.engine.gregor.mutators.experimental.extended.UOIMutator1.java

License:Apache License

@Override
public void visitVarInsn(int opcode, int var) {
    mv.visitVarInsn(opcode, var);

    switch (opcode) {
    case Opcodes.ILOAD:
        if (this.shouldMutate("Incremented (a++) integer local variable number " + var)) {
            mv.visitIincInsn(var, 1);
        }//from w w  w  .j  av a 2  s. c o  m
        break;
    case Opcodes.FLOAD:
        if (this.shouldMutate("Incremented (a++) float local variable number " + var)) {
            mv.visitInsn(Opcodes.DUP);
            mv.visitInsn(Opcodes.FCONST_1);
            mv.visitInsn(Opcodes.FADD);
            mv.visitVarInsn(Opcodes.FSTORE, var);
        }
        break;
    case Opcodes.LLOAD:
        if (this.shouldMutate("Incremented (a++) long local variable number " + var)) {
            mv.visitInsn(Opcodes.DUP2);
            mv.visitInsn(Opcodes.LCONST_1);
            mv.visitInsn(Opcodes.LADD);
            mv.visitVarInsn(Opcodes.LSTORE, var);
        }
        break;
    case Opcodes.DLOAD:
        if (this.shouldMutate("Incremented (a++) double local variable number " + var)) {
            mv.visitInsn(Opcodes.DUP2);
            mv.visitInsn(Opcodes.DCONST_1);
            mv.visitInsn(Opcodes.DADD);
            mv.visitVarInsn(Opcodes.DSTORE, var);
        }
        break;

    default:
        break;
    }
}

From source file:org.pitest.mutationtest.engine.gregor.mutators.experimental.extended.UOIMutator2.java

License:Apache License

@Override
public void visitVarInsn(int opcode, int var) {
    mv.visitVarInsn(opcode, var);
    switch (opcode) {
    case Opcodes.ILOAD:
        if (this.shouldMutate("Decremented (a--) integer local variable number " + var)) {
            mv.visitIincInsn(var, -1);
        }//from   w ww  . j a va 2  s  .  c  o  m
        break;
    case Opcodes.FLOAD:
        if (this.shouldMutate("Decremented (a--) float local variable number " + var)) {
            mv.visitInsn(Opcodes.DUP);
            mv.visitInsn(Opcodes.FCONST_1);
            mv.visitInsn(Opcodes.FSUB);
            mv.visitVarInsn(Opcodes.FSTORE, var);
        }
        break;
    case Opcodes.LLOAD:
        if (this.shouldMutate("Decremented (a--) long local variable number " + var)) {
            mv.visitInsn(Opcodes.DUP2);
            mv.visitInsn(Opcodes.LCONST_1);
            mv.visitInsn(Opcodes.LSUB);
            mv.visitVarInsn(Opcodes.LSTORE, var);
        }
        break;
    case Opcodes.DLOAD:
        if (this.shouldMutate("Decremented (a--) double local variable number " + var)) {
            mv.visitInsn(Opcodes.DUP2);
            mv.visitInsn(Opcodes.DCONST_1);
            mv.visitInsn(Opcodes.DSUB);
            mv.visitVarInsn(Opcodes.DSTORE, var);
        }
        break;
    default:
        break;
    }
}

From source file:org.pitest.mutationtest.engine.gregor.mutators.experimental.extended.UOIMutator3.java

License:Apache License

@Override
public void visitVarInsn(int opcode, int var) {
    switch (opcode) {
    case Opcodes.ILOAD:
        if (this.shouldMutate("Incremented (++a) integer local variable number " + var)) {
            mv.visitIincInsn(var, 1);
        }// w ww . j a v a 2s  . c  o m
        mv.visitVarInsn(opcode, var);
        break;
    case Opcodes.FLOAD:
        if (this.shouldMutate("Incremented (++a) float local variable number " + var)) {
            mv.visitVarInsn(opcode, var);
            mv.visitInsn(Opcodes.FCONST_1);
            mv.visitInsn(Opcodes.FADD);
            mv.visitVarInsn(Opcodes.FSTORE, var);
        }
        mv.visitVarInsn(opcode, var);
        break;
    case Opcodes.LLOAD:
        if (this.shouldMutate("Incremented (++a) long local variable number " + var)) {
            mv.visitVarInsn(opcode, var);
            mv.visitInsn(Opcodes.LCONST_1);
            mv.visitInsn(Opcodes.LADD);
            mv.visitVarInsn(Opcodes.LSTORE, var);
        }
        mv.visitVarInsn(opcode, var);
        break;
    case Opcodes.DLOAD:
        if (this.shouldMutate("Incremented (++a) double local variable number " + var)) {
            mv.visitVarInsn(opcode, var);
            mv.visitInsn(Opcodes.DCONST_1);
            mv.visitInsn(Opcodes.DADD);
            mv.visitVarInsn(Opcodes.DSTORE, var);
        }
        mv.visitVarInsn(opcode, var);
        break;
    default:
        mv.visitVarInsn(opcode, var);
        break;
    }
}

From source file:org.pitest.mutationtest.engine.gregor.mutators.experimental.extended.UOIMutator4.java

License:Apache License

@Override
public void visitVarInsn(int opcode, int var) {
    switch (opcode) {
    case Opcodes.ILOAD:
        if (this.shouldMutate("Decremented (--a) integer local variable number " + var)) {
            mv.visitIincInsn(var, -1);
        }//from w w  w . j a v  a  2 s  . co m
        mv.visitVarInsn(opcode, var);

        break;

    case Opcodes.FLOAD:
        if (this.shouldMutate("Decremented (--a) float local variable number " + var)) {
            mv.visitVarInsn(opcode, var);
            mv.visitInsn(Opcodes.FCONST_1);
            mv.visitInsn(Opcodes.FSUB);
            mv.visitVarInsn(Opcodes.FSTORE, var);
        }
        mv.visitVarInsn(opcode, var);

        break;

    case Opcodes.LLOAD:
        if (this.shouldMutate("Decremented (--a) long local variable number " + var)) {
            mv.visitVarInsn(opcode, var);
            mv.visitInsn(Opcodes.LCONST_1);
            mv.visitInsn(Opcodes.LSUB);
            mv.visitVarInsn(Opcodes.LSTORE, var);
        }
        mv.visitVarInsn(opcode, var);
        break;

    case Opcodes.DLOAD:
        if (this.shouldMutate("Decremented (--a) double local variable number " + var)) {
            mv.visitVarInsn(opcode, var);
            mv.visitInsn(Opcodes.DCONST_1);
            mv.visitInsn(Opcodes.DSUB);
            mv.visitVarInsn(Opcodes.DSTORE, var);
        }
        mv.visitVarInsn(opcode, var);
        break;

    default:
        mv.visitVarInsn(opcode, var);
        break;
    }
}

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

License:Open Source License

@Test
public void test_load() throws Exception {
    int[] loadRefOpcodes = new int[] { Opcodes.ILOAD, Opcodes.LLOAD, Opcodes.FLOAD, Opcodes.DLOAD,
            Opcodes.ALOAD };/*  w  w  w  .  ja  v  a  2 s .co m*/
    for (int loadRefOpcode : loadRefOpcodes) {
        SymbolicValue loadRef = new SymbolicValue();
        ProgramState programState = execute(new Instruction(loadRefOpcode, 0),
                ProgramState.EMPTY_STATE.put(0, loadRef));
        assertThat(programState.peekValue()).isEqualTo(loadRef);
        // no SV indexed should failed
        assertThatThrownBy(() -> execute(new Instruction(loadRefOpcode, 0), ProgramState.EMPTY_STATE))
                .hasMessage("Loading a symbolic value unindexed");
    }
}

From source file:org.spongepowered.despector.emitter.bytecode.instruction.BytecodeLocalAccessEmitter.java

License:Open Source License

@Override
public void emit(BytecodeEmitterContext ctx, LocalAccess arg, TypeSignature t) {
    MethodVisitor mv = ctx.getMethodVisitor();
    TypeSignature type = arg.getLocal().getType();
    if (type == ClassTypeSignature.INT || type == ClassTypeSignature.BOOLEAN || type == ClassTypeSignature.BYTE
            || type == ClassTypeSignature.SHORT || type == ClassTypeSignature.CHAR) {
        mv.visitVarInsn(Opcodes.ILOAD, arg.getLocal().getIndex());
    } else if (type == ClassTypeSignature.LONG) {
        mv.visitVarInsn(Opcodes.LLOAD, arg.getLocal().getIndex());
    } else if (type == ClassTypeSignature.FLOAT) {
        mv.visitVarInsn(Opcodes.FLOAD, arg.getLocal().getIndex());
    } else if (type == ClassTypeSignature.DOUBLE) {
        mv.visitVarInsn(Opcodes.DLOAD, arg.getLocal().getIndex());
    } else {//from   w  w w  . j a va 2s .  com
        mv.visitVarInsn(Opcodes.ALOAD, arg.getLocal().getIndex());
    }
    ctx.updateStack(1);
}

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();//from w  w  w . ja  v a 2  s  .  com

    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:scouter.agent.asm.ApicallASM.java

License:Apache License

public void visitCode() {
    int sidx = isStatic ? 0 : 1;
    int arrVarIdx = newLocal(Type.getType("[Ljava/lang/Object;"));
    AsmUtil.PUSH(mv, paramTypes.length);
    mv.visitTypeInsn(Opcodes.ANEWARRAY, "java/lang/Object");
    mv.visitVarInsn(Opcodes.ASTORE, arrVarIdx);
    for (int i = 0; i < paramTypes.length; i++) {
        Type tp = paramTypes[i];//w  w  w .ja  v a  2s. co m
        mv.visitVarInsn(Opcodes.ALOAD, arrVarIdx);
        AsmUtil.PUSH(mv, i);
        switch (tp.getSort()) {
        case Type.BOOLEAN:
            mv.visitVarInsn(Opcodes.ILOAD, sidx);
            mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Boolean", "valueOf", "(Z)Ljava/lang/Boolean;",
                    false);
            break;
        case Type.BYTE:
            mv.visitVarInsn(Opcodes.ILOAD, sidx);
            mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Byte", "valueOf", "(B)Ljava/lang/Byte;", false);
            break;
        case Type.CHAR:
            mv.visitVarInsn(Opcodes.ILOAD, sidx);
            mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Character", "valueOf",
                    "(C)Ljava/lang/Character;", false);
            break;
        case Type.SHORT:
            mv.visitVarInsn(Opcodes.ILOAD, sidx);
            mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Short", "valueOf", "(S)Ljava/lang/Short;",
                    false);
            break;
        case Type.INT:
            mv.visitVarInsn(Opcodes.ILOAD, sidx);
            mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;",
                    false);
            break;
        case Type.LONG:
            mv.visitVarInsn(Opcodes.LLOAD, sidx);
            mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Long", "valueOf", "(J)Ljava/lang/Long;", false);
            break;
        case Type.FLOAT:
            mv.visitVarInsn(Opcodes.FLOAD, sidx);
            mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Float", "valueOf", "(F)Ljava/lang/Float;",
                    false);
            break;
        case Type.DOUBLE:
            mv.visitVarInsn(Opcodes.DLOAD, sidx);
            mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Double", "valueOf", "(D)Ljava/lang/Double;",
                    false);
            break;
        default:
            mv.visitVarInsn(Opcodes.ALOAD, sidx);
        }
        mv.visitInsn(Opcodes.AASTORE);
        sidx += tp.getSize();
    }
    AsmUtil.PUSH(mv, className);
    AsmUtil.PUSH(mv, methodName);
    AsmUtil.PUSH(mv, methodDesc);
    if (isStatic) {
        AsmUtil.PUSHNULL(mv);
    } else {
        mv.visitVarInsn(Opcodes.ALOAD, 0);
    }
    mv.visitVarInsn(Opcodes.ALOAD, arrVarIdx);
    mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACESUBCALL, START_METHOD, START_SIGNATURE, false);
    statIdx = newLocal(Type.getType(Object.class));
    mv.visitVarInsn(Opcodes.ASTORE, statIdx);
    mv.visitLabel(startFinally);
    mv.visitCode();
}