Search in sources :

Example 51 with Field

use of com.oracle.truffle.espresso.impl.Field in project graal by oracle.

the class Target_sun_misc_Unsafe method putByteVolatile.

@TruffleBoundary(allowInlining = true)
@Substitution(hasReceiver = true)
public static void putByteVolatile(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, byte value, @Inject Meta meta) {
    if (isNullOrArray(holder)) {
        UnsafeAccess.getIfAllowed(meta).putByteVolatile(unwrapNullOrArray(holder), offset, value);
        return;
    }
    // TODO(peterssen): Current workaround assumes it's a field access, encoding is offset <->
    // field index.
    Field f = getInstanceFieldFromIndex(holder, Math.toIntExact(offset) - SAFETY_FIELD_OFFSET);
    assert f != null;
    assert f.getKind().isSubWord();
    f.setByte(holder, value, true);
}
Also used : Field(com.oracle.truffle.espresso.impl.Field) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Example 52 with Field

use of com.oracle.truffle.espresso.impl.Field in project graal by oracle.

the class Target_sun_misc_Unsafe method putShortVolatile.

@TruffleBoundary(allowInlining = true)
@Substitution(hasReceiver = true)
public static void putShortVolatile(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, short value, @Inject Meta meta) {
    if (isNullOrArray(holder)) {
        UnsafeAccess.getIfAllowed(meta).putShortVolatile(unwrapNullOrArray(holder), offset, value);
        return;
    }
    // TODO(peterssen): Current workaround assumes it's a field access, encoding is offset <->
    // field index.
    Field f = getInstanceFieldFromIndex(holder, Math.toIntExact(offset) - SAFETY_FIELD_OFFSET);
    assert f != null;
    assert f.getKind().isSubWord();
    f.setShort(holder, value, true);
}
Also used : Field(com.oracle.truffle.espresso.impl.Field) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Example 53 with Field

use of com.oracle.truffle.espresso.impl.Field in project graal by oracle.

the class Target_sun_misc_Unsafe method putFloatVolatile.

@TruffleBoundary(allowInlining = true)
@Substitution(hasReceiver = true)
public static void putFloatVolatile(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, float value, @Inject Meta meta) {
    if (isNullOrArray(holder)) {
        UnsafeAccess.getIfAllowed(meta).putFloatVolatile(unwrapNullOrArray(holder), offset, value);
        return;
    }
    // TODO(peterssen): Current workaround assumes it's a field access, encoding is offset <->
    // field index.
    Field f = getInstanceFieldFromIndex(holder, Math.toIntExact(offset) - SAFETY_FIELD_OFFSET);
    assert f != null;
    assert f.getKind().isSubWord();
    f.setFloat(holder, value, true);
}
Also used : Field(com.oracle.truffle.espresso.impl.Field) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Example 54 with Field

use of com.oracle.truffle.espresso.impl.Field in project graal by oracle.

the class Target_sun_misc_Unsafe method putOrderedLong.

@Substitution(hasReceiver = true)
public static void putOrderedLong(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, long value, @Inject Meta meta) {
    if (isNullOrArray(holder)) {
        UnsafeAccess.getIfAllowed(meta).putOrderedLong(unwrapNullOrArray(holder), offset, value);
        return;
    }
    // TODO(peterssen): Current workaround assumes it's a field access, encoding is offset <->
    // field index.
    Field f = getInstanceFieldFromIndex(holder, Math.toIntExact(offset) - SAFETY_FIELD_OFFSET);
    assert f != null;
    // TODO(peterssen): Volatile is stronger than needed.
    f.setLong(holder, value, true);
}
Also used : Field(com.oracle.truffle.espresso.impl.Field)

Example 55 with Field

use of com.oracle.truffle.espresso.impl.Field in project graal by oracle.

the class Target_java_lang_invoke_MethodHandleNatives method init.

/**
 * Plants an already resolved target into a memberName.
 *
 * @param self the memberName
 * @param ref the target. Can be either a mathod or a field.
 */
@Substitution
public static void init(@JavaType(internalName = "Ljava/lang/invoke/MemberName;") StaticObject self, @JavaType(Object.class) StaticObject ref, @Inject Meta meta) {
    Klass targetKlass = ref.getKlass();
    if (targetKlass.getType() == Type.java_lang_reflect_Method) {
        // Actual planting
        Method target = Method.getHostReflectiveMethodRoot(ref, meta);
        plantResolvedMethod(self, target, target.getRefKind(), meta);
        // Finish the job
        meta.java_lang_invoke_MemberName_clazz.setObject(self, target.getDeclaringKlass().mirror());
    } else if (targetKlass.getType() == Type.java_lang_reflect_Field) {
        // Actual planting
        Field field = Field.getReflectiveFieldRoot(ref, meta);
        plantResolvedField(self, field, getRefKind(meta.java_lang_invoke_MemberName_flags.getInt(self)), meta);
        // Finish the job
        Klass fieldKlass = meta.java_lang_reflect_Field_class.getObject(ref).getMirrorKlass();
        meta.java_lang_invoke_MemberName_clazz.setObject(self, fieldKlass.mirror());
    } else if (targetKlass.getType() == Type.java_lang_reflect_Constructor) {
        Method target = Method.getHostReflectiveConstructorRoot(ref, meta);
        plantResolvedMethod(self, target, target.getRefKind(), meta);
        meta.java_lang_invoke_MemberName_clazz.setObject(self, target.getDeclaringKlass().mirror());
    } else {
        throw EspressoError.shouldNotReachHere("invalid argument for MemberName.init: ", ref.getKlass());
    }
}
Also used : REF_getField(com.oracle.truffle.espresso.classfile.Constants.REF_getField) Field(com.oracle.truffle.espresso.impl.Field) REF_putField(com.oracle.truffle.espresso.classfile.Constants.REF_putField) Klass(com.oracle.truffle.espresso.impl.Klass) Method(com.oracle.truffle.espresso.impl.Method)

Aggregations

Field (com.oracle.truffle.espresso.impl.Field)60 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)14 ObjectKlass (com.oracle.truffle.espresso.impl.ObjectKlass)8 Klass (com.oracle.truffle.espresso.impl.Klass)7 Method (com.oracle.truffle.espresso.impl.Method)5 StaticObject (com.oracle.truffle.espresso.runtime.StaticObject)5 JavaType (com.oracle.truffle.espresso.substitutions.JavaType)5 ExportMessage (com.oracle.truffle.api.library.ExportMessage)4 ArrayKlass (com.oracle.truffle.espresso.impl.ArrayKlass)4 Meta (com.oracle.truffle.espresso.meta.Meta)4 ArrayList (java.util.ArrayList)4 Name (com.oracle.truffle.espresso.descriptors.Symbol.Name)3 ParserField (com.oracle.truffle.espresso.impl.ParserField)3 REF_getField (com.oracle.truffle.espresso.classfile.Constants.REF_getField)2 REF_putField (com.oracle.truffle.espresso.classfile.Constants.REF_putField)2 Type (com.oracle.truffle.espresso.descriptors.Symbol.Type)2 NativeType (com.oracle.truffle.espresso.ffi.NativeType)2 ParserKlass (com.oracle.truffle.espresso.impl.ParserKlass)2 ParserMethod (com.oracle.truffle.espresso.impl.ParserMethod)2 RedefineAddedField (com.oracle.truffle.espresso.impl.RedefineAddedField)2