Commit 952e053b authored by Erik Brangs's avatar Erik Brangs

Move creation of SpillCostEstimators out of ActiveSet.

parent 7dab1955
......@@ -20,7 +20,6 @@ import java.util.Map;
import org.jikesrvm.VM;
import org.jikesrvm.ArchitectureSpecificOpt.PhysicalRegisterSet;
import org.jikesrvm.ArchitectureSpecificOpt.RegisterRestrictions;
import org.jikesrvm.compilers.opt.OptOptions;
import org.jikesrvm.compilers.opt.OptimizingCompilerException;
import org.jikesrvm.compilers.opt.ir.IR;
import org.jikesrvm.compilers.opt.ir.Instruction;
......@@ -58,27 +57,13 @@ final class ActiveSet extends IncreasingEndMappedIntervalSet {
*/
private boolean spilled;
ActiveSet(IR ir, SpillLocationManager sm) {
ActiveSet(IR ir, SpillLocationManager sm, SpillCostEstimator cost) {
super();
spilled = false;
this.ir = ir;
this.regAllocState = ir.MIRInfo.regAllocState;
this.spillManager = sm;
switch (ir.options.REGALLOC_SPILL_COST_ESTIMATE) {
case OptOptions.REGALLOC_SIMPLE_SPILL_COST:
spillCost = new SimpleSpillCost(ir);
break;
case OptOptions.REGALLOC_BRAINDEAD_SPILL_COST:
spillCost = new BrainDeadSpillCost(ir);
break;
case OptOptions.REGALLOC_BLOCK_COUNT_SPILL_COST:
spillCost = new BlockCountSpillCost(ir);
break;
default:
OptimizingCompilerException.UNREACHABLE("unsupported spill cost");
spillCost = null;
}
this.spillCost = cost;
}
boolean spilledSomething() {
......
......@@ -16,6 +16,7 @@ import java.lang.reflect.Constructor;
import org.jikesrvm.ArchitectureSpecificOpt.PhysicalRegisterConstants;
import org.jikesrvm.compilers.opt.OptOptions;
import org.jikesrvm.compilers.opt.OptimizingCompilerException;
import org.jikesrvm.compilers.opt.driver.CompilerPhase;
import org.jikesrvm.compilers.opt.ir.IR;
......@@ -67,9 +68,7 @@ public final class LinearScanPhase extends CompilerPhase
// Create the object that manages spill locations
spillManager = new SpillLocationManager(ir);
// Create an (empty) set of active intervals.
ActiveSet active = new ActiveSet(ir, spillManager);
ir.MIRInfo.linearScanState.active = active;
ActiveSet active = createEmptySetOfActiveIntervals(ir);
// Intervals sorted by increasing start point
for (BasicInterval b : ir.MIRInfo.linearScanState.intervals) {
......@@ -96,4 +95,30 @@ public final class LinearScanPhase extends CompilerPhase
ir.MIRInfo.linearScanState.spilledSomething = true;
}
}
private ActiveSet createEmptySetOfActiveIntervals(IR ir) {
SpillCostEstimator spillCost = determineSpillCostEstimator(ir);
ActiveSet active = new ActiveSet(ir, spillManager, spillCost);
ir.MIRInfo.linearScanState.active = active;
return active;
}
private SpillCostEstimator determineSpillCostEstimator(IR ir) {
SpillCostEstimator spillCost = null;
switch (ir.options.REGALLOC_SPILL_COST_ESTIMATE) {
case OptOptions.REGALLOC_SIMPLE_SPILL_COST:
spillCost = new SimpleSpillCost(ir);
break;
case OptOptions.REGALLOC_BRAINDEAD_SPILL_COST:
spillCost = new BrainDeadSpillCost(ir);
break;
case OptOptions.REGALLOC_BLOCK_COUNT_SPILL_COST:
spillCost = new BlockCountSpillCost(ir);
break;
default:
OptimizingCompilerException.UNREACHABLE("unsupported spill cost");
spillCost = null;
}
return spillCost;
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment