use of com.oracle.graal.pointsto.meta.AnalysisField in project graal by oracle.
the class GraalObjectReplacer method updateSubstrateDataAfterCompilation.
/**
* Updates all relevant data from universe building. Object replacement is done during analysis.
* Therefore all substrate VM related data has to be updated after building the substrate
* universe.
*/
@SuppressWarnings("try")
public void updateSubstrateDataAfterCompilation(HostedUniverse hUniverse) {
for (Map.Entry<AnalysisType, SubstrateType> entry : types.entrySet()) {
AnalysisType aType = entry.getKey();
SubstrateType sType = entry.getValue();
if (!hUniverse.contains(aType)) {
continue;
}
HostedType hType = hUniverse.lookup(aType);
DynamicHub uniqueImplementation = null;
if (hType.getUniqueConcreteImplementation() != null) {
uniqueImplementation = hType.getUniqueConcreteImplementation().getHub();
}
sType.setTypeCheckData(hType.getInstanceOfFromTypeID(), hType.getInstanceOfNumTypeIDs(), uniqueImplementation);
SubstrateField[] originalFields = sType.getInstanceFields(false);
if (originalFields != null) {
/*
* What we do here is just a reordering of the instance fields array. The fields
* array already contains all the fields, but in the order of the AnalysisType. As
* the UniverseBuilder reorders the fields, we re-construct the fields array in the
* order of the HostedType. The correct order is essential for materialization
* during deoptimization.
*/
SubstrateField[] newFields = createFields(hType);
sType.setInstanceFields(newFields);
}
}
for (Map.Entry<AnalysisField, SubstrateField> entry : fields.entrySet()) {
AnalysisField aField = entry.getKey();
SubstrateField sField = entry.getValue();
HostedField hField = hUniverse.lookup(aField);
sField.setSubstrateData(hField.getLocation(), hField.isAccessed(), hField.isWritten(), hField.getConstantValue());
}
}
use of com.oracle.graal.pointsto.meta.AnalysisField in project graal by oracle.
the class GraalObjectReplacer method updateDataDuringAnalysis.
/**
* Some meta data must be updated during analysis. This is done here.
*/
public boolean updateDataDuringAnalysis(AnalysisMetaAccess metaAccess) {
boolean result = false;
List<AnalysisMethod> aMethods = new ArrayList<>();
aMethods.addAll(methods.keySet());
int index = 0;
while (index < aMethods.size()) {
AnalysisMethod aMethod = aMethods.get(index++);
SubstrateMethod sMethod = methods.get(aMethod);
SubstrateMethod[] implementations = new SubstrateMethod[aMethod.getImplementations().length];
int idx = 0;
for (AnalysisMethod impl : aMethod.getImplementations()) {
SubstrateMethod sImpl = methods.get(impl);
if (sImpl == null) {
sImpl = createMethod(impl);
aMethods.add(impl);
result = true;
}
implementations[idx++] = sImpl;
}
if (sMethod.setImplementations(implementations)) {
result = true;
}
}
for (Map.Entry<AnalysisMethod, SubstrateMethod> entry : methods.entrySet()) {
if (entry.getValue().setAnnotationsEncoding(Inflation.encodeAnnotations(metaAccess, entry.getKey().getAnnotations(), entry.getValue().getAnnotationsEncoding()))) {
result = true;
}
}
for (Map.Entry<AnalysisField, SubstrateField> entry : fields.entrySet()) {
if (entry.getValue().setAnnotationsEncoding(Inflation.encodeAnnotations(metaAccess, entry.getKey().getAnnotations(), entry.getValue().getAnnotationsEncoding()))) {
result = true;
}
}
return result;
}
use of com.oracle.graal.pointsto.meta.AnalysisField in project graal by oracle.
the class GraalObjectReplacer method createField.
public SubstrateField createField(ResolvedJavaField original) {
AnalysisField aField;
if (original instanceof AnalysisField) {
aField = (AnalysisField) original;
} else {
aField = ((HostedField) original).wrapped;
}
SubstrateField sField = fields.get(aField);
if (sField == null) {
assert !(original instanceof HostedField) : "too late to create new field";
int modifiers = aField.getModifiers();
if (ReadableJavaField.injectFinalForRuntimeCompilation(aField.wrapped)) {
modifiers = modifiers | Modifier.FINAL;
}
sField = new SubstrateField(aMetaAccess, aField, modifiers, stringTable);
fields.put(aField, sField);
sField.setLinks(createType(aField.getType()), createType(aField.getDeclaringClass()));
/*
* Annotations are updated in every analysis iteration, but this is a starting point. It
* also ensures that all types used by annotations are created eagerly.
*/
sField.setAnnotationsEncoding(Inflation.encodeAnnotations(aMetaAccess, aField.getAnnotations(), null));
}
return sField;
}
use of com.oracle.graal.pointsto.meta.AnalysisField in project graal by oracle.
the class SVMMethodTypeFlowBuilder method checkUnsafeOffset.
@Override
protected void checkUnsafeOffset(ValueNode offsetNode) {
if (!NativeImageOptions.ThrowUnsafeOffsetErrors.getValue()) {
/* Skip the checks bellow. */
return;
}
if (offsetNode instanceof LoadFieldNode) {
LoadFieldNode offsetLoadNode = (LoadFieldNode) offsetNode;
AnalysisField field = (AnalysisField) offsetLoadNode.field();
if (!(field.wrapped instanceof ComputedValueField)) {
UnsafeOffsetError.report("Field " + field + " is used as an offset in an unsafe operation, but no value recomputation found. \n Wrapped field: " + field.wrapped);
}
} else if (NativeImageOptions.ReportUnsafeOffsetWarnings.getValue()) {
String message = "Offset used in an unsafe operation. Cannot determine if the offset value is recomputed.";
message += "Location: " + offsetNode.getNodeSourcePosition() + "\n";
message += "Node class: " + offsetNode.getClass().getName() + "\n";
if (NativeImageOptions.UnsafeOffsetWarningsAreFatal.getValue()) {
UnsafeOffsetError.report(message);
} else {
System.out.println(message);
}
}
}
use of com.oracle.graal.pointsto.meta.AnalysisField in project graal by oracle.
the class BigBang method addSystemField.
@SuppressWarnings("try")
public AnalysisType addSystemField(Class<?> clazz, String fieldName) {
AnalysisType type = addSystemClass(clazz, false, false);
for (AnalysisField field : type.getInstanceFields(true)) {
if (field.getName().equals(fieldName)) {
try (Indent indent = debug.logAndIndent("add system field %s in class %s", fieldName, clazz.getName())) {
field.registerAsAccessed();
/*
* For system classes any instantiated (sub)type of the declared field type can
* be written to the field flow.
*/
TypeFlow<?> fieldDeclaredTypeFlow = field.getType().getTypeFlow(this, true);
fieldDeclaredTypeFlow.addUse(this, type.getContextInsensitiveAnalysisObject().getInstanceFieldFlow(this, field, true));
}
return field.getType();
}
}
throw shouldNotReachHere("field not found: " + fieldName);
}
Aggregations