# HG changeset patch # User Gilles Duboscq # Date 1309273725 -7200 # Node ID 05dcd49a2df2522b263931a3b24534167020f5dc # Parent 25b5ec0568e61ac73c35878971e05b7c0d7e7bce Added -G:+PlotOnError option to print graph to IGV even without -G:+Plot on error condition (verification failure or AssertionError/RuntimeException in a Phase) diff -r 25b5ec0568e6 -r 05dcd49a2df2 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompiler.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompiler.java Tue Jun 28 16:45:48 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalCompiler.java Tue Jun 28 17:08:45 2011 +0200 @@ -72,7 +72,7 @@ Graph.verificationListeners.add(new VerificationListener() { @Override public void verificationFailed(Node n, String message) { - GraalCompiler.this.fireCompilationEvent(new CompilationEvent(currentCompilation, "Verification Error on Node " + n.id(), currentCompilation.graph, true, false)); + GraalCompiler.this.fireCompilationEvent(new CompilationEvent(currentCompilation, "Verification Error on Node " + n.id(), currentCompilation.graph, true, false, true)); for (Node p : n.predecessors()) { TTY.println("predecessor: " + p); } @@ -142,7 +142,7 @@ if (GraalOptions.PrintDOTGraphToPdf) { addCompilationObserver(new GraphvizPrinterObserver(true)); } - if (GraalOptions.PrintIdealGraphLevel != 0 || GraalOptions.Plot) { + if (GraalOptions.PrintIdealGraphLevel != 0 || GraalOptions.Plot || GraalOptions.PlotOnError) { CompilationObserver observer; if (GraalOptions.PrintIdealGraphFile) { observer = new IdealGraphPrinterObserver(); diff -r 25b5ec0568e6 -r 05dcd49a2df2 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java Tue Jun 28 16:45:48 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java Tue Jun 28 17:08:45 2011 +0200 @@ -80,6 +80,7 @@ // Ideal graph visualizer output settings public static boolean Plot = ____; + public static boolean PlotOnError = ____; public static int PrintIdealGraphLevel = 0; public static boolean PrintIdealGraphFile = ____; public static String PrintIdealGraphAddress = "127.0.0.1"; diff -r 25b5ec0568e6 -r 05dcd49a2df2 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinter.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinter.java Tue Jun 28 16:45:48 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinter.java Tue Jun 28 17:08:45 2011 +0200 @@ -128,7 +128,12 @@ // nothing to do here... //t.printStackTrace(); } - List loops = LoopUtil.computeLoops(graph); + List loops = null; + try { + LoopUtil.computeLoops(graph); + } catch (Throwable t) { + + } stream.println(" "); List edges = printNodes(graph, shortNames, schedule == null ? null : schedule.getNodeToBlock(), loops, debugObjects); @@ -156,8 +161,10 @@ private List printNodes(Graph graph, boolean shortNames, NodeMap nodeToBlock, List loops, Map debugObjects) { ArrayList edges = new ArrayList(); NodeBitMap loopExits = graph.createNodeBitMap(); - for (Loop loop : loops) { - loopExits.setUnion(loop.exits()); + if (loops != null) { + for (Loop loop : loops) { + loopExits.setUnion(loop.exits()); + } } Map>> colors = new HashMap>>(); @@ -232,12 +239,14 @@ stream.printf("

true

%n"); } StringBuilder sb = new StringBuilder(); - for (Loop loop : loops) { - if (loop.nodes().isMarked(node)) { - if (sb.length() > 0) { - sb.append(", "); + if (loops != null) { + for (Loop loop : loops) { + if (loop.nodes().isMarked(node)) { + if (sb.length() > 0) { + sb.append(", "); + } + sb.append(loop.loopBegin().id()); } - sb.append(loop.loopBegin().id()); } } if (sb.length() > 0) { diff -r 25b5ec0568e6 -r 05dcd49a2df2 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinterObserver.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinterObserver.java Tue Jun 28 16:45:48 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/debug/IdealGraphPrinterObserver.java Tue Jun 28 17:08:45 2011 +0200 @@ -67,7 +67,7 @@ public void compilationStarted(CompilationEvent event) { assert (stream == null && printer == null); - if (!TTY.isSuppressed()) { + if ((!TTY.isSuppressed() && GraalOptions.Plot) || (GraalOptions.PlotOnError && event.isErrorEvent())) { String name = event.getMethod().holder().name(); name = name.substring(1, name.length() - 1).replace('/', '.'); name = name + "." + event.getMethod().name(); @@ -140,6 +140,9 @@ @Override public void compilationEvent(CompilationEvent event) { + if (printer == null && event.isErrorEvent()) { + this.compilationStarted(event); // lazy start + } if (printer != null && event.getGraph() != null && event.isHIRValid()) { Graph graph = event.getGraph(); printer.print(graph, event.getLabel(), true, event.getDebugObjects()); diff -r 25b5ec0568e6 -r 05dcd49a2df2 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/observer/CompilationEvent.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/observer/CompilationEvent.java Tue Jun 28 16:45:48 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/observer/CompilationEvent.java Tue Jun 28 17:08:45 2011 +0200 @@ -52,11 +52,12 @@ private CiTargetMethod targetMethod; private boolean hirValid = false; private boolean lirValid = false; + private boolean errorEvent; + private Map debugObjects; private Interval[] intervals; private int intervalsSize; private Interval[] intervalsCopy = null; - Map debugObjects; public CompilationEvent(GraalCompilation compilation) { this(compilation, null); @@ -69,18 +70,23 @@ } public CompilationEvent(GraalCompilation compilation, String label, Graph graph, boolean hirValid, boolean lirValid) { - this(compilation, label); - this.graph = graph; - this.hirValid = hirValid; - this.lirValid = lirValid; + this(compilation, label, graph, hirValid, lirValid, false, (Map) null); + } + public CompilationEvent(GraalCompilation compilation, String label, Graph graph, boolean hirValid, boolean lirValid, boolean error) { + this(compilation, label, graph, hirValid, lirValid, error, (Map) null); } public CompilationEvent(GraalCompilation compilation, String label, Graph graph, boolean hirValid, boolean lirValid, Map debugObjects) { + this(compilation, label, graph, hirValid, lirValid, false, debugObjects); + } + + public CompilationEvent(GraalCompilation compilation, String label, Graph graph, boolean hirValid, boolean lirValid, boolean error, Map debugObjects) { this(compilation, label); this.graph = graph; this.hirValid = hirValid; this.lirValid = lirValid; this.debugObjects = debugObjects; + this.errorEvent = error; } public CompilationEvent(GraalCompilation compilation, String label, Graph graph, boolean hirValid, boolean lirValid, CiTargetMethod targetMethod) { @@ -137,6 +143,10 @@ return lirValid; } + public boolean isErrorEvent() { + return errorEvent; + } + public Interval[] getIntervals() { if (intervalsCopy == null && intervals != null) { // deferred copy of the valid range of the intervals array diff -r 25b5ec0568e6 -r 05dcd49a2df2 graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/Phase.java --- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/Phase.java Tue Jun 28 16:45:48 2011 +0200 +++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/Phase.java Tue Jun 28 17:08:45 2011 +0200 @@ -62,7 +62,21 @@ GraalTimers.get(getName()).start(); } //System.out.println("Starting Phase " + getName()); - run(graph); + try { + run(graph); + } catch (AssertionError t) { + GraalCompilation compilation = GraalCompilation.compilation(); + if (compilation.compiler.isObserved() && this.getClass() != IdentifyBlocksPhase.class) { + compilation.compiler.fireCompilationEvent(new CompilationEvent(compilation, "AssertionError in " + getName(), graph, true, false, true)); + } + throw t; + } catch (RuntimeException t) { + GraalCompilation compilation = GraalCompilation.compilation(); + if (compilation.compiler.isObserved() && this.getClass() != IdentifyBlocksPhase.class) { + compilation.compiler.fireCompilationEvent(new CompilationEvent(compilation, "RuntimeException in " + getName(), graph, true, false, true)); + } + throw t; + } //System.out.println("Finished Phase " + getName()); if (GraalOptions.Time) { GraalTimers.get(getName()).stop();