# HG changeset patch # User Josef Eisl # Date 1401124915 -7200 # Node ID 94ea3f60a65aa08b986b0b30a7f21e7119b740fe # Parent 705fe382e2da9f508d86b3f66f4c8a24254e2a00 LSRA optimization: split intervals at block boundaries. diff -r 705fe382e2da -r 94ea3f60a65a graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/OptimizingLinearScanWalker.java --- 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)); + } } }