use of com.oracle.graal.pointsto.meta.AnalysisField in project graal by oracle.
the class Inflation method checkType.
private void checkType(AnalysisType type) {
SVMHost svmHost = (SVMHost) hostVM;
if (type.getJavaKind() == JavaKind.Object) {
if (type.isArray() && (type.isInstantiated() || type.isInTypeCheck())) {
svmHost.dynamicHub(type).getComponentHub().setArrayHub(svmHost.dynamicHub(type));
}
try {
AnalysisType enclosingType = type.getEnclosingType();
if (enclosingType != null) {
svmHost.dynamicHub(type).setEnclosingClass(svmHost.dynamicHub(enclosingType));
}
} catch (UnsupportedFeatureException ex) {
getUnsupportedFeatures().addMessage(type.toJavaName(true), null, ex.getMessage(), null, ex);
}
fillGenericInfo(type);
fillInterfaces(type);
/*
* Support for Java annotations.
*/
svmHost.dynamicHub(type).setAnnotationsEncoding(encodeAnnotations(metaAccess, type.getAnnotations(), svmHost.dynamicHub(type).getAnnotationsEncoding()));
/*
* Support for Java enumerations.
*/
if (type.getSuperclass() != null && type.getSuperclass().equals(metaAccess.lookupJavaType(Enum.class)) && svmHost.dynamicHub(type).getEnumConstantsShared() == null) {
/*
* We want to retrieve the enum constant array that is maintained as a private
* static field in the enumeration class. We do not want a copy because that would
* mean we have the array twice in the native image: as the static field, and in the
* enumConstant field of DynamicHub. The only way to get the original value is via a
* reflective field access, and we even have to guess the field name.
*/
AnalysisField found = null;
for (AnalysisField f : type.getStaticFields()) {
if (f.getName().endsWith("$VALUES")) {
if (found != null) {
throw shouldNotReachHere("Enumeration has more than one static field with enumeration values: " + type);
}
found = f;
}
}
if (found == null) {
throw shouldNotReachHere("Enumeration does not have static field with enumeration values: " + type);
}
AnalysisField field = found;
// field.registerAsRead(null);
Enum<?>[] enumConstants = (Enum[]) SubstrateObjectConstant.asObject(getConstantReflectionProvider().readFieldValue(field, null));
assert enumConstants != null;
svmHost.dynamicHub(type).setEnumConstants(enumConstants);
}
}
}
use of com.oracle.graal.pointsto.meta.AnalysisField in project graal by oracle.
the class JNIAccessFeature method addField.
private static void addField(Field reflField, DuringAnalysisAccessImpl access) {
BigBang bigBang = access.getBigBang();
JNIAccessibleClass jniClass = addClass(reflField.getDeclaringClass(), access);
jniClass.addFieldIfAbsent(reflField.getName(), n -> {
AnalysisField field = access.getMetaAccess().lookupJavaField(reflField);
field.registerAsAccessed();
// Same as BigBang.addSystemField() and BigBang.addSystemStaticField():
// create type flows for any subtype of the field's declared type
TypeFlow<?> declaredTypeFlow = field.getType().getTypeFlow(bigBang, true);
if (field.isStatic()) {
declaredTypeFlow.addUse(bigBang, field.getStaticFieldFlow());
} else {
FieldTypeFlow instanceFieldFlow = field.getDeclaringClass().getContextInsensitiveAnalysisObject().getInstanceFieldFlow(bigBang, field, true);
declaredTypeFlow.addUse(bigBang, instanceFieldFlow);
}
return new JNIAccessibleField(jniClass, reflField.getName(), field.getJavaKind(), field.getModifiers());
});
}
use of com.oracle.graal.pointsto.meta.AnalysisField in project graal by oracle.
the class AnnotationSubstitutionProcessor method processComputedValueFields.
/**
* Eagerly register all target fields of recomputed value fields as unsafe accessed.
*/
public void processComputedValueFields(BigBang bb) {
for (ResolvedJavaField field : fieldSubstitutions.values()) {
if (field instanceof ComputedValue) {
ComputedValue cvField = (ComputedValue) field;
switch(cvField.getRecomputeValueKind()) {
case FieldOffset:
AnalysisField targetField = bb.getMetaAccess().lookupJavaField(cvField.getTargetField());
targetField.registerAsAccessed();
targetField.registerAsUnsafeAccessed();
break;
}
}
}
}
use of com.oracle.graal.pointsto.meta.AnalysisField in project graal by oracle.
the class ComputedValueField method processAnalysis.
public void processAnalysis(AnalysisMetaAccess aMetaAccess) {
switch(kind) {
case FieldOffset:
AnalysisField target = aMetaAccess.lookupJavaField(targetField);
target.registerAsAccessed();
break;
}
}
use of com.oracle.graal.pointsto.meta.AnalysisField in project graal by oracle.
the class UniverseBuilder method build.
/**
* This step is single threaded, i.e., all the maps are modified only by a single thread, so no
* synchronization is necessary. Accesses (the lookup methods) are multi-threaded.
*/
@SuppressWarnings("try")
public void build(DebugContext debug) {
for (AnalysisField aField : aUniverse.getFields()) {
if (aField.wrapped instanceof ComputedValueField) {
((ComputedValueField) aField.wrapped).processAnalysis(aMetaAccess);
}
}
aUniverse.seal();
try (Indent indent = debug.logAndIndent("build universe")) {
for (AnalysisType aType : aUniverse.getTypes()) {
makeType(aType);
}
for (AnalysisField aField : aUniverse.getFields()) {
makeField(aField);
}
for (AnalysisMethod aMethod : aUniverse.getMethods()) {
makeMethod(aMethod);
}
BigBang bb = staticAnalysisResultsBuilder.getBigBang();
ForkJoinTask<?> profilingInformationBuildTask = ForkJoinTask.adapt(this::buildProfilingInformation).fork();
buildSubTypes();
buildOrderedTypes();
buildTypeCheckIDs();
collectDeclaredMethods();
collectMonitorFieldInfo(bb);
collectHashCodeFieldInfo(bb);
layoutInstanceFields();
layoutStaticFields();
collectMethodImplementations();
buildVTables();
buildHubs();
setConstantFieldValues();
hUniverse.orderedMethods = new ArrayList<>(hUniverse.methods.values());
Collections.sort(hUniverse.orderedMethods);
hUniverse.orderedFields = new ArrayList<>(hUniverse.fields.values());
Collections.sort(hUniverse.orderedFields);
profilingInformationBuildTask.join();
}
}
Aggregations