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:com.google.gwt.jvm.asm.NativeMethodDelegatingVisitor.java

License:Apache License

private int nativeDelegate_addArgument(String parameter, int index) {
    int size = 1;
    delegate.visitInsn(Opcodes.DUP);// www .j  a  va 2 s . c o m
    switch (parameter.charAt(0)) {
    case 'L':
    case '[':
        parameter = "Ljava/lang/Object;";
        delegate.visitVarInsn(Opcodes.ALOAD, index);
        break;
    case 'Z':
    case 'B':
    case 'C':
    case 'S':
    case 'I':
        delegate.visitVarInsn(Opcodes.ILOAD, index);
        break;
    case 'J':
        delegate.visitVarInsn(Opcodes.LLOAD, index);
        size = 2;
        break;
    case 'F':
        delegate.visitVarInsn(Opcodes.FLOAD, index);
        break;
    case 'D':
        delegate.visitVarInsn(Opcodes.DLOAD, index);
        size = 2;
        break;
    default:
        throw new IllegalStateException(parameter);
    }
    delegate.visitMethodInsn(Opcodes.INVOKEVIRTUAL, InvocationDelegate, "addArg", "(" + parameter + ")V");
    return size;
}

From source file:com.google.test.metric.asm.MethodVisitorBuilder.java

License:Apache License

public void visitVarInsn(final int opcode, final int var) {
    switch (opcode) {
    case Opcodes.ILOAD:
        load(var, JavaType.INT);
        break;//w  ww. ja va2s  .co  m
    case Opcodes.LLOAD:
        load(var, JavaType.LONG);
        break;
    case Opcodes.FLOAD:
        load(var, JavaType.FLOAT);
        break;
    case Opcodes.DLOAD:
        load(var, JavaType.DOUBLE);
        break;
    case Opcodes.ALOAD:
        load(var, JavaType.OBJECT);
        break;

    case Opcodes.ISTORE:
        store(var, JavaType.INT);
        break;
    case Opcodes.LSTORE:
        store(var, JavaType.LONG);
        break;
    case Opcodes.FSTORE:
        store(var, JavaType.FLOAT);
        break;
    case Opcodes.DSTORE:
        store(var, JavaType.DOUBLE);
        break;
    case Opcodes.ASTORE:
        store(var, JavaType.OBJECT);
        break;

    case Opcodes.RET:
        recorder.add(new Runnable() {
            public void run() {
                block.addOp(new RetSub(lineNumber));
            }
        });
        break;
    default:
        throw new UnsupportedOperationException("opcode: " + opcode);
    }
}

From source file:com.hea3ven.hardmodetweaks.core.ClassTransformerHardModeTweaks.java

License:Open Source License

private MethodNode createNewSetWorldTimeMethod(String methodName, boolean obfuscated) {
    // > void setWorldTime(long time) {
    // >     TimeTweaksManager.setWorldTime(this, time);
    // > }/*from  w w w.  j a  v  a2  s  .c o  m*/
    MethodNode setWorldTimeMethod = new MethodNode(Opcodes.ASM4, Opcodes.ACC_PUBLIC, methodName, "(J)V", null,
            null);
    setWorldTimeMethod.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
    setWorldTimeMethod.instructions.add(new VarInsnNode(Opcodes.LLOAD, 1));
    setWorldTimeMethod.instructions
            .add(new MethodInsnNode(Opcodes.INVOKESTATIC, "com/hea3ven/hardmodetweaks/TimeTweaksManager",
                    "setWorldTime", "(L" + WORLD_INFO.getPath(obfuscated) + ";J)V"));
    setWorldTimeMethod.instructions.add(new InsnNode(Opcodes.RETURN));
    return setWorldTimeMethod;
}

From source file:com.hea3ven.hardmodetweaks.core.ClassTransformerHardModeTweaks.java

License:Open Source License

private MethodNode createNewCalcCelAngleMethod(String methodName, boolean obfuscated) {
    // > float calculateCelestialAngle(long time, float off) {
    // >     return TimeTweaksManager.calculateCelestialAngle(time, off);
    // > }//from  ww  w  .  java  2s  . c om
    MethodNode getWorldTimeMethod = new MethodNode(Opcodes.ASM4, Opcodes.ACC_PUBLIC, methodName, "(JF)F", null,
            null);
    getWorldTimeMethod.instructions.add(new VarInsnNode(Opcodes.LLOAD, 1));
    getWorldTimeMethod.instructions.add(new VarInsnNode(Opcodes.FLOAD, 3));
    getWorldTimeMethod.instructions.add(new MethodInsnNode(Opcodes.INVOKESTATIC,
            "com/hea3ven/hardmodetweaks/TimeTweaksManager", "calculateCelestialAngle", "(JF)F"));
    getWorldTimeMethod.instructions.add(new InsnNode(Opcodes.FRETURN));
    return getWorldTimeMethod;
}

From source file:com.lodgon.parboiled.transform.AsmUtils.java

License:Open Source License

public static int getLoadingOpcode(Type argType) {
    checkArgNotNull(argType, "argType");
    switch (argType.getSort()) {
    case Type.BOOLEAN:
    case Type.BYTE:
    case Type.CHAR:
    case Type.SHORT:
    case Type.INT:
        return Opcodes.ILOAD;
    case Type.DOUBLE:
        return Opcodes.DLOAD;
    case Type.FLOAT:
        return Opcodes.FLOAD;
    case Type.LONG:
        return Opcodes.LLOAD;
    case Type.OBJECT:
    case Type.ARRAY:
        return Opcodes.ALOAD;
    default://from w  w w .j a  va 2 s .c o  m
        throw new IllegalStateException();
    }
}

From source file:com.lucidtechnics.blackboard.TargetConstructor.java

License:Apache License

private static int getLoadOpcode(String _parameterType) {
    int opCode = 0;
    char typeChar = _parameterType.toCharArray()[0];

    switch (typeChar) {
    case 'Z':
    case 'B':
    case 'C':
    case 'I':
    case 'S':
        opCode = Opcodes.ILOAD;/*from   ww  w  .j  a  va  2  s .  c om*/
        break;

    case 'D':
        opCode = Opcodes.DLOAD;
        break;

    case 'F':
        opCode = Opcodes.FLOAD;
        break;

    case 'J':
        opCode = Opcodes.LLOAD;
        break;

    case 'L':
    case '[':
        opCode = Opcodes.ALOAD;
        break;

    default:
        if (true)
            throw new RuntimeException(
                    "Cannot handle parameter type identified by first character: " + typeChar);
        break;
    }

    return opCode;
}

From source file:com.mebigfatguy.exagent.StackTraceMethodVisitor.java

License:Apache License

private void injectCallStackPopulation() {

    // ExAgent.METHOD_INFO.get();
    super.visitFieldInsn(Opcodes.GETSTATIC, EXASUPPORT_CLASS_NAME, "METHOD_INFO",
            signaturizeClass(THREADLOCAL_CLASS_NAME));
    super.visitMethodInsn(Opcodes.INVOKEVIRTUAL, THREADLOCAL_CLASS_NAME, "get", "()Ljava/lang/Object;", false);
    super.visitTypeInsn(Opcodes.CHECKCAST, LIST_CLASS_NAME);

    super.visitInsn(Opcodes.DUP);
    super.visitMethodInsn(Opcodes.INVOKEINTERFACE, LIST_CLASS_NAME, "size", "()I", true);
    super.visitVarInsn(Opcodes.ISTORE, depthLocalSlot);

    //new MethodInfo(cls, name, parmMap);
    super.visitTypeInsn(Opcodes.NEW, METHODINFO_CLASS_NAME);
    super.visitInsn(Opcodes.DUP);
    super.visitLdcInsn(clsName.replace('.', '/'));
    super.visitLdcInsn(methodName);

    if (parms.isEmpty()) {
        super.visitMethodInsn(Opcodes.INVOKESTATIC, COLLECTIONS_CLASS_NAME, "emptyList", "()Ljava/util/List;",
                false);/*from  ww  w. java2 s  . co  m*/
    } else {
        super.visitTypeInsn(Opcodes.NEW, ARRAYLIST_CLASS_NAME);
        super.visitInsn(Opcodes.DUP);
        super.visitIntInsn(Opcodes.BIPUSH, parms.size());
        super.visitMethodInsn(Opcodes.INVOKESPECIAL, ARRAYLIST_CLASS_NAME, CTOR_NAME, "(I)V", false);

        for (Parm parm : parms) {
            super.visitInsn(Opcodes.DUP);

            switch (parm.signature) {

            case "C":
                super.visitVarInsn(Opcodes.ILOAD, parm.register);
                super.visitMethodInsn(Opcodes.INVOKESTATIC, STRING_CLASS_NAME, "valueOf",
                        "(C)Ljava/lang/String;", false);
                break;

            case "Z":
                super.visitVarInsn(Opcodes.ILOAD, parm.register);
                super.visitMethodInsn(Opcodes.INVOKESTATIC, STRING_CLASS_NAME, "valueOf",
                        "(Z)Ljava/lang/String;", false);
                break;

            case "B":
            case "S":
            case "I":
                super.visitVarInsn(Opcodes.ILOAD, parm.register);
                super.visitMethodInsn(Opcodes.INVOKESTATIC, STRING_CLASS_NAME, "valueOf",
                        "(I)Ljava/lang/String;", false);
                break;

            case "J":
                super.visitVarInsn(Opcodes.LLOAD, parm.register);
                super.visitMethodInsn(Opcodes.INVOKESTATIC, STRING_CLASS_NAME, "valueOf",
                        "(J)Ljava/lang/String;", false);
                break;

            case "F":
                super.visitVarInsn(Opcodes.FLOAD, parm.register);
                super.visitMethodInsn(Opcodes.INVOKESTATIC, STRING_CLASS_NAME, "valueOf",
                        "(F)Ljava/lang/String;", false);
                break;

            case "D":
                super.visitVarInsn(Opcodes.DLOAD, parm.register);
                super.visitMethodInsn(Opcodes.INVOKESTATIC, STRING_CLASS_NAME, "valueOf",
                        "(D)Ljava/lang/String;", false);
                break;

            default:
                super.visitVarInsn(Opcodes.ALOAD, parm.register);
                if (parm.signature.startsWith("[")) {
                    char arrayElemTypeChar = parm.signature.charAt(1);
                    if ((arrayElemTypeChar == 'L') || (arrayElemTypeChar == '[')) {
                        super.visitMethodInsn(Opcodes.INVOKESTATIC, ARRAYS_CLASS_NAME, "toString",
                                "([Ljava/lang/Object;)Ljava/lang/String;", false);
                    } else {
                        super.visitMethodInsn(Opcodes.INVOKESTATIC, ARRAYS_CLASS_NAME, "toString",
                                "([" + arrayElemTypeChar + ")Ljava/lang/String;", false);
                    }
                } else {
                    super.visitMethodInsn(Opcodes.INVOKESTATIC, STRING_CLASS_NAME, "valueOf",
                            "(Ljava/lang/Object;)Ljava/lang/String;", false);
                }
                break;
            }

            if (maxParmSize > 0) {
                super.visitInsn(Opcodes.DUP);
                super.visitMethodInsn(Opcodes.INVOKEVIRTUAL, STRING_CLASS_NAME, "length", "()I", false);
                if (maxParmSize <= 127) {
                    super.visitIntInsn(Opcodes.BIPUSH, maxParmSize);
                } else {
                    super.visitLdcInsn(maxParmSize);
                }
                Label falseLabel = new Label();
                super.visitJumpInsn(Opcodes.IF_ICMPLE, falseLabel);
                super.visitIntInsn(Opcodes.BIPUSH, 0);
                super.visitLdcInsn(maxParmSize);
                super.visitMethodInsn(Opcodes.INVOKEVIRTUAL, STRING_CLASS_NAME, "substring",
                        "(II)Ljava/lang/String;", false);
                super.visitLabel(falseLabel);
            }

            super.visitMethodInsn(Opcodes.INVOKEINTERFACE, LIST_CLASS_NAME, "add", "(Ljava/lang/Object;)Z",
                    true);
            super.visitInsn(Opcodes.POP);
        }
    }

    super.visitMethodInsn(Opcodes.INVOKESPECIAL, METHODINFO_CLASS_NAME, CTOR_NAME,
            "(Ljava/lang/String;Ljava/lang/String;Ljava/util/List;)V", false);

    //add(methodInfo);
    super.visitMethodInsn(Opcodes.INVOKEINTERFACE, LIST_CLASS_NAME, "add", "(Ljava/lang/Object;)Z", true);
    super.visitInsn(Opcodes.POP);
}

From source file:com.mebigfatguy.junitflood.jvm.OperandStack.java

License:Apache License

public void performVarInsn(int opcode, int var) {
    switch (opcode) {
    case Opcodes.ILOAD:
    case Opcodes.LLOAD:
    case Opcodes.FLOAD:
    case Opcodes.DLOAD:
    case Opcodes.ALOAD:
        stack.add(registers.get(Integer.valueOf(var)));
        break;/*ww  w.ja v a  2s.  co m*/

    case Opcodes.ISTORE:
    case Opcodes.LSTORE:
    case Opcodes.FSTORE:
    case Opcodes.DSTORE:
    case Opcodes.ASTORE:
        registers.put(Integer.valueOf(var), stack.remove(stack.size() - 1));
        break;

    case Opcodes.RET:
        //nop - a fudge
        break;
    }
}

From source file:com.microsoft.applicationinsights.agent.internal.agent.redis.JedisMethodVisitor.java

License:Open Source License

protected void boxVariable(Type argumentType, int argumentIndex) {
    if (argumentType.equals(Type.BOOLEAN_TYPE)) {
        mv.visitVarInsn(Opcodes.ILOAD, argumentIndex);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Boolean", "valueOf", "(Z)Ljava/lang/Boolean;",
                false);/*from w  w  w.j a  v  a  2s  .co  m*/
    } else if (argumentType.equals(Type.BYTE_TYPE)) {
        mv.visitVarInsn(Opcodes.ILOAD, argumentIndex);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Byte", "valueOf", "(B)Ljava/lang/Byte;", false);
    } else if (argumentType.equals(Type.CHAR_TYPE)) {
        mv.visitVarInsn(Opcodes.ILOAD, argumentIndex);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Character", "valueOf", "(C)Ljava/lang/Character;",
                false);
    } else if (argumentType.equals(Type.SHORT_TYPE)) {
        mv.visitVarInsn(Opcodes.ILOAD, argumentIndex);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Short", "valueOf", "(S)Ljava/lang/Short;", false);
    } else if (argumentType.equals(Type.INT_TYPE)) {
        mv.visitVarInsn(Opcodes.ILOAD, argumentIndex);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;",
                false);
    } else if (argumentType.equals(Type.LONG_TYPE)) {
        mv.visitVarInsn(Opcodes.LLOAD, argumentIndex);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Long", "valueOf", "(J)Ljava/lang/Long;", false);
    } else if (argumentType.equals(Type.FLOAT_TYPE)) {
        mv.visitVarInsn(Opcodes.FLOAD, argumentIndex);
        super.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Float", "valueOf", "(F)Ljava/lang/Long;",
                false);
    } else if (argumentType.equals(Type.DOUBLE_TYPE)) {
        mv.visitVarInsn(Opcodes.DLOAD, argumentIndex);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Double", "valueOf", "(D)Ljava/lang/Double;", false);
    } else {
        mv.visitVarInsn(Opcodes.ALOAD, argumentIndex);
    }
}

From source file:com.offbynull.coroutines.instrumenter.asm.InstructionUtils.java

License:Open Source License

/**
 * Copies a local variable on to the stack.
 * @param variable variable within the local variable table to load from
 * @return instructions to load a local variable on to the stack
 * @throws NullPointerException if any argument is {@code null}
 * @throws IllegalArgumentException if {@code variable} has been released
 *///from w w  w.  j  a  va 2 s .co  m
public static InsnList loadVar(Variable variable) {
    Validate.notNull(variable);

    InsnList ret = new InsnList();
    switch (variable.getType().getSort()) {
    case Type.BOOLEAN:
    case Type.BYTE:
    case Type.CHAR:
    case Type.SHORT:
    case Type.INT:
        ret.add(new VarInsnNode(Opcodes.ILOAD, variable.getIndex()));
        break;
    case Type.LONG:
        ret.add(new VarInsnNode(Opcodes.LLOAD, variable.getIndex()));
        break;
    case Type.FLOAT:
        ret.add(new VarInsnNode(Opcodes.FLOAD, variable.getIndex()));
        break;
    case Type.DOUBLE:
        ret.add(new VarInsnNode(Opcodes.DLOAD, variable.getIndex()));
        break;
    case Type.OBJECT:
    case Type.ARRAY:
        ret.add(new VarInsnNode(Opcodes.ALOAD, variable.getIndex()));
        ret.add(new TypeInsnNode(Opcodes.CHECKCAST, variable.getType().getInternalName()));
        break;
    default:
        throw new IllegalStateException(); // should never happen, there is code in Variable/VariableTable to make sure invalid
                                           // types aren't set
    }

    return ret;
}