# HG changeset patch # User Josef Eisl # Date 1422700244 -3600 # Node ID 8e1c9c73ce24538ab4d52d422df450bb8cea2b3f # Parent 09292c24d555eb337942d3655a01a6092efc5c86 LSStackSlotAllocator make SlowIntervalBuilder static. diff -r 09292c24d555 -r 8e1c9c73ce24 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/LSStackSlotAllocator.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/LSStackSlotAllocator.java Sat Jan 31 11:07:15 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/LSStackSlotAllocator.java Sat Jan 31 11:30:44 2015 +0100 @@ -116,17 +116,23 @@ } private void buildIntervalsSlow() { - new SlowIntervalBuilder().build(); + new SlowIntervalBuilder(lir, stackSlotMap, maxOpId()).build(); } /** * Calculates the stack intervals using a worklist-based backwards data-flow analysis. */ - private final class SlowIntervalBuilder { - final BlockMap liveInMap; - final BlockMap liveOutMap; + private static final class SlowIntervalBuilder { + private final BlockMap liveInMap; + private final BlockMap liveOutMap; + private final LIR lir; + private final int maxOpId; + private final StackInterval[] stackSlotMap; - private SlowIntervalBuilder() { + private SlowIntervalBuilder(LIR lir, StackInterval[] stackSlotMap, int maxOpId) { + this.lir = lir; + this.stackSlotMap = stackSlotMap; + this.maxOpId = maxOpId; liveInMap = new BlockMap<>(lir.getControlFlowGraph()); liveOutMap = new BlockMap<>(lir.getControlFlowGraph()); } @@ -137,7 +143,7 @@ worklist.add(lir.getControlFlowGraph().getBlocks().get(i)); } for (AbstractBlock block : lir.getControlFlowGraph().getBlocks()) { - liveInMap.put(block, new BitSet(frameMapBuilder.getNumberOfStackSlots())); + liveInMap.put(block, new BitSet(stackSlotMap.length)); } while (!worklist.isEmpty()) { AbstractBlock block = worklist.poll(); @@ -149,7 +155,7 @@ * Merge outSet with in-set of successors. */ private boolean updateOutBlock(AbstractBlock block) { - BitSet union = new BitSet(frameMapBuilder.getNumberOfStackSlots()); + BitSet union = new BitSet(stackSlotMap.length); block.getSuccessors().forEach(succ -> union.or(liveInMap.get(succ))); BitSet outSet = liveOutMap.get(block); // check if changed @@ -291,11 +297,11 @@ if (flags.contains(OperandFlag.UNINITIALIZED)) { // Stack slot is marked uninitialized so we have to assume it is live all // the time. - if (Debug.isMeterEnabled() && !(interval.from() == 0 && interval.to() == maxOpId())) { + if (Debug.isMeterEnabled() && !(interval.from() == 0 && interval.to() == maxOpId)) { uninitializedSlots.increment(); } interval.addFrom(0); - interval.addTo(maxOpId()); + interval.addTo(maxOpId); } else { interval.addTo(inst.id()); } @@ -307,6 +313,32 @@ } } + + private StackInterval get(VirtualStackSlot stackSlot) { + return stackSlotMap[stackSlot.getId()]; + } + + private void put(VirtualStackSlot stackSlot, StackInterval interval) { + stackSlotMap[stackSlot.getId()] = interval; + } + + private StackInterval getOrCreateInterval(VirtualStackSlot stackSlot) { + StackInterval interval = get(stackSlot); + if (interval == null) { + interval = new StackInterval(stackSlot, stackSlot.getLIRKind()); + put(stackSlot, interval); + } + return interval; + } + + private StackInterval getIntervalFromStackId(int id) { + return stackSlotMap[id]; + } + + } + + private StackInterval get(VirtualStackSlot stackSlot) { + return stackSlotMap[stackSlot.getId()]; } private static int getBlockBegin(List instructions) { @@ -317,27 +349,6 @@ return instructions.get(instructions.size() - 1).id() + 1; } - private StackInterval getOrCreateInterval(VirtualStackSlot stackSlot) { - StackInterval interval = get(stackSlot); - if (interval == null) { - interval = new StackInterval(stackSlot, stackSlot.getLIRKind()); - put(stackSlot, interval); - } - return interval; - } - - private StackInterval get(VirtualStackSlot stackSlot) { - return stackSlotMap[stackSlot.getId()]; - } - - private StackInterval getIntervalFromStackId(int id) { - return stackSlotMap[id]; - } - - private void put(VirtualStackSlot stackSlot, StackInterval interval) { - stackSlotMap[stackSlot.getId()] = interval; - } - private void verifyIntervals() { forEachInterval(interval -> { assert interval.verify(maxOpId());