use of com.oracle.truffle.espresso.impl.Field in project graal by oracle.
the class Target_sun_misc_Unsafe method putObject.
// endregion put*(long offset, * value)
// region put*(Object holder, long offset, * value)
@Substitution(hasReceiver = true, nameProvider = SharedUnsafeObjectAccessToReference.class)
public static void putObject(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, @JavaType(Object.class) StaticObject value, @Inject Meta meta) {
if (isNullOrArray(holder)) {
UnsafeAccess.getIfAllowed(meta).putObject(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.setObject(holder, value);
}
use of com.oracle.truffle.espresso.impl.Field in project graal by oracle.
the class Target_sun_misc_Unsafe method putDoubleVolatile.
@TruffleBoundary(allowInlining = true)
@Substitution(hasReceiver = true)
public static void putDoubleVolatile(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, double value, @Inject Meta meta) {
if (isNullOrArray(holder)) {
UnsafeAccess.getIfAllowed(meta).putDoubleVolatile(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().needsTwoSlots();
f.setDouble(holder, value, true);
}
use of com.oracle.truffle.espresso.impl.Field in project graal by oracle.
the class Target_sun_misc_Unsafe method putFloat.
@Substitution(hasReceiver = true)
public static void putFloat(@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).putFloat(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.setFloat(holder, value);
}
use of com.oracle.truffle.espresso.impl.Field in project graal by oracle.
the class Target_sun_misc_Unsafe method putLongVolatile.
@TruffleBoundary(allowInlining = true)
@Substitution(hasReceiver = true)
public static void putLongVolatile(@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).putLongVolatile(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().needsTwoSlots();
f.setLong(holder, value, true);
}
use of com.oracle.truffle.espresso.impl.Field in project graal by oracle.
the class ClassInfo method create.
public static ImmutableClassInfo create(Klass klass, InnerClassRedefiner innerClassRedefiner) {
StringBuilder hierarchy = new StringBuilder();
StringBuilder methods = new StringBuilder();
StringBuilder fields = new StringBuilder();
StringBuilder enclosing = new StringBuilder();
Symbol<Name> name = klass.getName();
Matcher matcher = InnerClassRedefiner.ANON_INNER_CLASS_PATTERN.matcher(name.toString());
if (matcher.matches()) {
// fingerprints are only relevant for inner classes
hierarchy.append(klass.getSuperClass().getTypeAsString()).append(";");
for (Klass itf : klass.getImplementedInterfaces()) {
hierarchy.append(itf.getTypeAsString()).append(";");
}
for (Method method : klass.getDeclaredMethods()) {
methods.append(method.getNameAsString()).append(";");
methods.append(method.getSignatureAsString()).append(";");
}
for (Field field : klass.getDeclaredFields()) {
fields.append(field.getTypeAsString()).append(";");
fields.append(field.getNameAsString()).append(";");
}
ObjectKlass objectKlass = (ObjectKlass) klass;
ConstantPool pool = klass.getConstantPool();
NameAndTypeConstant nmt = pool.nameAndTypeAt(objectKlass.getEnclosingMethod().getMethodIndex());
enclosing.append(nmt.getName(pool)).append(";").append(nmt.getDescriptor(pool));
}
// find all currently loaded direct inner classes and create class infos
ArrayList<ImmutableClassInfo> inners = new ArrayList<>(1);
Set<ObjectKlass> loadedInnerClasses = innerClassRedefiner.findLoadedInnerClasses(klass);
for (Klass inner : loadedInnerClasses) {
matcher = InnerClassRedefiner.ANON_INNER_CLASS_PATTERN.matcher(inner.getNameAsString());
// only add anonymous inner classes
if (matcher.matches()) {
inners.add(innerClassRedefiner.getGlobalClassInfo(inner));
}
}
return new ImmutableClassInfo((ObjectKlass) klass, name, klass.getDefiningClassLoader(), hierarchy.toString(), methods.toString(), fields.toString(), enclosing.toString(), inners, null);
}
Aggregations