Skip to content

Commit

Permalink
[GR-12082] Register reflectively accessed fields as accessed in analy…
Browse files Browse the repository at this point in the history
…sis.

PullRequest: graal/2315
  • Loading branch information
vjovanov committed Oct 26, 2018
2 parents 4d3ea02 + 44dcf51 commit 6eab5e6
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,18 @@ public class FieldOffsetComputer implements CustomFieldValueComputer {
public Object compute(MetaAccessProvider metaAccess, ResolvedJavaField original, ResolvedJavaField annotated, Object receiver) {
VMError.guarantee(metaAccess instanceof HostedMetaAccess, "Field offset computation must be done during compilation.");

Field reflectionField = (Field) receiver;
HostedField hostedField = ((HostedMetaAccess) metaAccess).lookupJavaField(reflectionField);

if (hostedField.wrapped.isUnsafeAccessed()) {
/*
* We have to use `optionalLookupJavaField` as fields are omitted when there is no
* reflective access in an image.
*/
HostedField hostedField = ((HostedMetaAccess) metaAccess).optionalLookupJavaField((Field) receiver);
if (hostedField != null && hostedField.wrapped.isUnsafeAccessed()) {
int location = hostedField.getLocation();
if (location <= 0) {
VMError.shouldNotReachHere("Incorrect field location: " + location + " for " + hostedField.format("%H.%n"));
}
VMError.guarantee(location > 0, "Incorrect field location: " + location + " for " + hostedField.format("%H.%n"));
return location;
} else {
/* A value of -1 signals that the field was not marked as unsafe accessed. */
return -1;
}
// a value of -1 signals that the field was not marked as unsafe accessed
return -1;
}
}

0 comments on commit 6eab5e6

Please sign in to comment.