Mercurial > hg > graal-compiler
changeset 2814:31e0786a986c
IdealGraph: fix omittedClasses, put FrameStates, Locals and Phis into the correct blocks
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Mon, 30 May 2011 15:19:26 +0200 |
parents | b003ea36fa12 |
children | 878bbf7dbf31 |
files | graal/GraalCompiler/src/com/sun/c1x/debug/IdealGraphPrinter.java |
diffstat | 1 files changed, 35 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/GraalCompiler/src/com/sun/c1x/debug/IdealGraphPrinter.java Mon May 30 14:55:09 2011 +0200 +++ b/graal/GraalCompiler/src/com/sun/c1x/debug/IdealGraphPrinter.java Mon May 30 15:19:26 2011 +0200 @@ -28,6 +28,7 @@ import com.oracle.graal.graph.*; import com.oracle.max.graal.schedule.*; +import com.sun.c1x.ir.*; /** * Generates a representation of {@link Graph Graphs} that can be visualized and inspected with the <a @@ -125,7 +126,7 @@ stream.println(" <controlFlow>"); for (Block block : schedule.getBlocks()) { - printBlock(block); + printBlock(graph, block); } printNoBlock(); stream.println(" </controlFlow>"); @@ -137,7 +138,7 @@ ArrayList<Edge> edges = new ArrayList<Edge>(); for (Node node : nodes) { - if (node == Node.Null || omittedClasses.contains(node)) { + if (node == Node.Null || omittedClasses.contains(node.getClass())) { continue; } @@ -195,7 +196,7 @@ stream.printf(" <edge from='%d' fromIndex='%d' to='%d' toIndex='%d'/>%n", edge.from, edge.fromIndex, edge.to, edge.toIndex); } - private void printBlock(Block block) { + private void printBlock(Graph graph, Block block) { stream.printf(" <block name='%d'>%n", block.blockID()); stream.printf(" <successors>%n"); for (Block sux : block.getSuccessors()) { @@ -203,8 +204,38 @@ } stream.printf(" </successors>%n"); stream.printf(" <nodes>%n"); + + ArrayList<Node> nodes = new ArrayList<Node>(block.getInstructions()); + // if this is the first block: add all locals to this block + if (nodes.get(0) == graph.start()) { + for (Node node : graph.getNodes()) { + if (node instanceof Local) { + nodes.add(node); + } + } + } + // add all framestates and phis to their blocks for (Node node : block.getInstructions()) { - stream.printf(" <node id='%d'/>%n", node.id()); + if (node instanceof Instruction && ((Instruction) node).stateAfter() != null) { + nodes.add(((Instruction) node).stateAfter()); + } + if (node instanceof Merge) { + Merge merge = (Merge) node; + if (merge.stateBefore() != null) { + nodes.add(merge.stateBefore()); + } + for (Node usage : merge.usages()) { + if (usage instanceof Phi) { + nodes.add(usage); + } + } + } + } + + for (Node node : nodes) { + if (!omittedClasses.contains(node.getClass())) { + stream.printf(" <node id='%d'/>%n", node.id()); + } } stream.printf(" </nodes>%n"); stream.printf(" </block>%n", block.blockID());