Search in sources :

Example 1 with DynamicConstant

use of com.oracle.truffle.espresso.classfile.constantpool.DynamicConstant in project graal by oracle.

the class MethodVerifier method ldcFromTag.

private Operand ldcFromTag(PoolConstant pc) {
    // checkstyle: stop
    switch(pc.tag()) {
        case INTEGER:
            return Int;
        case FLOAT:
            return Float;
        case LONG:
            return Long;
        case DOUBLE:
            return Double;
        case CLASS:
            return jlClass;
        case STRING:
            return jlString;
        case METHODHANDLE:
            formatGuarantee(version51OrLater(), "LDC for MethodHandleConstant in classfile version < 51");
            return jliMethodHandle;
        case METHODTYPE:
            formatGuarantee(version51OrLater(), "LDC for MethodType in classfile version < 51");
            return jliMethodType;
        case DYNAMIC:
            formatGuarantee(version55OrLater(), "LDC for Dynamic in classfile version < 55");
            DynamicConstant constant = (DynamicConstant) pc;
            return kindToOperand(constant.getTypeSymbol(pool));
        default:
            throw failVerify("invalid CP load: " + pc.tag());
    }
// checkstyle: resume
// @formatter:on
}
Also used : InvokeDynamicConstant(com.oracle.truffle.espresso.classfile.constantpool.InvokeDynamicConstant) DynamicConstant(com.oracle.truffle.espresso.classfile.constantpool.DynamicConstant)

Example 2 with DynamicConstant

use of com.oracle.truffle.espresso.classfile.constantpool.DynamicConstant in project graal by oracle.

the class BytecodeNode method putPoolConstant.

private void putPoolConstant(VirtualFrame frame, int top, char cpi, int opcode) {
    assert opcode == LDC || opcode == LDC_W || opcode == LDC2_W;
    RuntimeConstantPool pool = getConstantPool();
    PoolConstant constant = pool.at(cpi);
    if (constant instanceof IntegerConstant) {
        assert opcode == LDC || opcode == LDC_W;
        putInt(frame, top, ((IntegerConstant) constant).value());
    } else if (constant instanceof LongConstant) {
        assert opcode == LDC2_W;
        putLong(frame, top, ((LongConstant) constant).value());
    } else if (constant instanceof DoubleConstant) {
        assert opcode == LDC2_W;
        putDouble(frame, top, ((DoubleConstant) constant).value());
    } else if (constant instanceof FloatConstant) {
        assert opcode == LDC || opcode == LDC_W;
        putFloat(frame, top, ((FloatConstant) constant).value());
    } else if (constant instanceof StringConstant) {
        assert opcode == LDC || opcode == LDC_W;
        StaticObject internedString = pool.resolvedStringAt(cpi);
        putObject(frame, top, internedString);
    } else if (constant instanceof ClassConstant) {
        assert opcode == LDC || opcode == LDC_W;
        Klass klass = pool.resolvedKlassAt(getDeclaringKlass(), cpi);
        putObject(frame, top, klass.mirror());
    } else if (constant instanceof MethodHandleConstant) {
        assert opcode == LDC || opcode == LDC_W;
        StaticObject methodHandle = pool.resolvedMethodHandleAt(getDeclaringKlass(), cpi);
        putObject(frame, top, methodHandle);
    } else if (constant instanceof MethodTypeConstant) {
        assert opcode == LDC || opcode == LDC_W;
        StaticObject methodType = pool.resolvedMethodTypeAt(getDeclaringKlass(), cpi);
        putObject(frame, top, methodType);
    } else if (constant instanceof DynamicConstant) {
        DynamicConstant.Resolved dynamicConstant = pool.resolvedDynamicConstantAt(getDeclaringKlass(), cpi);
        dynamicConstant.putResolved(frame, top, this);
    } else {
        CompilerDirectives.transferToInterpreter();
        throw EspressoError.unimplemented(constant.toString());
    }
}
Also used : LongConstant(com.oracle.truffle.espresso.classfile.constantpool.LongConstant) DoubleConstant(com.oracle.truffle.espresso.classfile.constantpool.DoubleConstant) PoolConstant(com.oracle.truffle.espresso.classfile.constantpool.PoolConstant) FloatConstant(com.oracle.truffle.espresso.classfile.constantpool.FloatConstant) MethodHandleConstant(com.oracle.truffle.espresso.classfile.constantpool.MethodHandleConstant) IntegerConstant(com.oracle.truffle.espresso.classfile.constantpool.IntegerConstant) InvokeDynamicConstant(com.oracle.truffle.espresso.classfile.constantpool.InvokeDynamicConstant) DynamicConstant(com.oracle.truffle.espresso.classfile.constantpool.DynamicConstant) RuntimeConstantPool(com.oracle.truffle.espresso.classfile.RuntimeConstantPool) Klass(com.oracle.truffle.espresso.impl.Klass) ArrayKlass(com.oracle.truffle.espresso.impl.ArrayKlass) StaticObject(com.oracle.truffle.espresso.runtime.StaticObject) StringConstant(com.oracle.truffle.espresso.classfile.constantpool.StringConstant) ClassConstant(com.oracle.truffle.espresso.classfile.constantpool.ClassConstant) MethodTypeConstant(com.oracle.truffle.espresso.classfile.constantpool.MethodTypeConstant)

Aggregations

DynamicConstant (com.oracle.truffle.espresso.classfile.constantpool.DynamicConstant)2 InvokeDynamicConstant (com.oracle.truffle.espresso.classfile.constantpool.InvokeDynamicConstant)2 RuntimeConstantPool (com.oracle.truffle.espresso.classfile.RuntimeConstantPool)1 ClassConstant (com.oracle.truffle.espresso.classfile.constantpool.ClassConstant)1 DoubleConstant (com.oracle.truffle.espresso.classfile.constantpool.DoubleConstant)1 FloatConstant (com.oracle.truffle.espresso.classfile.constantpool.FloatConstant)1 IntegerConstant (com.oracle.truffle.espresso.classfile.constantpool.IntegerConstant)1 LongConstant (com.oracle.truffle.espresso.classfile.constantpool.LongConstant)1 MethodHandleConstant (com.oracle.truffle.espresso.classfile.constantpool.MethodHandleConstant)1 MethodTypeConstant (com.oracle.truffle.espresso.classfile.constantpool.MethodTypeConstant)1 PoolConstant (com.oracle.truffle.espresso.classfile.constantpool.PoolConstant)1 StringConstant (com.oracle.truffle.espresso.classfile.constantpool.StringConstant)1 ArrayKlass (com.oracle.truffle.espresso.impl.ArrayKlass)1 Klass (com.oracle.truffle.espresso.impl.Klass)1 StaticObject (com.oracle.truffle.espresso.runtime.StaticObject)1