changeset 2792:2f3258e3800e

Merge.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Thu, 26 May 2011 11:55:16 +0200
parents 6d14aa4fbf90 (current diff) 9253df721472 (diff)
children d3fc4fe063bf
files graal/GraalGraph/src/com/oracle/graal/graph/Node.java
diffstat 4 files changed, 67 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- 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("   <node id='%d'><properties>%n", node.id());
+            stream.printf("    <p name='idx'>%d</p>%n", node.id());
+
+            Map<Object, Object> props = node.getDebugProperties();
+            if (!props.containsKey("name")) {
+                String name;
+                if (shortNames) {
+                    name = node.shortName();
+                } else {
+                    name = node.toString();
+                }
+                stream.printf("    <p name='name'>%s</p>%n", escape(name));
+            }
+            for (Entry<Object, Object> entry : props.entrySet()) {
+                String key = entry.getKey().toString();
+                String value = entry.getValue().toString();
+                stream.printf("    <p name='%s'>%s</p>%n", escape(key), escape(value));
             }
 
-            stream.printf("   <node id='%d'><properties>", node.id());
-            stream.printf("<p name='idx'>%d</p>", node.id());
-            stream.printf("<p name='name'>%s</p>", escape(name));
-            stream.println("</properties></node>");
+            stream.println("   </properties></node>");
 
-            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("   <edge from='%d' to='%d' index='%d'/>%n", edge.from, edge.to, edge.index);
+        stream.printf("   <edge from='%d' fromIndex='%d' to='%d' toIndex='%d'/>%n", edge.from, edge.fromIndex, edge.to, edge.toIndex);
     }
 
     private String escape(String s) {
--- 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;
+    }
 }
--- 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<Object, Object> getDebugProperties() {
+        Map<Object, Object> map = new HashMap<Object, Object>();
+        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();
--- 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() {