Search in sources :

Example 81 with FixedNode

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

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

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

use of org.graalvm.compiler.nodes.FixedNode 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)

Example 85 with FixedNode

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

the class LockEliminationPhase method run.

@Override
protected void run(StructuredGraph graph) {
    for (MonitorExitNode monitorExitNode : graph.getNodes(MonitorExitNode.TYPE)) {
        FixedNode next = monitorExitNode.next();
        if ((next instanceof MonitorEnterNode || next instanceof RawMonitorEnterNode)) {
            // start
            assert !(next instanceof OSRMonitorEnterNode);
            AccessMonitorNode monitorEnterNode = (AccessMonitorNode) next;
            if (GraphUtil.unproxify(monitorEnterNode.object()) == GraphUtil.unproxify(monitorExitNode.object())) {
                /*
                     * We've coarsened the lock so use the same monitor id for the whole region,
                     * otherwise the monitor operations appear to be unrelated.
                     */
                MonitorIdNode enterId = monitorEnterNode.getMonitorId();
                MonitorIdNode exitId = monitorExitNode.getMonitorId();
                if (enterId != exitId) {
                    enterId.replaceAndDelete(exitId);
                }
                GraphUtil.removeFixedWithUnusedInputs(monitorEnterNode);
                GraphUtil.removeFixedWithUnusedInputs(monitorExitNode);
            }
        }
    }
}
Also used : OSRMonitorEnterNode(org.graalvm.compiler.nodes.extended.OSRMonitorEnterNode) MonitorIdNode(org.graalvm.compiler.nodes.java.MonitorIdNode) AccessMonitorNode(org.graalvm.compiler.nodes.java.AccessMonitorNode) OSRMonitorEnterNode(org.graalvm.compiler.nodes.extended.OSRMonitorEnterNode) RawMonitorEnterNode(org.graalvm.compiler.nodes.java.RawMonitorEnterNode) MonitorEnterNode(org.graalvm.compiler.nodes.java.MonitorEnterNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) MonitorExitNode(org.graalvm.compiler.nodes.java.MonitorExitNode) RawMonitorEnterNode(org.graalvm.compiler.nodes.java.RawMonitorEnterNode)

Aggregations

FixedNode (org.graalvm.compiler.nodes.FixedNode)87 Node (org.graalvm.compiler.graph.Node)41 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)41 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)39 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)39 ValueNode (org.graalvm.compiler.nodes.ValueNode)34 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)33 EndNode (org.graalvm.compiler.nodes.EndNode)27 AbstractEndNode (org.graalvm.compiler.nodes.AbstractEndNode)25 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)23 PhiNode (org.graalvm.compiler.nodes.PhiNode)22 ControlSplitNode (org.graalvm.compiler.nodes.ControlSplitNode)21 LoopExitNode (org.graalvm.compiler.nodes.LoopExitNode)21 LoopEndNode (org.graalvm.compiler.nodes.LoopEndNode)20 ControlSinkNode (org.graalvm.compiler.nodes.ControlSinkNode)17 MergeNode (org.graalvm.compiler.nodes.MergeNode)17 StartNode (org.graalvm.compiler.nodes.StartNode)17 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)16 DeoptimizeNode (org.graalvm.compiler.nodes.DeoptimizeNode)13 ProxyNode (org.graalvm.compiler.nodes.ProxyNode)13