# HG changeset patch # User Josef Eisl # Date 1422698486 -3600 # Node ID 613a2b7f88c31d4a17130ffab454b4bdc787a6ce # Parent 5447a27a6fd7171cdfd2bbae25d94cb2daf516ab InstructionNumberer: make opIdToInstructionMap and opIdToBlockMap final. diff -r 5447a27a6fd7 -r 613a2b7f88c3 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/InstructionNumberer.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/InstructionNumberer.java Fri Jan 30 15:39:59 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/InstructionNumberer.java Sat Jan 31 11:01:26 2015 +0100 @@ -31,12 +31,24 @@ public class InstructionNumberer { - private LIRInstruction[] opIdToInstructionMap; - private AbstractBlock[] opIdToBlockMap; + private final LIRInstruction[] opIdToInstructionMap; + private final AbstractBlock[] opIdToBlockMap; + + protected InstructionNumberer(LIR lir) { + // Assign IDs to LIR nodes and build a mapping, lirOps, from ID to LIRInstruction node. + int numInstructions = 0; + for (AbstractBlock block : lir.getControlFlowGraph().getBlocks()) { + numInstructions += lir.getLIRforBlock(block).size(); + } + + // initialize with correct length + opIdToInstructionMap = new LIRInstruction[numInstructions]; + opIdToBlockMap = new AbstractBlock[numInstructions]; + } /** * Converts an {@linkplain LIRInstruction#id instruction id} to an instruction index. All LIR - * instructions in a method have an index one greater than their linear-scan order predecesor + * instructions in a method have an index one greater than their linear-scan order predecessor * with the first instruction having an index of 0. */ private static int opIdToIndex(int opId) { @@ -61,16 +73,6 @@ */ protected void numberInstructions(LIR lir, List> sortedBlocks) { - // Assign IDs to LIR nodes and build a mapping, lirOps, from ID to LIRInstruction node. - int numInstructions = 0; - for (AbstractBlock block : sortedBlocks) { - numInstructions += lir.getLIRforBlock(block).size(); - } - - // initialize with correct length - opIdToInstructionMap = new LIRInstruction[numInstructions]; - opIdToBlockMap = new AbstractBlock[numInstructions]; - int opId = 0; int index = 0; for (AbstractBlock block : sortedBlocks) { @@ -90,8 +92,9 @@ opId += 2; // numbering of lirOps by two } } - assert index == numInstructions : "must match"; + assert index == opIdToBlockMap.length : "must match"; assert (index << 1) == opId : "must match: " + (index << 1); + assert opId - 2 == maxOpId() : "must match"; } /** diff -r 5447a27a6fd7 -r 613a2b7f88c3 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 Fri Jan 30 15:39:59 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/LSStackSlotAllocator.java Sat Jan 31 11:01:26 2015 +0100 @@ -77,6 +77,7 @@ private List> sortedBlocks; private Allocator(LIR lir, FrameMapBuilderTool frameMapBuilder) { + super(lir); this.lir = lir; this.frameMapBuilder = frameMapBuilder; this.stackSlotMap = new StackInterval[frameMapBuilder.getNumberOfStackSlots()];