changeset 16154:f9f7bd1a6b2c

IGV: Support for InputType.
author Roland Schatz <roland.schatz@oracle.com>
date Mon, 23 Jun 2014 13:13:41 +0200
parents e8eeee2176ff
children c903c4e693bf
files graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/match/MatchRuleRegistry.java graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java graal/com.oracle.graal.printer/src/com/oracle/graal/printer/BinaryGraphPrinter.java 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/BinaryParser.java src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java src/share/tools/IdealGraphVisualizer/Difference/src/com/sun/hotspot/igv/difference/Difference.java src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/CombineFilter.java src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/GraalEdgeColorFilter.java src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/edgeColor.filter src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Connection.java src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Diagram.java
diffstat 12 files changed, 91 insertions(+), 92 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/match/MatchRuleRegistry.java	Fri Jun 20 15:25:07 2014 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/match/MatchRuleRegistry.java	Mon Jun 23 13:13:41 2014 +0200
@@ -68,9 +68,6 @@
         for (int i = 0; i < names.length; i++) {
             for (NodeClass.Position position : nodeClass.getFirstLevelInputPositions()) {
                 String name = nodeClass.getName(position);
-                if (name.endsWith("#NDF")) {
-                    name = name.substring(0, name.length() - 4);
-                }
                 if (name.equals(names[i])) {
                     result[i] = position;
                     break;
--- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java	Fri Jun 20 15:25:07 2014 +0200
+++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java	Mon Jun 23 13:13:41 2014 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -298,9 +298,6 @@
                 }
                 types.put(offset, inputAnnotation.value());
                 names.put(offset, field.getName());
-                if (inputAnnotation.value() != InputType.Value) {
-                    fieldNames.put(offset, field.getName() + "#NDF");
-                }
             } else if (field.isAnnotationPresent(Node.Successor.class)) {
                 if (SUCCESSOR_LIST_CLASS.isAssignableFrom(type)) {
                     GraalInternalError.guarantee(Modifier.isFinal(field.getModifiers()), "NodeSuccessorList successor field % should be final", field);
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/BinaryGraphPrinter.java	Fri Jun 20 15:25:07 2014 +0200
+++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/BinaryGraphPrinter.java	Mon Jun 23 13:13:41 2014 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -299,6 +299,7 @@
             for (Position pos : directInputPositions) {
                 writeByte(pos.getSubIndex() == NodeClass.NOT_ITERABLE ? 0 : 1);
                 writePoolObject(nodeClass.getName(pos));
+                writePoolObject(nodeClass.getInputType(pos));
             }
             Collection<Position> directSuccessorPositions = nodeClass.getFirstLevelSuccessorPositions();
             writeShort((char) directSuccessorPositions.size());
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputEdge.java	Fri Jun 20 15:25:07 2014 +0200
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputEdge.java	Mon Jun 23 13:13:41 2014 +0200
@@ -68,29 +68,31 @@
     private final int from;
     private final int to;
     private final String label;
+    private final String type;
     private State state;
 
     public InputEdge(char toIndex, int from, int to) {
-        this((char) 0, toIndex, from, to, null);
+        this((char) 0, toIndex, from, to, null, null);
     }
 
     public InputEdge(char fromIndex, char toIndex, int from, int to) {
-        this(fromIndex, toIndex, from, to, null);
+        this(fromIndex, toIndex, from, to, null, null);
     }
 
-    public InputEdge(char fromIndex, char toIndex, int from, int to, String label) {
+    public InputEdge(char fromIndex, char toIndex, int from, int to, String label, String type) {
         this.toIndex = toIndex;
         this.fromIndex = fromIndex;
         this.from = from;
         this.to = to;
         this.state = State.SAME;
         this.label = label;
+        this.type = type;
     }
 
     static WeakHashMap<InputEdge, WeakReference<InputEdge>> immutableCache = new WeakHashMap<>();
 
-    public static synchronized InputEdge createImmutable(char fromIndex, char toIndex, int from, int to, String label) {
-        InputEdge edge = new InputEdge(fromIndex, toIndex, from, to, label, State.IMMUTABLE);
+    public static synchronized InputEdge createImmutable(char fromIndex, char toIndex, int from, int to, String label, String type) {
+        InputEdge edge = new InputEdge(fromIndex, toIndex, from, to, label, type, State.IMMUTABLE);
         WeakReference<InputEdge> result = immutableCache.get(edge);
         if (result != null) {
             InputEdge edge2 = result.get();
@@ -102,13 +104,14 @@
         return edge;
     }
 
-    public InputEdge(char fromIndex, char toIndex, int from, int to, String label, State state) {
+    public InputEdge(char fromIndex, char toIndex, int from, int to, String label, String type, State state) {
         this.toIndex = toIndex;
         this.fromIndex = fromIndex;
         this.from = from;
         this.to = to;
         this.state = state;
         this.label = label;
+        this.type = type;
     }
 
     public State getState() {
@@ -145,6 +148,10 @@
     public String getLabel() {
         return label;
     }
+    
+    public String getType() {
+        return type;
+    }
 
     @Override
     public boolean equals(Object o) {
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/BinaryParser.java	Fri Jun 20 15:25:07 2014 +0200
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/BinaryParser.java	Mon Jun 23 13:13:41 2014 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -215,12 +215,20 @@
         }
     }
     
+    private static class TypedPort extends Port {
+        public final EnumValue type;
+        private TypedPort(boolean isList, String name, EnumValue type) {
+            super(isList, name);
+            this.type = type;
+        }
+    }
+    
     private static class NodeClass {
         public final String className;
         public final String nameTemplate;
-        public final List<Port> inputs;
+        public final List<TypedPort> inputs;
         public final List<Port> sux;
-        private NodeClass(String className, String nameTemplate, List<Port> inputs, List<Port> sux) {
+        private NodeClass(String className, String nameTemplate, List<TypedPort> inputs, List<Port> sux) {
             this.className = className;
             this.nameTemplate = nameTemplate;
             this.inputs = inputs;
@@ -464,11 +472,12 @@
                 String className = readString();
                 String nameTemplate = readString();
                 int inputCount = readShort();
-                List<Port> inputs = new ArrayList<>(inputCount);
+                List<TypedPort> inputs = new ArrayList<>(inputCount);
                 for (int i = 0; i < inputCount; i++) {
                     boolean isList = readByte() != 0;
                     String name = readPoolObject(String.class);
-                    inputs.add(new Port(isList, name));
+                    EnumValue inputType = readPoolObject(EnumValue.class);
+                    inputs.add(new TypedPort(isList, name, inputType));
                 }
                 int suxCount = readShort();
                 List<Port> sux = new ArrayList<>(suxCount);
@@ -726,20 +735,20 @@
             }
             int edgesStart = edges.size();
             int portNum = 0;
-            for (Port p : nodeClass.inputs) {
+            for (TypedPort p : nodeClass.inputs) {
                 if (p.isList) {
                     int size = readShort();
                     for (int j = 0; j < size; j++) {
                         int in = readInt();
                         if (in >= 0) {
-                            edges.add(new Edge(in, id, (char) (preds + portNum), p.name + "[" + j + "]", true));
+                            edges.add(new Edge(in, id, (char) (preds + portNum), p.name + "[" + j + "]", p.type.toString(Length.S), true));
                             portNum++;
                         }
                     }
                 } else {
                     int in = readInt();
                     if (in >= 0) {
-                        edges.add(new Edge(in, id, (char) (preds + portNum), p.name, true));
+                        edges.add(new Edge(in, id, (char) (preds + portNum), p.name, p.type.toString(Length.S), true));
                         portNum++;
                     }
                 }
@@ -752,14 +761,14 @@
                     for (int j = 0; j < size; j++) {
                         int sux = readInt();
                         if (sux >= 0) {
-                            edges.add(new Edge(id, sux, (char) portNum, p.name + "[" + j + "]", false));
+                            edges.add(new Edge(id, sux, (char) portNum, p.name + "[" + j + "]", "Successor", false));
                             portNum++;
                         }
                     }
                 } else {
                     int sux = readInt();
                     if (sux >= 0) {
-                        edges.add(new Edge(id, sux, (char) portNum, p.name, false));
+                        edges.add(new Edge(id, sux, (char) portNum, p.name, "Successor", false));
                         portNum++;
                     }
                 }
@@ -780,7 +789,7 @@
         for (Edge e : edges) {
             char fromIndex = e.input ? 1 : e.num;
             char toIndex = e.input ? e.num : 0;
-            graph.addEdge(InputEdge.createImmutable(fromIndex, toIndex, e.from, e.to, e.label));
+            graph.addEdge(InputEdge.createImmutable(fromIndex, toIndex, e.from, e.to, e.label, e.type));
         }
     }
     
@@ -845,14 +854,16 @@
         final int to;
         final char num;
         final String label;
+        final String type;
         final boolean input;
         public Edge(int from, int to) {
-            this(from, to, (char) 0, null, false);
+            this(from, to, (char) 0, null, null, false);
         }
-        public Edge(int from, int to, char num, String label, boolean input) {
+        public Edge(int from, int to, char num, String label, String type, boolean input) {
             this.from = from;
             this.to = to;
             this.label = label != null ? label.intern() : label;
+            this.type = type != null ? type.intern() : type;
             this.num = num;
             this.input = input;
         }
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java	Fri Jun 20 15:25:07 2014 +0200
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java	Mon Jun 23 13:13:41 2014 +0200
@@ -410,7 +410,7 @@
                 throw new SAXException(e);
             }
 
-            InputEdge conn = new InputEdge((char) fromIndex, (char) toIndex, from, to, label);
+            InputEdge conn = new InputEdge((char) fromIndex, (char) toIndex, from, to, label, "");
             return start(conn);
         }
 
--- a/src/share/tools/IdealGraphVisualizer/Difference/src/com/sun/hotspot/igv/difference/Difference.java	Fri Jun 20 15:25:07 2014 +0200
+++ b/src/share/tools/IdealGraphVisualizer/Difference/src/com/sun/hotspot/igv/difference/Difference.java	Mon Jun 23 13:13:41 2014 +0200
@@ -211,7 +211,7 @@
             if (nodeFrom == null || nodeTo == null) {
                 System.out.println("Unexpected edge : " + from + " -> " + to);
             } else {
-                InputEdge newEdge = new InputEdge(fromIndex, toIndex, nodeFrom.getId(), nodeTo.getId());
+                InputEdge newEdge = new InputEdge(fromIndex, toIndex, nodeFrom.getId(), nodeTo.getId(), e.getLabel(), e.getType());
                 if (!newEdges.contains(newEdge)) {
                     markAsDeleted(newEdge);
                     newEdges.add(newEdge);
@@ -231,7 +231,7 @@
             if (nodeFrom == null || nodeTo == null) {
                 System.out.println("Unexpected edge : " + from + " -> " + to);
             } else {
-                InputEdge newEdge = new InputEdge(fromIndex, toIndex, nodeFrom.getId(), nodeTo.getId());
+                InputEdge newEdge = new InputEdge(fromIndex, toIndex, nodeFrom.getId(), nodeTo.getId(), e.getLabel(), e.getType());
                 if (!newEdges.contains(newEdge)) {
                     markAsNew(newEdge);
                     newEdges.add(newEdge);
--- a/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/CombineFilter.java	Fri Jun 20 15:25:07 2014 +0200
+++ b/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/CombineFilter.java	Mon Jun 23 13:13:41 2014 +0200
@@ -97,7 +97,7 @@
 
                         for (InputSlot s : f.getInputSlots()) {
                             for (Connection c : s.getConnections()) {
-                                Connection newConn = diagram.createConnection(slot, c.getOutputSlot(), c.getLabel());
+                                Connection newConn = diagram.createConnection(slot, c.getOutputSlot(), c.getLabel(), c.getType());
                                 newConn.setColor(c.getColor());
                                 newConn.setStyle(c.getStyle());
                             }
@@ -154,7 +154,7 @@
                                     }
                                 }
                                 for (Connection c : nextSlot.getConnections()) {
-                                    Connection newConn = diagram.createConnection(c.getInputSlot(), slot, c.getLabel());
+                                    Connection newConn = diagram.createConnection(c.getInputSlot(), slot, c.getLabel(), c.getType());
                                     newConn.setColor(c.getColor());
                                     newConn.setStyle(c.getStyle());
                                 }
--- a/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/GraalEdgeColorFilter.java	Fri Jun 20 15:25:07 2014 +0200
+++ b/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/GraalEdgeColorFilter.java	Mon Jun 23 13:13:41 2014 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
 import com.sun.hotspot.igv.graph.Figure;
 import com.sun.hotspot.igv.graph.InputSlot;
 import java.awt.Color;
+import java.util.HashMap;
 import java.util.List;
 import java.util.regex.Pattern;
 
@@ -41,9 +42,8 @@
  */
 public class GraalEdgeColorFilter extends AbstractFilter {
 
-    private Color successorColor = Color.BLUE;
-    private Color usageColor = Color.RED;
-    private Color memoryColor = Color.GREEN;
+    private HashMap<String,Color> usageColor = new HashMap<>();
+    private Color otherUsageColor = Color.BLACK;
 
     public GraalEdgeColorFilter() {
     }
@@ -56,66 +56,43 @@
     @Override
     public void apply(Diagram d) {
         List<Figure> figures = d.getFigures();
-        Pattern ndf = Pattern.compile(".*#NDF(\\[[0-9]*\\])?");
         for (Figure f : figures) {
-            Properties p = f.getProperties();
-            int predCount;
-            String predCountString = p.get("predecessorCount");
-            if (predCountString != null) {
-                predCount = Integer.parseInt(predCountString);
-            } else if (Boolean.parseBoolean(p.get("hasPredecessor"))) {
-                predCount = 1;
-            } else {
-                predCount = 0;
-            }
             for (InputSlot is : f.getInputSlots()) {
-                Color color;
-                ConnectionStyle style = ConnectionStyle.NORMAL;
-                if (is.getPosition() < predCount) {
-                    color = successorColor;
-                    style = ConnectionStyle.BOLD;
-                } else {
-                    color = usageColor;
-                }
-
-                is.setColor(color);
                 for (Connection c : is.getConnections()) {
-                    if (c.getLabel() == null || !ndf.matcher(c.getLabel()).matches()) {
-                        c.setColor(color);
-                        if (c.getStyle() != ConnectionStyle.DASHED) {
-                            c.setStyle(style);
+                    String type = c.getType();
+                    if (type == "Association" && "EndNode".equals(c.getOutputSlot().getFigure().getProperties().get("class"))) {
+                        type = "Successor";
+                    }
+                    
+                    if (type != null) {
+                        Color typeColor = usageColor.get(type);
+                        if (typeColor == null) {
+                            c.setColor(otherUsageColor);
+                        } else {
+                            c.setColor(typeColor);
                         }
-                    } else if ("EndNode".equals(c.getOutputSlot().getFigure().getProperties().get("class"))
-                            || "EndNode".equals(c.getOutputSlot().getProperties().get("class"))) {
-                        c.setColor(successorColor);
-                        c.setStyle(ConnectionStyle.BOLD);
+                        if (c.getStyle() != ConnectionStyle.DASHED && type == "Successor") {
+                            c.setStyle(ConnectionStyle.BOLD);
+                        }
                     }
                 }
             }
         }
     }
 
-    public Color getUsageColor() {
-        return usageColor;
-    }
-
-    public void setUsageColor(Color usageColor) {
-        this.usageColor = usageColor;
-    }
-
-    public void setMemoryColor(Color memoryColor) {
-        this.memoryColor = memoryColor;
+    public Color getUsageColor(String type) {
+        return usageColor.get(type);
     }
 
-    public Color getMemoryColor() {
-        return memoryColor;
+    public void setUsageColor(String type, Color usageColor) {
+        this.usageColor.put(type, usageColor);
     }
-
-    public Color getSuccessorColor() {
-        return successorColor;
+    
+    public Color getOtherUsageColor() {
+        return otherUsageColor;
     }
-
-    public void setSuccessorColor(Color successorColor) {
-        this.successorColor = successorColor;
+    
+    public void setOtherUsageColor(Color otherUsageColor) {
+        this.otherUsageColor = otherUsageColor;
     }
 }
--- a/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/edgeColor.filter	Fri Jun 20 15:25:07 2014 +0200
+++ b/src/share/tools/IdealGraphVisualizer/Graal/src/com/sun/hotspot/igv/graal/filters/edgeColor.filter	Mon Jun 23 13:13:41 2014 +0200
@@ -1,4 +1,5 @@
 var f = new com.sun.hotspot.igv.graal.filters.GraalEdgeColorFilter();
-f.setUsageColor(blue);
-f.setSuccessorColor(red);
+f.setUsageColor("Successor", red);
+f.setUsageColor("Value", blue);
+f.setUsageColor("Memory", new Color(0.0, 0.5, 0.0));
 f.apply(graph);
--- a/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Connection.java	Fri Jun 20 15:25:07 2014 +0200
+++ b/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Connection.java	Mon Jun 23 13:13:41 2014 +0200
@@ -55,11 +55,13 @@
     private ConnectionStyle style;
     private List<Point> controlPoints;
     private String label;
+    private String type;
 
-    protected Connection(InputSlot inputSlot, OutputSlot outputSlot, String label) {
+    protected Connection(InputSlot inputSlot, OutputSlot outputSlot, String label, String type) {
         this.inputSlot = inputSlot;
         this.outputSlot = outputSlot;
         this.label = label;
+        this.type = type;
         this.inputSlot.connections.add(this);
         this.outputSlot.connections.add(this);
         controlPoints = new ArrayList<>();
@@ -105,6 +107,10 @@
     public String getLabel() {
         return label;
     }
+    
+    public String getType() {
+        return type;
+    }
 
     public void remove() {
         inputSlot.getFigure().removePredecessor(outputSlot.getFigure());
@@ -116,10 +122,12 @@
     public String getToolTipText() {
         StringBuilder builder = new StringBuilder();
         if (label != null) {
-            builder.append(label).append(": from ");
-        } else {
-            builder.append("From ");
+            builder.append(label).append(": ");
         }
+        if (type != null) {
+            builder.append(type).append(" ");
+        }
+        builder.append("from ");
         builder.append(getOutputSlot().getFigure().getSource().getSourceNodes().get(0).getId());
         builder.append(" to ");
         builder.append(getInputSlot().getFigure().getSource().getSourceNodes().get(0).getId());
--- a/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Diagram.java	Fri Jun 20 15:25:07 2014 +0200
+++ b/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Diagram.java	Mon Jun 23 13:13:41 2014 +0200
@@ -82,10 +82,10 @@
         return f;
     }
 
-    public Connection createConnection(InputSlot inputSlot, OutputSlot outputSlot, String label) {
+    public Connection createConnection(InputSlot inputSlot, OutputSlot outputSlot, String label, String type) {
         assert inputSlot.getFigure().getDiagram() == this;
         assert outputSlot.getFigure().getDiagram() == this;
-        return new Connection(inputSlot, outputSlot, label);
+        return new Connection(inputSlot, outputSlot, label, type);
     }
     
     public Map<InputNode, Set<Figure>> calcSourceToFigureRelation() {
@@ -145,7 +145,7 @@
             }
             InputSlot inputSlot = toFigure.getInputSlots().get(toIndex);
 
-            Connection c = d.createConnection(inputSlot, outputSlot, e.getLabel());
+            Connection c = d.createConnection(inputSlot, outputSlot, e.getLabel(), e.getType());
 
             if (e.getState() == InputEdge.State.NEW) {
                 c.setStyle(Connection.ConnectionStyle.BOLD);