changeset 5139:ee615aee55b4

Merge.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Wed, 21 Mar 2012 14:32:47 +0100
parents 4d8ebb0fc484 (diff) e1a03c81cef0 (current diff)
children 5f79c8ebc5dc
files
diffstat 14 files changed, 272 insertions(+), 178 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Wed Mar 21 13:05:57 2012 +0100
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Wed Mar 21 14:32:47 2012 +0100
@@ -80,7 +80,7 @@
             throw new CiBailout("No OSR supported");
         }
 
-        return Debug.scope(createScopeName(method), new Object[] {graph, method, this}, new Callable<CiTargetMethod>() {
+        return Debug.scope("GraalCompiler", new Object[] {graph, method, this}, new Callable<CiTargetMethod>() {
             public CiTargetMethod call() {
                 final CiAssumptions assumptions = GraalOptions.OptAssumptions ? new CiAssumptions() : null;
                 final LIR lir = Debug.scope("FrontEnd", new Callable<LIR>() {
@@ -102,23 +102,6 @@
         });
     }
 
-    private static String createScopeName(RiResolvedMethod method) {
-        if (Debug.isEnabled()) {
-            return String.format("[%s::%s]", createSimpleName(method.holder()), method.name());
-        } else {
-            return null;
-        }
-    }
-
-    private static String createSimpleName(RiResolvedType holder) {
-        String base = holder.name();
-        int slashIndex = base.lastIndexOf('/');
-        if (slashIndex == -1) {
-            slashIndex = 0;
-        }
-        return base.substring(slashIndex + 1, base.length() - 1);
-    }
-
     /**
      * Builds the graph, optimizes it.
      */
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalOptions.java	Wed Mar 21 13:05:57 2012 +0100
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalOptions.java	Wed Mar 21 14:32:47 2012 +0100
@@ -107,12 +107,11 @@
     public static boolean PrintLIR                           = ____;
     public static boolean PrintCFGToFile                     = ____;
 
-    // statistics independent from debug mode
-    public static boolean PrintCompilationStatistics         = ____;
-
     // Debug settings:
     public static boolean Debug                              = true;
+    public static boolean PerThreadDebugValues               = ____;
     public static boolean SummarizeDebugValues               = ____;
+    public static boolean SummarizePerPhase                  = ____;
     public static String Dump                                = null;
     public static String Meter                               = null;
     public static String Time                                = null;
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/CanonicalizerPhase.java	Wed Mar 21 13:05:57 2012 +0100
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/CanonicalizerPhase.java	Wed Mar 21 14:32:47 2012 +0100
@@ -33,6 +33,9 @@
 
 public class CanonicalizerPhase extends Phase {
     private static final int MAX_ITERATION_PER_NODE = 10;
+    private static final DebugMetric METRIC_CANONICALIZED_NODES = Debug.metric("CanonicalizedNodes");
+    private static final DebugMetric METRIC_CANONICALIZATION_CONSIDERED_NODES = Debug.metric("CanonicalizationConsideredNodes");
+    private static final DebugMetric METRIC_SIMPLIFICATION_CONSIDERED_NODES = Debug.metric("SimplificationConsideredNodes");
 
     private boolean newNodes;
     private final CiTarget target;
@@ -64,7 +67,9 @@
         graph.trackInputChange(nodeWorkList);
         Tool tool = new Tool(nodeWorkList, runtime, target, assumptions);
         for (Node node : nodeWorkList) {
+            METRIC_PROCESSED_NODES.increment();
             if (node instanceof Canonicalizable) {
+                METRIC_CANONICALIZATION_CONSIDERED_NODES.increment();
                 Debug.log("Canonicalizer: work on %s", node);
                 graph.mark();
                 ValueNode canonical = ((Canonicalizable) node).canonical(tool);
@@ -81,6 +86,7 @@
 //                                         --------------------------------------------
 //       X: must not happen (checked with assertions)
                 if (canonical != node) {
+                    METRIC_CANONICALIZED_NODES.increment();
                     if (node instanceof FloatingNode) {
                         if (canonical == null) {
                             // case 1
@@ -116,6 +122,7 @@
                     nodeWorkList.addAll(graph.getNewNodes());
                 }
             } else if (node instanceof Simplifiable) {
+                METRIC_SIMPLIFICATION_CONSIDERED_NODES.increment();
                 ((Simplifiable) node).simplify(tool);
             }
         }
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/Phase.java	Wed Mar 21 13:05:57 2012 +0100
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/Phase.java	Wed Mar 21 14:32:47 2012 +0100
@@ -28,6 +28,8 @@
 public abstract class Phase {
 
     private String name;
+    private static final DebugMetric metricPhaseRuns = Debug.metric("Runs");
+    protected static final DebugMetric METRIC_PROCESSED_NODES = Debug.metric("ProcessedNodes");
 
     protected Phase() {
         this.name = this.getClass().getSimpleName();
@@ -52,6 +54,7 @@
         Debug.scope(name, this, new Runnable() {
             public void run() {
                 Phase.this.run(graph);
+                metricPhaseRuns.increment();
                 if (dumpGraph) {
                     Debug.dump(graph, "After phase %s", name);
                 }
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java	Wed Mar 21 13:05:57 2012 +0100
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java	Wed Mar 21 14:32:47 2012 +0100
@@ -55,6 +55,22 @@
         return ENABLED && DebugScope.getInstance().isLogEnabled();
     }
 
+    public static Runnable decorateDebugRoot(Runnable runnable, String name, DebugConfig config) {
+        return runnable;
+    }
+
+    public static <T> Callable<T> decorateDebugRoot(Callable<T> callable, String name, DebugConfig config) {
+        return callable;
+    }
+
+    public static Runnable decorateScope(Runnable runnable, String name, Object... context) {
+        return runnable;
+    }
+
+    public static <T> Callable<T> decorateScope(Callable<T> callable, String name, Object... context) {
+        return callable;
+    }
+
     public static void sandbox(String name, Runnable runnable) {
         if (ENABLED) {
             DebugScope.getInstance().scope(name, runnable, null, true, new Object[0]);
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java	Wed Mar 21 13:05:57 2012 +0100
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugScope.java	Wed Mar 21 14:32:47 2012 +0100
@@ -41,7 +41,6 @@
 
     private DebugValueMap valueMap;
     private String qualifiedName;
-    private String name;
 
     private static final char SCOPE_SEP = '.';
 
@@ -67,11 +66,23 @@
     }
 
     private DebugScope(String name, String qualifiedName, DebugScope parent, Object... context) {
-        this.name = name;
         this.parent = parent;
         this.context = context;
         this.qualifiedName = qualifiedName;
         assert context != null;
+
+        if (parent != null) {
+            for (DebugValueMap child : parent.getValueMap().getChildren()) {
+                if (child.getName().equals(name)) {
+                    this.valueMap = child;
+                    return;
+                }
+            }
+            this.valueMap = new DebugValueMap(name);
+            parent.getValueMap().addChild(this.valueMap);
+        } else {
+            this.valueMap = new DebugValueMap(name);
+        }
     }
 
     public boolean isDumpEnabled() {
@@ -123,9 +134,6 @@
         try (TimerCloseable a = scopeTime.start()) {
             return executeScope(runnable, callable);
         } finally {
-            if (!sandbox && newChild.hasValueMap()) {
-                getValueMap().addChild(newChild.getValueMap());
-            }
             newChild.context = null;
             instanceTL.set(oldContext);
             setConfig(oldConfig);
@@ -133,6 +141,7 @@
     }
 
     private <T> T executeScope(Runnable runnable, Callable<T> callable) {
+
         try {
             if (runnable != null) {
                 runnable.run();
@@ -191,16 +200,9 @@
     }
 
     private DebugValueMap getValueMap() {
-        if (valueMap == null) {
-            valueMap = new DebugValueMap(name);
-        }
         return valueMap;
     }
 
-    private boolean hasValueMap() {
-        return valueMap != null;
-    }
-
     long getCurrentValue(int index) {
         return getValueMap().getCurrentValue(index);
     }
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugValue.java	Wed Mar 21 13:05:57 2012 +0100
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugValue.java	Wed Mar 21 14:32:47 2012 +0100
@@ -22,7 +22,7 @@
  */
 package com.oracle.graal.debug.internal;
 
-public class DebugValue {
+public abstract class DebugValue {
 
     private String name;
     private int index;
@@ -59,4 +59,6 @@
     public String getName() {
         return name;
     }
+
+    public abstract String toString(long value);
 }
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugValueMap.java	Wed Mar 21 13:05:57 2012 +0100
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/DebugValueMap.java	Wed Mar 21 14:32:47 2012 +0100
@@ -46,6 +46,12 @@
         return values[index];
     }
 
+    public void clearChildren() {
+        if (children != null) {
+            children.clear();
+        }
+    }
+
     private void ensureSize(int index) {
         if (values == null) {
             values = new long[index + 1];
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/MetricImpl.java	Wed Mar 21 13:05:57 2012 +0100
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/MetricImpl.java	Wed Mar 21 14:32:47 2012 +0100
@@ -39,4 +39,9 @@
             super.addToCurrentValue(value);
         }
     }
+
+    @Override
+    public String toString(long value) {
+        return Long.toString(value);
+    }
 }
--- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/TimerImpl.java	Wed Mar 21 13:05:57 2012 +0100
+++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/internal/TimerImpl.java	Wed Mar 21 14:32:47 2012 +0100
@@ -32,6 +32,8 @@
         }
     };
 
+    private ThreadLocal<Long> valueToSubstract = new ThreadLocal<>();
+
     public TimerImpl(String name) {
         super(name);
     }
@@ -39,16 +41,29 @@
     @Override
     public TimerCloseable start() {
         if (Debug.isTimeEnabled()) {
-            final long startTime = System.currentTimeMillis();
-            return new TimerCloseable() {
+            final long startTime = System.nanoTime();
+            if (valueToSubstract.get() == null) {
+                valueToSubstract.set(0L);
+            }
+            final long previousValueToSubstract = valueToSubstract.get();
+            TimerCloseable result = new TimerCloseable() {
                 @Override
                 public void close() {
-                    long timeSpan = System.currentTimeMillis() - startTime;
-                    TimerImpl.this.addToCurrentValue(timeSpan);
+                    long timeSpan = System.nanoTime() - startTime;
+                    long oldValueToSubstract = valueToSubstract.get();
+                    valueToSubstract.set(timeSpan + previousValueToSubstract);
+                    TimerImpl.this.addToCurrentValue(timeSpan - oldValueToSubstract);
                 }
             };
+            valueToSubstract.set(0L);
+            return result;
         } else {
             return VOID_CLOSEABLE;
         }
     }
+
+    @Override
+    public String toString(long value) {
+        return String.format("%d.%d ms", value / 1000000, (value / 100000) % 10);
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java	Wed Mar 21 14:32:47 2012 +0100
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot;
+
+import java.util.concurrent.*;
+
+import com.oracle.graal.compiler.*;
+import com.oracle.graal.compiler.phases.*;
+import com.oracle.graal.debug.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.max.cri.ci.*;
+import com.oracle.max.cri.ri.*;
+import com.oracle.max.criutils.*;
+
+
+public final class CompilationTask implements Runnable {
+
+    private final Compiler compiler;
+    private final PhasePlan plan;
+    private final RiResolvedMethod method;
+    private final OptimisticOptimizations optimisticOpts;
+
+    public static CompilationTask create(Compiler compiler, PhasePlan plan, OptimisticOptimizations optimisticOpts, RiResolvedMethod method) {
+        return new CompilationTask(compiler, plan, optimisticOpts, method);
+    }
+
+    private CompilationTask(Compiler compiler, PhasePlan plan, OptimisticOptimizations optimisticOpts, RiResolvedMethod method) {
+        this.compiler = compiler;
+        this.plan = plan;
+        this.method = method;
+        this.optimisticOpts = optimisticOpts;
+    }
+
+    public void run() {
+        try {
+            final boolean printCompilation = GraalOptions.PrintCompilation && !TTY.isSuppressed();
+            if (printCompilation) {
+                TTY.println(String.format("Graal %-70s %-45s %-50s ...", method.holder().name(), method.name(), method.signature().asString()));
+            }
+
+            CiTargetMethod result = null;
+            TTY.Filter filter = new TTY.Filter(GraalOptions.PrintFilter, method);
+            try {
+                result = Debug.scope("Compiling", new Callable<CiTargetMethod>() {
+
+                    @Override
+                    public CiTargetMethod call() throws Exception {
+                        StructuredGraph graph = new StructuredGraph(method);
+                        return compiler.getCompiler().compileMethod(method, graph, -1, plan, optimisticOpts);
+                    }
+                });
+            } finally {
+                filter.remove();
+                if (printCompilation) {
+                    TTY.println(String.format("Graal %-70s %-45s %-50s | %4dnodes %5dB", "", "", "", 0, (result != null ? result.targetCodeSize() : -1)));
+                }
+            }
+            compiler.getRuntime().installMethod(method, result);
+        } catch (CiBailout bailout) {
+            Debug.metric("Bailouts").increment();
+            if (GraalOptions.ExitVMOnBailout) {
+                bailout.printStackTrace(TTY.cachedOut);
+                System.exit(-1);
+            }
+        } catch (Throwable t) {
+            if (GraalOptions.ExitVMOnException) {
+                t.printStackTrace(TTY.cachedOut);
+                System.exit(-1);
+            }
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilerThread.java	Wed Mar 21 14:32:47 2012 +0100
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot;
+
+import java.util.concurrent.*;
+
+import com.oracle.graal.compiler.*;
+import com.oracle.graal.debug.*;
+
+
+public final class CompilerThread extends Thread {
+
+    public static final ThreadFactory FACTORY = new ThreadFactory() {
+
+        @Override
+        public Thread newThread(Runnable r) {
+            return new CompilerThread(r);
+        }
+    };
+
+    private CompilerThread(Runnable r) {
+        super(r);
+        this.setName("GraalCompilerThread-" + this.getId());
+        this.setDaemon(true);
+    }
+
+    @Override
+    public void run() {
+        if (GraalOptions.Debug) {
+            Debug.enable();
+            HotSpotDebugConfig hotspotDebugConfig = new HotSpotDebugConfig(GraalOptions.Log, GraalOptions.Meter, GraalOptions.Time, GraalOptions.Dump, GraalOptions.MethodFilter);
+            Debug.setConfig(hotspotDebugConfig);
+        }
+        super.run();
+    }
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Wed Mar 21 13:05:57 2012 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Wed Mar 21 14:32:47 2012 +0100
@@ -114,30 +114,6 @@
     }
 
     public int getArrayOffset(CiKind kind) {
-        return arrayOffsets[getKindNumber(kind)];
-    }
-
-    private static int getKindNumber(CiKind kind) {
-        if (kind == CiKind.Boolean) {
-            return 0;
-        } else if (kind == CiKind.Byte) {
-            return 1;
-        } else if (kind == CiKind.Short) {
-            return 2;
-        } else if (kind == CiKind.Char) {
-            return 3;
-        } else if (kind == CiKind.Int) {
-            return 4;
-        } else if (kind == CiKind.Float) {
-            return 5;
-        } else if (kind == CiKind.Long) {
-            return 6;
-        } else if (kind == CiKind.Double) {
-            return 7;
-        } else if (kind == CiKind.Object) {
-            return 8;
-        } else {
-            throw new RuntimeException(kind + " is not a Java kind");
-        }
+        return arrayOffsets[kind.ordinal()];
     }
 }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java	Wed Mar 21 13:05:57 2012 +0100
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java	Wed Mar 21 14:32:47 2012 +0100
@@ -38,7 +38,6 @@
 import com.oracle.graal.hotspot.server.*;
 import com.oracle.graal.hotspot.snippets.*;
 import com.oracle.graal.java.*;
-import com.oracle.graal.nodes.*;
 import com.oracle.graal.snippets.*;
 import com.oracle.max.cri.ci.*;
 import com.oracle.max.cri.ri.*;
@@ -50,8 +49,6 @@
 public class VMToCompilerImpl implements VMToCompiler, Remote {
 
     private final Compiler compiler;
-    private int compiledMethodCount;
-    private long totalCompilationTime;
     private IntrinsifyArrayCopyPhase intrinsifyArrayCopy;
 
     public final HotSpotTypePrimitive typeBoolean;
@@ -64,33 +61,6 @@
     public final HotSpotTypePrimitive typeLong;
     public final HotSpotTypePrimitive typeVoid;
 
-    ThreadFactory compilerThreadFactory = new ThreadFactory() {
-
-        @Override
-        public Thread newThread(Runnable r) {
-            return new CompilerThread(r);
-        }
-    };
-
-    private final class CompilerThread extends Thread {
-
-        public CompilerThread(Runnable r) {
-            super(r);
-            this.setName("GraalCompilerThread-" + this.getId());
-            this.setDaemon(true);
-        }
-
-        @Override
-        public void run() {
-            if (GraalOptions.Debug) {
-                Debug.enable();
-                HotSpotDebugConfig hotspotDebugConfig = new HotSpotDebugConfig(GraalOptions.Log, GraalOptions.Meter, GraalOptions.Time, GraalOptions.Dump, GraalOptions.MethodFilter);
-                Debug.setConfig(hotspotDebugConfig);
-            }
-            super.run();
-        }
-    }
-
     private ThreadPoolExecutor compileQueue;
 
     public VMToCompilerImpl(Compiler compiler) {
@@ -120,6 +90,7 @@
         final HotSpotRuntime runtime = (HotSpotRuntime) compiler.getCompiler().runtime;
         if (GraalOptions.Intrinsify) {
             Debug.scope("InstallSnippets", new DebugDumpScope("InstallSnippets"), new Runnable() {
+
                 @Override
                 public void run() {
                     VMToCompilerImpl.this.intrinsifyArrayCopy = new IntrinsifyArrayCopyPhase(runtime);
@@ -133,7 +104,7 @@
         }
 
         // Create compilation queue.
-        compileQueue = new ThreadPoolExecutor(GraalOptions.Threads, GraalOptions.Threads, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(), compilerThreadFactory);
+        compileQueue = new ThreadPoolExecutor(GraalOptions.Threads, GraalOptions.Threads, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(), CompilerThread.FACTORY);
 
         // Create queue status printing thread.
         if (GraalOptions.PrintQueue) {
@@ -199,8 +170,6 @@
     }
 
     public void shutdownCompiler() throws Throwable {
-        // compiler.getCompiler().context.print();
-        // TODO (thomaswue): Print context results.
         compileQueue.shutdown();
 
         if (Debug.isEnabled()) {
@@ -209,26 +178,40 @@
             if (debugValues.size() > 0) {
                 if (GraalOptions.SummarizeDebugValues) {
                     printSummary(topLevelMaps, debugValues);
-                } else {
+                } else if (GraalOptions.PerThreadDebugValues) {
                     for (DebugValueMap map : topLevelMaps) {
                         TTY.println("Showing the results for thread: " + map.getName());
                         map.group();
                         map.normalize();
                         printMap(map, debugValues, 0);
                     }
+                } else {
+                    DebugValueMap globalMap = new DebugValueMap("Global");
+                    for (DebugValueMap map : topLevelMaps) {
+                        if (GraalOptions.SummarizePerPhase) {
+                            flattenChildren(map, globalMap);
+                        } else {
+                            for (DebugValueMap child : map.getChildren()) {
+                                globalMap.addChild(child);
+                            }
+                        }
+                    }
+                    if (!GraalOptions.SummarizePerPhase) {
+                        globalMap.group();
+                    }
+                    globalMap.normalize();
+                    printMap(globalMap, debugValues, 0);
                 }
             }
         }
-
-        if (GraalOptions.PrintCompilationStatistics) {
-            printCompilationStatistics();
-        }
     }
 
-    private void printCompilationStatistics() {
-        TTY.println("Accumulated compilation statistics");
-        TTY.println("  Compiled methods         : %d", compiledMethodCount);
-        TTY.println("  Total compilation time   : %6.3f s", totalCompilationTime / Math.pow(10, 9));
+    private void flattenChildren(DebugValueMap map, DebugValueMap globalMap) {
+        globalMap.addChild(map);
+        for (DebugValueMap child : map.getChildren()) {
+            flattenChildren(child, globalMap);
+        }
+        map.clearChildren();
     }
 
     private static void printSummary(List<DebugValueMap> topLevelMaps, List<DebugValue> debugValues) {
@@ -257,16 +240,15 @@
         return total;
     }
 
-
     private static void printMap(DebugValueMap map, List<DebugValue> debugValues, int level) {
 
         printIndent(level);
-        TTY.println(map.getName());
+        TTY.println("%s", map.getName());
         for (DebugValue value : debugValues) {
             long l = map.getCurrentValue(value.getIndex());
             if (l != 0) {
                 printIndent(level + 1);
-                TTY.println(value.getName() + "=" + l);
+                TTY.println(value.getName() + "=" + value.toString(l));
             }
         }
 
@@ -284,79 +266,27 @@
 
     @Override
     public boolean compileMethod(final HotSpotMethodResolved method, final int entryBCI, boolean blocking) throws Throwable {
-        try {
-            if (Thread.currentThread() instanceof CompilerThread) {
-                if (method.holder().name().contains("java/util/concurrent")) {
-                    // This is required to avoid deadlocking a compiler thread. The issue is that a
-                    // java.util.concurrent.BlockingQueue is used to implement the compilation worker
-                    // queues. If a compiler thread triggers a compilation, then it may be blocked trying
-                    // to add something to its own queue.
-                    return false;
-                }
+        if (Thread.currentThread() instanceof CompilerThread) {
+            if (method.holder().name().contains("java/util/concurrent")) {
+                // This is required to avoid deadlocking a compiler thread. The issue is that a
+                // java.util.concurrent.BlockingQueue is used to implement the compilation worker
+                // queues. If a compiler thread triggers a compilation, then it may be blocked trying
+                // to add something to its own queue.
+                return false;
             }
-
-            Runnable runnable = new Runnable() {
-
-                public void run() {
-                    try {
-                        final OptimisticOptimizations optimisticOpts = new OptimisticOptimizations(method);
-                        final PhasePlan plan = createHotSpotSpecificPhasePlan(optimisticOpts);
-                        long startTime = System.nanoTime();
-                        int index = compiledMethodCount++;
-                        final boolean printCompilation = GraalOptions.PrintCompilation && !TTY.isSuppressed();
-                        if (printCompilation) {
-                            TTY.println(String.format("Graal %4d %-70s %-45s %-50s ...", index, method.holder().name(), method.name(), method.signature().asString()));
-                        }
-                        optimisticOpts.log(method);
+        }
 
-                        CiTargetMethod result = null;
-                        TTY.Filter filter = new TTY.Filter(GraalOptions.PrintFilter, method);
-                        long nanoTime;
-                        try {
-                            result = Debug.scope("Compiling", new Callable<CiTargetMethod>() {
-                                @Override
-                                public CiTargetMethod call() throws Exception {
-                                    StructuredGraph graph = new StructuredGraph(method);
-                                    return compiler.getCompiler().compileMethod(method, graph, -1, plan, optimisticOpts);
-                                }
-                            });
-                        } finally {
-                            filter.remove();
-                            nanoTime = System.nanoTime() - startTime;
-                            totalCompilationTime += nanoTime;
-                            if (printCompilation) {
-                                TTY.println(String.format("Graal %4d %-70s %-45s %-50s | %3d.%dms %4dnodes %5dB", index, "", "", "", nanoTime / 1000000, nanoTime % 1000000, 0, (result != null ? result.targetCodeSize()
-                                                : -1)));
-                            }
-                        }
-                        compiler.getRuntime().installMethod(method, result);
-                    } catch (CiBailout bailout) {
-                        Debug.metric("Bailouts").increment();
-                        if (GraalOptions.PrintBailouts || GraalOptions.ExitVMOnBailout) {
-                            TTY.println("WARN: Compilation bailout");
-                            bailout.printStackTrace(TTY.cachedOut);
-
-                            if (GraalOptions.ExitVMOnBailout) {
-                                System.exit(-1);
-                            }
-                        }
-                    } catch (Throwable t) {
-                        if (GraalOptions.ExitVMOnException) {
-                            t.printStackTrace(TTY.cachedOut);
-                            System.exit(-1);
-                        }
-                    }
-                }
-            };
-
-            if (blocking) {
-                runnable.run();
-            } else {
-                compileQueue.execute(runnable);
+        final OptimisticOptimizations optimisticOpts = new OptimisticOptimizations(method);
+        Runnable task = CompilationTask.create(compiler, createHotSpotSpecificPhasePlan(optimisticOpts), optimisticOpts, method);
+        if (blocking) {
+            task.run();
+        } else {
+            try {
+                compileQueue.execute(task);
+            } catch (RejectedExecutionException e) {
+                // The compile queue was already shut down.
+                return false;
             }
-        } catch (RejectedExecutionException e) {
-            // The compile queue was already shut down.
-            return false;
         }
         return true;
     }
@@ -450,6 +380,7 @@
         return CiConstant.forObject(object);
     }
 
+
     private PhasePlan createHotSpotSpecificPhasePlan(OptimisticOptimizations optimisticOpts) {
         PhasePlan phasePlan = new PhasePlan();
         GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(compiler.getRuntime(), GraphBuilderConfiguration.getDefault(), optimisticOpts);