diff graal/GraalCompiler/src/com/sun/c1x/C1XCompiler.java @ 2648:d456b679b6de

Add option PrintDOTGraphToFile to produce Graphviz graphs in the DOT language for compiled methods that match PrintFilter
author Peter Hofer <peter.hofer@jku.at>
date Wed, 11 May 2011 14:45:32 +0200
parents 3558ca7088c0
children 6ab73784566a
line wrap: on
line diff
--- a/graal/GraalCompiler/src/com/sun/c1x/C1XCompiler.java	Wed May 11 14:39:56 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/C1XCompiler.java	Wed May 11 14:45:32 2011 +0200
@@ -22,11 +22,8 @@
  */
 package com.sun.c1x;
 
-import java.io.*;
 import java.util.*;
 
-import com.oracle.graal.graph.*;
-import com.oracle.graal.graph.vis.*;
 import com.sun.c1x.debug.*;
 import com.sun.c1x.globalstub.*;
 import com.sun.c1x.observer.*;
@@ -128,46 +125,8 @@
         if (C1XOptions.PrintCFGToFile) {
             addCompilationObserver(new CFGPrinterObserver());
         }
-        String dot = System.getProperty("c1x.dot");
-        if (dot != null && !dot.isEmpty()) {
-            if (!dot.endsWith("$")) {
-                dot = dot + ".*";
-            }
-            if (!dot.startsWith("^")) {
-                dot = ".*" + dot;
-            }
-            final String dotPattern = dot;
-            addCompilationObserver(new CompilationObserver() {
-                private Graph graph;
-                private int n;
-                public void compilationStarted(CompilationEvent event) {
-                    n = 0;
-                }
-                public void compilationFinished(CompilationEvent event) {
-                }
-                public void compilationEvent(CompilationEvent event) {
-                    if (event.getStartBlock() != null) {
-                        graph = event.getStartBlock().graph();
-                        String name = event.getMethod().holder().name();
-                        name = name.substring(1, name.length() - 1).replace('/', '.');
-                        name = name + "." + event.getMethod().name();
-                        if (name.matches(dotPattern)) {
-                            ByteArrayOutputStream out = new ByteArrayOutputStream();
-                            GraphvizPrinter printer = new GraphvizPrinter(out);
-                            printer.begin(name);
-                            printer.print(graph, true);
-                            printer.end();
-
-                            try {
-                                GraphvizRunner.process(GraphvizRunner.DOT_LAYOUT, new ByteArrayInputStream(out.toByteArray()),
-                                                new FileOutputStream(name + "_" + (n++) + event.getLabel() + ".pdf"), "pdf");
-                            } catch (Exception e) {
-                                e.printStackTrace();
-                            }
-                        }
-                    }
-                }
-            });
+        if (C1XOptions.PrintDOTGraphToFile) {
+            addCompilationObserver(new GraphvizPrinterObserver());
         }
     }