use of org.graalvm.compiler.nodes.FixedNode in project graal by oracle.
the class GraphUtil method unlinkFixedNode.
public static void unlinkFixedNode(FixedWithNextNode fixed) {
assert fixed.next() != null && fixed.predecessor() != null && fixed.isAlive() : fixed;
FixedNode next = fixed.next();
fixed.setNext(null);
fixed.replaceAtPredecessor(next);
}
use of org.graalvm.compiler.nodes.FixedNode in project graal by oracle.
the class GraphUtil method killCFGInner.
private static void killCFGInner(FixedNode node) {
EconomicSet<Node> markedNodes = EconomicSet.create();
EconomicMap<AbstractMergeNode, List<AbstractEndNode>> unmarkedMerges = EconomicMap.create();
// Detach this node from CFG
node.replaceAtPredecessor(null);
markFixedNodes(node, markedNodes, unmarkedMerges);
fixSurvivingAffectedMerges(markedNodes, unmarkedMerges);
DebugContext debug = node.getDebug();
debug.dump(DebugContext.DETAILED_LEVEL, node.graph(), "After fixing merges (killCFG %s)", node);
// Mark non-fixed nodes
markUsages(markedNodes);
// Detach marked nodes from non-marked nodes
for (Node marked : markedNodes) {
for (Node input : marked.inputs()) {
if (!markedNodes.contains(input)) {
marked.replaceFirstInput(input, null);
tryKillUnused(input);
}
}
}
debug.dump(DebugContext.VERY_DETAILED_LEVEL, node.graph(), "After disconnecting non-marked inputs (killCFG %s)", node);
// Kill marked nodes
for (Node marked : markedNodes) {
if (marked.isAlive()) {
marked.markDeleted();
}
}
}
use of org.graalvm.compiler.nodes.FixedNode in project graal by oracle.
the class GraphUtil method killCFG.
@SuppressWarnings("try")
public static void killCFG(FixedNode node) {
DebugContext debug = node.getDebug();
try (DebugContext.Scope scope = debug.scope("KillCFG", node)) {
EconomicSet<Node> unusedNodes = null;
EconomicSet<Node> unsafeNodes = null;
Graph.NodeEventScope nodeEventScope = null;
OptionValues options = node.getOptions();
if (Graph.Options.VerifyGraalGraphEdges.getValue(options)) {
unsafeNodes = collectUnsafeNodes(node.graph());
}
if (GraphUtil.Options.VerifyKillCFGUnusedNodes.getValue(options)) {
EconomicSet<Node> collectedUnusedNodes = unusedNodes = EconomicSet.create(Equivalence.IDENTITY);
nodeEventScope = node.graph().trackNodeEvents(new Graph.NodeEventListener() {
@Override
public void changed(Graph.NodeEvent e, Node n) {
if (e == Graph.NodeEvent.ZERO_USAGES && isFloatingNode(n) && !(n instanceof GuardNode)) {
collectedUnusedNodes.add(n);
}
}
});
}
debug.dump(DebugContext.VERY_DETAILED_LEVEL, node.graph(), "Before killCFG %s", node);
killCFGInner(node);
debug.dump(DebugContext.VERY_DETAILED_LEVEL, node.graph(), "After killCFG %s", node);
if (Graph.Options.VerifyGraalGraphEdges.getValue(options)) {
EconomicSet<Node> newUnsafeNodes = collectUnsafeNodes(node.graph());
newUnsafeNodes.removeAll(unsafeNodes);
assert newUnsafeNodes.isEmpty() : "New unsafe nodes: " + newUnsafeNodes;
}
if (GraphUtil.Options.VerifyKillCFGUnusedNodes.getValue(options)) {
nodeEventScope.close();
Iterator<Node> iterator = unusedNodes.iterator();
while (iterator.hasNext()) {
Node curNode = iterator.next();
if (curNode.isDeleted()) {
iterator.remove();
}
}
assert unusedNodes.isEmpty() : "New unused nodes: " + unusedNodes;
}
} catch (Throwable t) {
throw debug.handle(t);
}
}
use of org.graalvm.compiler.nodes.FixedNode in project graal by oracle.
the class EnsureVirtualizedNode method ensureVirtualFailure.
public static void ensureVirtualFailure(Node location, Stamp stamp) {
String additionalReason = "";
if (location instanceof FixedWithNextNode && !(location instanceof EnsureVirtualizedNode)) {
FixedWithNextNode fixedWithNextNode = (FixedWithNextNode) location;
FixedNode next = fixedWithNextNode.next();
if (next instanceof StoreFieldNode) {
additionalReason = " (must not store virtual object into a field)";
} else if (next instanceof Invoke) {
additionalReason = " (must not pass virtual object into an invoke that cannot be inlined)";
} else {
additionalReason = " (must not let virtual object escape at node " + next + ")";
}
}
Throwable exception = new VerificationError("Object of type %s should not be materialized%s:", StampTool.typeOrNull(stamp).getName(), additionalReason);
Node pos;
if (location instanceof FixedWithNextNode) {
pos = ((FixedWithNextNode) location).next();
} else if (location instanceof AbstractEndNode) {
pos = ((AbstractEndNode) location).merge();
} else {
pos = location;
}
throw GraphUtil.approxSourceException(pos, exception);
}
use of org.graalvm.compiler.nodes.FixedNode in project graal by oracle.
the class ConvertDeoptimizeToGuardPhase method propagateFixed.
@SuppressWarnings("try")
private void propagateFixed(FixedNode from, StaticDeoptimizingNode deopt, LoweringProvider loweringProvider) {
Node current = from;
while (current != null) {
if (GraalOptions.GuardPriorities.getValue(from.getOptions()) && current instanceof FixedGuardNode) {
FixedGuardNode otherGuard = (FixedGuardNode) current;
if (otherGuard.computePriority().isHigherPriorityThan(deopt.computePriority())) {
moveAsDeoptAfter(otherGuard, deopt);
return;
}
} else if (current instanceof AbstractBeginNode) {
if (current instanceof AbstractMergeNode) {
AbstractMergeNode mergeNode = (AbstractMergeNode) current;
FixedNode next = mergeNode.next();
while (mergeNode.isAlive()) {
AbstractEndNode end = mergeNode.forwardEnds().first();
propagateFixed(end, deopt, loweringProvider);
}
assert next.isAlive();
propagateFixed(next, deopt, loweringProvider);
return;
} else if (current.predecessor() instanceof IfNode) {
IfNode ifNode = (IfNode) current.predecessor();
// Prioritize the source position of the IfNode
try (DebugCloseable closable = ifNode.withNodeSourcePosition()) {
StructuredGraph graph = ifNode.graph();
LogicNode conditionNode = ifNode.condition();
boolean negateGuardCondition = current == ifNode.trueSuccessor();
FixedGuardNode guard = graph.add(new FixedGuardNode(conditionNode, deopt.getReason(), deopt.getAction(), deopt.getSpeculation(), negateGuardCondition));
FixedWithNextNode pred = (FixedWithNextNode) ifNode.predecessor();
AbstractBeginNode survivingSuccessor;
if (negateGuardCondition) {
survivingSuccessor = ifNode.falseSuccessor();
} else {
survivingSuccessor = ifNode.trueSuccessor();
}
graph.removeSplitPropagate(ifNode, survivingSuccessor);
Node newGuard = guard;
if (survivingSuccessor instanceof LoopExitNode) {
newGuard = ProxyNode.forGuard(guard, (LoopExitNode) survivingSuccessor, graph);
}
survivingSuccessor.replaceAtUsages(InputType.Guard, newGuard);
graph.getDebug().log("Converting deopt on %-5s branch of %s to guard for remaining branch %s.", negateGuardCondition, ifNode, survivingSuccessor);
FixedNode next = pred.next();
pred.setNext(guard);
guard.setNext(next);
SimplifierTool simplifierTool = GraphUtil.getDefaultSimplifier(null, null, null, false, graph.getAssumptions(), graph.getOptions(), loweringProvider);
survivingSuccessor.simplify(simplifierTool);
return;
}
} else if (current.predecessor() == null || current.predecessor() instanceof ControlSplitNode) {
assert current.predecessor() != null || (current instanceof StartNode && current == ((AbstractBeginNode) current).graph().start());
moveAsDeoptAfter((AbstractBeginNode) current, deopt);
return;
}
}
current = current.predecessor();
}
}
Aggregations