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.evosuite.graphs.cfg.BytecodeInstructionPool.java

License:Open Source License

/**
 * Determine how many bytes the current instruction occupies together with
 * its operands/* w ww .j  a  v  a2 s. c o  m*/
 * 
 * @return
 */
private int getBytecodeIncrement(AbstractInsnNode instructionNode) {
    int opcode = instructionNode.getOpcode();
    switch (opcode) {
    case Opcodes.ALOAD: // index
    case Opcodes.ASTORE: // index
    case Opcodes.DLOAD:
    case Opcodes.DSTORE:
    case Opcodes.FLOAD:
    case Opcodes.FSTORE:
    case Opcodes.ILOAD:
    case Opcodes.ISTORE:
    case Opcodes.LLOAD:
    case Opcodes.LSTORE:
        VarInsnNode varNode = (VarInsnNode) instructionNode;
        if (varNode.var > 3)
            return 1;
        else
            return 0;
    case Opcodes.BIPUSH: // byte
    case Opcodes.NEWARRAY:
    case Opcodes.RET:
        return 1;
    case Opcodes.LDC:
        LdcInsnNode ldcNode = (LdcInsnNode) instructionNode;
        if (ldcNode.cst instanceof Double || ldcNode.cst instanceof Long)
            return 2; // LDC2_W
        else
            return 1;
    case 19: //LDC_W
    case 20: //LDC2_W
        return 2;
    case Opcodes.ANEWARRAY: // indexbyte1, indexbyte2
    case Opcodes.CHECKCAST: // indexbyte1, indexbyte2
    case Opcodes.GETFIELD:
    case Opcodes.GETSTATIC:
    case Opcodes.GOTO:
    case Opcodes.IF_ACMPEQ:
    case Opcodes.IF_ACMPNE:
    case Opcodes.IF_ICMPEQ:
    case Opcodes.IF_ICMPNE:
    case Opcodes.IF_ICMPGE:
    case Opcodes.IF_ICMPGT:
    case Opcodes.IF_ICMPLE:
    case Opcodes.IF_ICMPLT:
    case Opcodes.IFLE:
    case Opcodes.IFLT:
    case Opcodes.IFGE:
    case Opcodes.IFGT:
    case Opcodes.IFNE:
    case Opcodes.IFEQ:
    case Opcodes.IFNONNULL:
    case Opcodes.IFNULL:
    case Opcodes.IINC:
    case Opcodes.INSTANCEOF:
    case Opcodes.INVOKESPECIAL:
    case Opcodes.INVOKESTATIC:
    case Opcodes.INVOKEVIRTUAL:
    case Opcodes.JSR:
    case Opcodes.NEW:
    case Opcodes.PUTFIELD:
    case Opcodes.PUTSTATIC:
    case Opcodes.SIPUSH:
        // case Opcodes.LDC_W
        // case Opcodes.LDC2_W

        return 2;
    case Opcodes.MULTIANEWARRAY:
        return 3;
    case Opcodes.INVOKEDYNAMIC:
    case Opcodes.INVOKEINTERFACE:
        return 4;

    case Opcodes.LOOKUPSWITCH:
    case Opcodes.TABLESWITCH:
        // TODO: Could be more
        return 4;
    // case Opcodes.GOTO_W 
    // case Opcodes.JSR_W
    }
    return 0;
}

From source file:org.evosuite.instrumentation.mutation.InsertUnaryOperator.java

License:Open Source License

/** {@inheritDoc} */
@Override//from w ww  .  jav  a  2s  .  c o  m
public boolean isApplicable(BytecodeInstruction instruction) {
    AbstractInsnNode node = instruction.getASMNode();
    switch (node.getOpcode()) {
    case Opcodes.ILOAD:
    case Opcodes.LLOAD:
    case Opcodes.FLOAD:
    case Opcodes.DLOAD:
        return true;
    case Opcodes.GETFIELD:
    case Opcodes.GETSTATIC:
        FieldInsnNode fieldNode = (FieldInsnNode) instruction.getASMNode();
        Type type = Type.getType(fieldNode.desc);
        if (type == Type.BYTE_TYPE || type == Type.SHORT_TYPE || type == Type.LONG_TYPE
                || type == Type.FLOAT_TYPE || type == Type.DOUBLE_TYPE || type == Type.BOOLEAN_TYPE
                || type == Type.INT_TYPE) {
            return true;
        }
    default:
        return false;
    }
}

From source file:org.evosuite.instrumentation.mutation.InsertUnaryOperator.java

License:Open Source License

private int getNegation(int opcode) {
    switch (opcode) {
    case Opcodes.ILOAD:
        return Opcodes.INEG;
    case Opcodes.LLOAD:
        return Opcodes.LNEG;
    case Opcodes.FLOAD:
        return Opcodes.FNEG;
    case Opcodes.DLOAD:
        return Opcodes.DNEG;
    default://  ww w . ja v a2 s  .co m
        throw new RuntimeException("Invalid opcode for negation: " + opcode);
    }
}

From source file:org.evosuite.instrumentation.mutation.ReplaceArithmeticOperator.java

License:Open Source License

@SuppressWarnings("rawtypes")
private static int getNextIndexFromLoad(MethodNode mn) {
    Iterator it = mn.instructions.iterator();
    int index = 0;
    while (it.hasNext()) {
        AbstractInsnNode node = (AbstractInsnNode) it.next();
        if (node instanceof VarInsnNode) {
            VarInsnNode varNode = (VarInsnNode) node;
            int varIndex = varNode.var;
            switch (varNode.getOpcode()) {
            case Opcodes.ALOAD:
            case Opcodes.ILOAD:
            case Opcodes.FLOAD:
            case Opcodes.IALOAD:
            case Opcodes.BALOAD:
            case Opcodes.CALOAD:
            case Opcodes.AALOAD:
            case Opcodes.ASTORE:
            case Opcodes.ISTORE:
            case Opcodes.FSTORE:
            case Opcodes.IASTORE:
            case Opcodes.BASTORE:
            case Opcodes.CASTORE:
            case Opcodes.AASTORE:
                index = Math.max(index, varIndex + 1);
                break;
            case Opcodes.DLOAD:
            case Opcodes.DSTORE:
            case Opcodes.LLOAD:
            case Opcodes.LSTORE:
            case Opcodes.DALOAD:
            case Opcodes.DASTORE:
            case Opcodes.LALOAD:
            case Opcodes.LASTORE:
                index = Math.max(index, varIndex + 2);
                break;
            }//from  w  w w  .j av a2  s.  c  om
        }
    }

    return index;
}

From source file:org.evosuite.instrumentation.mutation.ReplaceArithmeticOperator.java

License:Open Source License

/**
 * <p>getInfectionDistance</p>
 *
 * @param opcodeOrig a int./*from  w  w  w.  java 2  s  .c o  m*/
 * @param opcodeNew a int.
 * @return a {@link org.objectweb.asm.tree.InsnList} object.
 */
public InsnList getInfectionDistance(int opcodeOrig, int opcodeNew) {
    InsnList distance = new InsnList();

    if (opcodesInt.contains(opcodeOrig)) {
        distance.add(new InsnNode(Opcodes.DUP2));
        distance.add(new LdcInsnNode(opcodeOrig));
        distance.add(new LdcInsnNode(opcodeNew));
        distance.add(new MethodInsnNode(Opcodes.INVOKESTATIC,
                PackageInfo.getNameWithSlash(ReplaceArithmeticOperator.class), "getInfectionDistanceInt",
                "(IIII)D", false));
    } else if (opcodesLong.contains(opcodeOrig)) {
        distance.add(new VarInsnNode(Opcodes.LSTORE, numVariable));
        distance.add(new InsnNode(Opcodes.DUP2));
        distance.add(new VarInsnNode(Opcodes.LLOAD, numVariable));
        distance.add(new InsnNode(Opcodes.DUP2_X2));
        distance.add(new LdcInsnNode(opcodeOrig));
        distance.add(new LdcInsnNode(opcodeNew));
        distance.add(new MethodInsnNode(Opcodes.INVOKESTATIC,
                PackageInfo.getNameWithSlash(ReplaceArithmeticOperator.class), "getInfectionDistanceLong",
                "(JJII)D", false));
        numVariable += 2;
    } else if (opcodesFloat.contains(opcodeOrig)) {
        distance.add(new InsnNode(Opcodes.DUP2));
        distance.add(new LdcInsnNode(opcodeOrig));
        distance.add(new LdcInsnNode(opcodeNew));
        distance.add(new MethodInsnNode(Opcodes.INVOKESTATIC,
                PackageInfo.getNameWithSlash(ReplaceArithmeticOperator.class), "getInfectionDistanceFloat",
                "(FFII)D", false));
    } else if (opcodesDouble.contains(opcodeOrig)) {
        distance.add(new VarInsnNode(Opcodes.DSTORE, numVariable));
        distance.add(new InsnNode(Opcodes.DUP2));
        distance.add(new VarInsnNode(Opcodes.DLOAD, numVariable));
        distance.add(new InsnNode(Opcodes.DUP2_X2));
        distance.add(new LdcInsnNode(opcodeOrig));
        distance.add(new LdcInsnNode(opcodeNew));
        distance.add(new MethodInsnNode(Opcodes.INVOKESTATIC,
                PackageInfo.getNameWithSlash(ReplaceArithmeticOperator.class), "getInfectionDistanceDouble",
                "(DDII)D", false));
        numVariable += 2;
    }

    return distance;
}

From source file:org.evosuite.instrumentation.mutation.ReplaceBitwiseOperator.java

License:Open Source License

/**
 * <p>getInfectionDistance</p>
 *
 * @param opcodeOrig a int./*from  w  w  w .  j a  va  2  s .c om*/
 * @param opcodeNew a int.
 * @return a {@link org.objectweb.asm.tree.InsnList} object.
 */
public InsnList getInfectionDistance(int opcodeOrig, int opcodeNew) {
    InsnList distance = new InsnList();

    if (opcodesInt.contains(opcodeOrig)) {
        distance.add(new InsnNode(Opcodes.DUP2));
        distance.add(new LdcInsnNode(opcodeOrig));
        distance.add(new LdcInsnNode(opcodeNew));
        distance.add(new MethodInsnNode(Opcodes.INVOKESTATIC,
                PackageInfo.getNameWithSlash(ReplaceBitwiseOperator.class), "getInfectionDistanceInt",
                "(IIII)D", false));
    } else if (opcodesIntShift.contains(opcodeOrig)) {
        distance.add(new InsnNode(Opcodes.DUP2));
        distance.add(new LdcInsnNode(opcodeOrig));
        distance.add(new LdcInsnNode(opcodeNew));
        distance.add(new MethodInsnNode(Opcodes.INVOKESTATIC,
                PackageInfo.getNameWithSlash(ReplaceBitwiseOperator.class), "getInfectionDistanceInt",
                "(IIII)D", false));
    } else if (opcodesLong.contains(opcodeOrig)) {

        distance.add(new VarInsnNode(Opcodes.LSTORE, numVariable));
        distance.add(new InsnNode(Opcodes.DUP2));
        distance.add(new VarInsnNode(Opcodes.LLOAD, numVariable));
        distance.add(new InsnNode(Opcodes.DUP2_X2));
        distance.add(new LdcInsnNode(opcodeOrig));
        distance.add(new LdcInsnNode(opcodeNew));
        distance.add(new MethodInsnNode(Opcodes.INVOKESTATIC,
                PackageInfo.getNameWithSlash(ReplaceBitwiseOperator.class), "getInfectionDistanceLong",
                "(JJII)D", false));
        numVariable += 2;

    } else if (opcodesLongShift.contains(opcodeOrig)) {
        distance.add(new VarInsnNode(Opcodes.ISTORE, numVariable));
        distance.add(new InsnNode(Opcodes.DUP2));
        distance.add(new VarInsnNode(Opcodes.ILOAD, numVariable));
        distance.add(new InsnNode(Opcodes.DUP_X2));
        distance.add(new LdcInsnNode(opcodeOrig));
        distance.add(new LdcInsnNode(opcodeNew));
        distance.add(new MethodInsnNode(Opcodes.INVOKESTATIC,
                PackageInfo.getNameWithSlash(ReplaceBitwiseOperator.class), "getInfectionDistanceLong",
                "(JIII)D", false));
        numVariable += 1;
    }

    return distance;
}

From source file:org.evosuite.testcarver.instrument.Instrumenter.java

License:Open Source License

private void addLoadInsn(final InsnList il, final Type type, final int argLocation) {
    if (type.equals(Type.BOOLEAN_TYPE)) {
        il.add(new VarInsnNode(Opcodes.ILOAD, argLocation));
    } else if (type.equals(Type.CHAR_TYPE)) {
        il.add(new VarInsnNode(Opcodes.ILOAD, argLocation));
    } else if (type.equals(Type.BYTE_TYPE)) {
        il.add(new VarInsnNode(Opcodes.ILOAD, argLocation));
    } else if (type.equals(Type.SHORT_TYPE)) {
        il.add(new VarInsnNode(Opcodes.ILOAD, argLocation));
    } else if (type.equals(Type.INT_TYPE)) {
        il.add(new VarInsnNode(Opcodes.ILOAD, argLocation));
    } else if (type.equals(Type.FLOAT_TYPE)) {
        il.add(new VarInsnNode(Opcodes.FLOAD, argLocation));
    } else if (type.equals(Type.LONG_TYPE)) {
        il.add(new VarInsnNode(Opcodes.LLOAD, argLocation));
    } else if (type.equals(Type.DOUBLE_TYPE)) {
        il.add(new VarInsnNode(Opcodes.DLOAD, argLocation));
    } else {/* w  ww .j  ava 2  s  .c  om*/
        il.add(new VarInsnNode(Opcodes.ALOAD, argLocation));
    }
}

From source file:org.evosuite.testcarver.instrument.Instrumenter.java

License:Open Source License

private void loadAndConvertToObject(final InsnList il, final Type type, final int argLocation) {
    if (type.equals(Type.BOOLEAN_TYPE)) {
        il.add(new VarInsnNode(Opcodes.ILOAD, argLocation));
        il.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "java/lang/Boolean", "valueOf",
                "(Z)Ljava/lang/Boolean;"));
    } else if (type.equals(Type.CHAR_TYPE)) {
        il.add(new VarInsnNode(Opcodes.ILOAD, argLocation));
        il.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "java/lang/Character", "valueOf",
                "(C)Ljava/lang/Character;"));
    } else if (type.equals(Type.BYTE_TYPE)) {
        il.add(new VarInsnNode(Opcodes.ILOAD, argLocation));
        il.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "java/lang/Byte", "valueOf", "(B)Ljava/lang/Byte;"));
    } else if (type.equals(Type.SHORT_TYPE)) {
        il.add(new VarInsnNode(Opcodes.ILOAD, argLocation));
        il.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "java/lang/Short", "valueOf", "(S)Ljava/lang/Short;"));
    } else if (type.equals(Type.INT_TYPE)) {
        il.add(new VarInsnNode(Opcodes.ILOAD, argLocation));
        il.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "java/lang/Integer", "valueOf",
                "(I)Ljava/lang/Integer;"));
    } else if (type.equals(Type.FLOAT_TYPE)) {
        il.add(new VarInsnNode(Opcodes.FLOAD, argLocation));
        il.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "java/lang/Float", "valueOf", "(F)Ljava/lang/Float;"));
    } else if (type.equals(Type.LONG_TYPE)) {
        il.add(new VarInsnNode(Opcodes.LLOAD, argLocation));
        il.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "java/lang/Long", "valueOf", "(J)Ljava/lang/Long;"));
    } else if (type.equals(Type.DOUBLE_TYPE)) {
        il.add(new VarInsnNode(Opcodes.DLOAD, argLocation));
        il.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "java/lang/Double", "valueOf",
                "(D)Ljava/lang/Double;"));
    } else {/*from   w w w.  j  av a2s.co m*/
        il.add(new VarInsnNode(Opcodes.ALOAD, argLocation));
    }
}

From source file:org.fabric3.implementation.bytecode.proxy.common.ProxyFactoryImpl.java

License:Open Source License

@SuppressWarnings("unchecked")
public void emitWrappedParameters(Method method, MethodVisitor mv, int[] index, int[] stack) {
    int numberOfParameters = method.getParameterTypes().length;

    // create the Object[] used to pass the parameters to _f3_invoke and push it on the stack
    if (numberOfParameters >= 0 && numberOfParameters <= 5) {
        // use an integer constant if within range
        mv.visitInsn(Opcodes.ICONST_0 + numberOfParameters);
    } else {//w w  w.  jav  a  2 s.c om
        mv.visitIntInsn(Opcodes.BIPUSH, numberOfParameters);
    }
    mv.visitTypeInsn(ANEWARRAY, "java/lang/Object");
    mv.visitInsn(DUP);

    for (Class<?> param : method.getParameterTypes()) {
        if (Integer.TYPE.equals(param)) {
            mv.visitInsn(Opcodes.ICONST_0 + index[0]);
            mv.visitVarInsn(Opcodes.ILOAD, stack[0]);
            mv.visitMethodInsn(INVOKESTATIC, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;");
            mv.visitInsn(AASTORE);
            if (index[0] < numberOfParameters - 1) {
                mv.visitInsn(DUP);
            }
        } else if (Float.TYPE.equals(param)) {
            mv.visitInsn(Opcodes.ICONST_0 + index[0]);
            mv.visitVarInsn(Opcodes.FLOAD, stack[0]);
            mv.visitMethodInsn(INVOKESTATIC, "java/lang/Float", "valueOf", "(F)Ljava/lang/Float;");
            mv.visitInsn(AASTORE);
            if (index[0] < numberOfParameters - 1) {
                mv.visitInsn(DUP);
            }
        } else if (Boolean.TYPE.equals(param)) {
            mv.visitInsn(Opcodes.ICONST_0 + index[0]);
            mv.visitVarInsn(Opcodes.ILOAD, stack[0]);
            mv.visitMethodInsn(INVOKESTATIC, "java/lang/Boolean", "valueOf", "(Z)Ljava/lang/Boolean;");
            mv.visitInsn(AASTORE);
            if (index[0] < numberOfParameters - 1) {
                mv.visitInsn(DUP);
            }
        } else if (Short.TYPE.equals(param)) {
            mv.visitInsn(Opcodes.ICONST_0 + index[0]);
            mv.visitVarInsn(Opcodes.ILOAD, stack[0]);
            mv.visitMethodInsn(INVOKESTATIC, "java/lang/Short", "valueOf", "(S)Ljava/lang/Short;");
            mv.visitInsn(AASTORE);
            if (index[0] < numberOfParameters - 1) {
                mv.visitInsn(DUP);
            }
        } else if (Byte.TYPE.equals(param)) {
            mv.visitInsn(Opcodes.ICONST_0 + index[0]);
            mv.visitVarInsn(Opcodes.ILOAD, stack[0]);
            mv.visitMethodInsn(INVOKESTATIC, "java/lang/Byte", "valueOf", "(B)Ljava/lang/Byte;");
            mv.visitInsn(AASTORE);
            if (index[0] < numberOfParameters - 1) {
                mv.visitInsn(DUP);
            }
        } else if (Double.TYPE.equals(param)) {
            mv.visitInsn(Opcodes.ICONST_0 + index[0]);
            mv.visitVarInsn(Opcodes.DLOAD, stack[0]);
            mv.visitMethodInsn(INVOKESTATIC, "java/lang/Double", "valueOf", "(D)Ljava/lang/Double;");
            mv.visitInsn(AASTORE);
            if (index[0] < numberOfParameters - 1) {
                mv.visitInsn(DUP);
            }
            stack[0]++; // double occupies two positions

        } else if (Long.TYPE.equals(param)) {
            mv.visitInsn(Opcodes.ICONST_0 + index[0]);
            mv.visitVarInsn(Opcodes.LLOAD, stack[0]);
            mv.visitMethodInsn(INVOKESTATIC, "java/lang/Long", "valueOf", "(J)Ljava/lang/Long;");
            mv.visitInsn(AASTORE);
            if (index[0] < numberOfParameters - 1) {
                mv.visitInsn(DUP);
            }
            stack[0]++; // long occupies two positions
        } else {
            // object type
            mv.visitInsn(Opcodes.ICONST_0 + index[0]);
            mv.visitVarInsn(ALOAD, stack[0]);
            mv.visitInsn(AASTORE);
            if (index[0] < numberOfParameters - 1) {
                mv.visitInsn(DUP);
            }
        }
        index[0]++;
    }
    // TODO other primitive types
    stack[0]++;

}

From source file:org.fabric3.implementation.bytecode.proxy.common.ProxyFactoryImpl.java

License:Open Source License

@SuppressWarnings("unchecked")
public void emitUnWrappedParameters(Method method, MethodVisitor mv, int[] index, int[] stack) {
    int numberOfParameters = method.getParameterTypes().length;
    if (numberOfParameters > 1) {
        // FIXME/*from   w ww  . j  a  v a2 s.  c  o m*/
        throw new AssertionError("Not supported");
    }

    Class<?> param = method.getParameterTypes()[0];
    if (Integer.TYPE.equals(param)) {
        mv.visitVarInsn(ILOAD, 1);
        mv.visitMethodInsn(INVOKESTATIC, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;");
    } else if (Float.TYPE.equals(param)) {
        mv.visitVarInsn(Opcodes.FLOAD, 1);
        mv.visitMethodInsn(INVOKESTATIC, "java/lang/Float", "valueOf", "(F)Ljava/lang/Float;");
    } else if (Boolean.TYPE.equals(param)) {
        mv.visitVarInsn(Opcodes.ILOAD, 1);
        mv.visitMethodInsn(INVOKESTATIC, "java/lang/Boolean", "valueOf", "(Z)Ljava/lang/Boolean;");
    } else if (Short.TYPE.equals(param)) {
        mv.visitVarInsn(Opcodes.ILOAD, 1);
        mv.visitMethodInsn(INVOKESTATIC, "java/lang/Short", "valueOf", "(S)Ljava/lang/Short;");
    } else if (Byte.TYPE.equals(param)) {
        mv.visitVarInsn(Opcodes.ILOAD, 1);
        mv.visitMethodInsn(INVOKESTATIC, "java/lang/Byte", "valueOf", "(B)Ljava/lang/Byte;");
    } else if (Double.TYPE.equals(param)) {
        mv.visitVarInsn(Opcodes.DLOAD, 1);
        mv.visitMethodInsn(INVOKESTATIC, "java/lang/Double", "valueOf", "(D)Ljava/lang/Double;");
    } else if (Long.TYPE.equals(param)) {
        mv.visitVarInsn(Opcodes.LLOAD, 1);
        mv.visitMethodInsn(INVOKESTATIC, "java/lang/Long", "valueOf", "(J)Ljava/lang/Long;");
    } else {
        // object type
        mv.visitVarInsn(ALOAD, 1);
    }

}