use of org.graalvm.compiler.graph.Node in project graal by oracle.
the class ScheduledNodeIterator method processNodes.
public void processNodes(Block block, ScheduleResult schedule) {
lastFixed = block.getBeginNode();
assert lastFixed != null;
reconnect = null;
iterator = schedule.nodesFor(block).listIterator();
while (iterator.hasNext()) {
Node node = iterator.next();
if (!node.isAlive()) {
continue;
}
if (reconnect != null && node instanceof FixedNode) {
reconnect.setNext((FixedNode) node);
reconnect = null;
}
if (node instanceof FixedWithNextNode) {
lastFixed = (FixedWithNextNode) node;
}
processNode(node);
}
if (reconnect != null) {
assert block.getSuccessorCount() == 1;
reconnect.setNext(block.getFirstSuccessor().getBeginNode());
}
}
use of org.graalvm.compiler.graph.Node in project graal by oracle.
the class ScheduledNodeIterator method replaceCurrent.
protected void replaceCurrent(FixedWithNextNode newNode) {
Node current = iterator.previous();
// needed because of the previous() call
iterator.next();
current.replaceAndDelete(newNode);
insert(newNode, newNode);
iterator.set(newNode);
}
use of org.graalvm.compiler.graph.Node in project graal by oracle.
the class ComputeInliningRelevance method getMaxProbabilityLoopExit.
/**
* Returns the most probable loop exit. If multiple successors share the maximum probability,
* one is returned and the others are enqueued in pathBeginNodes.
*/
private Node getMaxProbabilityLoopExit(LoopBeginNode loopBegin, ArrayList<FixedNode> pathBeginNodes) {
Node maxSux = null;
double maxProbability = 0.0;
int pathBeginCount = pathBeginNodes.size();
for (LoopExitNode sux : loopBegin.loopExits()) {
double probability = nodeProbabilities.applyAsDouble(sux);
if (probability > maxProbability) {
maxProbability = probability;
maxSux = sux;
truncate(pathBeginNodes, pathBeginCount);
} else if (probability == maxProbability) {
pathBeginNodes.add(sux);
}
}
return maxSux;
}
use of org.graalvm.compiler.graph.Node in project graal by oracle.
the class ComputeInliningRelevance method computeFastPathMinProbability.
/**
* Computes the minimum probability along the most probable path within the scope. During
* iteration, the method returns immediately once a loop exit is discovered.
*/
private double computeFastPathMinProbability(FixedNode scopeStart) {
ArrayList<FixedNode> pathBeginNodes = new ArrayList<>();
pathBeginNodes.add(scopeStart);
double minPathProbability = nodeProbabilities.applyAsDouble(scopeStart);
boolean isLoopScope = scopeStart instanceof LoopBeginNode;
do {
Node current = pathBeginNodes.remove(pathBeginNodes.size() - 1);
do {
if (isLoopScope && current instanceof LoopExitNode && ((LoopBeginNode) scopeStart).loopExits().contains((LoopExitNode) current)) {
return minPathProbability;
} else if (current instanceof LoopBeginNode && current != scopeStart) {
current = getMaxProbabilityLoopExit((LoopBeginNode) current, pathBeginNodes);
minPathProbability = getMinPathProbability((FixedNode) current, minPathProbability);
} else if (current instanceof ControlSplitNode) {
current = getMaxProbabilitySux((ControlSplitNode) current, pathBeginNodes);
minPathProbability = getMinPathProbability((FixedNode) current, minPathProbability);
} else {
assert current.successors().count() <= 1;
current = current.successors().first();
}
} while (current != null);
} while (!pathBeginNodes.isEmpty());
return minPathProbability;
}
use of org.graalvm.compiler.graph.Node in project graal by oracle.
the class InliningData method doInline.
@SuppressWarnings("try")
private void doInline(CallsiteHolderExplorable callerCallsiteHolder, MethodInvocation calleeInvocation) {
StructuredGraph callerGraph = callerCallsiteHolder.graph();
InlineInfo calleeInfo = calleeInvocation.callee();
try {
try (DebugContext.Scope scope = debug.scope("doInline", callerGraph)) {
EconomicSet<Node> canonicalizedNodes = EconomicSet.create(Equivalence.IDENTITY);
canonicalizedNodes.addAll(calleeInfo.invoke().asNode().usages());
EconomicSet<Node> parameterUsages = calleeInfo.inline(new Providers(context));
canonicalizedNodes.addAll(parameterUsages);
counterInliningRuns.increment(debug);
debug.dump(DebugContext.DETAILED_LEVEL, callerGraph, "after %s", calleeInfo);
Graph.Mark markBeforeCanonicalization = callerGraph.getMark();
canonicalizer.applyIncremental(callerGraph, context, canonicalizedNodes);
// process invokes that are possibly created during canonicalization
for (Node newNode : callerGraph.getNewNodes(markBeforeCanonicalization)) {
if (newNode instanceof Invoke) {
callerCallsiteHolder.pushInvoke((Invoke) newNode);
}
}
callerCallsiteHolder.computeProbabilities();
counterInliningPerformed.increment(debug);
}
} catch (BailoutException bailout) {
throw bailout;
} catch (AssertionError | RuntimeException e) {
throw new GraalError(e).addContext(calleeInfo.toString());
} catch (GraalError e) {
throw e.addContext(calleeInfo.toString());
} catch (Throwable e) {
throw debug.handle(e);
}
}
Aggregations