changeset 2902:434d71eec7a9

Ensure that only one phase timer is running at one time.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Wed, 08 Jun 2011 17:07:06 +0200
parents d577d07cedec
children eb3a82946429
files graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/IR.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GraphBuilderPhase.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/Phase.java
diffstat 5 files changed, 15 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java	Wed Jun 08 17:01:16 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/GraalOptions.java	Wed Jun 08 17:07:06 2011 +0200
@@ -39,7 +39,7 @@
     // Checkstyle: resume
 
     // inlining settings
-    public static boolean Inline                             = ____;
+    public static boolean Inline                             = true;
     public static int     MaximumInstructionCount            = 37000;
     public static float   MaximumInlineRatio                 = 0.90f;
     public static int     MaximumInlineSize                  = 35;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/IR.java	Wed Jun 08 17:01:16 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/graph/IR.java	Wed Jun 08 17:07:06 2011 +0200
@@ -68,7 +68,7 @@
      * Builds the graph, optimizes it, and computes the linear scan block order.
      */
     public void build() {
-        new GraphBuilderPhase(compilation, compilation.method, false).apply(compilation.graph);
+        new GraphBuilderPhase(compilation, compilation.method, false, false).apply(compilation.graph);
         new DuplicationPhase().apply(compilation.graph);
         new DeadCodeEliminationPhase().apply(compilation.graph);
 
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GraphBuilderPhase.java	Wed Jun 08 17:01:16 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/GraphBuilderPhase.java	Wed Jun 08 17:07:06 2011 +0200
@@ -108,7 +108,8 @@
      * @param ir the IR to build the graph into
      * @param graph
      */
-    public GraphBuilderPhase(GraalCompilation compilation, RiMethod method, boolean createUnwind) {
+    public GraphBuilderPhase(GraalCompilation compilation, RiMethod method, boolean createUnwind, boolean inline) {
+        super(inline ? "Build Inline Graph" : "Build Graph");
         this.compilation = compilation;
 
         this.runtime = compilation.runtime;
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java	Wed Jun 08 17:01:16 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/InliningPhase.java	Wed Jun 08 17:07:06 2011 +0200
@@ -151,7 +151,7 @@
         }
 
         CompilerGraph graph = new CompilerGraph();
-        new GraphBuilderPhase(compilation, method, true).apply(graph);
+        new GraphBuilderPhase(compilation, method, true, true).apply(graph);
 
         boolean withReceiver = !Modifier.isStatic(method.accessFlags());
 
--- a/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/Phase.java	Wed Jun 08 17:01:16 2011 +0200
+++ b/graal/com.oracle.max.graal.compiler/src/com/oracle/max/graal/compiler/phases/Phase.java	Wed Jun 08 17:07:06 2011 +0200
@@ -28,6 +28,7 @@
 public abstract class Phase {
 
     private final String name;
+    private static final ThreadLocal<Phase> currentPhase = new ThreadLocal<Phase>();
 
     public Phase() {
         this.name = this.getClass().getSimpleName();
@@ -42,13 +43,22 @@
 
         int startDeletedNodeCount = graph.getDeletedNodeCount();
         int startNodeCount = graph.getNodeCount();
+        Phase oldCurrentPhase = currentPhase.get();
+        currentPhase.set(this);
         if (GraalOptions.Time) {
+            if (oldCurrentPhase != null) {
+                GraalTimers.get(oldCurrentPhase.getName()).stop();
+            }
             GraalTimers.get(getName()).start();
         }
         run(graph);
         if (GraalOptions.Time) {
             GraalTimers.get(getName()).stop();
+            if (oldCurrentPhase != null) {
+                GraalTimers.get(oldCurrentPhase.getName()).start();
+            }
         }
+        currentPhase.set(oldCurrentPhase);
         int deletedNodeCount = graph.getDeletedNodeCount() - startDeletedNodeCount;
         int nodeCount = graph.getNodeCount() - startNodeCount;