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;
}
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);
}
}
}
}
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;
}
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));
}
}
}
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();
}
Aggregations