changeset 2696:c4201554beeb

Merge.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Wed, 18 May 2011 15:05:00 +0200
parents 785e9ecdcc69 (current diff) 79590d6b4a7c (diff)
children bd4c3be86fb7
files graal/GraalCompiler/.classpath graal/GraalRuntime/.classpath runtests.sh
diffstat 4 files changed, 51 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/graal/GraalCompiler/src/com/sun/c1x/debug/GraphvizPrinterObserver.java	Wed May 18 15:03:45 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/debug/GraphvizPrinterObserver.java	Wed May 18 15:05:00 2011 +0200
@@ -23,6 +23,7 @@
 package com.sun.c1x.debug;
 
 import java.io.*;
+import java.util.regex.*;
 
 import com.oracle.graal.graph.*;
 import com.oracle.graal.graph.vis.*;
@@ -38,6 +39,8 @@
  */
 public class GraphvizPrinterObserver implements CompilationObserver {
 
+    private static final Pattern INVALID_CHAR = Pattern.compile("[^A-Za-z0-9_.-]");
+
     private final boolean pdf;
     private int n;
 
@@ -59,11 +62,15 @@
             String name = event.getMethod().holder().name();
             name = name.substring(1, name.length() - 1).replace('/', '.');
             name = name + "." + event.getMethod().name();
+
             String filename = name + "_" + (n++) + "_" + event.getLabel();
+            filename = INVALID_CHAR.matcher(filename).replaceAll("_");
+
+            OutputStream out = null;
             try {
                 if (pdf) {
-                    ByteArrayOutputStream out = new ByteArrayOutputStream();
-                    GraphvizPrinter printer = new GraphvizPrinter(out);
+                    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+                    GraphvizPrinter printer = new GraphvizPrinter(buffer);
                     if (C1XOptions.OmitDOTFrameStates) {
                         printer.addOmittedClass(FrameState.class);
                     }
@@ -71,24 +78,28 @@
                     printer.print(graph, true);
                     printer.end();
 
-                    FileOutputStream output = new FileOutputStream(filename + ".pdf");
-                    GraphvizRunner.process(GraphvizRunner.DOT_LAYOUT, new ByteArrayInputStream(out.toByteArray()), output, "pdf");
-                    output.close();
+                    out = new FileOutputStream(filename + ".pdf");
+                    GraphvizRunner.process(GraphvizRunner.DOT_LAYOUT, new ByteArrayInputStream(buffer.toByteArray()), out, "pdf");
                 } else {
-                    final FileOutputStream stream = new FileOutputStream(filename + ".gv");
+                    out = new FileOutputStream(filename + ".gv");
 
-                    GraphvizPrinter printer = new GraphvizPrinter(stream);
+                    GraphvizPrinter printer = new GraphvizPrinter(out);
                     if (C1XOptions.OmitDOTFrameStates) {
                         printer.addOmittedClass(FrameState.class);
                     }
                     printer.begin(name);
                     printer.print(graph, true);
                     printer.end();
-
-                    stream.close();
                 }
             } catch (IOException e) {
                 e.printStackTrace();
+            } finally {
+                if (out != null) {
+                    try {
+                        out.close();
+                    } catch (IOException e) {
+                    }
+                }
             }
         }
     }
--- a/graal/GraalCompiler/src/com/sun/c1x/debug/IdealGraphPrinter.java	Wed May 18 15:03:45 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/debug/IdealGraphPrinter.java	Wed May 18 15:05:00 2011 +0200
@@ -63,20 +63,33 @@
     }
 
     /**
-     * Starts a new graph document containing a single group of graphs with the given name, short name and byte code
-     * index (BCI) as properties.
+     * Starts a new graph document.
      */
-    public void begin(String name, String shortName, int bci) {
-        stream.println("<graphDocument><group>");
+    public void begin() {
+        stream.println("<graphDocument>");
+    }
+
+    /**
+     * Starts a new group of graphs with the given name, short name and method byte code index (BCI) as properties.
+     */
+    public void beginGroup(String name, String shortName, int bci) {
+        stream.println("<group>");
         stream.printf(" <properties><p name='name'>%s</p></properties>%n", escape(name));
         stream.printf(" <method name='%s' shortName='%s' bci='%d'/>%n", escape(name), escape(shortName), bci);
     }
 
     /**
-     * Finishes the graph document.
+     * Ends the current group.
+     */
+    public void endGroup() {
+        stream.println("</group>");
+    }
+
+    /**
+     * Finishes the graph document and flushes the output stream.
      */
     public void end() {
-        stream.println("</group></graphDocument>");
+        stream.println("</graphDocument>");
         stream.flush();
     }
 
--- a/graal/GraalCompiler/src/com/sun/c1x/debug/IdealGraphPrinterObserver.java	Wed May 18 15:03:45 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/debug/IdealGraphPrinterObserver.java	Wed May 18 15:05:00 2011 +0200
@@ -23,6 +23,7 @@
 package com.sun.c1x.debug;
 
 import java.io.*;
+import java.util.regex.*;
 
 import com.oracle.graal.graph.*;
 import com.sun.c1x.*;
@@ -32,11 +33,13 @@
 /**
  * Observes compilation events and uses {@link IdealGraphPrinter} to generate a graph representation that can be
  * inspected with the <a href="http://kenai.com/projects/igv">Ideal Graph Visualizer</a>.
- * 
+ *
  * @author Peter Hofer
  */
 public class IdealGraphPrinterObserver implements CompilationObserver {
 
+    private static final Pattern INVALID_CHAR = Pattern.compile("[^A-Za-z0-9_.-]");
+
     private IdealGraphPrinter printer;
     private OutputStream stream;
 
@@ -48,7 +51,10 @@
             String name = event.getMethod().holder().name();
             name = name.substring(1, name.length() - 1).replace('/', '.');
             name = name + "." + event.getMethod().name();
+
             String filename = name + ".igv.xml";
+            filename = INVALID_CHAR.matcher(filename).replaceAll("_");
+
             try {
                 stream = new FileOutputStream(filename);
                 printer = new IdealGraphPrinter(stream);
@@ -57,7 +63,8 @@
                     printer.addOmittedClass(FrameState.class);
                 }
 
-                printer.begin(name, name, -1);
+                printer.begin();
+                printer.beginGroup(name, name, -1);
             } catch (IOException e) {
                 e.printStackTrace();
             }
@@ -76,6 +83,7 @@
     public void compilationFinished(CompilationEvent event) {
         if (printer != null) {
             try {
+                printer.endGroup();
                 printer.end();
                 stream.close();
             } catch (IOException e) {
--- a/graal/GraalCompiler/src/com/sun/c1x/value/ValueUtil.java	Wed May 18 15:03:45 2011 +0200
+++ b/graal/GraalCompiler/src/com/sun/c1x/value/ValueUtil.java	Wed May 18 15:05:00 2011 +0200
@@ -23,6 +23,7 @@
 package com.sun.c1x.value;
 
 import com.sun.c1x.ir.*;
+import com.sun.c1x.util.*;
 import com.sun.cri.ci.*;
 
 
@@ -73,7 +74,7 @@
     }
 
     public static boolean typeMismatch(Value x, Value y) {
-        return y == null || x.kind != y.kind;
+        return y == null || !Util.archKindsEqual(x, y);
     }
 
     public static boolean isDoubleWord(Value x) {