Search in sources :

Example 31 with AnalysisType

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;
}
Also used : AnalysisType(com.oracle.graal.pointsto.meta.AnalysisType) HostedType(com.oracle.svm.hosted.meta.HostedType) SVMHost(com.oracle.svm.hosted.SVMHost) DynamicHub(com.oracle.svm.core.hub.DynamicHub) SubstrateType(com.oracle.svm.graal.meta.SubstrateType)

Example 32 with AnalysisType

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);
        }
    }
}
Also used : AnalysisType(com.oracle.graal.pointsto.meta.AnalysisType) AnalysisObject(com.oracle.graal.pointsto.flow.context.object.AnalysisObject) FieldTypeFlow(com.oracle.graal.pointsto.flow.FieldTypeFlow) TypeState(com.oracle.graal.pointsto.typestate.TypeState)

Example 33 with AnalysisType

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);
    }
}
Also used : AnalysisType(com.oracle.graal.pointsto.meta.AnalysisType) AnalysisObject(com.oracle.graal.pointsto.flow.context.object.AnalysisObject)

Example 34 with AnalysisType

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();
    }
}
Also used : AnalysisType(com.oracle.graal.pointsto.meta.AnalysisType) AnalysisObject(com.oracle.graal.pointsto.flow.context.object.AnalysisObject)

Example 35 with AnalysisType

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;
}
Also used : AnalysisType(com.oracle.graal.pointsto.meta.AnalysisType) Indent(org.graalvm.compiler.debug.Indent) OptionValues(org.graalvm.compiler.options.OptionValues) DebugHandlersFactory(org.graalvm.compiler.debug.DebugHandlersFactory) GraalDebugHandlersFactory(org.graalvm.compiler.printer.GraalDebugHandlersFactory) DebugContext(org.graalvm.compiler.debug.DebugContext) DebugContextRunnable(com.oracle.graal.pointsto.util.CompletionExecutor.DebugContextRunnable) MethodTypeFlow(com.oracle.graal.pointsto.flow.MethodTypeFlow)

Aggregations

AnalysisType (com.oracle.graal.pointsto.meta.AnalysisType)38 AnalysisField (com.oracle.graal.pointsto.meta.AnalysisField)10 TypeState (com.oracle.graal.pointsto.typestate.TypeState)7 AnalysisMethod (com.oracle.graal.pointsto.meta.AnalysisMethod)6 AnalysisObject (com.oracle.graal.pointsto.flow.context.object.AnalysisObject)5 DynamicHub (com.oracle.svm.core.hub.DynamicHub)5 ArrayList (java.util.ArrayList)5 UnsupportedFeatureException (com.oracle.graal.pointsto.constraints.UnsupportedFeatureException)4 SVMHost (com.oracle.svm.hosted.SVMHost)4 JavaKind (jdk.vm.ci.meta.JavaKind)4 Indent (org.graalvm.compiler.debug.Indent)4 MethodTypeFlow (com.oracle.graal.pointsto.flow.MethodTypeFlow)3 BytecodeLocation (com.oracle.graal.pointsto.flow.context.BytecodeLocation)3 AnalysisMetaAccess (com.oracle.graal.pointsto.meta.AnalysisMetaAccess)3 AnalysisUniverse (com.oracle.graal.pointsto.meta.AnalysisUniverse)3 DuringAnalysisAccessImpl (com.oracle.svm.hosted.FeatureImpl.DuringAnalysisAccessImpl)3 HostedType (com.oracle.svm.hosted.meta.HostedType)3 CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)3 BigBang (com.oracle.graal.pointsto.BigBang)2 HostedProviders (com.oracle.graal.pointsto.meta.HostedProviders)2