Java Code Examples for jdk.internal.org.objectweb.asm.tree.AbstractInsnNode#getOpcode()

The following examples show how to use jdk.internal.org.objectweb.asm.tree.AbstractInsnNode#getOpcode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SourceInterpreter.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public SourceValue newOperation(final AbstractInsnNode insn) {
    int size;
    switch (insn.getOpcode()) {
    case LCONST_0:
    case LCONST_1:
    case DCONST_0:
    case DCONST_1:
        size = 2;
        break;
    case LDC:
        Object cst = ((LdcInsnNode) insn).cst;
        size = cst instanceof Long || cst instanceof Double ? 2 : 1;
        break;
    case GETSTATIC:
        size = Type.getType(((FieldInsnNode) insn).desc).getSize();
        break;
    default:
        size = 1;
    }
    return new SourceValue(size, insn);
}
 
Example 2
Source File: SourceInterpreter.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public SourceValue unaryOperation(final AbstractInsnNode insn,
        final SourceValue value) {
    int size;
    switch (insn.getOpcode()) {
    case LNEG:
    case DNEG:
    case I2L:
    case I2D:
    case L2D:
    case F2L:
    case F2D:
    case D2L:
        size = 2;
        break;
    case GETFIELD:
        size = Type.getType(((FieldInsnNode) insn).desc).getSize();
        break;
    default:
        size = 1;
    }
    return new SourceValue(size, insn);
}
 
Example 3
Source File: SourceInterpreter.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public SourceValue unaryOperation(final AbstractInsnNode insn,
        final SourceValue value) {
    int size;
    switch (insn.getOpcode()) {
    case LNEG:
    case DNEG:
    case I2L:
    case I2D:
    case L2D:
    case F2L:
    case F2D:
    case D2L:
        size = 2;
        break;
    case GETFIELD:
        size = Type.getType(((FieldInsnNode) insn).desc).getSize();
        break;
    default:
        size = 1;
    }
    return new SourceValue(size, insn);
}
 
Example 4
Source File: SourceInterpreter.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public SourceValue unaryOperation(final AbstractInsnNode insn,
        final SourceValue value) {
    int size;
    switch (insn.getOpcode()) {
    case LNEG:
    case DNEG:
    case I2L:
    case I2D:
    case L2D:
    case F2L:
    case F2D:
    case D2L:
        size = 2;
        break;
    case GETFIELD:
        size = Type.getType(((FieldInsnNode) insn).desc).getSize();
        break;
    default:
        size = 1;
    }
    return new SourceValue(size, insn);
}
 
Example 5
Source File: SourceInterpreter.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public SourceValue newOperation(final AbstractInsnNode insn) {
    int size;
    switch (insn.getOpcode()) {
    case LCONST_0:
    case LCONST_1:
    case DCONST_0:
    case DCONST_1:
        size = 2;
        break;
    case LDC:
        Object cst = ((LdcInsnNode) insn).cst;
        size = cst instanceof Long || cst instanceof Double ? 2 : 1;
        break;
    case GETSTATIC:
        size = Type.getType(((FieldInsnNode) insn).desc).getSize();
        break;
    default:
        size = 1;
    }
    return new SourceValue(size, insn);
}
 
Example 6
Source File: SourceInterpreter.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public SourceValue newOperation(final AbstractInsnNode insn) {
    int size;
    switch (insn.getOpcode()) {
    case LCONST_0:
    case LCONST_1:
    case DCONST_0:
    case DCONST_1:
        size = 2;
        break;
    case LDC:
        Object cst = ((LdcInsnNode) insn).cst;
        size = cst instanceof Long || cst instanceof Double ? 2 : 1;
        break;
    case GETSTATIC:
        size = Type.getType(((FieldInsnNode) insn).desc).getSize();
        break;
    default:
        size = 1;
    }
    return new SourceValue(size, insn);
}
 
Example 7
Source File: SourceInterpreter.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public SourceValue naryOperation(final AbstractInsnNode insn,
        final List<? extends SourceValue> values) {
    int size;
    int opcode = insn.getOpcode();
    if (opcode == MULTIANEWARRAY) {
        size = 1;
    } else {
        String desc = (opcode == INVOKEDYNAMIC) ? ((InvokeDynamicInsnNode) insn).desc
                : ((MethodInsnNode) insn).desc;
        size = Type.getReturnType(desc).getSize();
    }
    return new SourceValue(size, insn);
}
 
Example 8
Source File: SourceInterpreter.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public SourceValue binaryOperation(final AbstractInsnNode insn,
        final SourceValue value1, final SourceValue value2) {
    int size;
    switch (insn.getOpcode()) {
    case LALOAD:
    case DALOAD:
    case LADD:
    case DADD:
    case LSUB:
    case DSUB:
    case LMUL:
    case DMUL:
    case LDIV:
    case DDIV:
    case LREM:
    case DREM:
    case LSHL:
    case LSHR:
    case LUSHR:
    case LAND:
    case LOR:
    case LXOR:
        size = 2;
        break;
    default:
        size = 1;
    }
    return new SourceValue(size, insn);
}
 
Example 9
Source File: SourceInterpreter.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public SourceValue binaryOperation(final AbstractInsnNode insn,
        final SourceValue value1, final SourceValue value2) {
    int size;
    switch (insn.getOpcode()) {
    case LALOAD:
    case DALOAD:
    case LADD:
    case DADD:
    case LSUB:
    case DSUB:
    case LMUL:
    case DMUL:
    case LDIV:
    case DDIV:
    case LREM:
    case DREM:
    case LSHL:
    case LSHR:
    case LUSHR:
    case LAND:
    case LOR:
    case LXOR:
        size = 2;
        break;
    default:
        size = 1;
    }
    return new SourceValue(size, insn);
}
 
Example 10
Source File: BasicInterpreter.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public BasicValue naryOperation(final AbstractInsnNode insn,
        final List<? extends BasicValue> values) throws AnalyzerException {
    int opcode = insn.getOpcode();
    if (opcode == MULTIANEWARRAY) {
        return newValue(Type.getType(((MultiANewArrayInsnNode) insn).desc));
    } else if (opcode == INVOKEDYNAMIC) {
        return newValue(Type
                .getReturnType(((InvokeDynamicInsnNode) insn).desc));
    } else {
        return newValue(Type.getReturnType(((MethodInsnNode) insn).desc));
    }
}
 
Example 11
Source File: SourceInterpreter.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public SourceValue naryOperation(final AbstractInsnNode insn,
        final List<? extends SourceValue> values) {
    int size;
    int opcode = insn.getOpcode();
    if (opcode == MULTIANEWARRAY) {
        size = 1;
    } else {
        String desc = (opcode == INVOKEDYNAMIC) ? ((InvokeDynamicInsnNode) insn).desc
                : ((MethodInsnNode) insn).desc;
        size = Type.getReturnType(desc).getSize();
    }
    return new SourceValue(size, insn);
}
 
Example 12
Source File: SourceInterpreter.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public SourceValue naryOperation(final AbstractInsnNode insn,
        final List<? extends SourceValue> values) {
    int size;
    int opcode = insn.getOpcode();
    if (opcode == MULTIANEWARRAY) {
        size = 1;
    } else {
        String desc = (opcode == INVOKEDYNAMIC) ? ((InvokeDynamicInsnNode) insn).desc
                : ((MethodInsnNode) insn).desc;
        size = Type.getReturnType(desc).getSize();
    }
    return new SourceValue(size, insn);
}
 
Example 13
Source File: BasicVerifier.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public BasicValue ternaryOperation(final AbstractInsnNode insn,
        final BasicValue value1, final BasicValue value2,
        final BasicValue value3) throws AnalyzerException {
    BasicValue expected1;
    BasicValue expected3;
    switch (insn.getOpcode()) {
    case IASTORE:
        expected1 = newValue(Type.getType("[I"));
        expected3 = BasicValue.INT_VALUE;
        break;
    case BASTORE:
        if (isSubTypeOf(value1, newValue(Type.getType("[Z")))) {
            expected1 = newValue(Type.getType("[Z"));
        } else {
            expected1 = newValue(Type.getType("[B"));
        }
        expected3 = BasicValue.INT_VALUE;
        break;
    case CASTORE:
        expected1 = newValue(Type.getType("[C"));
        expected3 = BasicValue.INT_VALUE;
        break;
    case SASTORE:
        expected1 = newValue(Type.getType("[S"));
        expected3 = BasicValue.INT_VALUE;
        break;
    case LASTORE:
        expected1 = newValue(Type.getType("[J"));
        expected3 = BasicValue.LONG_VALUE;
        break;
    case FASTORE:
        expected1 = newValue(Type.getType("[F"));
        expected3 = BasicValue.FLOAT_VALUE;
        break;
    case DASTORE:
        expected1 = newValue(Type.getType("[D"));
        expected3 = BasicValue.DOUBLE_VALUE;
        break;
    case AASTORE:
        expected1 = value1;
        expected3 = BasicValue.REFERENCE_VALUE;
        break;
    default:
        throw new Error("Internal error.");
    }
    if (!isSubTypeOf(value1, expected1)) {
        throw new AnalyzerException(insn, "First argument", "a "
                + expected1 + " array reference", value1);
    } else if (!BasicValue.INT_VALUE.equals(value2)) {
        throw new AnalyzerException(insn, "Second argument",
                BasicValue.INT_VALUE, value2);
    } else if (!isSubTypeOf(value3, expected3)) {
        throw new AnalyzerException(insn, "Third argument", expected3,
                value3);
    }
    return null;
}
 
Example 14
Source File: BasicVerifier.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public BasicValue unaryOperation(final AbstractInsnNode insn,
        final BasicValue value) throws AnalyzerException {
    BasicValue expected;
    switch (insn.getOpcode()) {
    case INEG:
    case IINC:
    case I2F:
    case I2L:
    case I2D:
    case I2B:
    case I2C:
    case I2S:
    case IFEQ:
    case IFNE:
    case IFLT:
    case IFGE:
    case IFGT:
    case IFLE:
    case TABLESWITCH:
    case LOOKUPSWITCH:
    case IRETURN:
    case NEWARRAY:
    case ANEWARRAY:
        expected = BasicValue.INT_VALUE;
        break;
    case FNEG:
    case F2I:
    case F2L:
    case F2D:
    case FRETURN:
        expected = BasicValue.FLOAT_VALUE;
        break;
    case LNEG:
    case L2I:
    case L2F:
    case L2D:
    case LRETURN:
        expected = BasicValue.LONG_VALUE;
        break;
    case DNEG:
    case D2I:
    case D2F:
    case D2L:
    case DRETURN:
        expected = BasicValue.DOUBLE_VALUE;
        break;
    case GETFIELD:
        expected = newValue(Type
                .getObjectType(((FieldInsnNode) insn).owner));
        break;
    case CHECKCAST:
        if (!value.isReference()) {
            throw new AnalyzerException(insn, null, "an object reference",
                    value);
        }
        return super.unaryOperation(insn, value);
    case ARRAYLENGTH:
        if (!isArrayValue(value)) {
            throw new AnalyzerException(insn, null, "an array reference",
                    value);
        }
        return super.unaryOperation(insn, value);
    case ARETURN:
    case ATHROW:
    case INSTANCEOF:
    case MONITORENTER:
    case MONITOREXIT:
    case IFNULL:
    case IFNONNULL:
        if (!value.isReference()) {
            throw new AnalyzerException(insn, null, "an object reference",
                    value);
        }
        return super.unaryOperation(insn, value);
    case PUTSTATIC:
        expected = newValue(Type.getType(((FieldInsnNode) insn).desc));
        break;
    default:
        throw new Error("Internal error.");
    }
    if (!isSubTypeOf(value, expected)) {
        throw new AnalyzerException(insn, null, expected, value);
    }
    return super.unaryOperation(insn, value);
}
 
Example 15
Source File: BasicInterpreter.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
public BasicValue binaryOperation(final AbstractInsnNode insn,
        final BasicValue value1, final BasicValue value2)
        throws AnalyzerException {
    switch (insn.getOpcode()) {
    case IALOAD:
    case BALOAD:
    case CALOAD:
    case SALOAD:
    case IADD:
    case ISUB:
    case IMUL:
    case IDIV:
    case IREM:
    case ISHL:
    case ISHR:
    case IUSHR:
    case IAND:
    case IOR:
    case IXOR:
        return BasicValue.INT_VALUE;
    case FALOAD:
    case FADD:
    case FSUB:
    case FMUL:
    case FDIV:
    case FREM:
        return BasicValue.FLOAT_VALUE;
    case LALOAD:
    case LADD:
    case LSUB:
    case LMUL:
    case LDIV:
    case LREM:
    case LSHL:
    case LSHR:
    case LUSHR:
    case LAND:
    case LOR:
    case LXOR:
        return BasicValue.LONG_VALUE;
    case DALOAD:
    case DADD:
    case DSUB:
    case DMUL:
    case DDIV:
    case DREM:
        return BasicValue.DOUBLE_VALUE;
    case AALOAD:
        return BasicValue.REFERENCE_VALUE;
    case LCMP:
    case FCMPL:
    case FCMPG:
    case DCMPL:
    case DCMPG:
        return BasicValue.INT_VALUE;
    case IF_ICMPEQ:
    case IF_ICMPNE:
    case IF_ICMPLT:
    case IF_ICMPGE:
    case IF_ICMPGT:
    case IF_ICMPLE:
    case IF_ACMPEQ:
    case IF_ACMPNE:
    case PUTFIELD:
        return null;
    default:
        throw new Error("Internal error.");
    }
}
 
Example 16
Source File: BasicVerifier.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public BasicValue copyOperation(final AbstractInsnNode insn,
        final BasicValue value) throws AnalyzerException {
    Value expected;
    switch (insn.getOpcode()) {
    case ILOAD:
    case ISTORE:
        expected = BasicValue.INT_VALUE;
        break;
    case FLOAD:
    case FSTORE:
        expected = BasicValue.FLOAT_VALUE;
        break;
    case LLOAD:
    case LSTORE:
        expected = BasicValue.LONG_VALUE;
        break;
    case DLOAD:
    case DSTORE:
        expected = BasicValue.DOUBLE_VALUE;
        break;
    case ALOAD:
        if (!value.isReference()) {
            throw new AnalyzerException(insn, null, "an object reference",
                    value);
        }
        return value;
    case ASTORE:
        if (!value.isReference()
                && !BasicValue.RETURNADDRESS_VALUE.equals(value)) {
            throw new AnalyzerException(insn, null,
                    "an object reference or a return address", value);
        }
        return value;
    default:
        return value;
    }
    if (!expected.equals(value)) {
        throw new AnalyzerException(insn, null, expected, value);
    }
    return value;
}
 
Example 17
Source File: BasicVerifier.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public BasicValue ternaryOperation(final AbstractInsnNode insn,
        final BasicValue value1, final BasicValue value2,
        final BasicValue value3) throws AnalyzerException {
    BasicValue expected1;
    BasicValue expected3;
    switch (insn.getOpcode()) {
    case IASTORE:
        expected1 = newValue(Type.getType("[I"));
        expected3 = BasicValue.INT_VALUE;
        break;
    case BASTORE:
        if (isSubTypeOf(value1, newValue(Type.getType("[Z")))) {
            expected1 = newValue(Type.getType("[Z"));
        } else {
            expected1 = newValue(Type.getType("[B"));
        }
        expected3 = BasicValue.INT_VALUE;
        break;
    case CASTORE:
        expected1 = newValue(Type.getType("[C"));
        expected3 = BasicValue.INT_VALUE;
        break;
    case SASTORE:
        expected1 = newValue(Type.getType("[S"));
        expected3 = BasicValue.INT_VALUE;
        break;
    case LASTORE:
        expected1 = newValue(Type.getType("[J"));
        expected3 = BasicValue.LONG_VALUE;
        break;
    case FASTORE:
        expected1 = newValue(Type.getType("[F"));
        expected3 = BasicValue.FLOAT_VALUE;
        break;
    case DASTORE:
        expected1 = newValue(Type.getType("[D"));
        expected3 = BasicValue.DOUBLE_VALUE;
        break;
    case AASTORE:
        expected1 = value1;
        expected3 = BasicValue.REFERENCE_VALUE;
        break;
    default:
        throw new Error("Internal error.");
    }
    if (!isSubTypeOf(value1, expected1)) {
        throw new AnalyzerException(insn, "First argument", "a "
                + expected1 + " array reference", value1);
    } else if (!BasicValue.INT_VALUE.equals(value2)) {
        throw new AnalyzerException(insn, "Second argument",
                BasicValue.INT_VALUE, value2);
    } else if (!isSubTypeOf(value3, expected3)) {
        throw new AnalyzerException(insn, "Third argument", expected3,
                value3);
    }
    return null;
}
 
Example 18
Source File: BasicVerifier.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public BasicValue copyOperation(final AbstractInsnNode insn,
        final BasicValue value) throws AnalyzerException {
    Value expected;
    switch (insn.getOpcode()) {
    case ILOAD:
    case ISTORE:
        expected = BasicValue.INT_VALUE;
        break;
    case FLOAD:
    case FSTORE:
        expected = BasicValue.FLOAT_VALUE;
        break;
    case LLOAD:
    case LSTORE:
        expected = BasicValue.LONG_VALUE;
        break;
    case DLOAD:
    case DSTORE:
        expected = BasicValue.DOUBLE_VALUE;
        break;
    case ALOAD:
        if (!value.isReference()) {
            throw new AnalyzerException(insn, null, "an object reference",
                    value);
        }
        return value;
    case ASTORE:
        if (!value.isReference()
                && !BasicValue.RETURNADDRESS_VALUE.equals(value)) {
            throw new AnalyzerException(insn, null,
                    "an object reference or a return address", value);
        }
        return value;
    default:
        return value;
    }
    if (!expected.equals(value)) {
        throw new AnalyzerException(insn, null, expected, value);
    }
    return value;
}
 
Example 19
Source File: BasicVerifier.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public BasicValue unaryOperation(final AbstractInsnNode insn,
        final BasicValue value) throws AnalyzerException {
    BasicValue expected;
    switch (insn.getOpcode()) {
    case INEG:
    case IINC:
    case I2F:
    case I2L:
    case I2D:
    case I2B:
    case I2C:
    case I2S:
    case IFEQ:
    case IFNE:
    case IFLT:
    case IFGE:
    case IFGT:
    case IFLE:
    case TABLESWITCH:
    case LOOKUPSWITCH:
    case IRETURN:
    case NEWARRAY:
    case ANEWARRAY:
        expected = BasicValue.INT_VALUE;
        break;
    case FNEG:
    case F2I:
    case F2L:
    case F2D:
    case FRETURN:
        expected = BasicValue.FLOAT_VALUE;
        break;
    case LNEG:
    case L2I:
    case L2F:
    case L2D:
    case LRETURN:
        expected = BasicValue.LONG_VALUE;
        break;
    case DNEG:
    case D2I:
    case D2F:
    case D2L:
    case DRETURN:
        expected = BasicValue.DOUBLE_VALUE;
        break;
    case GETFIELD:
        expected = newValue(Type
                .getObjectType(((FieldInsnNode) insn).owner));
        break;
    case CHECKCAST:
        if (!value.isReference()) {
            throw new AnalyzerException(insn, null, "an object reference",
                    value);
        }
        return super.unaryOperation(insn, value);
    case ARRAYLENGTH:
        if (!isArrayValue(value)) {
            throw new AnalyzerException(insn, null, "an array reference",
                    value);
        }
        return super.unaryOperation(insn, value);
    case ARETURN:
    case ATHROW:
    case INSTANCEOF:
    case MONITORENTER:
    case MONITOREXIT:
    case IFNULL:
    case IFNONNULL:
        if (!value.isReference()) {
            throw new AnalyzerException(insn, null, "an object reference",
                    value);
        }
        return super.unaryOperation(insn, value);
    case PUTSTATIC:
        expected = newValue(Type.getType(((FieldInsnNode) insn).desc));
        break;
    default:
        throw new Error("Internal error.");
    }
    if (!isSubTypeOf(value, expected)) {
        throw new AnalyzerException(insn, null, expected, value);
    }
    return super.unaryOperation(insn, value);
}
 
Example 20
Source File: BasicVerifier.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public BasicValue ternaryOperation(final AbstractInsnNode insn,
        final BasicValue value1, final BasicValue value2,
        final BasicValue value3) throws AnalyzerException {
    BasicValue expected1;
    BasicValue expected3;
    switch (insn.getOpcode()) {
    case IASTORE:
        expected1 = newValue(Type.getType("[I"));
        expected3 = BasicValue.INT_VALUE;
        break;
    case BASTORE:
        if (isSubTypeOf(value1, newValue(Type.getType("[Z")))) {
            expected1 = newValue(Type.getType("[Z"));
        } else {
            expected1 = newValue(Type.getType("[B"));
        }
        expected3 = BasicValue.INT_VALUE;
        break;
    case CASTORE:
        expected1 = newValue(Type.getType("[C"));
        expected3 = BasicValue.INT_VALUE;
        break;
    case SASTORE:
        expected1 = newValue(Type.getType("[S"));
        expected3 = BasicValue.INT_VALUE;
        break;
    case LASTORE:
        expected1 = newValue(Type.getType("[J"));
        expected3 = BasicValue.LONG_VALUE;
        break;
    case FASTORE:
        expected1 = newValue(Type.getType("[F"));
        expected3 = BasicValue.FLOAT_VALUE;
        break;
    case DASTORE:
        expected1 = newValue(Type.getType("[D"));
        expected3 = BasicValue.DOUBLE_VALUE;
        break;
    case AASTORE:
        expected1 = value1;
        expected3 = BasicValue.REFERENCE_VALUE;
        break;
    default:
        throw new Error("Internal error.");
    }
    if (!isSubTypeOf(value1, expected1)) {
        throw new AnalyzerException(insn, "First argument", "a "
                + expected1 + " array reference", value1);
    } else if (!BasicValue.INT_VALUE.equals(value2)) {
        throw new AnalyzerException(insn, "Second argument",
                BasicValue.INT_VALUE, value2);
    } else if (!isSubTypeOf(value3, expected3)) {
        throw new AnalyzerException(insn, "Third argument", expected3,
                value3);
    }
    return null;
}