changeset 21593:098cc00fbe93

SSAMoveResolver: outsource VirtualStackSlot index calculation.
author Josef Eisl <josef.eisl@jku.at>
date Fri, 29 May 2015 11:46:51 +0200
parents a9f347ae6f5f
children cc9e15bbbd3c
files graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/SSAMoveResolver.java
diffstat 1 files changed, 15 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/SSAMoveResolver.java	Fri May 29 11:33:47 2015 +0200
+++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/SSAMoveResolver.java	Fri May 29 11:46:51 2015 +0200
@@ -22,22 +22,24 @@
  */
 package com.oracle.graal.lir.alloc.lsra;
 
-import com.oracle.jvmci.meta.Value;
-import com.oracle.jvmci.meta.AllocatableValue;
 import static com.oracle.jvmci.code.ValueUtil.*;
 
 import java.util.*;
 
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.framemap.*;
+import com.oracle.jvmci.code.*;
+import com.oracle.jvmci.meta.*;
 
 final class SSAMoveResolver extends MoveResolver {
 
     private int[] stackBlocked;
+    private final int firstVirtualStackIndex;
 
     SSAMoveResolver(LinearScan allocator) {
         super(allocator);
         this.stackBlocked = new int[((FrameMapBuilderTool) allocator.frameMapBuilder).getNumberOfStackSlots()];
+        this.firstVirtualStackIndex = 0;
     }
 
     @Override
@@ -78,14 +80,12 @@
     protected void setValueBlocked(Value location, int direction) {
         assert direction == 1 || direction == -1 : "out of bounds";
         if (isVirtualStackSlot(location)) {
-            assert LinearScanPhase.SSA_LSRA.getValue() : "should only happen if SSA LSRA is used!";
-            int stack = asVirtualStackSlot(location).getId();
-            if (stack >= stackBlocked.length) {
-                stackBlocked = Arrays.copyOf(stackBlocked, stack + 1);
+            int stackIdx = getStackArrayIndex(asVirtualStackSlot(location));
+            if (stackIdx >= stackBlocked.length) {
+                stackBlocked = Arrays.copyOf(stackBlocked, stackIdx + 1);
             }
-            stackBlocked[stack] += direction;
+            stackBlocked[stackIdx] += direction;
         } else if (isStackSlot(location)) {
-            assert LinearScanPhase.SSA_LSRA.getValue() : "should only happen if SSA LSRA is used!";
             assert asStackSlot(location).isInCallerFrame() : "Unexpected stack slot: " + location;
             // incoming stack arguments can be ignored
         } else {
@@ -96,15 +96,13 @@
     @Override
     protected int valueBlocked(Value location) {
         if (isVirtualStackSlot(location)) {
-            assert LinearScanPhase.SSA_LSRA.getValue() : "should only happen if SSA LSRA is used!";
-            int stack = asVirtualStackSlot(location).getId();
-            if (stack >= stackBlocked.length) {
+            int stackIdx = getStackArrayIndex(asVirtualStackSlot(location));
+            if (stackIdx >= stackBlocked.length) {
                 return 0;
             }
-            return stackBlocked[stack];
+            return stackBlocked[stackIdx];
         }
         if (isStackSlot(location)) {
-            assert LinearScanPhase.SSA_LSRA.getValue() : "should only happen if SSA LSRA is used!";
             assert asStackSlot(location).isInCallerFrame() : "Unexpected stack slot: " + location;
             // incoming stack arguments are always blocked (aka they can not be written)
             return 1;
@@ -112,6 +110,10 @@
         return super.valueBlocked(location);
     }
 
+    private int getStackArrayIndex(VirtualStackSlot virtualStackSlot) {
+        return firstVirtualStackIndex + virtualStackSlot.getId();
+    }
+
     @Override
     protected LIRInstruction createMove(AllocatableValue fromOpr, AllocatableValue toOpr, AllocatableValue fromLocation, AllocatableValue toLocation) {
         if (isStackSlotValue(toLocation) && isStackSlotValue(fromLocation)) {