Search in sources :

Example 1 with AnalysisContext

use of com.oracle.graal.pointsto.flow.context.AnalysisContext in project graal by oracle.

the class MethodTypeFlow method addContext.

/**
 * Add the context, if not already added, and return the method flows clone from that context.
 */
public MethodFlowsGraph addContext(BigBang bb, AnalysisContext calleeContext, InvokeTypeFlow reason) {
    // make sure that the method is parsed before attempting to clone it;
    // the parsing should always happen on the same thread
    this.ensureParsed(bb, reason);
    AnalysisContext newContext = bb.contextPolicy().peel(calleeContext, localCallingContextDepth);
    MethodFlowsGraph methodFlows = clonedMethodFlows.get(newContext);
    if (methodFlows == null) {
        MethodFlowsGraph newFlows = new MethodFlowsGraph(method, newContext);
        newFlows.cloneOriginalFlows(bb);
        MethodFlowsGraph oldFlows = clonedMethodFlows.putIfAbsent(newContext, newFlows);
        methodFlows = oldFlows != null ? oldFlows : newFlows;
        if (oldFlows == null) {
            // link uses after adding the clone to the map since linking uses might trigger
            // updates to the current method in the current context
            methodFlows.linkClones(bb);
        }
    }
    return methodFlows;
}
Also used : AnalysisContext(com.oracle.graal.pointsto.flow.context.AnalysisContext)

Example 2 with AnalysisContext

use of com.oracle.graal.pointsto.flow.context.AnalysisContext in project graal by oracle.

the class CloneTypeFlow method copy.

@Override
public TypeFlow<ValueNode> copy(BigBang bb, MethodFlowsGraph methodFlows) {
    AnalysisContext enclosingContext = methodFlows.context();
    AnalysisContext allocContext = bb.contextPolicy().allocationContext(enclosingContext, PointstoOptions.MaxHeapContextDepth.getValue(bb.getOptions()));
    return new CloneTypeFlow(bb, this, methodFlows, allocContext);
}
Also used : AnalysisContext(com.oracle.graal.pointsto.flow.context.AnalysisContext)

Example 3 with AnalysisContext

use of com.oracle.graal.pointsto.flow.context.AnalysisContext in project graal by oracle.

the class DynamicNewInstanceTypeFlow method copy.

@Override
public TypeFlow<ValueNode> copy(BigBang bb, MethodFlowsGraph methodFlows) {
    AnalysisContext enclosingContext = methodFlows.context();
    AnalysisContext allocContext = bb.contextPolicy().allocationContext(enclosingContext, PointstoOptions.MaxHeapContextDepth.getValue(bb.getOptions()));
    return new DynamicNewInstanceTypeFlow(bb, this, methodFlows, allocContext);
}
Also used : AnalysisContext(com.oracle.graal.pointsto.flow.context.AnalysisContext)

Example 4 with AnalysisContext

use of com.oracle.graal.pointsto.flow.context.AnalysisContext in project graal by oracle.

the class SpecialInvokeTypeFlow method onObservedUpdate.

@Override
public void onObservedUpdate(BigBang bb) {
    assert this.isClone();
    /*
         * Initialize the callee lazily so that if the invoke flow is not reached in this context,
         * i.e. for this clone, there is no callee linked.
         */
    if (callee == null) {
        MethodCallTargetNode target = (MethodCallTargetNode) invoke.callTarget();
        callee = ((AnalysisMethod) target.targetMethod()).getTypeFlow();
        // set the callee in the original invoke too
        ((DirectInvokeTypeFlow) originalInvoke).callee = callee;
    }
    TypeState invokeState = getReceiver().getState();
    for (AnalysisObject receiverObject : invokeState.objects()) {
        AnalysisContext calleeContext = bb.contextPolicy().calleeContext(bb, receiverObject, callerContext, callee);
        MethodFlowsGraph calleeFlows = callee.addContext(bb, calleeContext, this);
        if (calleesFlows.putIfAbsent(calleeFlows, Boolean.TRUE) == null) {
            linkCallee(bb, false, calleeFlows);
        }
        updateReceiver(bb, calleeFlows, receiverObject);
    }
}
Also used : AnalysisObject(com.oracle.graal.pointsto.flow.context.object.AnalysisObject) MethodCallTargetNode(org.graalvm.compiler.nodes.java.MethodCallTargetNode) TypeState(com.oracle.graal.pointsto.typestate.TypeState) AnalysisContext(com.oracle.graal.pointsto.flow.context.AnalysisContext)

Example 5 with AnalysisContext

use of com.oracle.graal.pointsto.flow.context.AnalysisContext in project graal by oracle.

the class NewInstanceTypeFlow method cloneSourceState.

/**
 * Create the type state for a clone.
 */
protected TypeState cloneSourceState(BigBang bb, MethodFlowsGraph methodFlows) {
    assert !this.isClone();
    AnalysisContext allocatorContext = methodFlows.context();
    AnalysisContext allocationContext = bb.contextPolicy().allocationContext(allocatorContext, PointstoOptions.MaxHeapContextDepth.getValue(bb.getOptions()));
    if (bb.analysisPolicy().isContextSensitiveAllocation(bb, type, allocationContext)) {
        /*
             * If the analysis is context sensitive create a new heap object for the new context, or
             * return an existing one. The original NewInstanceTypeFlow is the one that stores the
             * (Context->HeapObject) mapping.
             */
        AnalysisObject newHeapObject = createHeapObject(bb, allocationContext);
        return TypeState.forNonNullObject(bb, newHeapObject);
    } else {
        /*
             * In the heap insensitive case instead of more precise heap abstractions (i.e.
             * allocation site) we use just the type of the object wrapped into the AbstractObject
             * base class. There is no cloning in this case.
             */
        return TypeState.forExactType(bb, type, false);
    }
}
Also used : AnalysisObject(com.oracle.graal.pointsto.flow.context.object.AnalysisObject) AnalysisContext(com.oracle.graal.pointsto.flow.context.AnalysisContext)

Aggregations

AnalysisContext (com.oracle.graal.pointsto.flow.context.AnalysisContext)5 AnalysisObject (com.oracle.graal.pointsto.flow.context.object.AnalysisObject)2 TypeState (com.oracle.graal.pointsto.typestate.TypeState)1 MethodCallTargetNode (org.graalvm.compiler.nodes.java.MethodCallTargetNode)1