Search in sources :

Example 56 with AbstractBeginNode

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

the class ComputeInliningRelevance method getMaxProbabilitySux.

/**
 * Returns the most probable successor. If multiple successors share the maximum probability,
 * one is returned and the others are enqueued in pathBeginNodes.
 */
private static Node getMaxProbabilitySux(ControlSplitNode controlSplit, ArrayList<FixedNode> pathBeginNodes) {
    Node maxSux = null;
    double maxProbability = 0.0;
    int pathBeginCount = pathBeginNodes.size();
    for (Node sux : controlSplit.successors()) {
        double probability = controlSplit.probability((AbstractBeginNode) sux);
        if (probability > maxProbability) {
            maxProbability = probability;
            maxSux = sux;
            truncate(pathBeginNodes, pathBeginCount);
        } else if (probability == maxProbability) {
            pathBeginNodes.add((FixedNode) sux);
        }
    }
    return maxSux;
}
Also used : LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) StartNode(org.graalvm.compiler.nodes.StartNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) LoopEndNode(org.graalvm.compiler.nodes.LoopEndNode) ControlSplitNode(org.graalvm.compiler.nodes.ControlSplitNode) LoopExitNode(org.graalvm.compiler.nodes.LoopExitNode) Node(org.graalvm.compiler.graph.Node) EndNode(org.graalvm.compiler.nodes.EndNode) MergeNode(org.graalvm.compiler.nodes.MergeNode) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) ControlSinkNode(org.graalvm.compiler.nodes.ControlSinkNode) FixedNode(org.graalvm.compiler.nodes.FixedNode)

Example 57 with AbstractBeginNode

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

the class PostOrderNodeIterator method queueSuccessors.

private void queueSuccessors(FixedNode x, Set<Node> successors) {
    nodeStates.put(x, state);
    if (successors != null) {
        for (Node node : successors) {
            if (node != null) {
                nodeStates.put((FixedNode) node.predecessor(), state);
                nodeQueue.addFirst((AbstractBeginNode) node);
            }
        }
    } else {
        for (Node node : x.successors()) {
            if (node != null) {
                nodeQueue.addFirst((AbstractBeginNode) node);
            }
        }
    }
}
Also used : LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) InvokeWithExceptionNode(org.graalvm.compiler.nodes.InvokeWithExceptionNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) LoopEndNode(org.graalvm.compiler.nodes.LoopEndNode) ControlSplitNode(org.graalvm.compiler.nodes.ControlSplitNode) Node(org.graalvm.compiler.graph.Node) EndNode(org.graalvm.compiler.nodes.EndNode) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) ControlSinkNode(org.graalvm.compiler.nodes.ControlSinkNode)

Example 58 with AbstractBeginNode

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

the class PostOrderNodeIterator method nextQueuedNode.

private FixedNode nextQueuedNode() {
    int maxIterations = nodeQueue.size();
    while (maxIterations-- > 0) {
        AbstractBeginNode node = nodeQueue.removeFirst();
        if (node instanceof AbstractMergeNode) {
            AbstractMergeNode merge = (AbstractMergeNode) node;
            state = nodeStates.get(merge.forwardEndAt(0)).clone();
            ArrayList<T> states = new ArrayList<>(merge.forwardEndCount() - 1);
            for (int i = 1; i < merge.forwardEndCount(); i++) {
                T other = nodeStates.get(merge.forwardEndAt(i));
                assert other != null;
                states.add(other);
            }
            boolean ready = state.merge(merge, states);
            if (ready) {
                return merge;
            } else {
                nodeQueue.addLast(merge);
            }
        } else {
            assert node.predecessor() != null;
            state = nodeStates.get((FixedNode) node.predecessor()).clone();
            state.afterSplit(node);
            return node;
        }
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode)

Example 59 with AbstractBeginNode

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

the class SinglePassNodeIterator method queueSuccessors.

/**
 * Two methods enqueue items in {@link #nodeQueue}. Of them, only this method enqueues items
 * with non-null state (the other method being {@link #queueMerge(EndNode)}).
 *
 * <p>
 * A space optimization is made: the state is cloned for all successors except the first. Given
 * that right after invoking this method, {@link #nextQueuedNode()} is invoked, that single
 * non-cloned state instance is in effect "handed over" to its next owner (thus realizing an
 * owner-is-mutator access protocol).
 * </p>
 */
private void queueSuccessors(FixedNode x) {
    T startState = state;
    T curState = startState;
    for (Node succ : x.successors()) {
        if (succ != null) {
            if (curState == null) {
                // the current state isn't cloned for the first successor
                // conceptually, the state is handed over to it
                curState = startState.clone();
            }
            AbstractBeginNode begin = (AbstractBeginNode) succ;
            nodeQueue.addFirst(new PathStart<>(begin, curState));
        }
    }
}
Also used : LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) StartNode(org.graalvm.compiler.nodes.StartNode) InvokeWithExceptionNode(org.graalvm.compiler.nodes.InvokeWithExceptionNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) LoopEndNode(org.graalvm.compiler.nodes.LoopEndNode) ControlSplitNode(org.graalvm.compiler.nodes.ControlSplitNode) Node(org.graalvm.compiler.graph.Node) EndNode(org.graalvm.compiler.nodes.EndNode) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) ControlSinkNode(org.graalvm.compiler.nodes.ControlSinkNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode)

Example 60 with AbstractBeginNode

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

the class StatelessPostOrderNodeIterator method apply.

public void apply() {
    FixedNode current = start;
    do {
        if (current instanceof LoopBeginNode) {
            loopBegin((LoopBeginNode) current);
            current = ((LoopBeginNode) current).next();
            assert current != null;
        } else if (current instanceof LoopEndNode) {
            loopEnd((LoopEndNode) current);
            assert !visitedEnds.isMarked(current);
            visitedEnds.mark(current);
            current = nodeQueue.pollFirst();
        } else if (current instanceof AbstractMergeNode) {
            merge((AbstractMergeNode) current);
            current = ((AbstractMergeNode) current).next();
            assert current != null;
        } else if (current instanceof FixedWithNextNode) {
            node(current);
            current = ((FixedWithNextNode) current).next();
        } else if (current instanceof EndNode) {
            end((EndNode) current);
            queueMerge((EndNode) current);
            current = nodeQueue.pollFirst();
        } else if (current instanceof ControlSinkNode) {
            node(current);
            current = nodeQueue.pollFirst();
        } else if (current instanceof ControlSplitNode) {
            controlSplit((ControlSplitNode) current);
            for (Node node : current.successors()) {
                nodeQueue.addFirst((AbstractBeginNode) node);
            }
            current = nodeQueue.pollFirst();
        } else {
            assert false : current;
        }
    } while (current != null);
    finished();
}
Also used : FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) LoopEndNode(org.graalvm.compiler.nodes.LoopEndNode) EndNode(org.graalvm.compiler.nodes.EndNode) LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) LoopEndNode(org.graalvm.compiler.nodes.LoopEndNode) ControlSplitNode(org.graalvm.compiler.nodes.ControlSplitNode) Node(org.graalvm.compiler.graph.Node) EndNode(org.graalvm.compiler.nodes.EndNode) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) ControlSinkNode(org.graalvm.compiler.nodes.ControlSinkNode) ControlSplitNode(org.graalvm.compiler.nodes.ControlSplitNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) ControlSinkNode(org.graalvm.compiler.nodes.ControlSinkNode) LoopEndNode(org.graalvm.compiler.nodes.LoopEndNode)

Aggregations

AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)63 FixedNode (org.graalvm.compiler.nodes.FixedNode)32 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)31 Node (org.graalvm.compiler.graph.Node)24 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)23 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)23 EndNode (org.graalvm.compiler.nodes.EndNode)22 BeginNode (org.graalvm.compiler.nodes.BeginNode)21 ValueNode (org.graalvm.compiler.nodes.ValueNode)20 AbstractEndNode (org.graalvm.compiler.nodes.AbstractEndNode)16 IfNode (org.graalvm.compiler.nodes.IfNode)16 ControlSplitNode (org.graalvm.compiler.nodes.ControlSplitNode)15 MergeNode (org.graalvm.compiler.nodes.MergeNode)15 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)15 LoopExitNode (org.graalvm.compiler.nodes.LoopExitNode)14 PhiNode (org.graalvm.compiler.nodes.PhiNode)14 LoopEndNode (org.graalvm.compiler.nodes.LoopEndNode)13 LogicNode (org.graalvm.compiler.nodes.LogicNode)12 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)11 DeoptimizeNode (org.graalvm.compiler.nodes.DeoptimizeNode)11