Search in sources :

Example 26 with Type

use of com.oracle.truffle.espresso.descriptors.Symbol.Type in project graal by oracle.

the class ClassfileParser method parseLocalVariableTable.

private LocalVariableTable parseLocalVariableTable(Symbol<Name> name, int codeLength, int maxLocals) {
    boolean isLVTT = Name.LocalVariableTypeTable.equals(name);
    int entryCount = stream.readU2();
    if (entryCount == 0) {
        return isLVTT ? LocalVariableTable.EMPTY_LVTT : LocalVariableTable.EMPTY_LVT;
    }
    Local[] locals = new Local[entryCount];
    for (int i = 0; i < entryCount; i++) {
        int bci = stream.readU2();
        int length = stream.readU2();
        int nameIndex = stream.readU2();
        int descIndex = stream.readU2();
        int slot = stream.readU2();
        if (bci < 0 || bci >= codeLength) {
            throw ConstantPool.classFormatError("Invalid local variable table attribute entry: start_pc out of bounds: " + bci);
        }
        if (bci + length > codeLength) {
            throw ConstantPool.classFormatError("Invalid local variable table attribute entry: start_pc + length out of bounds: " + (bci + length));
        }
        Utf8Constant poolName = pool.utf8At(nameIndex);
        Utf8Constant typeName = pool.utf8At(descIndex);
        typeName.validateUTF8();
        poolName.validateFieldName();
        int extraSlot = 0;
        if (!isLVTT) {
            typeName.validateType(false);
            Symbol<Type> type = typeName.value();
            if (type == Type._long || type == Type._double) {
                extraSlot = 1;
            }
        }
        if (slot + extraSlot >= maxLocals) {
            throw ConstantPool.classFormatError("Invalid local variable table attribute entry: index points to an invalid frame slot: " + slot);
        }
        locals[i] = new Local(poolName, typeName, bci, bci + length, slot);
    }
    return new LocalVariableTable(name, locals);
}
Also used : LocalVariableTable(com.oracle.truffle.espresso.classfile.attributes.LocalVariableTable) Type(com.oracle.truffle.espresso.descriptors.Symbol.Type) Local(com.oracle.truffle.espresso.classfile.attributes.Local) Utf8Constant(com.oracle.truffle.espresso.classfile.constantpool.Utf8Constant)

Aggregations

Type (com.oracle.truffle.espresso.descriptors.Symbol.Type)26 Name (com.oracle.truffle.espresso.descriptors.Symbol.Name)9 JavaType (com.oracle.truffle.espresso.substitutions.JavaType)9 NativeType (com.oracle.truffle.espresso.ffi.NativeType)8 ObjectKlass (com.oracle.truffle.espresso.impl.ObjectKlass)6 Meta (com.oracle.truffle.espresso.meta.Meta)6 StaticObject (com.oracle.truffle.espresso.runtime.StaticObject)6 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)5 ArrayKlass (com.oracle.truffle.espresso.impl.ArrayKlass)5 Klass (com.oracle.truffle.espresso.impl.Klass)5 TruffleSafepoint (com.oracle.truffle.api.TruffleSafepoint)3 ExplodeLoop (com.oracle.truffle.api.nodes.ExplodeLoop)3 EnclosingMethodAttribute (com.oracle.truffle.espresso.classfile.attributes.EnclosingMethodAttribute)3 MethodRefConstant (com.oracle.truffle.espresso.classfile.constantpool.MethodRefConstant)3 PoolConstant (com.oracle.truffle.espresso.classfile.constantpool.PoolConstant)3 Symbol (com.oracle.truffle.espresso.descriptors.Symbol)3 Signature (com.oracle.truffle.espresso.descriptors.Symbol.Signature)3 ParserField (com.oracle.truffle.espresso.impl.ParserField)3 DebugCloseable (com.oracle.truffle.espresso.perf.DebugCloseable)3 BootstrapMethodsAttribute (com.oracle.truffle.espresso.classfile.attributes.BootstrapMethodsAttribute)2