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

License:Apache License

private void capReturn() {
    Type tp = returnType;/*from   w w w  . j a  v  a 2s .  c o  m*/
    if (tp == null || tp.equals(Type.VOID_TYPE)) {
        mv.visitVarInsn(Opcodes.ALOAD, statIdx);
        mv.visitInsn(Opcodes.ACONST_NULL);
        mv.visitInsn(Opcodes.ACONST_NULL);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACESUBCALL, END_METHOD, END_SIGNATURE, false);
        return;
    }
    int i = newLocal(tp);
    switch (tp.getSort()) {
    case Type.BOOLEAN:
        mv.visitVarInsn(Opcodes.ISTORE, i);
        mv.visitVarInsn(Opcodes.ILOAD, i);
        mv.visitVarInsn(Opcodes.ALOAD, statIdx);// stat
        mv.visitVarInsn(Opcodes.ILOAD, i);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Boolean", "valueOf", "(Z)Ljava/lang/Boolean;",
                false);
        mv.visitInsn(Opcodes.ACONST_NULL);// throwable
        break;
    case Type.BYTE:
        mv.visitVarInsn(Opcodes.ISTORE, i);
        mv.visitVarInsn(Opcodes.ILOAD, i);
        mv.visitVarInsn(Opcodes.ALOAD, statIdx);// stat
        mv.visitVarInsn(Opcodes.ILOAD, i);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Byte", "valueOf", "(B)Ljava/lang/Byte;", false);
        mv.visitInsn(Opcodes.ACONST_NULL);// throwable
        break;
    case Type.CHAR:
        mv.visitVarInsn(Opcodes.ISTORE, i);
        mv.visitVarInsn(Opcodes.ILOAD, i);
        mv.visitVarInsn(Opcodes.ALOAD, statIdx);// stat
        mv.visitVarInsn(Opcodes.ILOAD, i);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Character", "valueOf", "(C)Ljava/lang/Character;",
                false);
        mv.visitInsn(Opcodes.ACONST_NULL);// throwable
        break;
    case Type.SHORT:
        mv.visitVarInsn(Opcodes.ISTORE, i);
        mv.visitVarInsn(Opcodes.ILOAD, i);
        mv.visitVarInsn(Opcodes.ALOAD, statIdx);// stat
        mv.visitVarInsn(Opcodes.ILOAD, i);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Short", "valueOf", "(S)Ljava/lang/Short;", false);
        mv.visitInsn(Opcodes.ACONST_NULL);// throwable
        break;
    case Type.INT:
        mv.visitVarInsn(Opcodes.ISTORE, i);
        mv.visitVarInsn(Opcodes.ILOAD, i);
        mv.visitVarInsn(Opcodes.ALOAD, statIdx);// stat
        mv.visitVarInsn(Opcodes.ILOAD, i);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;",
                false);
        mv.visitInsn(Opcodes.ACONST_NULL);// throwable
        break;
    case Type.LONG:
        mv.visitVarInsn(Opcodes.LSTORE, i);
        mv.visitVarInsn(Opcodes.LLOAD, i);
        mv.visitVarInsn(Opcodes.ALOAD, statIdx);// stat
        mv.visitVarInsn(Opcodes.LLOAD, i);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Long", "valueOf", "(J)Ljava/lang/Long;", false);
        mv.visitInsn(Opcodes.ACONST_NULL);// throwable
        break;
    case Type.FLOAT:
        mv.visitVarInsn(Opcodes.FSTORE, i);
        mv.visitVarInsn(Opcodes.FLOAD, i);
        mv.visitVarInsn(Opcodes.ALOAD, statIdx);// stat
        mv.visitVarInsn(Opcodes.FLOAD, i);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Float", "valueOf", "(F)Ljava/lang/Float;", false);
        mv.visitInsn(Opcodes.ACONST_NULL);// throwable
        break;
    case Type.DOUBLE:
        mv.visitVarInsn(Opcodes.DSTORE, i);
        mv.visitVarInsn(Opcodes.DLOAD, i);
        mv.visitVarInsn(Opcodes.ALOAD, statIdx);// stat
        mv.visitVarInsn(Opcodes.DLOAD, i);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Double", "valueOf", "(D)Ljava/lang/Double;", false);
        mv.visitInsn(Opcodes.ACONST_NULL);// throwable
        break;
    default:
        mv.visitVarInsn(Opcodes.ASTORE, i);
        mv.visitVarInsn(Opcodes.ALOAD, i);
        mv.visitVarInsn(Opcodes.ALOAD, statIdx);// stat
        mv.visitVarInsn(Opcodes.ALOAD, i);// return
        mv.visitInsn(Opcodes.ACONST_NULL);// throwable
    }
    mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACESUBCALL, END_METHOD, END_SIGNATURE, false);
}

From source file:scouter.agent.asm.ApicallInfoASM.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];//from w  w w .j  a  va 2s  .c o  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);
    mv.visitCode();
}

From source file:scouter.agent.asm.CapArgsASM.java

License:Apache License

@Override
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 type = paramTypes[i];
        mv.visitVarInsn(Opcodes.ALOAD, arrVarIdx);
        AsmUtil.PUSH(mv, i);/*  w w  w .  ja va  2s. c  om*/

        switch (type.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 += type.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, CLASS, METHOD, SIGNATURE, false);
    mv.visitCode();
}

From source file:scouter.agent.asm.CapReturnASM.java

License:Apache License

private void capReturn() {
    Type tp = returnType;//from w  ww  . j  a  va 2s .  co  m

    if (tp == null || tp.equals(Type.VOID_TYPE)) {
        pushCommon();
        mv.visitInsn(ACONST_NULL);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, CLASS, METHOD, SIGNATURE, false);
        return;
    }
    int i = newLocal(tp);
    switch (tp.getSort()) {
    case Type.BOOLEAN:
        mv.visitVarInsn(Opcodes.ISTORE, i);
        mv.visitVarInsn(Opcodes.ILOAD, i);

        pushCommon();
        mv.visitVarInsn(Opcodes.ILOAD, i);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Boolean", "valueOf", "(Z)Ljava/lang/Boolean;",
                false);
        break;
    case Type.BYTE:
        mv.visitVarInsn(Opcodes.ISTORE, i);
        mv.visitVarInsn(Opcodes.ILOAD, i);

        pushCommon();
        mv.visitVarInsn(Opcodes.ILOAD, i);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Byte", "valueOf", "(B)Ljava/lang/Byte;", false);
        break;
    case Type.CHAR:
        mv.visitVarInsn(Opcodes.ISTORE, i);
        mv.visitVarInsn(Opcodes.ILOAD, i);

        pushCommon();
        mv.visitVarInsn(Opcodes.ILOAD, i);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Character", "valueOf", "(C)Ljava/lang/Character;",
                false);
        break;
    case Type.SHORT:
        mv.visitVarInsn(Opcodes.ISTORE, i);
        mv.visitVarInsn(Opcodes.ILOAD, i);

        pushCommon();
        mv.visitVarInsn(Opcodes.ILOAD, i);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Short", "valueOf", "(S)Ljava/lang/Short;", false);
        break;
    case Type.INT:
        mv.visitVarInsn(Opcodes.ISTORE, i);
        mv.visitVarInsn(Opcodes.ILOAD, i);

        pushCommon();
        mv.visitVarInsn(Opcodes.ILOAD, i);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;",
                false);
        break;
    case Type.LONG:
        mv.visitVarInsn(Opcodes.LSTORE, i);
        mv.visitVarInsn(Opcodes.LLOAD, i);

        pushCommon();
        mv.visitVarInsn(Opcodes.LLOAD, i);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Long", "valueOf", "(J)Ljava/lang/Long;", false);
        break;
    case Type.FLOAT:
        mv.visitVarInsn(Opcodes.FSTORE, i);
        mv.visitVarInsn(Opcodes.FLOAD, i);

        pushCommon();
        mv.visitVarInsn(Opcodes.FLOAD, i);

        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Float", "valueOf", "(F)Ljava/lang/Float;", false);
        break;
    case Type.DOUBLE:
        mv.visitVarInsn(Opcodes.DSTORE, i);
        mv.visitVarInsn(Opcodes.DLOAD, i);

        pushCommon();
        mv.visitVarInsn(Opcodes.DLOAD, i);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Double", "valueOf", "(D)Ljava/lang/Double;", false);
        break;
    default:
        mv.visitVarInsn(Opcodes.ASTORE, i);
        mv.visitVarInsn(Opcodes.ALOAD, i);

        pushCommon();
        mv.visitVarInsn(Opcodes.ALOAD, i);
    }

    mv.visitMethodInsn(Opcodes.INVOKESTATIC, CLASS, METHOD, SIGNATURE, false);
}

From source file:scouter.agent.asm.jdbc.PsSetMV.java

License:Apache License

public void visitCode() {
    mv.visitVarInsn(Opcodes.ALOAD, 0);//from w  w w . ja v  a 2 s  .c o  m
    mv.visitFieldInsn(GETFIELD, owner, TraceSQL.PSTMT_PARAM_FIELD, "Lscouter/agent/trace/SqlParameter;");
    mv.visitVarInsn(Opcodes.ILOAD, 1);

    if (name.equals("setNull")) {
        AsmUtil.PUSH(mv, (String) null);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACESQL, "set",
                "(Lscouter/agent/trace/SqlParameter;ILjava/lang/String;)V", false);
    } else {
        Type tp = args[1];
        switch (tp.getSort()) {
        case Type.BOOLEAN:
            mv.visitVarInsn(Opcodes.ILOAD, 2);
            mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACESQL, "set", "(Lscouter/agent/trace/SqlParameter;IZ)V",
                    false);
            break;
        case Type.CHAR:
        case Type.BYTE:
        case Type.SHORT:
        case Type.INT:
            mv.visitVarInsn(Opcodes.ILOAD, 2);
            mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACESQL, "set", "(Lscouter/agent/trace/SqlParameter;II)V",
                    false);
            break;
        case Type.LONG:
            mv.visitVarInsn(Opcodes.LLOAD, 2);
            mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACESQL, "set", "(Lscouter/agent/trace/SqlParameter;IJ)V",
                    false);
            break;
        case Type.FLOAT:
            mv.visitVarInsn(Opcodes.FLOAD, 2);
            mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACESQL, "set", "(Lscouter/agent/trace/SqlParameter;IF)V",
                    false);
            break;
        case Type.DOUBLE:
            mv.visitVarInsn(Opcodes.DLOAD, 2);
            mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACESQL, "set", "(Lscouter/agent/trace/SqlParameter;ID)V",
                    false);
            break;
        case Type.ARRAY:
        case Type.OBJECT:
            mv.visitVarInsn(Opcodes.ALOAD, 2);
            if (tp.equals(AsmUtil.stringType)) {
                mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACESQL, "set",
                        "(Lscouter/agent/trace/SqlParameter;ILjava/lang/String;)V", false);
            } else {
                mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACESQL, "set",
                        "(Lscouter/agent/trace/SqlParameter;ILjava/lang/Object;)V", false);
            }
            break;
        default:
            mv.visitVarInsn(Opcodes.ALOAD, 2);
            AsmUtil.PUSH(mv, "unknown " + tp);
            mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACESQL, "set",
                    "(Lscouter/agent/trace/SqlParameter;ILjava/lang/String;)V", false);
            break;
        }
    }

    super.visitCode();
}

From source file:scouter.agent.asm.JspServletASM.java

License:Apache License

@Override
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];//from w  ww . ja  v a 2 s  .  c  om
        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();
    }
    mv.visitVarInsn(Opcodes.ALOAD, arrVarIdx);

    mv.visitMethodInsn(Opcodes.INVOKESTATIC, CLASS, METHOD, SIGNATURE, false);
    super.visitCode();
}

From source file:scouter.agent.asm.ServiceASM.java

License:Apache License

@Override
public void visitCode() {
    int sidx = isStatic ? 0 : 1;
    if (strArgIdx >= 0) {
        mv.visitVarInsn(Opcodes.ALOAD, strArgIdx);
    } else {//  ww w.jav a  2 s.  c o  m
        AsmUtil.PUSH(mv, fullname);
    }

    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];
        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);

    AsmUtil.PUSH(mv, xType);
    mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACEMAIN, START_METHOD, START_SIGNATURE, false);

    statIdx = newLocal(Type.getType(Object.class));
    mv.visitVarInsn(Opcodes.ASTORE, statIdx);
    mv.visitLabel(startFinally);
    mv.visitCode();
}

From source file:scouter.agent.asm.ServiceASM.java

License:Apache License

private void capReturn() {
    Type tp = returnType;//from  w  ww  . ja  v  a  2  s.c om

    if (tp == null || tp.equals(Type.VOID_TYPE)) {

        mv.visitVarInsn(Opcodes.ALOAD, statIdx);
        mv.visitInsn(Opcodes.ACONST_NULL);
        mv.visitInsn(Opcodes.ACONST_NULL);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACEMAIN, END_METHOD, END_SIGNATURE, false);
        return;
    }
    int i = newLocal(tp);
    switch (tp.getSort()) {
    case Type.BOOLEAN:
        mv.visitVarInsn(Opcodes.ISTORE, i);
        mv.visitVarInsn(Opcodes.ILOAD, i);

        mv.visitVarInsn(Opcodes.ALOAD, statIdx);// stat
        mv.visitVarInsn(Opcodes.ILOAD, i);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Boolean", "valueOf", "(Z)Ljava/lang/Boolean;",
                false);
        mv.visitInsn(Opcodes.ACONST_NULL);// throwable
        break;
    case Type.BYTE:
        mv.visitVarInsn(Opcodes.ISTORE, i);
        mv.visitVarInsn(Opcodes.ILOAD, i);

        mv.visitVarInsn(Opcodes.ALOAD, statIdx);// stat
        mv.visitVarInsn(Opcodes.ILOAD, i);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Byte", "valueOf", "(B)Ljava/lang/Byte;", false);
        mv.visitInsn(Opcodes.ACONST_NULL);// throwable
        break;
    case Type.CHAR:
        mv.visitVarInsn(Opcodes.ISTORE, i);
        mv.visitVarInsn(Opcodes.ILOAD, i);

        mv.visitVarInsn(Opcodes.ALOAD, statIdx);// stat
        mv.visitVarInsn(Opcodes.ILOAD, i);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Character", "valueOf", "(C)Ljava/lang/Character;",
                false);
        mv.visitInsn(Opcodes.ACONST_NULL);// throwable
        break;
    case Type.SHORT:
        mv.visitVarInsn(Opcodes.ISTORE, i);
        mv.visitVarInsn(Opcodes.ILOAD, i);

        mv.visitVarInsn(Opcodes.ALOAD, statIdx);// stat
        mv.visitVarInsn(Opcodes.ILOAD, i);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Short", "valueOf", "(S)Ljava/lang/Short;", false);
        mv.visitInsn(Opcodes.ACONST_NULL);// throwable
        break;
    case Type.INT:
        mv.visitVarInsn(Opcodes.ISTORE, i);
        mv.visitVarInsn(Opcodes.ILOAD, i);

        mv.visitVarInsn(Opcodes.ALOAD, statIdx);// stat
        mv.visitVarInsn(Opcodes.ILOAD, i);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;",
                false);
        mv.visitInsn(Opcodes.ACONST_NULL);// throwable
        break;
    case Type.LONG:
        mv.visitVarInsn(Opcodes.LSTORE, i);
        mv.visitVarInsn(Opcodes.LLOAD, i);

        mv.visitVarInsn(Opcodes.ALOAD, statIdx);// stat
        mv.visitVarInsn(Opcodes.LLOAD, i);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Long", "valueOf", "(J)Ljava/lang/Long;", false);
        mv.visitInsn(Opcodes.ACONST_NULL);// throwable
        break;
    case Type.FLOAT:
        mv.visitVarInsn(Opcodes.FSTORE, i);
        mv.visitVarInsn(Opcodes.FLOAD, i);

        mv.visitVarInsn(Opcodes.ALOAD, statIdx);// stat
        mv.visitVarInsn(Opcodes.FLOAD, i);

        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Float", "valueOf", "(F)Ljava/lang/Float;", false);
        mv.visitInsn(Opcodes.ACONST_NULL);// throwable
        break;
    case Type.DOUBLE:
        mv.visitVarInsn(Opcodes.DSTORE, i);
        mv.visitVarInsn(Opcodes.DLOAD, i);

        mv.visitVarInsn(Opcodes.ALOAD, statIdx);// stat
        mv.visitVarInsn(Opcodes.DLOAD, i);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Double", "valueOf", "(D)Ljava/lang/Double;", false);
        mv.visitInsn(Opcodes.ACONST_NULL);// throwable
        break;
    default:
        mv.visitVarInsn(Opcodes.ASTORE, i);
        mv.visitVarInsn(Opcodes.ALOAD, i);

        mv.visitVarInsn(Opcodes.ALOAD, statIdx);// stat
        mv.visitVarInsn(Opcodes.ALOAD, i);// return
        mv.visitInsn(Opcodes.ACONST_NULL);// throwable
    }

    mv.visitMethodInsn(Opcodes.INVOKESTATIC, TRACEMAIN, END_METHOD, END_SIGNATURE, false);
}

From source file:scouter.agent.asm.util.AsmUtil.java

License:Apache License

public static void loadForArrayElement(MethodVisitor mv, Type tp, int sidx) {
    switch (tp.getSort()) {
    case Type.BOOLEAN:
        mv.visitVarInsn(Opcodes.ILOAD, sidx);
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/Boolean", "valueOf", "(Z)Ljava/lang/Boolean;",
                false);//from w  w  w .  java 2s .c  om
        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);
    }
}

From source file:serianalyzer.JVMImpl.java

License:Open Source License

/**
 * @param opcode/*from   w  w  w .j a va 2s .  c o m*/
 * @param var
 * @param s
 */
static void handleVarInsn(int opcode, int var, JVMStackState s) {
    Set<BaseType> v;
    switch (opcode) {
    case Opcodes.LLOAD:
    case Opcodes.ILOAD:
    case Opcodes.FLOAD:
    case Opcodes.DLOAD:
    case Opcodes.ALOAD:
        v = s.getVariable(var);
        if (log.isTraceEnabled()) {
            log.trace("LOAD " + opcode + "@" + var + ":" + v); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        }
        if (v == null || v.isEmpty()) {
            s.push(new BasicVariable(toType(opcode), "unknown " + var, true)); //$NON-NLS-1$
        } else if (v.size() == 1) {
            s.push(v.iterator().next());
        } else {
            Set<BaseType> alts = new HashSet<>();
            for (BaseType o : v) {
                if (o instanceof MultiAlternatives && !((MultiAlternatives) o).getAlternatives().isEmpty()) {
                    alts.addAll(((MultiAlternatives) o).getAlternatives());
                } else {
                    alts.add(o);
                }
            }
            s.push(new MultiAlternatives(alts));
        }
        break;
    case Opcodes.LSTORE:
    case Opcodes.ISTORE:
    case Opcodes.FSTORE:
    case Opcodes.DSTORE:
    case Opcodes.ASTORE:
        s.getVariable(var).add(s.pop());
        break;
    case Opcodes.RET:
        break;
    default:
        log.warn("Unimplemented opcode " + opcode); //$NON-NLS-1$
    }
}