Search in sources :

Example 1 with MultiGuardNode

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

the class GraphUtil method markUsagesForKill.

private static void markUsagesForKill(EconomicSet<Node> markedNodes) {
    NodeStack workStack = new NodeStack(markedNodes.size() + 4);
    for (Node marked : markedNodes) {
        workStack.push(marked);
    }
    ArrayList<MultiGuardNode> unmarkedMultiGuards = new ArrayList<>();
    while (!workStack.isEmpty()) {
        Node marked = workStack.pop();
        for (Node usage : marked.usages()) {
            boolean doMark = true;
            if (usage instanceof MultiGuardNode) {
                // Only mark a MultiGuardNode for deletion if all of its guards are marked for
                // deletion. Otherwise, we would kill nodes outside the path to be killed.
                MultiGuardNode multiGuard = (MultiGuardNode) usage;
                for (Node guard : multiGuard.inputs()) {
                    if (!markedNodes.contains(guard)) {
                        doMark = false;
                        unmarkedMultiGuards.add(multiGuard);
                    }
                }
            }
            if (doMark && !markedNodes.contains(usage)) {
                workStack.push(usage);
                markedNodes.add(usage);
            }
        }
        // Detach unmarked multi guards from the marked node
        for (MultiGuardNode multiGuard : unmarkedMultiGuards) {
            multiGuard.replaceFirstInput(marked, null);
        }
        unmarkedMultiGuards.clear();
    }
}
Also used : ValuePhiNode(org.graalvm.compiler.nodes.ValuePhiNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) MonitorIdNode(org.graalvm.compiler.nodes.java.MonitorIdNode) MethodCallTargetNode(org.graalvm.compiler.nodes.java.MethodCallTargetNode) LoadIndexedNode(org.graalvm.compiler.nodes.java.LoadIndexedNode) LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) IfNode(org.graalvm.compiler.nodes.IfNode) VirtualObjectNode(org.graalvm.compiler.nodes.virtual.VirtualObjectNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) PiNode(org.graalvm.compiler.nodes.PiNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) MultiGuardNode(org.graalvm.compiler.nodes.extended.MultiGuardNode) VirtualArrayNode(org.graalvm.compiler.nodes.virtual.VirtualArrayNode) ControlSinkNode(org.graalvm.compiler.nodes.ControlSinkNode) GuardNode(org.graalvm.compiler.nodes.GuardNode) MemoryPhiNode(org.graalvm.compiler.nodes.memory.MemoryPhiNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) ControlSplitNode(org.graalvm.compiler.nodes.ControlSplitNode) MergeNode(org.graalvm.compiler.nodes.MergeNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) LoopEndNode(org.graalvm.compiler.nodes.LoopEndNode) ValueProxyNode(org.graalvm.compiler.nodes.ValueProxyNode) LoopExitNode(org.graalvm.compiler.nodes.LoopExitNode) WithExceptionNode(org.graalvm.compiler.nodes.WithExceptionNode) Node(org.graalvm.compiler.graph.Node) EndNode(org.graalvm.compiler.nodes.EndNode) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) PhiNode(org.graalvm.compiler.nodes.PhiNode) ProxyNode(org.graalvm.compiler.nodes.ProxyNode) MultiGuardNode(org.graalvm.compiler.nodes.extended.MultiGuardNode) ArrayList(java.util.ArrayList) LinkedNodeStack(org.graalvm.compiler.graph.LinkedNodeStack) NodeStack(org.graalvm.compiler.graph.NodeStack)

Aggregations

ArrayList (java.util.ArrayList)1 LinkedNodeStack (org.graalvm.compiler.graph.LinkedNodeStack)1 Node (org.graalvm.compiler.graph.Node)1 NodeStack (org.graalvm.compiler.graph.NodeStack)1 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)1 AbstractEndNode (org.graalvm.compiler.nodes.AbstractEndNode)1 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)1 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)1 ControlSinkNode (org.graalvm.compiler.nodes.ControlSinkNode)1 ControlSplitNode (org.graalvm.compiler.nodes.ControlSplitNode)1 EndNode (org.graalvm.compiler.nodes.EndNode)1 FixedNode (org.graalvm.compiler.nodes.FixedNode)1 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)1 GuardNode (org.graalvm.compiler.nodes.GuardNode)1 IfNode (org.graalvm.compiler.nodes.IfNode)1 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)1 LoopEndNode (org.graalvm.compiler.nodes.LoopEndNode)1 LoopExitNode (org.graalvm.compiler.nodes.LoopExitNode)1 MergeNode (org.graalvm.compiler.nodes.MergeNode)1 PhiNode (org.graalvm.compiler.nodes.PhiNode)1