Search in sources :

Example 1 with TypeState

use of com.oracle.graal.pointsto.typestate.TypeState in project graal by oracle.

the class SpecialInvokeTypeFlow method updateReceiver.

protected void updateReceiver(BigBang bb, MethodFlowsGraph calleeFlows, AnalysisObject receiverObject) {
    TypeState receiverTypeState = TypeState.forExactType(bb, receiverObject, false);
    updateReceiver(bb, calleeFlows, receiverTypeState);
}
Also used : TypeState(com.oracle.graal.pointsto.typestate.TypeState)

Example 2 with TypeState

use of com.oracle.graal.pointsto.typestate.TypeState in project graal by oracle.

the class MethodTypeFlow method foldTypeFlow.

/**
 * Get a type state containing the union of states over all the clones of the original flow.
 *
 * @param originalTypeFlow the original type flow
 * @return the resulting type state object
 */
public TypeState foldTypeFlow(BigBang bb, TypeFlow<?> originalTypeFlow) {
    if (originalTypeFlow == null) {
        return null;
    }
    TypeState result = TypeState.forEmpty();
    for (MethodFlowsGraph methodFlows : clonedMethodFlows.values()) {
        TypeFlow<?> clonedTypeFlow = methodFlows.lookupCloneOf(bb, originalTypeFlow);
        TypeState cloneState = clonedTypeFlow.getState();
        /*
             * Make a shallow copy of the clone state, i.e., only the types and not the concrete
             * objects, so that the union operation doesn't merge the concrete objects with abstract
             * objects.
             */
        TypeState cloneStateCopy = TypeState.forContextInsensitiveTypeState(bb, cloneState);
        result = TypeState.forUnion(bb, result, cloneStateCopy);
    }
    return result;
}
Also used : TypeState(com.oracle.graal.pointsto.typestate.TypeState)

Example 3 with TypeState

use of com.oracle.graal.pointsto.typestate.TypeState in project graal by oracle.

the class CloneTypeFlow method onObservedUpdate.

@Override
public void onObservedUpdate(BigBang bb) {
    /* Only a clone should be updated */
    assert this.isClone() && context != null;
    /* The input state has changed, clone its objects. */
    TypeState inputState = input.getState();
    TypeState currentState = getState();
    TypeState resultState;
    if (inputState.isEmpty() || inputState.isNull()) {
        /* Nothing to be cloned if the input state is not a concrete type state. */
        resultState = inputState.forNonNull(bb);
    } else {
        resultState = inputState.typesStream().filter(t -> !currentState.containsType(t)).map(type -> TypeState.forClone(bb, source, cloneSite, type, allocationContext)).reduce(TypeState.forEmpty(), (s1, s2) -> TypeState.forUnion(bb, s1, s2));
        assert !resultState.canBeNull();
    }
    /* Update the clone flow state. */
    addState(bb, resultState);
}
Also used : ValueNode(org.graalvm.compiler.nodes.ValueNode) BytecodeLocation(com.oracle.graal.pointsto.flow.context.BytecodeLocation) PointstoOptions(com.oracle.graal.pointsto.api.PointstoOptions) BigBang(com.oracle.graal.pointsto.BigBang) TypeState(com.oracle.graal.pointsto.typestate.TypeState) AnalysisContext(com.oracle.graal.pointsto.flow.context.AnalysisContext) AnalysisObject(com.oracle.graal.pointsto.flow.context.object.AnalysisObject) AnalysisField(com.oracle.graal.pointsto.meta.AnalysisField) AnalysisType(com.oracle.graal.pointsto.meta.AnalysisType) TypeState(com.oracle.graal.pointsto.typestate.TypeState)

Example 4 with TypeState

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

Example 5 with TypeState

use of com.oracle.graal.pointsto.typestate.TypeState in project graal by oracle.

the class DynamicNewInstanceTypeFlow method onObservedUpdate.

@Override
public void onObservedUpdate(BigBang bb) {
    /* Only a clone should be updated */
    assert this.isClone();
    /* The state of the new type provider has changed. */
    TypeState newTypeState = newTypeFlow.getState();
    TypeState currentTypeState = getState();
    /* Generate a heap object for every new incoming type. */
    TypeState resultState = newTypeState.typesStream().filter(t -> !currentTypeState.containsType(t)).map(type -> TypeState.forAllocation(bb, source, allocationSite, type, allocationContext)).reduce(TypeState.forEmpty(), (s1, s2) -> TypeState.forUnion(bb, s1, s2));
    assert !resultState.canBeNull();
    addState(bb, resultState);
}
Also used : ValueNode(org.graalvm.compiler.nodes.ValueNode) BytecodeLocation(com.oracle.graal.pointsto.flow.context.BytecodeLocation) PointstoOptions(com.oracle.graal.pointsto.api.PointstoOptions) BigBang(com.oracle.graal.pointsto.BigBang) TypeState(com.oracle.graal.pointsto.typestate.TypeState) AnalysisContext(com.oracle.graal.pointsto.flow.context.AnalysisContext) TypeState(com.oracle.graal.pointsto.typestate.TypeState)

Aggregations

TypeState (com.oracle.graal.pointsto.typestate.TypeState)22 AnalysisType (com.oracle.graal.pointsto.meta.AnalysisType)8 AnalysisObject (com.oracle.graal.pointsto.flow.context.object.AnalysisObject)6 AnalysisMethod (com.oracle.graal.pointsto.meta.AnalysisMethod)4 AnalysisContext (com.oracle.graal.pointsto.flow.context.AnalysisContext)3 AnalysisField (com.oracle.graal.pointsto.meta.AnalysisField)3 ArrayList (java.util.ArrayList)3 BigBang (com.oracle.graal.pointsto.BigBang)2 PointstoOptions (com.oracle.graal.pointsto.api.PointstoOptions)2 BytecodeLocation (com.oracle.graal.pointsto.flow.context.BytecodeLocation)2 BitSet (java.util.BitSet)2 ValueNode (org.graalvm.compiler.nodes.ValueNode)2 CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)2 AnalysisPolicy (com.oracle.graal.pointsto.AnalysisPolicy)1 UnsupportedFeatureException (com.oracle.graal.pointsto.constraints.UnsupportedFeatureException)1 AllInstantiatedTypeFlow (com.oracle.graal.pointsto.flow.AllInstantiatedTypeFlow)1 ArrayElementsTypeFlow (com.oracle.graal.pointsto.flow.ArrayElementsTypeFlow)1 FieldTypeFlow (com.oracle.graal.pointsto.flow.FieldTypeFlow)1 InstanceOfTypeFlow (com.oracle.graal.pointsto.flow.InstanceOfTypeFlow)1 InvokeTypeFlow (com.oracle.graal.pointsto.flow.InvokeTypeFlow)1