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);
}
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);
}
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);
}
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);
}
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());
}
}
Aggregations