use of org.graalvm.compiler.nodes.FixedWithNextNode in project graal by oracle.
the class EliminateRedundantInitializationPhase method removeInitsAtStaticCalls.
/**
* Find each {@link Invoke} that has a corresponding {@link InitializeKlassNode}. These
* {@link InitializeKlassNode} are redundant and are removed.
*/
private static void removeInitsAtStaticCalls(StructuredGraph graph) {
for (Invoke invoke : graph.getInvokes()) {
if (invoke.classInit() != null) {
Node classInit = invoke.classInit();
classInit.replaceAtUsages(null);
graph.removeFixed((FixedWithNextNode) classInit);
}
}
}
use of org.graalvm.compiler.nodes.FixedWithNextNode 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.FixedWithNextNode 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();
}
}
use of org.graalvm.compiler.nodes.FixedWithNextNode in project graal by oracle.
the class CFGPrinter method printNode.
private void printNode(Node node, boolean unscheduled) {
assert !printedNodes.isMarked(node);
printedNodes.mark(node);
if (!(node instanceof ValuePhiNode)) {
for (Node input : node.inputs()) {
if (!inFixedSchedule(input) && !printedNodes.isMarked(input)) {
printNode(input, true);
}
}
}
if (unscheduled) {
assert lir == null && schedule == null : "unscheduled nodes can only be present before LIR generation";
out.print("f ").print(HOVER_START).print("u").print(HOVER_SEP).print("unscheduled").print(HOVER_END).println(COLUMN_END);
} else if (node instanceof FixedWithNextNode) {
out.print("f ").print(HOVER_START).print("#").print(HOVER_SEP).print("fixed with next").print(HOVER_END).println(COLUMN_END);
} else if (node instanceof FixedNode) {
out.print("f ").print(HOVER_START).print("*").print(HOVER_SEP).print("fixed").print(HOVER_END).println(COLUMN_END);
} else if (node instanceof FloatingNode) {
out.print("f ").print(HOVER_START).print("~").print(HOVER_SEP).print("floating").print(HOVER_END).println(COLUMN_END);
}
out.print("tid ").print(nodeToString(node)).println(COLUMN_END);
if (nodeLirGenerator != null) {
Value operand = nodeLirGenerator.hasOperand(node) ? nodeLirGenerator.operand(node) : null;
if (operand != null) {
out.print("result ").print(operand.toString()).println(COLUMN_END);
}
}
if (node instanceof StateSplit) {
StateSplit stateSplit = (StateSplit) node;
if (stateSplit.stateAfter() != null) {
String state = stateToString(stateSplit.stateAfter());
out.print("st ").print(HOVER_START).print("st").print(HOVER_SEP).print(state).print(HOVER_END).println(COLUMN_END);
}
}
Map<Object, Object> props = new TreeMap<>(node.getDebugProperties());
out.print("d ").print(HOVER_START).print("d").print(HOVER_SEP);
out.println("=== Debug Properties ===");
for (Map.Entry<Object, Object> entry : props.entrySet()) {
out.print(entry.getKey().toString()).print(": ").print(entry.getValue() == null ? "[null]" : entry.getValue().toString()).println();
}
out.println("=== Inputs ===");
printNamedNodes(node, node.inputPositions().iterator(), "", "\n", null);
out.println("=== Succesors ===");
printNamedNodes(node, node.successorPositions().iterator(), "", "\n", null);
out.println("=== Usages ===");
if (!node.hasNoUsages()) {
for (Node usage : node.usages()) {
out.print(nodeToString(usage)).print(" ");
}
out.println();
}
out.println("=== Predecessor ===");
out.print(nodeToString(node.predecessor())).print(" ");
out.print(HOVER_END).println(COLUMN_END);
out.print("instruction ");
out.print(HOVER_START).print(node.getNodeClass().shortName()).print(HOVER_SEP).print(node.getClass().getName()).print(HOVER_END).print(" ");
printNamedNodes(node, node.inputPositions().iterator(), "", "", "#NDF");
printNamedNodes(node, node.successorPositions().iterator(), "#", "", "#NDF");
for (Map.Entry<Object, Object> entry : props.entrySet()) {
String key = entry.getKey().toString();
if (key.startsWith("data.") && !key.equals("data.stamp")) {
out.print(key.substring("data.".length())).print(": ").print(entry.getValue() == null ? "[null]" : entry.getValue().toString()).print(" ");
}
}
out.print(COLUMN_END).print(' ').println(COLUMN_END);
}
use of org.graalvm.compiler.nodes.FixedWithNextNode in project graal by oracle.
the class CanonicalStringGraphPrinter method writeCanonicalExpressionCFGString.
protected static void writeCanonicalExpressionCFGString(StructuredGraph graph, boolean checkConstants, boolean removeIdentities, PrintWriter writer) {
ControlFlowGraph controlFlowGraph = getControlFlowGraph(graph);
if (controlFlowGraph == null) {
return;
}
try {
for (Block block : controlFlowGraph.getBlocks()) {
writer.print("Block ");
writer.print(block);
writer.print(" ");
if (block == controlFlowGraph.getStartBlock()) {
writer.print("* ");
}
writer.print("-> ");
for (Block successor : block.getSuccessors()) {
writer.print(successor);
writer.print(" ");
}
writer.println();
FixedNode node = block.getBeginNode();
while (node != null) {
writeCanonicalGraphExpressionString(node, checkConstants, removeIdentities, writer);
writer.println();
if (node instanceof FixedWithNextNode) {
node = ((FixedWithNextNode) node).next();
} else {
node = null;
}
}
}
} catch (Throwable e) {
writer.println();
e.printStackTrace(writer);
}
}
Aggregations