Search in sources :

Example 51 with AbstractMergeNode

use of org.graalvm.compiler.nodes.AbstractMergeNode 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 52 with AbstractMergeNode

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

the class ScopedPostOrderNodeIterator method processScope.

public void processScope() {
    FixedNode current;
    queue(currentScopeStart);
    while ((current = nextQueuedNode()) != null) {
        assert current.isAlive();
        if (current instanceof Invoke) {
            invoke((Invoke) current);
            queueSuccessors(current);
        } else if (current instanceof LoopBeginNode) {
            queueLoopBeginSuccessors((LoopBeginNode) current);
        } else if (current instanceof LoopExitNode) {
            queueLoopExitSuccessors((LoopExitNode) current);
        } else if (current instanceof LoopEndNode) {
        // nothing todo
        } else if (current instanceof AbstractMergeNode) {
            queueSuccessors(current);
        } else if (current instanceof FixedWithNextNode) {
            queueSuccessors(current);
        } else if (current instanceof EndNode) {
            queueMerge((EndNode) current);
        } else if (current instanceof ControlSinkNode) {
        // nothing todo
        } else if (current instanceof ControlSplitNode) {
            queueSuccessors(current);
        } else {
            assert false : current;
        }
    }
}
Also used : FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) LoopExitNode(org.graalvm.compiler.nodes.LoopExitNode) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) LoopEndNode(org.graalvm.compiler.nodes.LoopEndNode) EndNode(org.graalvm.compiler.nodes.EndNode) ControlSplitNode(org.graalvm.compiler.nodes.ControlSplitNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) ControlSinkNode(org.graalvm.compiler.nodes.ControlSinkNode) Invoke(org.graalvm.compiler.nodes.Invoke) LoopEndNode(org.graalvm.compiler.nodes.LoopEndNode)

Example 53 with AbstractMergeNode

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

the class SinglePassNodeIterator method apply.

/**
 * Performs a single-pass iteration.
 *
 * <p>
 * After this method has been invoked, the {@link SinglePassNodeIterator} instance can't be used
 * again. This saves clearing up fields in {@link #finished()}, the assumption being that this
 * instance will be garbage-collected soon afterwards.
 * </p>
 */
public void apply() {
    FixedNode current = start;
    do {
        if (current instanceof InvokeWithExceptionNode) {
            invoke((Invoke) current);
            queueSuccessors(current);
            current = nextQueuedNode();
        } else if (current instanceof LoopBeginNode) {
            state.loopBegin((LoopBeginNode) current);
            keepForLater(current, state);
            state = state.clone();
            loopBegin((LoopBeginNode) current);
            current = ((LoopBeginNode) current).next();
            assert current != null;
        } else if (current instanceof LoopEndNode) {
            loopEnd((LoopEndNode) current);
            finishLoopEnds((LoopEndNode) current);
            current = nextQueuedNode();
        } else if (current instanceof AbstractMergeNode) {
            merge((AbstractMergeNode) current);
            current = ((AbstractMergeNode) current).next();
            assert current != null;
        } else if (current instanceof FixedWithNextNode) {
            FixedNode next = ((FixedWithNextNode) current).next();
            assert next != null : current;
            node(current);
            current = next;
        } else if (current instanceof EndNode) {
            end((EndNode) current);
            queueMerge((EndNode) current);
            current = nextQueuedNode();
        } else if (current instanceof ControlSinkNode) {
            node(current);
            current = nextQueuedNode();
        } else if (current instanceof ControlSplitNode) {
            controlSplit((ControlSplitNode) current);
            queueSuccessors(current);
            current = nextQueuedNode();
        } 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) InvokeWithExceptionNode(org.graalvm.compiler.nodes.InvokeWithExceptionNode) 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)

Example 54 with AbstractMergeNode

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

the class SinglePassNodeIterator method queueMerge.

/**
 * Once all end-nodes for a given merge-node have been visited, that merge-node is added to the
 * {@link #nodeQueue}
 *
 * <p>
 * {@link #nextQueuedNode()} is in charge of pruning entries (held by {@link #nodeStates}) for
 * the forward-ends inserted by this method.
 * </p>
 */
private void queueMerge(EndNode end) {
    assert !visitedEnds.isMarked(end);
    visitedEnds.mark(end);
    keepForLater(end, state);
    AbstractMergeNode merge = end.merge();
    boolean endsVisited = true;
    for (int i = 0; i < merge.forwardEndCount(); i++) {
        if (!visitedEnds.isMarked(merge.forwardEndAt(i))) {
            endsVisited = false;
            break;
        }
    }
    if (endsVisited) {
        nodeQueue.add(new PathStart<>(merge, null));
    }
}
Also used : AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode)

Example 55 with AbstractMergeNode

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

the class StatelessPostOrderNodeIterator method queueMerge.

private void queueMerge(EndNode end) {
    assert !visitedEnds.isMarked(end);
    visitedEnds.mark(end);
    AbstractMergeNode merge = end.merge();
    boolean endsVisited = true;
    for (int i = 0; i < merge.forwardEndCount(); i++) {
        if (!visitedEnds.isMarked(merge.forwardEndAt(i))) {
            endsVisited = false;
            break;
        }
    }
    if (endsVisited) {
        nodeQueue.add(merge);
    }
}
Also used : AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode)

Aggregations

AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)59 FixedNode (org.graalvm.compiler.nodes.FixedNode)31 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)28 EndNode (org.graalvm.compiler.nodes.EndNode)24 Node (org.graalvm.compiler.graph.Node)22 AbstractEndNode (org.graalvm.compiler.nodes.AbstractEndNode)22 ValueNode (org.graalvm.compiler.nodes.ValueNode)22 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)20 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)19 PhiNode (org.graalvm.compiler.nodes.PhiNode)18 MergeNode (org.graalvm.compiler.nodes.MergeNode)16 ValuePhiNode (org.graalvm.compiler.nodes.ValuePhiNode)14 ControlSplitNode (org.graalvm.compiler.nodes.ControlSplitNode)13 LoopEndNode (org.graalvm.compiler.nodes.LoopEndNode)13 LoopExitNode (org.graalvm.compiler.nodes.LoopExitNode)13 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)12 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)11 ArrayList (java.util.ArrayList)10 FrameState (org.graalvm.compiler.nodes.FrameState)10 IfNode (org.graalvm.compiler.nodes.IfNode)9