changeset 2766:61f839853da8

IdealGraphVisualizer: Allow to specify the index of both the output and input slots of an edge in the XML input
author Peter Hofer <peter.hofer@jku.at>
date Mon, 23 May 2011 18:08:10 +0200
parents 2fd52cd64156
children 4f3053eef0de
files src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputEdge.java src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Printer.java src/share/tools/IdealGraphVisualizer/Difference/src/com/sun/hotspot/igv/difference/Difference.java src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Diagram.java
diffstat 5 files changed, 31 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputEdge.java	Mon May 23 18:03:55 2011 +0200
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputEdge.java	Mon May 23 18:08:10 2011 +0200
@@ -35,12 +35,14 @@
         NEW,
         DELETED
     }
+    private char fromIndex;
     private char toIndex;
     private int from;
     private int to;
     private State state;
 
-    public InputEdge(char toIndex, int from, int to) {
+    public InputEdge(char fromIndex, char toIndex, int from, int to) {
+        this.fromIndex = fromIndex;
         this.toIndex = toIndex;
         this.from = from;
         this.to = to;
@@ -55,6 +57,10 @@
         this.state = x;
     }
 
+    public char getFromIndex() {
+        return fromIndex;
+    }
+
     public char getToIndex() {
         return toIndex;
     }
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java	Mon May 23 18:03:55 2011 +0200
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java	Mon May 23 18:08:10 2011 +0200
@@ -73,7 +73,9 @@
     public static final String TO_PROPERTY = "to";
     public static final String PROPERTY_NAME_PROPERTY = "name";
     public static final String GRAPH_NAME_PROPERTY = "name";
-    public static final String TO_INDEX_PROPERTY = "index";
+    public static final String FROM_INDEX_PROPERTY = "fromIndex";
+    public static final String TO_INDEX_PROPERTY = "toIndex";
+    public static final String TO_INDEX_ALT_PROPERTY = "index";
     public static final String METHOD_ELEMENT = "method";
     public static final String INLINE_ELEMENT = "inline";
     public static final String BYTECODES_ELEMENT = "bytecodes";
@@ -301,12 +303,21 @@
 
         @Override
         protected InputEdge start() throws SAXException {
+            int fromIndex = 0;
             int toIndex = 0;
             int from = -1;
             int to = -1;
 
             try {
+                String fromIndexString = readAttribute(FROM_INDEX_PROPERTY);
+                if (fromIndexString != null) {
+                    fromIndex = Integer.parseInt(fromIndexString);
+                }
+
                 String toIndexString = readAttribute(TO_INDEX_PROPERTY);
+                if (toIndexString == null) {
+                    toIndexString = readAttribute(TO_INDEX_ALT_PROPERTY);
+                }
                 if (toIndexString != null) {
                     toIndex = Integer.parseInt(toIndexString);
                 }
@@ -317,8 +328,7 @@
                 throw new SAXException(e);
             }
 
-
-            InputEdge conn = new InputEdge((char) toIndex, from, to);
+            InputEdge conn = new InputEdge((char) fromIndex, (char) toIndex, from, to);
             return start(conn);
         }
 
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Printer.java	Mon May 23 18:03:55 2011 +0200
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Printer.java	Mon May 23 18:08:10 2011 +0200
@@ -209,6 +209,7 @@
 
     private Properties createProperties(InputEdge edge) {
         Properties p = new Properties();
+        p.setProperty(Parser.FROM_INDEX_PROPERTY, Integer.toString(edge.getFromIndex()));
         p.setProperty(Parser.TO_INDEX_PROPERTY, Integer.toString(edge.getToIndex()));
         p.setProperty(Parser.TO_PROPERTY, Integer.toString(edge.getTo()));
         p.setProperty(Parser.FROM_PROPERTY, Integer.toString(edge.getFrom()));
--- a/src/share/tools/IdealGraphVisualizer/Difference/src/com/sun/hotspot/igv/difference/Difference.java	Mon May 23 18:03:55 2011 +0200
+++ b/src/share/tools/IdealGraphVisualizer/Difference/src/com/sun/hotspot/igv/difference/Difference.java	Mon May 23 18:08:10 2011 +0200
@@ -135,9 +135,10 @@
             int to = e.getTo();
             InputNode nodeFrom = inputNodeMap.get(a.getNode(from));
             InputNode nodeTo = inputNodeMap.get(a.getNode(to));
-            char index = e.getToIndex();
+            char fromIndex = e.getFromIndex();
+            char toIndex = e.getToIndex();
 
-            InputEdge newEdge = new InputEdge(index, nodeFrom.getId(), nodeTo.getId());
+            InputEdge newEdge = new InputEdge(fromIndex, toIndex, nodeFrom.getId(), nodeTo.getId());
             if (!newEdges.contains(newEdge)) {
                 markAsNew(newEdge);
                 newEdges.add(newEdge);
@@ -150,9 +151,10 @@
             int to = e.getTo();
             InputNode nodeFrom = inputNodeMap.get(b.getNode(from));
             InputNode nodeTo = inputNodeMap.get(b.getNode(to));
-            char index = e.getToIndex();
+            char fromIndex = e.getFromIndex();
+            char toIndex = e.getToIndex();
 
-            InputEdge newEdge = new InputEdge(index, nodeFrom.getId(), nodeTo.getId());
+            InputEdge newEdge = new InputEdge(fromIndex, toIndex, nodeFrom.getId(), nodeTo.getId());
             if (!newEdges.contains(newEdge)) {
                 markAsDeleted(newEdge);
                 newEdges.add(newEdge);
--- a/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Diagram.java	Mon May 23 18:03:55 2011 +0200
+++ b/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Diagram.java	Mon May 23 18:08:10 2011 +0200
@@ -142,18 +142,16 @@
             Figure toFigure = figureHash.get(to);
             assert fromFigure != null && toFigure != null;
 
-            int toIndex = e.getToIndex();
-
-            while (fromFigure.getOutputSlots().size() <= 0) {
+            int fromIndex = e.getFromIndex();
+            while (fromFigure.getOutputSlots().size() <= fromIndex) {
                 fromFigure.createOutputSlot();
             }
+            OutputSlot outputSlot = fromFigure.getOutputSlots().get(fromIndex);
 
-            OutputSlot outputSlot = fromFigure.getOutputSlots().get(0);
-
+            int toIndex = e.getToIndex();
             while (toFigure.getInputSlots().size() <= toIndex) {
                 toFigure.createInputSlot();
             }
-
             InputSlot inputSlot = toFigure.getInputSlots().get(toIndex);
 
             Connection c = d.createConnection(inputSlot, outputSlot);