Skip to content

Commit

Permalink
Do not use the shadow heap for fields annotated with @unknown*Field
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Wimmer committed Jan 5, 2024
1 parent 015c26a commit aaedda0
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ public final JavaConstant readFieldValue(ResolvedJavaField field, JavaConstant r
return readValue(metaAccess, (AnalysisField) field, receiver, false);
}

public JavaConstant readValue(UniverseMetaAccess suppliedMetaAccess, AnalysisField field, JavaConstant receiver, boolean returnSimulatedValues) {
public JavaConstant readValue(UniverseMetaAccess suppliedMetaAccess, AnalysisField field, JavaConstant r, boolean returnSimulatedValues) {
JavaConstant receiver = r;
if (!field.isStatic()) {
if (receiver.isNull() || !field.getDeclaringClass().isAssignableFrom(((TypedConstant) receiver).getType(metaAccess))) {
/*
Expand All @@ -200,7 +201,17 @@ public JavaConstant readValue(UniverseMetaAccess suppliedMetaAccess, AnalysisFie
}
if (value == null && receiver instanceof ImageHeapConstant) {
ImageHeapInstance heapObject = (ImageHeapInstance) receiver;
value = heapObject.readFieldValue(field);
if (field.isComputedValue() && heapObject.isBackedByHostedObject()) {
/*
* The shadow heap is not complete yet, fields that are annotated
* with @UnknownObjectField or @UnknownPrimitiveField are not properly updated in
* the shadow heap when their value becomes available. We always must read the
* hosted values for such fields.
*/
receiver = heapObject.getHostedObject();
} else {
value = heapObject.readFieldValue(field);
}
}
if (value == null) {
value = universe.lookup(ReadableJavaField.readFieldValue(suppliedMetaAccess, classInitializationSupport, field.wrapped, universe.toHosted(receiver)));
Expand Down

0 comments on commit aaedda0

Please sign in to comment.