Search in sources :

Example 21 with Field

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

the class Target_sun_misc_Unsafe method putBoolean.

@Substitution(hasReceiver = true)
public static void putBoolean(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, boolean value, @Inject Meta meta) {
    if (isNullOrArray(holder)) {
        UnsafeAccess.getIfAllowed(meta).putBoolean(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;
    f.setBoolean(holder, value);
}
Also used : Field(com.oracle.truffle.espresso.impl.Field)

Example 22 with Field

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

the class Target_sun_misc_Unsafe method putChar.

@Substitution(hasReceiver = true)
public static void putChar(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, char value, @Inject Meta meta) {
    if (isNullOrArray(holder)) {
        UnsafeAccess.getIfAllowed(meta).putChar(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;
    f.setChar(holder, value);
}
Also used : Field(com.oracle.truffle.espresso.impl.Field)

Example 23 with Field

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

the class Target_sun_misc_Unsafe method putShort.

@Substitution(hasReceiver = true)
public static void putShort(@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).putShort(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;
    f.setShort(holder, value);
}
Also used : Field(com.oracle.truffle.espresso.impl.Field)

Example 24 with Field

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

the class Target_sun_misc_Unsafe method putBooleanVolatile.

@TruffleBoundary(allowInlining = true)
@Substitution(hasReceiver = true)
public static void putBooleanVolatile(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, boolean value, @Inject Meta meta) {
    if (isNullOrArray(holder)) {
        UnsafeAccess.getIfAllowed(meta).putBooleanVolatile(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.setBoolean(holder, value, true);
}
Also used : Field(com.oracle.truffle.espresso.impl.Field) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Example 25 with Field

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

the class Target_sun_misc_Unsafe method putInt.

@Substitution(hasReceiver = true)
public static void putInt(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, int value, @Inject Meta meta) {
    if (isNullOrArray(holder)) {
        UnsafeAccess.getIfAllowed(meta).putInt(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;
    f.setInt(holder, value);
}
Also used : Field(com.oracle.truffle.espresso.impl.Field)

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