# HG changeset patch # User Josef Eisl # Date 1422713126 -3600 # Node ID d367ad9138f8703e06636d187b7bb3c0dbdda806 # Parent 5b61f60e458f49c80aed9ef5e00541ed5f49fa6b LSStackSlotAllocator: clean up comments and sort methods. diff -r 5b61f60e458f -r d367ad9138f8 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 14:48:27 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/LSStackSlotAllocator.java Sat Jan 31 15:05:26 2015 +0100 @@ -82,7 +82,7 @@ // insert by to this.active = new PriorityQueue<>((a, b) -> a.to() - b.to()); - // number instructions + // step 1: number instructions this.maxOpId = numberInstructions(lir, sortedBlocks); } @@ -90,24 +90,24 @@ Debug.dump(lir, "After StackSlot numbering"); long currentFrameSize = Debug.isMeterEnabled() ? frameMapBuilder.getFrameMap().currentFrameSize() : 0; - // build intervals + // step 2: build intervals try (Scope s = Debug.scope("StackSlotAllocationBuildIntervals"); Indent indent = Debug.logAndIndent("BuildIntervals")) { buildIntervals(); } - // verify intervals + // step 3: verify intervals if (Debug.isEnabled()) { verifyIntervals(); } if (Debug.isDumpEnabled()) { dumpIntervals("Before stack slot allocation"); } - // allocate stack slots + // step 4: allocate stack slots allocateStackSlots(); if (Debug.isDumpEnabled()) { dumpIntervals("After stack slot allocation"); } - // assign stack slots + // step 5: assign stack slots assignStackSlots(); Debug.dump(lir, "After StackSlot assignment"); if (Debug.isMeterEnabled()) { @@ -115,6 +115,10 @@ } } + // ==================== + // step 1: number instructions + // ==================== + /** * Numbers all instructions in all blocks. * @@ -140,20 +144,17 @@ return opId - 2; } - /** - * Gets the highest instruction id allocated by this object. - */ - private int maxOpId() { - return maxOpId; - } + // ==================== + // step 2: build intervals + // ==================== private void buildIntervals() { new FixPointIntervalBuilder(lir, stackSlotMap, maxOpId()).build(); } - private StackInterval get(VirtualStackSlot stackSlot) { - return stackSlotMap[stackSlot.getId()]; - } + // ==================== + // step 3: verify intervals + // ==================== private void verifyIntervals() { forEachInterval(interval -> { @@ -161,27 +162,13 @@ }); } - private void forEachInterval(Consumer proc) { - for (StackInterval interval : stackSlotMap) { - if (interval != null) { - proc.accept(interval); - } - } - } - - private void dumpIntervals(String label) { - Debug.dump(stackSlotMap, label); - } - - private void createUnhandled() { - - // add all intervals to unhandled list - forEachInterval(unhandled::add); - } + // ==================== + // step 4: allocate stack slots + // ==================== private void allocateStackSlots() { - // create interval lists - createUnhandled(); + // create unhandled lists + forEachInterval(unhandled::add); for (StackInterval current = activateNext(); current != null; current = activateNext()) { try (Indent indent = Debug.logAndIndent("allocate %s", current)) { @@ -298,6 +285,10 @@ freeSlot(location); } + // ==================== + // step 5: assign stack slots + // ==================== + private void assignStackSlots() { for (AbstractBlock block : sortedBlocks) { lir.getLIRforBlock(block).forEach(op -> { @@ -326,5 +317,33 @@ } return value; } + + // ==================== + // + // ==================== + + /** + * Gets the highest instruction id allocated by this object. + */ + private int maxOpId() { + return maxOpId; + } + + private StackInterval get(VirtualStackSlot stackSlot) { + return stackSlotMap[stackSlot.getId()]; + } + + private void forEachInterval(Consumer proc) { + for (StackInterval interval : stackSlotMap) { + if (interval != null) { + proc.accept(interval); + } + } + } + + private void dumpIntervals(String label) { + Debug.dump(stackSlotMap, label); + } + } }