Mercurial > hg > truffle
changeset 21327:b8dcf353b822
LinearScan: encapsulate intervals.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Tue, 12 May 2015 12:03:55 +0200 |
parents | 8cef2c3f389b |
children | de17f6676a43 |
files | graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LifetimeAnalysis.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScan.java graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/OptimizeSpillPosition.java |
diffstat | 3 files changed, 20 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LifetimeAnalysis.java Tue May 12 11:55:11 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LifetimeAnalysis.java Tue May 12 12:03:55 2015 +0200 @@ -81,8 +81,7 @@ */ void numberInstructions() { - allocator.intervalsSize = allocator.operandSize(); - allocator.intervals = new Interval[allocator.intervalsSize + (allocator.intervalsSize >> LinearScan.SPLIT_INTERVALS_CAPACITY_RIGHT_SHIFT)]; + allocator.initIntervals(); ValueConsumer setVariableConsumer = (value, mode, flags) -> { if (isVariable(value)) { @@ -712,7 +711,7 @@ * Add the range [0, 1] to all fixed intervals. the register allocator need not handle * unhandled fixed intervals. */ - for (Interval interval : allocator.intervals) { + for (Interval interval : allocator.intervals()) { if (interval != null && isRegister(interval.operand)) { interval.addRange(0, 1); }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScan.java Tue May 12 11:55:11 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScan.java Tue May 12 12:03:55 2015 +0200 @@ -117,26 +117,24 @@ */ final List<? extends AbstractBlockBase<?>> sortedBlocks; - /** - * Map from {@linkplain #operandNumber(Value) operand numbers} to intervals. - */ - Interval[] intervals; + /** @see #intervals() */ + private Interval[] intervals; /** * The number of valid entries in {@link #intervals}. */ - int intervalsSize; + private int intervalsSize; /** * The index of the first entry in {@link #intervals} for a * {@linkplain #createDerivedInterval(Interval) derived interval}. */ - int firstDerivedIntervalIndex = -1; + private int firstDerivedIntervalIndex = -1; /** * Intervals sorted by {@link Interval#from()}. */ - Interval[] sortedIntervals; + private Interval[] sortedIntervals; /** * Map from an instruction {@linkplain LIRInstruction#id id} to the instruction. Entries should @@ -290,6 +288,18 @@ } /** + * Map from {@linkplain #operandNumber(Value) operand numbers} to intervals. + */ + Interval[] intervals() { + return intervals; + } + + void initIntervals() { + intervalsSize = operandSize(); + intervals = new Interval[intervalsSize + (intervalsSize >> SPLIT_INTERVALS_CAPACITY_RIGHT_SHIFT)]; + } + + /** * Creates a new interval. * * @param operand the operand for the interval
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/OptimizeSpillPosition.java Tue May 12 11:55:11 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/OptimizeSpillPosition.java Tue May 12 12:03:55 2015 +0200 @@ -57,7 +57,7 @@ private void optimizeSpillPosition() { LIRInsertionBuffer[] insertionBuffers = new LIRInsertionBuffer[allocator.ir.linearScanOrder().size()]; - for (Interval interval : allocator.intervals) { + for (Interval interval : allocator.intervals()) { if (interval != null && interval.isSplitParent() && interval.spillState() == SpillState.SpillInDominator) { AbstractBlockBase<?> defBlock = allocator.blockForId(interval.spillDefinitionPos()); AbstractBlockBase<?> spillBlock = null;