use of com.oracle.svm.graal.meta.SubstrateField in project graal by oracle.
the class GraalObjectReplacer method registerImmutableObjects.
public void registerImmutableObjects(CompilationAccess access) {
for (SubstrateMethod method : methods.values()) {
access.registerAsImmutable(method);
access.registerAsImmutable(method.getRawImplementations());
access.registerAsImmutable(method.getEncodedLineNumberTable());
}
for (SubstrateField field : fields.values()) {
access.registerAsImmutable(field);
}
for (FieldLocationIdentity fieldLocationIdentity : fieldLocationIdentities.values()) {
access.registerAsImmutable(fieldLocationIdentity);
}
for (SubstrateType type : types.values()) {
access.registerAsImmutable(type);
access.registerAsImmutable(type.getRawInstanceFields());
}
for (SubstrateSignature signature : signatures.values()) {
access.registerAsImmutable(signature);
access.registerAsImmutable(signature.getRawParameterTypes());
}
}
use of com.oracle.svm.graal.meta.SubstrateField 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.svm.graal.meta.SubstrateField 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.svm.graal.meta.SubstrateField 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;
}
use of com.oracle.svm.graal.meta.SubstrateField 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;
}
Aggregations