Mercurial > hg > graal-compiler
changeset 3103:6484bdc9b508
IdealGraphVisualizer: ensure that input graphs are scheduled and all nodes are assigned to blocks before computing their difference. This fixes exceptions when creating a diff against a graph without blocks that was never viewed before (for instance, graphs from the server compiler).
author | Peter Hofer <peter.hofer@jku.at> |
---|---|
date | Thu, 30 Jun 2011 16:50:53 +0200 |
parents | 86f83aec58ab |
children | c8bfc73cb21c |
files | src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputGraph.java src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java src/share/tools/IdealGraphVisualizer/Difference/nbproject/project.xml src/share/tools/IdealGraphVisualizer/Difference/src/com/sun/hotspot/igv/difference/Difference.java src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java |
diffstat | 5 files changed, 48 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputGraph.java Thu Jun 30 13:07:09 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputGraph.java Thu Jun 30 16:50:53 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 Thu Jun 30 13:07:09 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java Thu Jun 30 16:50:53 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 Thu Jun 30 13:07:09 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Difference/nbproject/project.xml Thu Jun 30 16:50:53 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 Thu Jun 30 13:07:09 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Difference/src/com/sun/hotspot/igv/difference/Difference.java Thu Jun 30 16:50:53 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/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java Thu Jun 30 13:07:09 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java Thu Jun 30 16:50:53 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); }