use of com.oracle.graal.pointsto.meta.AnalysisType in project graal by oracle.
the class GraalObjectReplacer method createType.
public SubstrateType createType(JavaType original) {
if (original == null) {
return null;
}
AnalysisType aType;
if (original instanceof AnalysisType) {
aType = (AnalysisType) original;
} else {
aType = ((HostedType) original).getWrapped();
}
SubstrateType sType = types.get(aType);
if (sType == null) {
assert !(original instanceof HostedType) : "too late to create new type";
DynamicHub hub = ((SVMHost) aUniverse.hostVM()).dynamicHub(aType);
sType = new SubstrateType(aType.getJavaKind(), hub);
types.put(aType, sType);
hub.setMetaType(sType);
sType.setInstanceFields(createFields(aType));
createType(aType.getSuperclass());
createType(aType.getComponentType());
for (AnalysisType aInterface : aType.getInterfaces()) {
createType(aInterface);
}
}
return sType;
}
use of com.oracle.graal.pointsto.meta.AnalysisType in project graal by oracle.
the class AnalysisObjectScanner method forNonNullFieldValue.
@Override
public void forNonNullFieldValue(JavaConstant receiver, AnalysisField field, JavaConstant fieldValue) {
AnalysisType fieldType = bb.getMetaAccess().lookupJavaType(bb.getSnippetReflectionProvider().asObject(Object.class, fieldValue).getClass());
assert fieldType.isInstantiated();
if (bb.getAllInstantiatedTypeFlow().getState().containsType(fieldType)) {
/* Add the constant value object to the field's type flow. */
FieldTypeFlow fieldTypeFlow = getFieldTypeFlow(field, receiver);
AnalysisObject constantObject = bb.analysisPolicy().createConstantObject(bb, fieldValue, fieldType);
if (!fieldTypeFlow.getState().isUnknown() && !fieldTypeFlow.getState().containsObject(constantObject)) {
/* Add the new constant to the field's flow state. */
TypeState constantTypeState = TypeState.forNonNullObject(bb, constantObject);
fieldTypeFlow.addState(bb, constantTypeState);
}
}
}
use of com.oracle.graal.pointsto.meta.AnalysisType in project graal by oracle.
the class AnalysisObjectScanner method getFieldTypeFlow.
/**
* Get the field type flow give a receiver.
*/
private FieldTypeFlow getFieldTypeFlow(AnalysisField field, JavaConstant receiver) {
/* The field type flow is used to track the constant field value. */
if (field.isStatic()) {
/* If the field is static it comes from the originalRoots. */
return field.getStaticFieldFlow();
} else {
/*
* The field comes from a constant scan, thus it's type flow is mapped to the unique
* constant object.
*/
AnalysisType receiverType = bb.getMetaAccess().lookupJavaType(bb.getSnippetReflectionProvider().asObject(Object.class, receiver).getClass());
AnalysisObject constantReceiverObj = bb.analysisPolicy().createConstantObject(bb, receiver, receiverType);
return constantReceiverObj.getInstanceFieldFlow(bb, field, true);
}
}
use of com.oracle.graal.pointsto.meta.AnalysisType in project graal by oracle.
the class AnalysisObjectScanner method forScannedConstant.
@Override
protected void forScannedConstant(JavaConstant value, Object reason) {
Object valueObj = bb.getSnippetReflectionProvider().asObject(Object.class, value);
AnalysisType type = bb.getMetaAccess().lookupJavaType(valueObj.getClass());
if (!type.isInstantiated()) {
type.registerAsInHeap();
}
}
use of com.oracle.graal.pointsto.meta.AnalysisType in project graal by oracle.
the class BigBang method addRootMethod.
@SuppressWarnings("try")
public AnalysisMethod addRootMethod(AnalysisMethod aMethod) {
if (aMethod.isRootMethod()) {
return aMethod;
}
aMethod.registerAsRootMethod();
final MethodTypeFlow methodFlow = aMethod.getTypeFlow();
try (Indent indent = debug.logAndIndent("add root method %s", aMethod.getName())) {
boolean isStatic = Modifier.isStatic(aMethod.getModifiers());
int paramCount = aMethod.getSignature().getParameterCount(!isStatic);
int offset = 0;
if (!isStatic) {
methodFlow.setInitialReceiverFlow(this, aMethod.getDeclaringClass());
offset = 1;
}
for (int i = offset; i < paramCount; i++) {
AnalysisType declaredParamType = (AnalysisType) aMethod.getSignature().getParameterType(i - offset, aMethod.getDeclaringClass());
if (declaredParamType.getJavaKind() == JavaKind.Object) {
methodFlow.setInitialParameterFlow(this, declaredParamType, i);
}
}
}
postTask(new DebugContextRunnable() {
@Override
public void run(DebugContext ignore) {
methodFlow.addContext(BigBang.this, BigBang.this.contextPolicy().emptyContext(), null);
}
@Override
public DebugContext getDebug(OptionValues ignored, List<DebugHandlersFactory> factories) {
return DebugContext.DISABLED;
}
});
return aMethod;
}
Aggregations