use of org.graalvm.compiler.graph.Node in project graal by oracle.
the class CFGPrinter method printNodes.
private void printNodes(Block block) {
printedNodes = new NodeBitMap(cfg.graph);
begin("IR");
out.println("HIR");
out.disableIndentation();
if (block.getBeginNode() instanceof AbstractMergeNode) {
// Currently phi functions are not in the schedule, so print them separately here.
for (ValueNode phi : ((AbstractMergeNode) block.getBeginNode()).phis()) {
printNode(phi, false);
}
}
Node cur = block.getBeginNode();
while (true) {
printNode(cur, false);
if (cur == block.getEndNode()) {
UnmodifiableMapCursor<Node, Block> cursor = latestScheduling.getEntries();
while (cursor.advance()) {
if (cursor.getValue() == block && !inFixedSchedule(cursor.getKey()) && !printedNodes.isMarked(cursor.getKey())) {
printNode(cursor.getKey(), true);
}
}
break;
}
assert cur.successors().count() == 1;
cur = cur.successors().first();
}
out.enableIndentation();
end("IR");
printedNodes = null;
}
use of org.graalvm.compiler.graph.Node in project graal by oracle.
the class CFGPrinter method printScheduledBlock.
private void printScheduledBlock(Block block, List<Node> nodesFor) {
printBlockProlog(block);
begin("IR");
out.println("HIR");
out.disableIndentation();
if (block.getBeginNode() instanceof AbstractMergeNode) {
// Currently phi functions are not in the schedule, so print them separately here.
for (ValueNode phi : ((AbstractMergeNode) block.getBeginNode()).phis()) {
printNode(phi, false);
}
}
for (Node n : nodesFor) {
printNode(n, false);
}
out.enableIndentation();
end("IR");
printBlockEpilog(block);
}
use of org.graalvm.compiler.graph.Node in project graal by oracle.
the class CanonicalStringGraphPrinter method writeCanonicalGraphString.
protected static void writeCanonicalGraphString(StructuredGraph graph, boolean excludeVirtual, boolean checkConstants, PrintWriter writer) {
StructuredGraph.ScheduleResult scheduleResult = GraphPrinter.getScheduleOrNull(graph);
if (scheduleResult == null) {
return;
}
try {
NodeMap<Integer> canonicalId = graph.createNodeMap();
int nextId = 0;
List<String> constantsLines = null;
if (checkConstants) {
constantsLines = new ArrayList<>();
}
for (Block block : scheduleResult.getCFG().getBlocks()) {
writer.print("Block ");
writer.print(block);
writer.print(" ");
if (block == scheduleResult.getCFG().getStartBlock()) {
writer.print("* ");
}
writer.print("-> ");
for (Block successor : block.getSuccessors()) {
writer.print(successor);
writer.print(" ");
}
writer.println();
for (Node node : scheduleResult.getBlockToNodesMap().get(block)) {
if (node instanceof ValueNode && node.isAlive()) {
if (!excludeVirtual || !(node instanceof VirtualObjectNode || node instanceof ProxyNode || node instanceof FullInfopointNode)) {
if (node instanceof ConstantNode) {
if (constantsLines != null) {
String name = node.toString(Verbosity.Name);
String str = name + (excludeVirtual ? "" : " (" + filteredUsageCount(node) + ")");
constantsLines.add(str);
}
} else {
int id;
if (canonicalId.get(node) != null) {
id = canonicalId.get(node);
} else {
id = nextId++;
canonicalId.set(node, id);
}
String name = node.getClass().getSimpleName();
writer.print(" ");
writer.print(id);
writer.print("|");
writer.print(name);
if (!excludeVirtual) {
writer.print(" (");
writer.print(filteredUsageCount(node));
writer.print(")");
}
writer.println();
}
}
}
}
}
if (constantsLines != null) {
writer.print(constantsLines.size());
writer.println(" constants:");
Collections.sort(constantsLines);
for (String s : constantsLines) {
writer.println(s);
}
}
} catch (Throwable t) {
writer.println();
t.printStackTrace(writer);
}
}
use of org.graalvm.compiler.graph.Node in project graal by oracle.
the class GraphOrder method visitForward.
private static void visitForward(ArrayList<Node> nodes, NodeBitMap visited, Node node, boolean floatingOnly) {
try {
assert node == null || node.isAlive() : node + " not alive";
if (node != null && !visited.isMarked(node)) {
if (floatingOnly && node instanceof FixedNode) {
throw new GraalError("unexpected reference to fixed node: %s (this indicates an unexpected cycle)", node);
}
visited.mark(node);
FrameState stateAfter = null;
if (node instanceof StateSplit) {
stateAfter = ((StateSplit) node).stateAfter();
}
for (Node input : node.inputs()) {
if (input != stateAfter) {
visitForward(nodes, visited, input, true);
}
}
if (node instanceof EndNode) {
EndNode end = (EndNode) node;
for (PhiNode phi : end.merge().phis()) {
visitForward(nodes, visited, phi.valueAt(end), true);
}
}
nodes.add(node);
if (node instanceof AbstractMergeNode) {
for (PhiNode phi : ((AbstractMergeNode) node).phis()) {
visited.mark(phi);
nodes.add(phi);
}
}
if (stateAfter != null) {
visitForward(nodes, visited, stateAfter, true);
}
}
} catch (GraalError e) {
throw GraalGraphError.transformAndAddContext(e, node);
}
}
use of org.graalvm.compiler.graph.Node in project graal by oracle.
the class GraphOrder method createOrder.
private static List<Node> createOrder(StructuredGraph graph) {
final ArrayList<Node> nodes = new ArrayList<>();
final NodeBitMap visited = graph.createNodeBitMap();
new StatelessPostOrderNodeIterator(graph.start()) {
@Override
protected void node(FixedNode node) {
visitForward(nodes, visited, node, false);
}
}.apply();
return nodes;
}
Aggregations