use of com.oracle.graal.pointsto.meta.AnalysisField in project graal by oracle.
the class PointsToStats method asString.
private static String asString(TypeFlow<?> flow) {
if (flow instanceof AllInstantiatedTypeFlow) {
return "AllInstantiated(" + formatType(flow.getDeclaredType(), true) + ")";
} else if (flow instanceof AllSynchronizedTypeFlow) {
return "AllSynchronized";
} else if (flow instanceof UnknownTypeFlow) {
return "Unknown";
} else if (flow instanceof FieldSinkTypeFlow) {
FieldSinkTypeFlow sink = (FieldSinkTypeFlow) flow;
return "FieldSink(" + formatField(sink.getSource()) + ")";
} else if (flow instanceof FieldTypeFlow) {
FieldTypeFlow fieldFlow = (FieldTypeFlow) flow;
AnalysisField field = fieldFlow.getSource();
return (field.isStatic() ? "StaticField" : "InstanceField") + "(" + formatField(field) + ")";
} else if (flow instanceof StoreInstanceFieldTypeFlow) {
StoreInstanceFieldTypeFlow store = (StoreInstanceFieldTypeFlow) flow;
return "InstanceStore(" + formatField(store.field()) + ")@" + formatSource(flow);
} else if (flow instanceof StoreStaticFieldTypeFlow) {
StoreStaticFieldTypeFlow store = (StoreStaticFieldTypeFlow) flow;
return "StaticStore(" + formatField(store.field()) + ")@" + formatSource(flow);
} else if (flow instanceof LoadInstanceFieldTypeFlow) {
LoadInstanceFieldTypeFlow load = (LoadInstanceFieldTypeFlow) flow;
return "InstanceLoad(" + formatField(load.field()) + ")@" + formatSource(flow);
} else if (flow instanceof LoadStaticFieldTypeFlow) {
LoadStaticFieldTypeFlow load = (LoadStaticFieldTypeFlow) flow;
return "StaticLoad(" + formatField(load.field()) + ")@" + formatSource(flow);
} else if (flow instanceof StoreIndexedTypeFlow) {
return "IndexedStore @ " + formatSource(flow);
} else if (flow instanceof UnsafeStoreTypeFlow) {
return "UnsafeStore @ " + formatSource(flow);
} else if (flow instanceof UnsafePartitionStoreTypeFlow) {
return "UnsafePartitionStore @ " + formatSource(flow);
} else if (flow instanceof UnsafeWriteSinkTypeFlow) {
UnsafeWriteSinkTypeFlow sink = (UnsafeWriteSinkTypeFlow) flow;
return "UnsafeWriteSink(" + formatField(sink.getSource()) + ")";
} else if (flow instanceof JavaWriteTypeFlow) {
return "JavaWrite @ " + formatSource(flow);
} else if (flow instanceof AtomicWriteTypeFlow) {
return "AtomicWrite @ " + formatSource(flow);
} else if (flow instanceof CompareAndSwapTypeFlow) {
return "CompareAndSwap @ " + formatSource(flow);
} else if (flow instanceof LoadIndexedTypeFlow) {
return "IndexedLoad @ " + formatSource(flow);
} else if (flow instanceof UnsafeLoadTypeFlow) {
return "UnsafeLoad @ " + formatSource(flow);
} else if (flow instanceof UnsafePartitionLoadTypeFlow) {
return "UnsafePartitionLoad @ " + formatSource(flow);
} else if (flow instanceof JavaReadTypeFlow) {
return "JavaRead @ " + formatSource(flow);
} else if (flow instanceof AtomicReadTypeFlow) {
return "AtomicRead @ " + formatSource(flow);
} else if (flow instanceof ArrayElementsTypeFlow) {
ArrayElementsTypeFlow arrayFlow = (ArrayElementsTypeFlow) flow;
return "ArrayElements(" + (arrayFlow.object() != null ? arrayFlow.object().type().toJavaName(false) : "?") + ")";
} else if (flow instanceof NullCheckTypeFlow) {
NullCheckTypeFlow nullCheck = (NullCheckTypeFlow) flow;
return "NullCheck(" + (nullCheck.isFilterNull() ? "not-null" : "only-null") + ")@" + formatSource(flow);
} else if (flow instanceof FilterTypeFlow) {
FilterTypeFlow filter = (FilterTypeFlow) flow;
String properties = filter.isExact() ? "exact" : "not-exact";
properties += ", " + (filter.isAssignable() ? "assignable" : "not-assignable");
properties += ", " + (filter.includeNull() ? "include-null" : "not-include-null");
return "Filter(" + properties + ", " + formatType(filter.getType(), true) + ")@" + formatSource(flow);
} else if (flow instanceof FieldFilterTypeFlow) {
FieldFilterTypeFlow filter = (FieldFilterTypeFlow) flow;
return "FieldFilter(" + formatField(filter.getSource()) + ")";
} else if (flow instanceof FrozenFieldFilterTypeFlow) {
FrozenFieldFilterTypeFlow filter = (FrozenFieldFilterTypeFlow) flow;
return "FrozenFieldFilter(" + formatField(filter.getSource()) + ")";
} else if (flow instanceof InstanceOfTypeFlow) {
InstanceOfTypeFlow instanceOf = (InstanceOfTypeFlow) flow;
return "InstanceOf(" + formatType(instanceOf.getDeclaredType(), true) + ")@" + formatSource(flow);
} else if (flow instanceof NewInstanceTypeFlow) {
return "NewInstance(" + flow.getDeclaredType().toJavaName(false) + ")@" + formatSource(flow);
} else if (flow instanceof DynamicNewInstanceTypeFlow) {
return "DynamicNewInstance @ " + formatSource(flow);
} else if (flow instanceof InvokeTypeFlow) {
InvokeTypeFlow invoke = (InvokeTypeFlow) flow;
return "Invoke(" + formatMethod(invoke.getTargetMethod()) + ")@" + formatSource(flow);
} else if (flow instanceof InitialParamTypeFlow) {
InitialParamTypeFlow param = (InitialParamTypeFlow) flow;
return "InitialParam(" + param.position() + ")@" + formatMethod(param.method());
} else if (flow instanceof FormalParamTypeFlow) {
FormalParamTypeFlow param = (FormalParamTypeFlow) flow;
return "Parameter(" + param.position() + ")@" + formatMethod(param.method());
} else if (flow instanceof FormalReturnTypeFlow) {
return "Return @ " + formatSource(flow);
} else if (flow instanceof ActualReturnTypeFlow) {
ActualReturnTypeFlow ret = (ActualReturnTypeFlow) flow;
InvokeTypeFlow invoke = ret.invokeFlow();
return "ActualReturn(" + formatMethod(invoke.getTargetMethod()) + ")@ " + formatSource(flow);
} else if (flow instanceof MergeTypeFlow) {
return "Merge @ " + formatSource(flow);
} else if (flow instanceof SourceTypeFlow) {
return "Source @ " + formatSource(flow);
} else if (flow instanceof CloneTypeFlow) {
return "Clone @ " + formatSource(flow);
} else if (flow instanceof MonitorEnterTypeFlow) {
MonitorEnterTypeFlow monitor = (MonitorEnterTypeFlow) flow;
return "MonitorEnter @ " + formatMethod(monitor.getMethod());
} else {
return flow.getClass().getSimpleName() + "@" + formatSource(flow);
}
}
use of com.oracle.graal.pointsto.meta.AnalysisField in project graal by oracle.
the class MethodTypeFlowBuilder method markFieldsUsedInComparison.
/**
* If the node corresponding to the compared value is an instance field load then mark that
* field as being used in a comparison.
*
* @param comparedValue the node corresponding to the compared value
*/
private static void markFieldsUsedInComparison(ValueNode comparedValue) {
if (comparedValue instanceof LoadFieldNode) {
LoadFieldNode load = (LoadFieldNode) comparedValue;
AnalysisField field = (AnalysisField) load.field();
if (!field.isStatic()) {
field.markAsUsedInComparison();
}
}
}
use of com.oracle.graal.pointsto.meta.AnalysisField in project graal by oracle.
the class AnalysisObject method getInstanceFieldTypeStore.
protected final FieldTypeStore getInstanceFieldTypeStore(BigBang bb, AnalysisField field) {
assert !Modifier.isStatic(field.getModifiers());
assert bb != null && !bb.getUniverse().sealed();
if (instanceFieldsTypeStore == null) {
AnalysisField[] fields = type.getInstanceFields(true);
INSTANCE_FIELD_TYPE_STORE_UPDATER.compareAndSet(this, null, new AtomicReferenceArray<>(fields.length));
}
FieldTypeStore fieldStore = instanceFieldsTypeStore.get(field.getPosition());
if (fieldStore == null) {
fieldStore = bb.analysisPolicy().createFieldTypeStore(this, field, bb.getUniverse());
boolean result = instanceFieldsTypeStore.compareAndSet(field.getPosition(), null, fieldStore);
if (result) {
fieldStore.init(bb);
// link the initial instance field flow to the field write flow
field.getInitialInstanceFieldFlow().addUse(bb, fieldStore.writeFlow());
// link the field read flow to the context insensitive instance field flow
fieldStore.readFlow().addUse(bb, field.getInstanceFieldFlow());
} else {
fieldStore = instanceFieldsTypeStore.get(field.getPosition());
}
}
return fieldStore;
}
use of com.oracle.graal.pointsto.meta.AnalysisField in project graal by oracle.
the class ContextSensitiveAnalysisObject method mergeInstanceFieldFlow.
/**
* Merge the read and write flows of the fieldTypeStore with those of the context insensitive
* object.
*/
private static void mergeInstanceFieldFlow(BigBang bb, FieldTypeStore fieldTypeStore, AnalysisObject object) {
AnalysisField field = fieldTypeStore.field();
FieldTypeFlow readFieldFlow = fieldTypeStore.readFlow();
FieldTypeFlow writeFieldFlow = fieldTypeStore.writeFlow();
FieldTypeFlow parentWriteFieldFlow = object.getInstanceFieldFlow(bb, field, true);
FieldTypeFlow parentReadFieldFlow = object.getInstanceFieldFlow(bb, field, false);
parentWriteFieldFlow.addUse(bb, writeFieldFlow);
readFieldFlow.addUse(bb, parentReadFieldFlow);
}
use of com.oracle.graal.pointsto.meta.AnalysisField in project graal by oracle.
the class NativeImageGenerator method checkUniverse.
private void checkUniverse() {
/*
* Check that the type states for method parameters and fields are compatible with the
* declared type. This is required for interface types because interfaces are not trusted
* according to the Java language specification, but we trust all interface types (see
* HostedType.isTrustedInterfaceType)
*
* TODO Enable checks for non-interface types too.
*/
for (AnalysisMethod method : aUniverse.getMethods()) {
for (int i = 0; i < method.getTypeFlow().getOriginalMethodFlows().getParameters().length; i++) {
TypeState state = method.getTypeFlow().getParameterTypeState(bigbang, i);
if (state != null) {
AnalysisType declaredType = method.getTypeFlow().getOriginalMethodFlows().getParameter(i).getDeclaredType();
if (declaredType.isInterface()) {
state = TypeState.forSubtraction(bigbang, state, declaredType.getTypeFlow(bigbang, true).getState());
if (!state.isEmpty()) {
bigbang.getUnsupportedFeatures().addMessage(method.format("%H.%n(%p)"), method, "Method parameter " + i + " has declaredType " + declaredType.toJavaName(true) + " and incompatible types in state: " + state);
}
}
}
}
}
for (AnalysisField field : aUniverse.getFields()) {
TypeState state = field.getTypeState();
if (state != null) {
AnalysisType declaredType = field.getType();
if (declaredType.isInterface()) {
state = TypeState.forSubtraction(bigbang, state, declaredType.getTypeFlow(bigbang, true).getState());
if (!state.isEmpty()) {
bigbang.getUnsupportedFeatures().addMessage(field.format("%H.%n"), null, "Field has declaredType " + declaredType.toJavaName(true) + " and incompatible types in state: " + state);
}
}
}
}
if (SubstrateOptions.VerifyNamingConventions.getValue()) {
for (AnalysisMethod method : aUniverse.getMethods()) {
if ((method.isInvoked() || method.isImplementationInvoked()) && method.getAnnotation(Fold.class) == null) {
checkName(method.format("%H.%n(%p)"), method);
}
}
for (AnalysisField field : aUniverse.getFields()) {
if (field.isAccessed()) {
checkName(field.format("%H.%n"), null);
}
}
for (AnalysisType type : aUniverse.getTypes()) {
if ((type.isInstantiated() || type.isInTypeCheck())) {
checkName(type.toJavaName(true), null);
}
}
}
/*
* Entry points use a different calling convention (the native C ABI calling convention), so
* they must not be called from other Java methods.
*/
for (AnalysisMethod method : aUniverse.getMethods()) {
if (method.isEntryPoint()) {
List<AnalysisMethod> invocations = method.getJavaInvocations();
if (invocations.size() > 0) {
String name = method.format("%H.%n(%p)");
StringBuilder msg = new StringBuilder("Native entry point is also called from within Java. Invocations: ");
String sep = "";
for (AnalysisMethod invocation : invocations) {
msg.append(sep).append(invocation.format("%H.%n(%p)"));
sep = ", ";
}
bigbang.getUnsupportedFeatures().addMessage(name, method, msg.toString());
}
}
}
// the unsupported features are reported after checkUniverse is invoked
}
Aggregations