# HG changeset patch # User Gilles Duboscq # Date 1309517830 -7200 # Node ID 3664989976e2aee48278b4928a43893e3df714a9 # Parent 44b3508a12c8a23c95bb740150193928f0f81504# Parent c8bfc73cb21c5f6893adb728a766f0749ca7e4b6 Merge diff -r 44b3508a12c8 -r 3664989976e2 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputGraph.java --- 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()); } diff -r 44b3508a12c8 -r 3664989976e2 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java --- 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()); } diff -r 44b3508a12c8 -r 3664989976e2 src/share/tools/IdealGraphVisualizer/Difference/nbproject/project.xml --- 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 @@ 1.0 + + org.openide.util.lookup + + + + 8.6.1 + + com.sun.hotspot.igv.difference diff -r 44b3508a12c8 -r 3664989976e2 src/share/tools/IdealGraphVisualizer/Difference/src/com/sun/hotspot/igv/difference/Difference.java --- 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 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); } diff -r 44b3508a12c8 -r 3664989976e2 src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/layer.xml --- 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 @@ - - + + + + + diff -r 44b3508a12c8 -r 3664989976e2 src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponent.java --- 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 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 tpl = new Lookup.Template(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 */ diff -r 44b3508a12c8 -r 3664989976e2 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 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); } diff -r 44b3508a12c8 -r 3664989976e2 src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramScene.java --- 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)); } }