changeset 5688:9bb0ba9e8ba6

Adjust loop unroll policy a bit Bailout in case unrolling goes very wrong Add FullUnroll metric In the gate, compile run* methods in product mode, not in fastdebug
author Gilles Duboscq <duboscq@ssw.jku.at>
date Mon, 25 Jun 2012 12:17:58 +0200
parents 5d06e32f10df
children 1d3df3a16940
files graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopPolicies.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopTransformations.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/LoopFullUnrollPhase.java mx/commands.py
diffstat 4 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopPolicies.java	Fri Jun 22 17:27:36 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopPolicies.java	Mon Jun 25 12:17:58 2012 +0200
@@ -44,6 +44,7 @@
         }
         long exactTrips = loop.counted().constantMaxTripCount();
         int maxNodes = Math.min(GraalOptions.FullUnrollMaxNodes, GraalOptions.MaximumDesiredSize - loop.loopBegin().graph().getNodeCount());
-        return loop.size() * exactTrips <= maxNodes;
+        int size = Math.max(1, loop.size() - 1 - loop.loopBegin().phis().count());
+        return size * exactTrips <= maxNodes;
     }
 }
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopTransformations.java	Fri Jun 22 17:27:36 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/loop/LoopTransformations.java	Mon Jun 25 12:17:58 2012 +0200
@@ -23,11 +23,14 @@
 package com.oracle.graal.compiler.loop;
 
 import com.oracle.graal.api.code.*;
+import com.oracle.graal.compiler.*;
 import com.oracle.graal.compiler.phases.*;
 import com.oracle.graal.nodes.*;
 
 
 public abstract class LoopTransformations {
+    private static final int UNROLL_LIMIT = GraalOptions.FullUnrollMaxNodes * 2;
+
     private LoopTransformations() {
         // does not need to be instantiated
     }
@@ -46,12 +49,16 @@
 
     public static void fullUnroll(LoopEx loop, CodeCacheProvider runtime) {
         //assert loop.isCounted(); //TODO (gd) strenghten : counted with known trip count
+        int iterations = 0;
         LoopBeginNode loopBegin = loop.loopBegin();
         StructuredGraph graph = (StructuredGraph) loopBegin.graph();
         while (!loopBegin.isDeleted()) {
             int mark = graph.getMark();
             peel(loop);
             new CanonicalizerPhase(null, runtime, null, mark, null).apply(graph);
+            if (iterations++ > UNROLL_LIMIT || graph.getNodeCount() > GraalOptions.MaximumDesiredSize * 3) {
+                throw new BailoutException("FullUnroll : Graph seems to grow out of proportion");
+            }
         }
     }
 
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/LoopFullUnrollPhase.java	Fri Jun 22 17:27:36 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/LoopFullUnrollPhase.java	Mon Jun 25 12:17:58 2012 +0200
@@ -29,6 +29,7 @@
 
 
 public class LoopFullUnrollPhase extends Phase {
+    private static final DebugMetric FULLY_UNROLLED_LOOPS = Debug.metric("FullUnrolls");
     private final ExtendedRiRuntime runtime;
 
     public LoopFullUnrollPhase(ExtendedRiRuntime runtime) {
@@ -47,6 +48,7 @@
                     if (LoopPolicies.shouldFullUnroll(loop)) {
                         Debug.log("FullUnroll %s", loop);
                         LoopTransformations.fullUnroll(loop, runtime);
+                        FULLY_UNROLLED_LOOPS.increment();
                         Debug.dump(graph, "After fullUnroll %s", loop);
                         peeled = true;
                         break;
--- a/mx/commands.py	Fri Jun 22 17:27:36 2012 +0200
+++ b/mx/commands.py	Mon Jun 25 12:17:58 2012 +0200
@@ -788,7 +788,7 @@
                 _jacoco = 'append'
             
             t = Task('JavaTesterTests:' + vmbuild)
-            jtt([])
+            jtt(['@-XX:CompileCommand=exclude,*::run*'] if vmbuild == 'product'  else [])
             tasks.append(t.stop())
             
             if vmbuild == 'product' and args.jacocout is not None: