use of com.oracle.graal.pointsto.meta.AnalysisType in project graal by oracle.
the class RuntimeStrengthenStampsPhase method toTarget.
@Override
protected ResolvedJavaType toTarget(ResolvedJavaType type) {
AnalysisType result = ((HostedType) type).getWrapped();
/* Make sure that the SubstrateType is created. */
objectReplacer.createType(result);
return result;
}
use of com.oracle.graal.pointsto.meta.AnalysisType in project graal by oracle.
the class MethodTypeFlowBuilder method processNewArray.
protected void processNewArray(NewArrayNode node, TypeFlowsOfNodes state) {
AnalysisType type = ((AnalysisType) node.elementType()).getArrayClass();
assert type.isInstantiated();
Object key = uniqueKey(node);
BytecodeLocation allocationLabel = bb.analysisPolicy().createAllocationSite(bb, key, method);
TypeFlowBuilder<?> newArrayBuilder = TypeFlowBuilder.create(bb, node, NewInstanceTypeFlow.class, () -> {
NewInstanceTypeFlow newArray = createNewArrayTypeFlow(node, type, allocationLabel);
methodFlow.addAllocation(newArray);
return newArray;
});
state.add(node, newArrayBuilder);
}
use of com.oracle.graal.pointsto.meta.AnalysisType 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.AnalysisType 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.AnalysisType 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);
}
Aggregations