use of org.graalvm.compiler.nodes.extended.MultiGuardNode in project graal by oracle.
the class GraphUtil method markUsagesForKill.
private static void markUsagesForKill(EconomicSet<Node> markedNodes) {
NodeStack workStack = new NodeStack(markedNodes.size() + 4);
for (Node marked : markedNodes) {
workStack.push(marked);
}
ArrayList<MultiGuardNode> unmarkedMultiGuards = new ArrayList<>();
while (!workStack.isEmpty()) {
Node marked = workStack.pop();
for (Node usage : marked.usages()) {
boolean doMark = true;
if (usage instanceof MultiGuardNode) {
// Only mark a MultiGuardNode for deletion if all of its guards are marked for
// deletion. Otherwise, we would kill nodes outside the path to be killed.
MultiGuardNode multiGuard = (MultiGuardNode) usage;
for (Node guard : multiGuard.inputs()) {
if (!markedNodes.contains(guard)) {
doMark = false;
unmarkedMultiGuards.add(multiGuard);
}
}
}
if (doMark && !markedNodes.contains(usage)) {
workStack.push(usage);
markedNodes.add(usage);
}
}
// Detach unmarked multi guards from the marked node
for (MultiGuardNode multiGuard : unmarkedMultiGuards) {
multiGuard.replaceFirstInput(marked, null);
}
unmarkedMultiGuards.clear();
}
}
Aggregations