use of org.graalvm.compiler.nodes.LoopEndNode in project graal by oracle.
the class ReentrantNodeIterator method processLoop.
public static <StateT> LoopInfo<StateT> processLoop(NodeIteratorClosure<StateT> closure, LoopBeginNode loop, StateT initialState) {
EconomicMap<FixedNode, StateT> blockEndStates = apply(closure, loop, initialState, loop);
LoopInfo<StateT> info = new LoopInfo<>(loop.loopEnds().count(), loop.loopExits().count());
for (LoopEndNode end : loop.loopEnds()) {
if (blockEndStates.containsKey(end)) {
info.endStates.put(end, blockEndStates.get(end));
}
}
for (LoopExitNode exit : loop.loopExits()) {
if (blockEndStates.containsKey(exit)) {
info.exitStates.put(exit, blockEndStates.get(exit));
}
}
return info;
}
use of org.graalvm.compiler.nodes.LoopEndNode 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;
}
}
}
use of org.graalvm.compiler.nodes.LoopEndNode 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();
}
use of org.graalvm.compiler.nodes.LoopEndNode 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();
}
use of org.graalvm.compiler.nodes.LoopEndNode in project graal by oracle.
the class LoopSafepointInsertionPhase method run.
@Override
protected void run(StructuredGraph graph) {
if (GenLoopSafepoints.getValue(graph.getOptions())) {
for (LoopBeginNode loopBeginNode : graph.getNodes(LoopBeginNode.TYPE)) {
for (LoopEndNode loopEndNode : loopBeginNode.loopEnds()) {
if (loopEndNode.canSafepoint()) {
SafepointNode safepointNode = graph.add(new SafepointNode());
graph.addBeforeFixed(loopEndNode, safepointNode);
}
}
}
}
}
Aggregations