changeset 3109:3664989976e2

Merge
author Gilles Duboscq <gilles.duboscq@oracle.com>
date Fri, 01 Jul 2011 12:57:10 +0200
parents 44b3508a12c8 c8bfc73cb21c
children 883c2f14e7d0 5cdaa94cd622
files
diffstat 8 files changed, 81 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputGraph.java	Fri Jul 01 12:56:52 2011 +0200
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputGraph.java	Fri Jul 01 12:57:10 2011 +0200
@@ -173,7 +173,7 @@
             assert nodes.get(n.getId()) == n;
             if (!scheduledNodes.contains(n)) {
                 if (noBlock == null) {
-                    noBlock = this.addBlock("no block");
+                    noBlock = this.addBlock("(no block)");
                 }
                 noBlock.addNode(n.getId());
             }
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java	Fri Jul 01 12:56:52 2011 +0200
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java	Fri Jul 01 12:57:10 2011 +0200
@@ -221,30 +221,35 @@
 
         @Override
         protected void end(String text) throws SAXException {
+            // NOTE: Some graphs intentionally don't provide blocks. Instead
+            //       they later generate the blocks from other information such
+            //       as node properties (example: ServerCompilerScheduler).
+            //       Thus, we shouldn't assign nodes that don't belong to any
+            //       block to some artificial block below unless blocks are
+            //       defined and nodes are assigned to them.
 
-            // Recover from control flow input with missing information
             if (graph.getBlocks().size() > 0) {
-                boolean blockContainsNodes = false;
+                boolean blocksContainNodes = false;
                 for (InputBlock b : graph.getBlocks()) {
                     if (b.getNodes().size() > 0) {
-                        blockContainsNodes = true;
+                        blocksContainNodes = true;
                         break;
                     }
                 }
 
-                if (!blockContainsNodes) {
+                if (!blocksContainNodes) {
                     graph.clearBlocks();
                     blockConnections.clear();
                 } else {
-                    
+                    // Blocks and their nodes defined: add other nodes to an
+                    //  artificial "no block" block
                     InputBlock noBlock = null;
-                    
                     for (InputNode n : graph.getNodes()) {
                         if (graph.getBlock(n) == null) {
                             if (noBlock == null) {
-                                noBlock = graph.addBlock("none");
+                                noBlock = graph.addBlock("(no block)");
                             }
-                            
+
                             noBlock.addNode(n.getId());
                         }
 
--- a/src/share/tools/IdealGraphVisualizer/Difference/nbproject/project.xml	Fri Jul 01 12:56:52 2011 +0200
+++ b/src/share/tools/IdealGraphVisualizer/Difference/nbproject/project.xml	Fri Jul 01 12:57:10 2011 +0200
@@ -14,6 +14,14 @@
                         <specification-version>1.0</specification-version>
                     </run-dependency>
                 </dependency>
+                <dependency>
+                    <code-name-base>org.openide.util.lookup</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <specification-version>8.6.1</specification-version>
+                    </run-dependency>
+                </dependency>
             </module-dependencies>
             <public-packages>
                 <package>com.sun.hotspot.igv.difference</package>
--- a/src/share/tools/IdealGraphVisualizer/Difference/src/com/sun/hotspot/igv/difference/Difference.java	Fri Jul 01 12:56:52 2011 +0200
+++ b/src/share/tools/IdealGraphVisualizer/Difference/src/com/sun/hotspot/igv/difference/Difference.java	Fri Jul 01 12:57:10 2011 +0200
@@ -31,11 +31,13 @@
 import com.sun.hotspot.igv.data.InputNode;
 import com.sun.hotspot.igv.data.Pair;
 import com.sun.hotspot.igv.data.Property;
+import com.sun.hotspot.igv.data.services.Scheduler;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
+import org.openide.util.Lookup;
 
 /**
  *
@@ -84,7 +86,19 @@
         return createDiff(a, b, pairs);
     }
 
+    private static void ensureScheduled(InputGraph a) {
+        if (a.getBlocks().isEmpty()) {
+            Scheduler s = Lookup.getDefault().lookup(Scheduler.class);
+            a.clearBlocks();
+            s.schedule(a);
+            a.ensureNodesInBlocks();
+        }
+    }
+
     private static InputGraph createDiff(InputGraph a, InputGraph b, Set<NodePair> pairs) {
+        ensureScheduled(a);
+        ensureScheduled(b);
+
         Group g = new Group();
         g.setMethod(a.getGroup().getMethod());
         g.setAssembly(a.getGroup().getAssembly());
@@ -97,7 +111,10 @@
             blocksMap.put(blk, diffblk);
         }
         for (InputBlock blk : b.getBlocks()) {
-            InputBlock diffblk = graph.addBlock(blk.getName());
+            InputBlock diffblk = graph.getBlock(blk.getName());
+            if (diffblk == null) {
+                diffblk = graph.addBlock(blk.getName());
+            }
             blocksMap.put(blk, diffblk);
         }
 
@@ -117,14 +134,16 @@
             inputNodeMap.put(n, n2);
             inputNodeMap.put(nB, n2);
             graph.addNode(n2);
-            graph.setBlock(n2, blocksMap.get(a.getBlock(n)));
+            InputBlock block = blocksMap.get(a.getBlock(n));
+            block.addNode(n2.getId());
             markAsChanged(n2, n, nB);
         }
 
         for (InputNode n : nodesA) {
             InputNode n2 = new InputNode(n);
             graph.addNode(n2);
-            graph.setBlock(n2, blocksMap.get(a.getBlock(n)));
+            InputBlock block = blocksMap.get(a.getBlock(n));
+            block.addNode(n2.getId());
             markAsDeleted(n2);
             inputNodeMap.put(n, n2);
         }
@@ -132,7 +151,7 @@
         int curIndex = 0;
         for (InputNode n : nodesB) {
             InputNode n2 = new InputNode(n);
-            
+
             // Find new ID for node of b, does not change the id property
             while (graph.getNode(curIndex) != null) {
                 curIndex++;
@@ -140,7 +159,8 @@
 
             n2.setId(curIndex);
             graph.addNode(n2);
-            graph.setBlock(n2, blocksMap.get(b.getBlock(n)));
+            InputBlock block = blocksMap.get(b.getBlock(n));
+            block.addNode(n2.getId());
             markAsNew(n2);
             inputNodeMap.put(n, n2);
         }
--- a/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/layer.xml	Fri Jul 01 12:56:52 2011 +0200
+++ b/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/layer.xml	Fri Jul 01 12:57:10 2011 +0200
@@ -18,8 +18,11 @@
             <attr name="position" intvalue="900"/>
         </file>
     </folder>
-    <folder name="Window">
-        <file name="com-sun-hotspot-igv-coordinator-actions-FilterAction.instance"/>
+    
+    <folder name="Actions">
+        <folder name="Window">
+            <file name="com-sun-hotspot-igv-filterwindow-actions-FilterAction.instance"/>
+        </folder>
     </folder>
     <folder name="Menu">
         <folder name="Window">
--- a/src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponent.java	Fri Jul 01 12:56:52 2011 +0200
+++ b/src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponent.java	Fri Jul 01 12:57:10 2011 +0200
@@ -39,6 +39,9 @@
 import java.awt.BorderLayout;
 import java.awt.CardLayout;
 import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
 import java.io.IOException;
@@ -79,7 +82,7 @@
     private CardLayout cardLayout;
     private JPanel cardLayoutPanel;
     private JComboBox sourceCombo;
-    private boolean firstTimeSlider = true;
+    private boolean firstTimeSplitter = true;
     private JPanel textDiffPanel;
 
     private static final String TWO_GRAPHS_TEXT_DIFF = "twoGraphsTextDiff";
@@ -127,9 +130,25 @@
         // Graph difference => show split pane with two graphs.
         splitPane = new JSplitPane();
         leftEditor = new TextEditor();
-        splitPane.setLeftComponent(leftEditor.getComponent());
         rightEditor = new TextEditor();
-        splitPane.setRightComponent(rightEditor.getComponent());
+        // Work around a problem with JSplitPane and the NetBeans editor:
+        // setDividerLocation() doesn't work when the split pane has not been
+        // layouted and painted yet. JSplitPane then initially uses a tiny width
+        // for the left editor component, which causes the editor to calculate
+        // invalid offsets and constantly throw exceptions, particularly on
+        // mouse events. Thus, defer adding the two components and setting the
+        // divider's location.
+        splitPane.addComponentListener(new ComponentAdapter() {
+            @Override
+            public void componentResized(ComponentEvent e) {
+                if (firstTimeSplitter && splitPane.getWidth() > 0) {
+                    splitPane.setLeftComponent(leftEditor.getComponent());
+                    splitPane.setRightComponent(rightEditor.getComponent());
+                    splitPane.setDividerLocation(0.5);
+                    firstTimeSplitter = false;
+                }
+            }
+        });
         cardLayoutPanel.add(splitPane, TWO_GRAPHS);
         
         // Text difference => NetBeans diff view
@@ -262,10 +281,6 @@
             showCard(NO_GRAPH);
         } else if (diagram.getGraph().getSourceGraphs() != null) {
             showCard(TWO_GRAPHS);
-            if (firstTimeSlider) {
-                splitPane.setDividerLocation(0.5);
-            }
-            firstTimeSlider = false;
             Pair<InputGraph, InputGraph> graphs = diagram.getGraph().getSourceGraphs();
             leftEditor.setStructuredText(convert(graphs.getLeft(), diagram));
             rightEditor.setStructuredText(convert(graphs.getRight(), diagram));
@@ -290,8 +305,7 @@
         
     };
 
-    private void updateDiagramProvider(DiagramProvider provider) {
-
+    private void setDiagramProvider(DiagramProvider provider) {
         if (provider == currentDiagramProvider) {
             return;
         }
@@ -321,7 +335,7 @@
             p = LookupHistory.getLast(DiagramProvider.class);
         }
 
-        updateDiagramProvider(p);
+        setDiagramProvider(p);
     }
 
     /** This method is called from within the constructor to
@@ -378,7 +392,7 @@
     public void componentOpened() {
 
         DiagramProvider p = LookupHistory.getLast(DiagramProvider.class);
-        updateDiagramProvider(p);
+        setDiagramProvider(p);
 
         Lookup.Template<DiagramProvider> tpl = new Lookup.Template<DiagramProvider>(DiagramProvider.class);
         result = Utilities.actionsGlobalContext().lookup(tpl);
@@ -389,7 +403,7 @@
     public void componentClosed() {
         result.removeLookupListener(this);
         result = null;
-        updateDiagramProvider(null);
+        setDiagramProvider(null);
     }
 
     /** replaces this in object stream */
--- a/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java	Fri Jul 01 12:56:52 2011 +0200
+++ b/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java	Fri Jul 01 12:57:10 2011 +0200
@@ -212,7 +212,7 @@
             for (InputNode n : graph.getNodes()) {
                 if (graph.getBlock(n) == null) {
                     if (noBlock == null) {
-                        noBlock = graph.addBlock("none");
+                        noBlock = graph.addBlock("(no block)");
                         blocks.add(noBlock);
                     }
                     
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramScene.java	Fri Jul 01 12:56:52 2011 +0200
+++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramScene.java	Fri Jul 01 12:57:10 2011 +0200
@@ -60,6 +60,7 @@
 import java.awt.event.MouseWheelEvent;
 import java.awt.event.MouseWheelListener;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -1141,11 +1142,9 @@
         Rectangle r = w.getBounds();
         Point p = w.getLocation();
         centerRectangle(new Rectangle(p.x, p.y, r.width, r.height));
-
     }
 
     public void gotoFigure(final Figure f) {
-
         if (!isVisible(f)) {
             showFigure(f);
         }
@@ -1153,7 +1152,7 @@
         FigureWidget fw = getWidget(f);
         if (fw != null) {
             centerWidget(fw);
-            getModel().setSelectedNodes(f.getSource().getSourceNodesAsSet());
+            setSelection(Arrays.asList(f));
         }
     }