use of org.graalvm.nativeimage.c.function.RelocatedPointer in project graal by oracle.
the class NativeImageHeap method writeConstant.
private void writeConstant(RelocatableBuffer buffer, int index, JavaKind kind, Object value, ObjectInfo info) {
if (value instanceof RelocatedPointer) {
addNonDataRelocation(buffer, index, (RelocatedPointer) value);
return;
}
final JavaConstant con;
if (value instanceof WordBase) {
con = JavaConstant.forIntegerKind(FrameAccess.getWordKind(), ((WordBase) value).rawValue());
} else if (value == null && kind == FrameAccess.getWordKind()) {
con = JavaConstant.forIntegerKind(FrameAccess.getWordKind(), 0);
} else {
assert kind == JavaKind.Object || value != null : "primitive value must not be null";
con = SubstrateObjectConstant.forBoxedValue(kind, value);
}
write(buffer, index, con, info);
}
use of org.graalvm.nativeimage.c.function.RelocatedPointer in project graal by oracle.
the class NativeImageHeap method writeField.
private void writeField(RelocatableBuffer buffer, ObjectInfo fields, HostedField field, JavaConstant receiver, ObjectInfo info) {
int index = fields.getIntIndexInSection(field.getLocation());
JavaConstant value = field.readValue(receiver);
if (value.getJavaKind() == JavaKind.Object && SubstrateObjectConstant.asObject(value) instanceof RelocatedPointer) {
addNonDataRelocation(buffer, index, (RelocatedPointer) SubstrateObjectConstant.asObject(value));
} else {
write(buffer, index, value, info != null ? info : field);
}
}
use of org.graalvm.nativeimage.c.function.RelocatedPointer in project graal by oracle.
the class GraalObjectReplacer method apply.
@Override
public Object apply(Object source) {
if (source == null) {
return null;
}
Object dest = source;
if (source instanceof RelocatedPointer) {
return dest;
}
if (source instanceof MetaAccessProvider) {
dest = sMetaAccess;
} else if (source instanceof GraalRuntime) {
dest = sGraalRuntime;
} else if (source instanceof AnalysisConstantReflectionProvider) {
dest = sConstantReflectionProvider;
} else if (source instanceof AnalysisConstantFieldProvider) {
dest = sConstantFieldProvider;
} else if (source instanceof ForeignCallsProvider) {
dest = GraalSupport.getRuntimeConfig().getProviders().getForeignCalls();
} else if (source instanceof HostedSnippetReflectionProvider) {
dest = GraalSupport.getRuntimeConfig().getSnippetReflection();
} else if (shouldBeReplaced(source)) {
/*
* The hash maps must be synchronized, because replace() may be called from
* BigBang.finish(), which is multi-threaded.
*/
synchronized (this) {
if (source instanceof ResolvedJavaMethod) {
dest = createMethod((ResolvedJavaMethod) source);
} else if (source instanceof ResolvedJavaField) {
dest = createField((ResolvedJavaField) source);
} else if (source instanceof ResolvedJavaType) {
dest = createType((ResolvedJavaType) source);
} else if (source instanceof Signature) {
dest = createSignature((Signature) source);
} else if (source instanceof FieldLocationIdentity) {
dest = fieldLocationIdentities.get(source);
if (dest == null) {
SubstrateField destField = (SubstrateField) apply(((FieldLocationIdentity) source).getField());
dest = new SubstrateFieldLocationIdentity(destField);
fieldLocationIdentities.put((FieldLocationIdentity) source, (FieldLocationIdentity) dest);
}
}
}
}
assert dest != null;
String className = dest.getClass().getName();
assert !className.contains(".hotspot.") || className.contains(".svm.jtt.hotspot.") : "HotSpot object in image " + className;
assert !className.contains(".analysis.meta.") : "Analysis meta object in image " + className;
assert !className.contains(".hosted.meta.") : "Hosted meta object in image " + className;
return dest;
}
Aggregations