changeset 11487:21738e530332

added metrics for timing front-end, back-end and code installation (GRAAL-448)
author Doug Simon <doug.simon@oracle.com>
date Wed, 28 Aug 2013 22:35:01 +0200
parents 5d5bfb75dae0
children 7ff355e1decd
files graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java
diffstat 2 files changed, 27 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Wed Aug 28 22:34:22 2013 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Wed Aug 28 22:35:01 2013 +0200
@@ -34,6 +34,7 @@
 import com.oracle.graal.compiler.gen.*;
 import com.oracle.graal.compiler.target.*;
 import com.oracle.graal.debug.*;
+import com.oracle.graal.debug.internal.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.asm.*;
 import com.oracle.graal.nodes.*;
@@ -52,6 +53,9 @@
  */
 public class GraalCompiler {
 
+    private static final DebugTimer FrontEnd = Debug.timer("FrontEnd");
+    private static final DebugTimer BackEnd = Debug.timer("BackEnd");
+
     /**
      * Requests compilation of a given graph.
      * 
@@ -62,13 +66,9 @@
      *            argument can be null.
      * @return the result of the compilation
      */
-    public static CompilationResult compileGraph(final StructuredGraph graph, final CallingConvention cc,
-                                                 final ResolvedJavaMethod installedCodeOwner, final GraalCodeCacheProvider runtime,
-                                                 final Replacements replacements, final Backend backend,
-                                                 final TargetDescription target, final GraphCache cache,
-                                                 final PhasePlan plan, final OptimisticOptimizations optimisticOpts,
-                                                 final SpeculationLog speculationLog, final Suites suites,
-                                                 final CompilationResult compilationResult) {
+    public static CompilationResult compileGraph(final StructuredGraph graph, final CallingConvention cc, final ResolvedJavaMethod installedCodeOwner, final GraalCodeCacheProvider runtime,
+                    final Replacements replacements, final Backend backend, final TargetDescription target, final GraphCache cache, final PhasePlan plan, final OptimisticOptimizations optimisticOpts,
+                    final SpeculationLog speculationLog, final Suites suites, final CompilationResult compilationResult) {
         Debug.scope("GraalCompiler", new Object[]{graph, runtime}, new Runnable() {
 
             public void run() {
@@ -76,22 +76,26 @@
                 final LIR lir = Debug.scope("FrontEnd", new Callable<LIR>() {
 
                     public LIR call() {
-                        return emitHIR(runtime, target, graph, replacements, assumptions, cache, plan, optimisticOpts, speculationLog, suites);
+                        try (TimerCloseable a = FrontEnd.start()) {
+                            return emitHIR(runtime, target, graph, replacements, assumptions, cache, plan, optimisticOpts, speculationLog, suites);
+                        }
                     }
                 });
-                final LIRGenerator lirGen = Debug.scope("BackEnd", lir, new Callable<LIRGenerator>() {
+                try (TimerCloseable a = BackEnd.start()) {
+                    final LIRGenerator lirGen = Debug.scope("BackEnd", lir, new Callable<LIRGenerator>() {
 
-                    public LIRGenerator call() {
-                        return emitLIR(backend, target, lir, graph, cc);
-                    }
-                });
-                Debug.scope("CodeGen", lirGen, new Runnable() {
+                        public LIRGenerator call() {
+                            return emitLIR(backend, target, lir, graph, cc);
+                        }
+                    });
+                    Debug.scope("CodeGen", lirGen, new Runnable() {
 
-                    public void run() {
-                        emitCode(backend, getLeafGraphIdArray(graph), assumptions, lirGen, compilationResult, installedCodeOwner);
-                    }
+                        public void run() {
+                            emitCode(backend, getLeafGraphIdArray(graph), assumptions, lirGen, compilationResult, installedCodeOwner);
+                        }
 
-                });
+                    });
+                }
             }
         });
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java	Wed Aug 28 22:34:22 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java	Wed Aug 28 22:35:01 2013 +0200
@@ -113,6 +113,8 @@
      */
     public static final DebugTimer CompilationTime = Debug.timer("CompilationTime");
 
+    public static final DebugTimer CodeInstallationTime = Debug.timer("CodeInstallation");
+
     public void runCompilation() {
         /*
          * no code must be outside this try/finally because it could happen otherwise that
@@ -164,7 +166,9 @@
                 }
             }
 
-            installMethod(result);
+            try (TimerCloseable b = CodeInstallationTime.start()) {
+                installMethod(result);
+            }
             stats.finish(method);
         } catch (BailoutException bailout) {
             Debug.metric("Bailouts").increment();