use of org.graalvm.compiler.nodes.FixedNode in project graal by oracle.
the class ConvertDeoptimizeToGuardPhase method moveAsDeoptAfter.
private static void moveAsDeoptAfter(FixedWithNextNode node, StaticDeoptimizingNode deopt) {
FixedNode next = node.next();
if (next != deopt.asNode()) {
node.setNext(node.graph().add(new DeoptimizeNode(deopt.getAction(), deopt.getReason(), deopt.getSpeculation())));
GraphUtil.killCFG(next);
}
}
use of org.graalvm.compiler.nodes.FixedNode in project graal by oracle.
the class LoopSafepointEliminationPhase method run.
@Override
protected void run(StructuredGraph graph, MidTierContext context) {
LoopsData loops = new LoopsData(graph);
if (context.getOptimisticOptimizations().useLoopLimitChecks(graph.getOptions()) && graph.getGuardsStage().allowsFloatingGuards()) {
loops.detectedCountedLoops();
for (LoopEx loop : loops.countedLoops()) {
if (loop.loop().getChildren().isEmpty() && loop.counted().getStamp().getBits() <= 32) {
boolean hasSafepoint = false;
for (LoopEndNode loopEnd : loop.loopBegin().loopEnds()) {
hasSafepoint |= loopEnd.canSafepoint();
}
if (hasSafepoint) {
loop.counted().createOverFlowGuard();
loop.loopBegin().disableSafepoint();
}
}
}
}
for (LoopEx loop : loops.loops()) {
for (LoopEndNode loopEnd : loop.loopBegin().loopEnds()) {
Block b = loops.getCFG().blockFor(loopEnd);
blocks: while (b != loop.loop().getHeader()) {
assert b != null;
for (FixedNode node : b.getNodes()) {
if (node instanceof Invoke || (node instanceof ForeignCallNode && ((ForeignCallNode) node).isGuaranteedSafepoint())) {
loopEnd.disableSafepoint();
break blocks;
}
}
b = b.getDominator();
}
}
}
loops.deleteUnusedNodes();
}
use of org.graalvm.compiler.nodes.FixedNode 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.FixedNode 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);
}
}
use of org.graalvm.compiler.nodes.FixedNode in project graal by oracle.
the class CanonicalStringGraphPrinter method writeCanonicalGraphExpressionString.
protected static void writeCanonicalGraphExpressionString(ValueNode node, boolean checkConstants, boolean removeIdentities, PrintWriter writer) {
writer.print(node.getClass().getSimpleName());
writer.print("(");
Fields properties = node.getNodeClass().getData();
for (int i = 0; i < properties.getCount(); i++) {
String dataStr = String.valueOf(properties.get(node, i));
if (removeIdentities) {
dataStr = removeIdentities(dataStr);
}
writer.print(dataStr);
if (i + 1 < properties.getCount() || node.inputPositions().iterator().hasNext()) {
writer.print(", ");
}
}
Iterator<Position> iterator = node.inputPositions().iterator();
while (iterator.hasNext()) {
Position position = iterator.next();
Node input = position.get(node);
if (checkConstants && input instanceof ConstantNode) {
ConstantNode constantNode = (ConstantNode) input;
String valueString = constantNode.getValue().toValueString();
if (removeIdentities) {
valueString = removeIdentities(valueString);
}
writer.print(valueString);
} else if (input instanceof ValueNode && !(input instanceof PhiNode) && !(input instanceof FixedNode)) {
writeCanonicalGraphExpressionString((ValueNode) input, checkConstants, removeIdentities, writer);
} else if (input == null) {
writer.print("null");
} else {
writer.print(input.getClass().getSimpleName());
}
if (iterator.hasNext()) {
writer.print(", ");
}
}
writer.print(")");
}
Aggregations