# HG changeset patch # User Thomas Wuerthinger # Date 1306403716 -7200 # Node ID 2f3258e3800e6bdc8ab51e617bb998e4ad3a3bb6 # Parent 6d14aa4fbf90c77d0ed776c891efeea123a2e621# Parent 9253df7214726cbf004fbbccedc62048271fb27a Merge. diff -r 6d14aa4fbf90 -r 2f3258e3800e graal/GraalCompiler/src/com/sun/c1x/debug/IdealGraphPrinter.java --- a/graal/GraalCompiler/src/com/sun/c1x/debug/IdealGraphPrinter.java Wed May 25 20:03:05 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/debug/IdealGraphPrinter.java Thu May 26 11:55:16 2011 +0200 @@ -24,6 +24,7 @@ import java.io.*; import java.util.*; +import java.util.Map.Entry; import com.oracle.graal.graph.*; @@ -36,12 +37,14 @@ private static class Edge { final int from; final int to; - final int index; + final int fromIndex; + final int toIndex; - Edge(int from, int to, int index) { + Edge(int from, int fromIndex, int to, int toIndex) { this.from = from; + this.fromIndex = fromIndex; this.to = to; - this.index = index; + this.toIndex = toIndex; } } @@ -127,30 +130,43 @@ continue; } - String name; - if (shortNames) { - name = node.shortName(); - } else { - name = node.toString(); + stream.printf(" %n", node.id()); + stream.printf("

%d

%n", node.id()); + + Map props = node.getDebugProperties(); + if (!props.containsKey("name")) { + String name; + if (shortNames) { + name = node.shortName(); + } else { + name = node.toString(); + } + stream.printf("

%s

%n", escape(name)); + } + for (Entry entry : props.entrySet()) { + String key = entry.getKey().toString(); + String value = entry.getValue().toString(); + stream.printf("

%s

%n", escape(key), escape(value)); } - stream.printf(" ", node.id()); - stream.printf("

%d

", node.id()); - stream.printf("

%s

", escape(name)); - stream.println("
"); + stream.println("
"); - int index = 0; - for (Node predecessor : node.predecessors()) { - if (predecessor != Node.Null && !omittedClasses.contains(predecessor.getClass())) { - edges.add(new Edge(predecessor.id(), node.id(), index)); + // successors + int fromIndex = 0; + for (Node successor : node.successors()) { + if (successor != Node.Null && !omittedClasses.contains(successor.getClass())) { + edges.add(new Edge(node.id(), fromIndex, successor.id(), 0)); } - index++; + fromIndex++; } + + // inputs + int toIndex = 1; for (Node input : node.inputs()) { if (input != Node.Null && !omittedClasses.contains(input.getClass())) { - edges.add(new Edge(input.id(), node.id(), index)); + edges.add(new Edge(input.id(), input.successors().size(), node.id(), toIndex)); } - index++; + toIndex++; } } @@ -158,7 +174,7 @@ } private void printEdge(Edge edge) { - stream.printf(" %n", edge.from, edge.to, edge.index); + stream.printf(" %n", edge.from, edge.fromIndex, edge.to, edge.toIndex); } private String escape(String s) { diff -r 6d14aa4fbf90 -r 2f3258e3800e graal/GraalCompiler/src/com/sun/c1x/ir/Local.java --- a/graal/GraalCompiler/src/com/sun/c1x/ir/Local.java Wed May 25 20:03:05 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/ir/Local.java Thu May 26 11:55:16 2011 +0200 @@ -34,6 +34,7 @@ public final class Local extends Value { private static final int INPUT_COUNT = 1; + private static final int SUCCESSOR_COUNT = 0; private final int index; @@ -84,4 +85,14 @@ public void print(LogStream out) { out.print("local[index ").print(index()).print(']'); } + + @Override + protected int inputCount() { + return super.inputCount() + INPUT_COUNT; + } + + @Override + protected int successorCount() { + return super.successorCount() + SUCCESSOR_COUNT; + } } diff -r 6d14aa4fbf90 -r 2f3258e3800e graal/GraalGraph/src/com/oracle/graal/graph/Node.java --- a/graal/GraalGraph/src/com/oracle/graal/graph/Node.java Wed May 25 20:03:05 2011 +0200 +++ b/graal/GraalGraph/src/com/oracle/graal/graph/Node.java Thu May 26 11:55:16 2011 +0200 @@ -24,7 +24,9 @@ import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; public abstract class Node { @@ -154,6 +156,19 @@ return 0; } + /** + * Provides a {@link Map} of properties of this node for use in debugging (e.g., to view in the ideal graph + * visualizer). Subclasses overriding this method should add to the map returned by their superclass. + */ + public Map getDebugProperties() { + Map map = new HashMap(); + map.put("inputCount", inputCount()); + map.put("usageCount", usages.size()); + map.put("successorCount", successorCount()); + map.put("predecessorCount", predecessors.size()); + return map; + } + @Override public String toString() { return this.getClass().getSimpleName() + "-" + this.id(); diff -r 6d14aa4fbf90 -r 2f3258e3800e src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java --- a/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java Wed May 25 20:03:05 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java Thu May 26 11:55:16 2011 +0200 @@ -538,15 +538,19 @@ } private Node findRoot() { + Node node0 = null; for (Node n : nodes) { InputNode inputNode = n.inputNode; if (inputNode.getProperties().get("name").equals("Root")) { return n; + } else if (inputNode.getId() == 0) { + // use as fallback in case no root node is found + node0 = n; } } - return null; + return node0; } public void buildUpGraph() {