Search in sources :

Example 6 with EspressoReference

use of com.oracle.truffle.espresso.ref.EspressoReference in project graal by oracle.

the class Target_java_lang_ref_Reference method get.

@SuppressWarnings("rawtypes")
@Substitution(hasReceiver = true)
@JavaType(Object.class)
public static StaticObject get(@JavaType(java.lang.ref.Reference.class) StaticObject self, @Inject Meta meta) {
    assert !InterpreterToVM.instanceOf(self, meta.java_lang_ref_PhantomReference) : "Cannot call Reference.get on PhantomReference";
    if (// 
    InterpreterToVM.instanceOf(self, meta.java_lang_ref_WeakReference) || // 
    InterpreterToVM.instanceOf(self, meta.java_lang_ref_SoftReference) || InterpreterToVM.instanceOf(self, meta.java_lang_ref_FinalReference)) {
        // Ignore guest referent field.
        EspressoReference ref = (EspressoReference) meta.HIDDEN_HOST_REFERENCE.getHiddenObject(self);
        if (ref == null) {
            return StaticObject.NULL;
        }
        assert ref instanceof Reference;
        StaticObject obj = ref.get();
        return obj == null ? StaticObject.NULL : obj;
    } else {
        return meta.java_lang_ref_Reference_referent.getObject(self);
    }
}
Also used : EspressoReference(com.oracle.truffle.espresso.ref.EspressoReference) StaticObject(com.oracle.truffle.espresso.runtime.StaticObject) Reference(java.lang.ref.Reference) EspressoReference(com.oracle.truffle.espresso.ref.EspressoReference)

Aggregations

EspressoReference (com.oracle.truffle.espresso.ref.EspressoReference)6 Reference (java.lang.ref.Reference)4 Meta (com.oracle.truffle.espresso.meta.Meta)2 Target_java_lang_ref_Reference (com.oracle.truffle.espresso.substitutions.Target_java_lang_ref_Reference)2 TruffleLanguage (com.oracle.truffle.api.TruffleLanguage)1 EspressoLock (com.oracle.truffle.espresso.blocking.EspressoLock)1 StaticObject (com.oracle.truffle.espresso.runtime.StaticObject)1