Search in sources :

Example 31 with StaticObject

use of com.oracle.truffle.espresso.runtime.StaticObject in project graal by oracle.

the class ExceptionDispatch method slowPath.

private StaticObject slowPath(ObjectKlass klass, StaticObject message, StaticObject cause) {
    assert meta.java_lang_Throwable.isAssignableFrom(klass);
    StaticObject ex;
    if (CompilerDirectives.isPartialEvaluationConstant(klass)) {
        // if klass was a compilation constant, the constantness of the klass field in ex should
        // propagate even through the boundary.
        ex = klass.allocateInstance();
    } else {
        ex = allocate(klass);
    }
    slowInitEx(ex, klass, message, cause);
    return ex;
}
Also used : StaticObject(com.oracle.truffle.espresso.runtime.StaticObject)

Example 32 with StaticObject

use of com.oracle.truffle.espresso.runtime.StaticObject in project graal by oracle.

the class ClassRegistries method getAllModuleRefs.

public ModuleRef[] getAllModuleRefs() {
    ArrayList<ModuleRef> list = new ArrayList<>();
    // add modules from boot registry
    list.addAll(bootClassRegistry.modules().values());
    // add modules from all other registries
    synchronized (weakClassLoaderSet) {
        for (StaticObject classLoader : weakClassLoaderSet) {
            list.addAll(getClassRegistry(classLoader).modules().values());
        }
    }
    return list.toArray(ModuleRef.EMPTY_ARRAY);
}
Also used : StaticObject(com.oracle.truffle.espresso.runtime.StaticObject) ModuleRef(com.oracle.truffle.espresso.jdwp.api.ModuleRef) ArrayList(java.util.ArrayList)

Example 33 with StaticObject

use of com.oracle.truffle.espresso.runtime.StaticObject in project graal by oracle.

the class Field method getReflectiveFieldRoot.

public static Field getReflectiveFieldRoot(StaticObject seed, Meta meta) {
    StaticObject curField = seed;
    Field target = null;
    while (target == null) {
        target = (Field) meta.HIDDEN_FIELD_KEY.getHiddenObject(curField);
        if (target == null) {
            curField = meta.java_lang_reflect_Field_root.getObject(curField);
        }
    }
    return target;
}
Also used : StaticObject(com.oracle.truffle.espresso.runtime.StaticObject)

Example 34 with StaticObject

use of com.oracle.truffle.espresso.runtime.StaticObject in project graal by oracle.

the class Klass method readMember.

@ExportMessage
Object readMember(String member, @Shared("lookupField") @Cached LookupFieldNode lookupFieldNode, @Shared("error") @Cached BranchProfile error) throws UnknownIdentifierException {
    Field field = lookupFieldNode.execute(this, member, true);
    if (field != null) {
        Object result = field.get(this.tryInitializeAndGetStatics());
        if (result instanceof StaticObject && ((StaticObject) result).isForeignObject()) {
            return ((StaticObject) result).rawForeignObject();
        }
        return result;
    }
    // Klass<T>.class == Class<T>
    if (STATIC_TO_CLASS.equals(member)) {
        return mirror();
    }
    // Klass<T>.static == Klass<T>
    if (CLASS_TO_STATIC.equals(member)) {
        return this;
    }
    if (getMeta()._void != this && ARRAY.equals(member)) {
        return array();
    }
    if (isArray() && COMPONENT.equals(member)) {
        return ((ArrayKlass) this).getComponentType();
    }
    if (getSuperKlass() != null && SUPER.equals(member)) {
        return getSuperKlass();
    }
    error.enter();
    throw UnknownIdentifierException.create(member);
}
Also used : StaticObject(com.oracle.truffle.espresso.runtime.StaticObject) StaticObject(com.oracle.truffle.espresso.runtime.StaticObject) TruffleObject(com.oracle.truffle.api.interop.TruffleObject) ExportMessage(com.oracle.truffle.api.library.ExportMessage)

Example 35 with StaticObject

use of com.oracle.truffle.espresso.runtime.StaticObject in project graal by oracle.

the class MethodTypeConstant method signatureToMethodType.

static StaticObject signatureToMethodType(Symbol<Symbol.Type>[] signature, Klass accessingKlass, boolean failWithBME, Meta meta) {
    Symbol<Symbol.Type> rt = Signatures.returnType(signature);
    int pcount = Signatures.parameterCount(signature, false);
    StaticObject[] ptypes = new StaticObject[pcount];
    StaticObject rtype;
    try {
        for (int i = 0; i < pcount; i++) {
            Symbol<Symbol.Type> paramType = Signatures.parameterType(signature, i);
            ptypes[i] = meta.resolveSymbolAndAccessCheck(paramType, accessingKlass).mirror();
        }
    } catch (EspressoException e) {
        if (meta.java_lang_ClassNotFoundException.isAssignableFrom(e.getGuestException().getKlass())) {
            throw meta.throwExceptionWithMessage(meta.java_lang_NoClassDefFoundError, e.getGuestMessage());
        }
        throw e;
    }
    try {
        rtype = meta.resolveSymbolAndAccessCheck(rt, accessingKlass).mirror();
    } catch (EspressoException e) {
        EspressoException rethrow = e;
        if (meta.java_lang_ClassNotFoundException.isAssignableFrom(e.getGuestException().getKlass())) {
            rethrow = EspressoException.wrap(Meta.initExceptionWithMessage(meta.java_lang_NoClassDefFoundError, e.getGuestMessage()), meta);
        }
        if (failWithBME) {
            rethrow = EspressoException.wrap(Meta.initExceptionWithCause(meta.java_lang_BootstrapMethodError, rethrow.getGuestException()), meta);
        }
        throw rethrow;
    }
    return (StaticObject) meta.java_lang_invoke_MethodHandleNatives_findMethodHandleType.invokeDirect(null, rtype, StaticObject.createArray(meta.java_lang_Class_array, ptypes));
}
Also used : EspressoException(com.oracle.truffle.espresso.runtime.EspressoException) StaticObject(com.oracle.truffle.espresso.runtime.StaticObject)

Aggregations

StaticObject (com.oracle.truffle.espresso.runtime.StaticObject)199 Method (com.oracle.truffle.espresso.impl.Method)57 JavaType (com.oracle.truffle.espresso.substitutions.JavaType)44 Klass (com.oracle.truffle.espresso.impl.Klass)32 ObjectKlass (com.oracle.truffle.espresso.impl.ObjectKlass)32 TruffleObject (com.oracle.truffle.api.interop.TruffleObject)30 Meta (com.oracle.truffle.espresso.meta.Meta)29 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)26 ArrayKlass (com.oracle.truffle.espresso.impl.ArrayKlass)23 NoSafepoint (com.oracle.truffle.espresso.jni.NoSafepoint)17 ArrayList (java.util.ArrayList)13 EspressoException (com.oracle.truffle.espresso.runtime.EspressoException)9 Symbol (com.oracle.truffle.espresso.descriptors.Symbol)8 FrameInstance (com.oracle.truffle.api.frame.FrameInstance)7 ExportMessage (com.oracle.truffle.api.library.ExportMessage)7 BytecodeNode (com.oracle.truffle.espresso.nodes.BytecodeNode)7 TruffleSafepoint (com.oracle.truffle.api.TruffleSafepoint)6 Name (com.oracle.truffle.espresso.descriptors.Symbol.Name)6 EspressoContext (com.oracle.truffle.espresso.runtime.EspressoContext)6 Type (com.oracle.truffle.espresso.descriptors.Symbol.Type)5