changeset 23063:7f4d76ddf97f

TraceRA: get rid of OneSpillStore, SpillInDominator, StoreAtDefinition and replace with single SpillState.SpillStore.
author Josef Eisl <josef.eisl@jku.at>
date Thu, 19 Nov 2015 18:09:53 +0100
parents 731796219d95
children a7c7205bd224
files graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceInterval.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceLinearScanEliminateSpillMovePhase.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceLinearScanWalker.java
diffstat 3 files changed, 19 insertions(+), 50 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceInterval.java	Sun Nov 22 20:56:31 2015 +0100
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceInterval.java	Thu Nov 19 18:09:53 2015 +0100
@@ -266,21 +266,9 @@
         NoSpillStore,
 
         /**
-         * One spill move has already been inserted.
+         * A spill move has already been inserted.
          */
-        OneSpillStore,
-
-        /**
-         * The interval is spilled multiple times or is spilled in a loop. Place the store somewhere
-         * on the dominator path between the definition and the usages.
-         */
-        SpillInDominator,
-
-        /**
-         * The interval should be stored immediately after its definition to prevent multiple
-         * redundant stores.
-         */
-        StoreAtDefinition,
+        SpillStore,
 
         /**
          * The interval starts in memory (e.g. method parameter), so a store is never necessary.
@@ -293,7 +281,7 @@
          */
         NoOptimization;
 
-        public static final EnumSet<SpillState> ALWAYS_IN_MEMORY = EnumSet.of(SpillInDominator, StoreAtDefinition, StartInMemory);
+        public static final EnumSet<SpillState> IN_MEMORY = EnumSet.of(SpillStore, StartInMemory);
     }
 
     /**
@@ -526,7 +514,7 @@
     }
 
     public void setSpillDefinitionPos(int pos) {
-        assert spillState() == SpillState.SpillInDominator || spillState() == SpillState.NoDefinitionFound || spillDefinitionPos() == -1 : "cannot set the position twice";
+        assert spillState() == SpillState.NoDefinitionFound || spillDefinitionPos() == -1 : "cannot set the position twice";
         splitParent().spillDefinitionPos = pos;
     }
 
@@ -535,7 +523,7 @@
      * {@code opId}.
      */
     public boolean inMemoryAt(int opId) {
-        return SpillState.ALWAYS_IN_MEMORY.contains(spillState()) && !canMaterialize() && opId > spillDefinitionPos();
+        return SpillState.IN_MEMORY.contains(spillState()) && !canMaterialize() && opId > spillDefinitionPos();
     }
 
     void removeFirstUsePos() {
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceLinearScanEliminateSpillMovePhase.java	Sun Nov 22 20:56:31 2015 +0100
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceLinearScanEliminateSpillMovePhase.java	Thu Nov 19 18:09:53 2015 +0100
@@ -49,11 +49,11 @@
 
 final class TraceLinearScanEliminateSpillMovePhase extends TraceLinearScanAllocationPhase {
 
-    private static final IntervalPredicate mustStoreAtDefinition = new TraceLinearScan.IntervalPredicate() {
+    private static final IntervalPredicate spilledIntervals = new TraceLinearScan.IntervalPredicate() {
 
         @Override
         public boolean apply(TraceInterval i) {
-            return i.isSplitParent() && i.spillState() == SpillState.StoreAtDefinition;
+            return i.isSplitParent() && SpillState.IN_MEMORY.contains(i.spillState());
         }
     };
 
@@ -77,7 +77,7 @@
              * collect all intervals that must be stored after their definition. The list is sorted
              * by Interval.spillDefinitionPos.
              */
-            TraceInterval interval = allocator.createUnhandledList(mustStoreAtDefinition);
+            TraceInterval interval = allocator.createUnhandledList(spilledIntervals);
             if (DetailedAsserts.getValue()) {
                 checkIntervals(interval);
             }
@@ -128,7 +128,7 @@
                              * interval.
                              */
                             assert interval == TraceInterval.EndMarker || interval.spillDefinitionPos() >= opId : "invalid order";
-                            assert interval == TraceInterval.EndMarker || (interval.isSplitParent() && interval.spillState() == SpillState.StoreAtDefinition) : "invalid interval";
+                            assert interval == TraceInterval.EndMarker || (interval.isSplitParent() && SpillState.IN_MEMORY.contains(interval.spillState())) : "invalid interval";
 
                             while (interval != TraceInterval.EndMarker && interval.spillDefinitionPos() == opId) {
                                 if (!interval.canMaterialize()) {
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceLinearScanWalker.java	Sun Nov 22 20:56:31 2015 +0100
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceLinearScanWalker.java	Thu Nov 19 18:09:53 2015 +0100
@@ -557,39 +557,20 @@
         }
     }
 
-    // called during register allocation
+    /**
+     * Note: called during register allocation
+     *
+     * @param spillPos position of the spill
+     */
+    @SuppressWarnings("static-method")
     private void changeSpillState(TraceInterval interval, int spillPos) {
         if (TraceLinearScan.Options.LIROptTraceRAEliminateSpillMoves.getValue()) {
             switch (interval.spillState()) {
-                case NoSpillStore: {
-                    int defLoopDepth = allocator.blockForId(interval.spillDefinitionPos()).getLoopDepth();
-                    int spillLoopDepth = allocator.blockForId(spillPos).getLoopDepth();
-
-                    if (defLoopDepth < spillLoopDepth) {
-                        /*
-                         * The loop depth of the spilling position is higher then the loop depth at
-                         * the definition of the interval. Move write to memory out of loop.
-                         */
-                        // store at definition of the interval
-                        interval.setSpillState(SpillState.StoreAtDefinition);
-                    } else {
-                        /*
-                         * The interval is currently spilled only once, so for now there is no
-                         * reason to store the interval at the definition.
-                         */
-                        interval.setSpillState(SpillState.OneSpillStore);
-                    }
+                case NoSpillStore:
+                    // It is better to store it to memory at the definition.
+                    interval.setSpillState(SpillState.SpillStore);
                     break;
-                }
-
-                case OneSpillStore: {
-                    // It is better to store it to memory at the definition.
-                    interval.setSpillState(SpillState.StoreAtDefinition);
-                    break;
-                }
-
-                case SpillInDominator:
-                case StoreAtDefinition:
+                case SpillStore:
                 case StartInMemory:
                 case NoOptimization:
                 case NoDefinitionFound: