Search in sources :

Example 31 with DeoptimizeNode

use of org.graalvm.compiler.nodes.DeoptimizeNode in project graal by oracle.

the class ConvertDeoptimizeToGuardPhase method moveAsDeoptAfter.

private static void moveAsDeoptAfter(FixedWithNextNode node, StaticDeoptimizingNode deopt) {
    FixedNode next = node.next();
    if (next != deopt.asNode()) {
        node.setNext(node.graph().add(new DeoptimizeNode(deopt.getAction(), deopt.getReason(), deopt.getSpeculation())));
        GraphUtil.killCFG(next);
    }
}
Also used : DeoptimizeNode(org.graalvm.compiler.nodes.DeoptimizeNode) FixedNode(org.graalvm.compiler.nodes.FixedNode)

Example 32 with DeoptimizeNode

use of org.graalvm.compiler.nodes.DeoptimizeNode 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;
}
Also used : AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) BeginNode(org.graalvm.compiler.nodes.BeginNode) MonitorIdNode(org.graalvm.compiler.nodes.java.MonitorIdNode) MethodCallTargetNode(org.graalvm.compiler.nodes.java.MethodCallTargetNode) ReturnNode(org.graalvm.compiler.nodes.ReturnNode) CallTargetNode(org.graalvm.compiler.nodes.CallTargetNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) FixedGuardNode(org.graalvm.compiler.nodes.FixedGuardNode) PiNode(org.graalvm.compiler.nodes.PiNode) LogicNode(org.graalvm.compiler.nodes.LogicNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) MonitorExitNode(org.graalvm.compiler.nodes.java.MonitorExitNode) IsNullNode(org.graalvm.compiler.nodes.calc.IsNullNode) GuardingNode(org.graalvm.compiler.nodes.extended.GuardingNode) KillingBeginNode(org.graalvm.compiler.nodes.KillingBeginNode) StartNode(org.graalvm.compiler.nodes.StartNode) InvokeWithExceptionNode(org.graalvm.compiler.nodes.InvokeWithExceptionNode) ExceptionObjectNode(org.graalvm.compiler.nodes.java.ExceptionObjectNode) InvokeNode(org.graalvm.compiler.nodes.InvokeNode) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) MergeNode(org.graalvm.compiler.nodes.MergeNode) DeoptimizeNode(org.graalvm.compiler.nodes.DeoptimizeNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) UnwindNode(org.graalvm.compiler.nodes.UnwindNode) Node(org.graalvm.compiler.graph.Node) EndNode(org.graalvm.compiler.nodes.EndNode) ForeignCallNode(org.graalvm.compiler.nodes.extended.ForeignCallNode) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) PhiNode(org.graalvm.compiler.nodes.PhiNode) ExceptionObjectNode(org.graalvm.compiler.nodes.java.ExceptionObjectNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) FrameState(org.graalvm.compiler.nodes.FrameState) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) NodeWorkList(org.graalvm.compiler.graph.NodeWorkList) InvokeWithExceptionNode(org.graalvm.compiler.nodes.InvokeWithExceptionNode) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) InvokeNode(org.graalvm.compiler.nodes.InvokeNode) DeoptimizeNode(org.graalvm.compiler.nodes.DeoptimizeNode) StateSplit(org.graalvm.compiler.nodes.StateSplit)

Aggregations

DeoptimizeNode (org.graalvm.compiler.nodes.DeoptimizeNode)32 FixedNode (org.graalvm.compiler.nodes.FixedNode)11 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)10 ValueNode (org.graalvm.compiler.nodes.ValueNode)10 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)8 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)8 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)7 BeginNode (org.graalvm.compiler.nodes.BeginNode)7 JavaConstant (jdk.vm.ci.meta.JavaConstant)6 Node (org.graalvm.compiler.graph.Node)6 GraphBuilderContext (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext)6 InvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin)6 FrameState (org.graalvm.compiler.nodes.FrameState)5 InvokeWithExceptionNode (org.graalvm.compiler.nodes.InvokeWithExceptionNode)5 KillingBeginNode (org.graalvm.compiler.nodes.KillingBeginNode)5 MergeNode (org.graalvm.compiler.nodes.MergeNode)5 Receiver (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver)5 JavaKind (jdk.vm.ci.meta.JavaKind)4 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)4 CallTargetNode (org.graalvm.compiler.nodes.CallTargetNode)4