use of com.oracle.graal.pointsto.meta.AnalysisField in project graal by oracle.
the class MethodTypeFlowBuilder method registerUsedElements.
public static void registerUsedElements(BigBang bb, StructuredGraph graph, MethodTypeFlow methodFlow) {
for (Node n : graph.getNodes()) {
if (n instanceof InstanceOfNode) {
InstanceOfNode node = (InstanceOfNode) n;
AnalysisType type = (AnalysisType) node.type().getType();
type.registerAsInTypeCheck();
} else if (n instanceof NewInstanceNode) {
NewInstanceNode node = (NewInstanceNode) n;
AnalysisType type = (AnalysisType) node.instanceClass();
type.registerAsAllocated(node);
} else if (n instanceof NewArrayNode) {
NewArrayNode node = (NewArrayNode) n;
AnalysisType type = ((AnalysisType) node.elementType()).getArrayClass();
type.registerAsAllocated(node);
} else if (n instanceof NewMultiArrayNode) {
NewMultiArrayNode node = (NewMultiArrayNode) n;
AnalysisType type = ((AnalysisType) node.type());
for (int i = 0; i < node.dimensionCount(); i++) {
type.registerAsAllocated(node);
type = type.getComponentType();
}
} else if (n instanceof BoxNode) {
BoxNode node = (BoxNode) n;
AnalysisType type = (AnalysisType) StampTool.typeOrNull(node);
type.registerAsAllocated(node);
} else if (n instanceof LoadFieldNode) {
LoadFieldNode node = (LoadFieldNode) n;
AnalysisField field = (AnalysisField) node.field();
field.registerAsRead(methodFlow);
} else if (n instanceof StoreFieldNode) {
StoreFieldNode node = (StoreFieldNode) n;
AnalysisField field = (AnalysisField) node.field();
field.registerAsWritten(methodFlow);
} else if (n instanceof StoreIndexedNode) {
StoreIndexedNode node = (StoreIndexedNode) n;
AnalysisType arrayType = (AnalysisType) StampTool.typeOrNull(node.array());
if (arrayType != null) {
assert arrayType.isArray();
arrayType.getComponentType().registerAsInTypeCheck();
}
} else if (n instanceof BytecodeExceptionNode) {
BytecodeExceptionNode node = (BytecodeExceptionNode) n;
AnalysisType type = bb.getMetaAccess().lookupJavaType(node.getExceptionClass());
type.registerAsInHeap();
} else if (n instanceof ConstantNode) {
ConstantNode cn = (ConstantNode) n;
if (cn.hasUsages() && cn.asJavaConstant().getJavaKind() == JavaKind.Object && cn.asJavaConstant().isNonNull()) {
assert StampTool.isExactType(cn);
AnalysisType type = (AnalysisType) StampTool.typeOrNull(cn);
type.registerAsInHeap();
}
} else if (n instanceof ForeignCallNode) {
ForeignCallNode node = (ForeignCallNode) n;
registerForeignCall(bb, node.getDescriptor());
} else if (n instanceof UnaryMathIntrinsicNode) {
UnaryMathIntrinsicNode node = (UnaryMathIntrinsicNode) n;
registerForeignCall(bb, node.getOperation().foreignCallDescriptor);
} else if (n instanceof BinaryMathIntrinsicNode) {
BinaryMathIntrinsicNode node = (BinaryMathIntrinsicNode) n;
registerForeignCall(bb, node.getOperation().foreignCallDescriptor);
}
}
}
use of com.oracle.graal.pointsto.meta.AnalysisField in project graal by oracle.
the class BigBang method addSystemClass.
@SuppressWarnings({ "try" })
private AnalysisType addSystemClass(AnalysisType type, boolean addFields, boolean addArrayClass) {
try (Indent indent = debug.logAndIndent("add system class %s", type.getName())) {
for (AnalysisField field : type.getInstanceFields(false)) {
if (addFields) {
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));
}
if (type.getSuperclass() != null) {
addSystemClass(type.getSuperclass(), addFields, addArrayClass);
}
if (addArrayClass) {
addSystemClass(type.getArrayClass(), false, false);
}
}
return type;
}
use of com.oracle.graal.pointsto.meta.AnalysisField in project graal by oracle.
the class ObjectScanner method doScan.
/**
* Processes one constant entry. If the constant has an instance class then it scans its fields,
* using the constant as a receiver. If the constant has an array class then it scans the array
* element constants.
*/
private void doScan(WorklistEntry entry) {
Object valueObj = bb.getSnippetReflectionProvider().asObject(Object.class, entry.constant);
assert checkCorrectClassloaders(entry, valueObj) : "Invalid classloader " + valueObj.getClass().getClassLoader() + " for " + valueObj + ".\nThis error happens when objects from previous image compilations are reached in the current compilation. " + "To prevent this issue reset all static state from the bootclasspath and application classpath that points to the application objects. " + "For reference, see com.oracle.svm.truffle.TruffleFeature.cleanup().";
AnalysisType type = bb.getMetaAccess().lookupJavaType(valueObj.getClass());
if (type.isInstanceClass()) {
/* Scan constant's instance fields. */
for (AnalysisField field : type.getInstanceFields(true)) {
if (field.getJavaKind() == JavaKind.Object && field.isAccessed()) {
assert !Modifier.isStatic(field.getModifiers());
scanField(field, entry.constant, entry);
}
}
} else if (type.isArray() && bb.getProviders().getWordTypes().asKind(type.getComponentType()) == JavaKind.Object) {
/* Scan the array elements. */
scanArray(entry.constant, entry);
}
}
use of com.oracle.graal.pointsto.meta.AnalysisField in project graal by oracle.
the class CloneTypeFlow method update.
@Override
public void update(BigBang bb) {
assert this.isClone();
TypeState inputState = input.getState();
TypeState cloneState = this.getState();
for (AnalysisType type : inputState.types()) {
if (type.isArray()) {
/* The object array clones must also get the elements flows of the originals. */
for (AnalysisObject originalObject : inputState.objects(type)) {
if (originalObject.isPrimitiveArray() || originalObject.isEmptyObjectArrayConstant(bb)) {
/* Nothing to read from a primitive array or an empty array constant. */
continue;
}
ArrayElementsTypeFlow originalObjectElementsFlow = originalObject.getArrayElementsFlow(bb, false);
for (AnalysisObject cloneObject : cloneState.objects(type)) {
if (cloneObject.isPrimitiveArray() || cloneObject.isEmptyObjectArrayConstant(bb)) {
/* Cannot write to a primitive array or an empty array constant. */
continue;
}
ArrayElementsTypeFlow cloneObjectElementsFlow = cloneObject.getArrayElementsFlow(bb, true);
originalObjectElementsFlow.addUse(bb, cloneObjectElementsFlow);
}
}
} else {
/* The object clones must get field flows of the originals. */
for (AnalysisObject originalObject : inputState.objects(type)) {
/* Link all the field flows of the original to the clone. */
for (AnalysisField field : type.getInstanceFields(true)) {
FieldTypeFlow originalObjectFieldFlow = originalObject.getInstanceFieldFlow(bb, field, false);
for (AnalysisObject cloneObject : cloneState.objects(type)) {
FieldTypeFlow cloneObjectFieldFlow = cloneObject.getInstanceFieldFlow(bb, field, true);
originalObjectFieldFlow.addUse(bb, cloneObjectFieldFlow);
}
}
}
}
}
/* Element flows of array clones (if any) have been updated, update the uses. */
super.update(bb);
}
use of com.oracle.graal.pointsto.meta.AnalysisField in project graal by oracle.
the class PointsToStats method formatSource.
private static String formatSource(TypeFlow<?> flow) {
Object source = flow.getSource();
if (source instanceof ValueNode) {
ValueNode node = (ValueNode) source;
NodeSourcePosition nodeSource = node.getNodeSourcePosition();
if (nodeSource != null) {
return formatMethod(nodeSource.getMethod()) + ":" + nodeSource.getBCI();
} else if (flow.graphRef() != null) {
return formatMethod(flow.graphRef().getMethod());
} else {
return "<unknown-source>";
}
} else if (source instanceof AnalysisType) {
return formatType((AnalysisType) source);
} else if (source instanceof AnalysisField) {
return formatField((AnalysisField) source);
} else if (source == null) {
return "<no-source>";
} else {
return source.getClass().getSimpleName();
}
}
Aggregations