use of org.graalvm.compiler.graph.NodeWorkList in project graal by oracle.
the class ComputeInliningRelevance method compute.
/**
* Initializes or updates the relevance computation. If there are no loops within the graph,
* most computation happens lazily.
*/
public void compute() {
rootScope = null;
if (!graph.hasLoops()) {
// fast path for the frequent case of no loops
rootScope = new Scope(graph.start(), null);
} else {
if (nodeRelevances == null) {
nodeRelevances = EconomicMap.create(Equivalence.IDENTITY, EXPECTED_MIN_INVOKE_COUNT + InliningUtil.getNodeCount(graph) / EXPECTED_INVOKE_RATIO);
}
NodeWorkList workList = graph.createNodeWorkList();
EconomicMap<LoopBeginNode, Scope> loops = EconomicMap.create(Equivalence.IDENTITY, EXPECTED_LOOP_COUNT);
Scope topScope = new Scope(graph.start(), null);
for (LoopBeginNode loopBegin : graph.getNodes(LoopBeginNode.TYPE)) {
createLoopScope(loopBegin, loops, topScope);
}
topScope.process(workList);
for (Scope scope : loops.getValues()) {
scope.process(workList);
}
}
}
use of org.graalvm.compiler.graph.NodeWorkList in project graal by oracle.
the class InliningUtil method handleMissingAfterExceptionFrameState.
public static FrameState handleMissingAfterExceptionFrameState(FrameState nonReplaceableFrameState, Invoke invoke, EconomicMap<Node, Node> replacements, boolean alwaysDuplicateStateAfter) {
StructuredGraph graph = nonReplaceableFrameState.graph();
NodeWorkList workList = graph.createNodeWorkList();
workList.add(nonReplaceableFrameState);
for (Node node : workList) {
FrameState fs = (FrameState) node;
for (Node usage : fs.usages().snapshot()) {
if (!usage.isAlive()) {
continue;
}
if (usage instanceof FrameState) {
workList.add(usage);
} else {
StateSplit stateSplit = (StateSplit) usage;
FixedNode fixedStateSplit = stateSplit.asNode();
if (fixedStateSplit instanceof AbstractMergeNode) {
AbstractMergeNode merge = (AbstractMergeNode) fixedStateSplit;
while (merge.isAlive()) {
AbstractEndNode end = merge.forwardEnds().first();
DeoptimizeNode deoptimizeNode = addDeoptimizeNode(graph, DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.NotCompiledExceptionHandler);
end.replaceAtPredecessor(deoptimizeNode);
GraphUtil.killCFG(end);
}
} else if (fixedStateSplit instanceof ExceptionObjectNode) {
// The target invoke does not have an exception edge. This means that the
// bytecode parser made the wrong assumption of making an
// InvokeWithExceptionNode for the partial intrinsic exit. We therefore
// replace the InvokeWithExceptionNode with a normal
// InvokeNode -- the deoptimization occurs when the invoke throws.
InvokeWithExceptionNode oldInvoke = (InvokeWithExceptionNode) fixedStateSplit.predecessor();
FrameState oldFrameState = oldInvoke.stateAfter();
InvokeNode newInvoke = oldInvoke.replaceWithInvoke();
newInvoke.setStateAfter(oldFrameState.duplicate());
if (replacements != null) {
replacements.put(oldInvoke, newInvoke);
}
handleAfterBciFrameState(newInvoke.stateAfter(), invoke, alwaysDuplicateStateAfter);
} else {
FixedNode deoptimizeNode = addDeoptimizeNode(graph, DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.NotCompiledExceptionHandler);
if (fixedStateSplit instanceof AbstractBeginNode) {
deoptimizeNode = BeginNode.begin(deoptimizeNode);
}
fixedStateSplit.replaceAtPredecessor(deoptimizeNode);
GraphUtil.killCFG(fixedStateSplit);
}
}
}
}
return nonReplaceableFrameState;
}
Aggregations