changeset 15936:94ea3f60a65a

LSRA optimization: split intervals at block boundaries.
author Josef Eisl <josef.eisl@jku.at>
date Mon, 26 May 2014 19:21:55 +0200
parents 705fe382e2da
children e5b1e4babf59
files graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/OptimizingLinearScanWalker.java
diffstat 1 files changed, 28 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/OptimizingLinearScanWalker.java	Mon May 26 16:57:16 2014 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/OptimizingLinearScanWalker.java	Mon May 26 19:21:55 2014 +0200
@@ -78,14 +78,14 @@
                     walkTo(nextBlock);
 
                     try (Scope s1 = Debug.scope("LSRAOptimization")) {
-                        try (Indent indent1 = Debug.logAndIndent("Active intevals:")) {
+                        try (Indent indent1 = Debug.logAndIndent("Active intervals: (block %s [%d])", block, nextBlock)) {
                             for (Interval active = activeLists.get(RegisterBinding.Any); active != Interval.EndMarker; active = active.next) {
                                 Debug.log("active   (any): %s", active);
-                                optimize(block, active);
+                                optimize(nextBlock, block, active, RegisterBinding.Any);
                             }
                             for (Interval active = activeLists.get(RegisterBinding.Stack); active != Interval.EndMarker; active = active.next) {
                                 Debug.log("active (stack): %s", active);
-                                optimize(block, active);
+                                optimize(nextBlock, block, active, RegisterBinding.Stack);
                             }
 
                         }
@@ -96,7 +96,7 @@
         super.walk();
     }
 
-    private void optimize(AbstractBlock<?> currentBlock, Interval currentInterval) {
+    private void optimize(int currentPos, AbstractBlock<?> currentBlock, Interval currentInterval, RegisterBinding binding) {
         // BEGIN initialize and sanity checks
         assert currentBlock != null : "block must not be null";
         assert currentInterval != null : "interval must not be null";
@@ -110,6 +110,11 @@
             return;
         }
 
+        if (currentInterval.from() == currentPos) {
+            // the interval starts at the current position so no need for splitting
+            return;
+        }
+
         // get current location
         AllocatableValue currentLocation = currentInterval.location();
         assert currentLocation != null : "active intervals must have a location assigned!";
@@ -138,6 +143,25 @@
         assert isStackSlot(currentLocation) || isRegister(currentLocation) : "current location not a register or stack slot " + currentLocation;
 
         try (Indent indent = Debug.logAndIndent("location differs: %s vs. %s", predecessorLocation, currentLocation)) {
+            // split current interval at current position
+            Debug.log("splitting at position %d", currentPos);
+
+            assert allocator.isBlockBegin(currentPos) && ((currentPos & 1) == 0) : "split pos must be even when on block boundary";
+
+            Interval splitPart = currentInterval.split(currentPos, allocator);
+
+            assert splitPart.from() >= currentPosition : "cannot append new interval before current walk position";
+            unhandledLists.addToListSortedByStartAndUsePositions(RegisterBinding.Any, splitPart);
+            activeLists.remove(binding, currentInterval);
+
+            // the currentSplitChild is needed later when moves are inserted for reloading
+            assert splitPart.currentSplitChild() == currentInterval : "overwriting wrong currentSplitChild";
+            splitPart.makeCurrentSplitChild();
+
+            if (Debug.isLogEnabled()) {
+                Debug.log("left interval  : %s", currentInterval.logString(allocator));
+                Debug.log("right interval : %s", splitPart.logString(allocator));
+            }
         }
 
     }