# HG changeset patch # User Josef Eisl # Date 1432892811 -7200 # Node ID 098cc00fbe93f73ca35bf93ad92002427ce9ea78 # Parent a9f347ae6f5f129d7488f893782c1aba45d152ec SSAMoveResolver: outsource VirtualStackSlot index calculation. diff -r a9f347ae6f5f -r 098cc00fbe93 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/SSAMoveResolver.java --- 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)) {