# HG changeset patch # User Josef Eisl # Date 1444390565 -7200 # Node ID 7b33db06a9517683de14935afb37bd3c36bf2265 # Parent bfb7523ffc03bfbd9fe34a716f75f60b8fb66db4 LinearScan: NeverSpillConstants non-stable and call it only once per compilation. diff -r bfb7523ffc03 -r 7b33db06a951 graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/BackendOptions.java --- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/BackendOptions.java Mon Oct 12 13:53:19 2015 +0200 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/BackendOptions.java Fri Oct 09 13:36:05 2015 +0200 @@ -27,7 +27,6 @@ import jdk.vm.ci.options.Option; import jdk.vm.ci.options.OptionType; import jdk.vm.ci.options.OptionValue; -import jdk.vm.ci.options.StableOptionValue; /** * Options to control the backend configuration. @@ -43,7 +42,7 @@ @Option(help = "Enable experimental Trace Register Allocation.", type = OptionType.Debug) public static final OptionValue TraceRA = new OptionValue<>(false); @Option(help = "Never spill constant intervals.", type = OptionType.Debug) - public static final OptionValue NeverSpillConstants = new StableOptionValue<>(false); + public static final OptionValue NeverSpillConstants = new OptionValue<>(false); // @formatter:on } diff -r bfb7523ffc03 -r 7b33db06a951 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScan.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScan.java Mon Oct 12 13:53:19 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScan.java Fri Oct 09 13:36:05 2015 +0200 @@ -52,6 +52,7 @@ import jdk.vm.ci.options.OptionType; import jdk.vm.ci.options.OptionValue; +import com.oracle.graal.compiler.common.BackendOptions; import com.oracle.graal.compiler.common.alloc.RegisterAllocationConfig; import com.oracle.graal.compiler.common.cfg.AbstractBlockBase; import com.oracle.graal.compiler.common.cfg.BlockMap; @@ -171,6 +172,7 @@ * The {@linkplain #operandNumber(Value) number} of the first variable operand allocated. */ private final int firstVariableNumber; + private final boolean neverSpillConstants; protected LinearScan(TargetDescription target, LIRGenerationResult res, SpillMoveFactory spillMoveFactory, RegisterAllocationConfig regAllocConfig, List> sortedBlocks) { @@ -184,6 +186,7 @@ this.registers = target.arch.getRegisters(); this.firstVariableNumber = getRegisters().length; this.blockData = new BlockMap<>(ir.getControlFlowGraph()); + this.neverSpillConstants = BackendOptions.UserOptions.NeverSpillConstants.getValue(); } public int getFirstLirInstructionId(AbstractBlockBase block) { @@ -915,4 +918,8 @@ return regAllocConfig.getRegisterConfig().areAllAllocatableRegistersCallerSaved(); } + boolean neverSpillConstants() { + return neverSpillConstants; + } + } diff -r bfb7523ffc03 -r 7b33db06a951 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanLifetimeAnalysisPhase.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanLifetimeAnalysisPhase.java Mon Oct 12 13:53:19 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanLifetimeAnalysisPhase.java Fri Oct 09 13:36:05 2015 +0200 @@ -48,7 +48,6 @@ import jdk.vm.ci.meta.LIRKind; import jdk.vm.ci.meta.Value; -import com.oracle.graal.compiler.common.BackendOptions; import com.oracle.graal.compiler.common.alloc.ComputeBlockOrder; import com.oracle.graal.compiler.common.alloc.RegisterAllocationConfig; import com.oracle.graal.compiler.common.cfg.AbstractBlockBase; @@ -826,10 +825,6 @@ } } - protected static Boolean neverSpillConstants() { - return BackendOptions.UserOptions.NeverSpillConstants.getValue(); - } - /** * Returns a value for a interval definition, which can be used for re-materialization. * @@ -840,12 +835,12 @@ * reload-locations in case the interval of this instruction is spilled. Currently this * can only be a {@link JavaConstant}. */ - protected static JavaConstant getMaterializedValue(LIRInstruction op, Value operand, Interval interval) { + protected JavaConstant getMaterializedValue(LIRInstruction op, Value operand, Interval interval) { if (op instanceof LoadConstantOp) { LoadConstantOp move = (LoadConstantOp) op; if (move.getConstant() instanceof JavaConstant) { - if (!neverSpillConstants()) { + if (!allocator.neverSpillConstants()) { /* * Check if the interval has any uses which would accept an stack location * (priority == ShouldHaveRegister). Rematerialization of such intervals can diff -r bfb7523ffc03 -r 7b33db06a951 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceLinearScan.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceLinearScan.java Mon Oct 12 13:53:19 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceLinearScan.java Fri Oct 09 13:36:05 2015 +0200 @@ -172,9 +172,10 @@ private AbstractBlockBase[] opIdToBlockMap; protected final TraceBuilderResult traceBuilderResult; + private final boolean neverSpillConstants; protected TraceLinearScan(TargetDescription target, LIRGenerationResult res, SpillMoveFactory spillMoveFactory, RegisterAllocationConfig regAllocConfig, - List> sortedBlocks, TraceBuilderResult traceBuilderResult) { + List> sortedBlocks, TraceBuilderResult traceBuilderResult, boolean neverSpillConstants) { this.ir = res.getLIR(); this.moveFactory = spillMoveFactory; this.frameMapBuilder = res.getFrameMapBuilder(); @@ -186,6 +187,7 @@ this.fixedIntervals = new FixedInterval[registers.length]; this.blockData = new BlockMap<>(ir.getControlFlowGraph()); this.traceBuilderResult = traceBuilderResult; + this.neverSpillConstants = neverSpillConstants; } public int getFirstLirInstructionId(AbstractBlockBase block) { @@ -987,4 +989,8 @@ return regAllocConfig.getRegisterConfig().areAllAllocatableRegistersCallerSaved(); } + boolean neverSpillConstants() { + return neverSpillConstants; + } + } diff -r bfb7523ffc03 -r 7b33db06a951 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceLinearScanLifetimeAnalysisPhase.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceLinearScanLifetimeAnalysisPhase.java Mon Oct 12 13:53:19 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceLinearScanLifetimeAnalysisPhase.java Fri Oct 09 13:36:05 2015 +0200 @@ -47,7 +47,6 @@ import jdk.vm.ci.meta.LIRKind; import jdk.vm.ci.meta.Value; -import com.oracle.graal.compiler.common.BackendOptions; import com.oracle.graal.compiler.common.alloc.ComputeBlockOrder; import com.oracle.graal.compiler.common.alloc.RegisterAllocationConfig; import com.oracle.graal.compiler.common.alloc.TraceBuilder.TraceBuilderResult; @@ -628,10 +627,6 @@ } } - protected static Boolean neverSpillConstants() { - return BackendOptions.UserOptions.NeverSpillConstants.getValue(); - } - /** * Returns a value for a interval definition, which can be used for re-materialization. * @@ -642,11 +637,11 @@ * all reload-locations in case the interval of this instruction is spilled. * Currently this can only be a {@link JavaConstant}. */ - private static JavaConstant getMaterializedValue(LIRInstruction op, Value operand, TraceInterval interval) { + private JavaConstant getMaterializedValue(LIRInstruction op, Value operand, TraceInterval interval) { if (op instanceof LoadConstantOp) { LoadConstantOp move = (LoadConstantOp) op; if (move.getConstant() instanceof JavaConstant) { - if (!neverSpillConstants()) { + if (!allocator.neverSpillConstants()) { /* * Check if the interval has any uses which would accept an stack location * (priority == ShouldHaveRegister). Rematerialization of such intervals can diff -r bfb7523ffc03 -r 7b33db06a951 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceRegisterAllocationPhase.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceRegisterAllocationPhase.java Mon Oct 12 13:53:19 2015 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/trace/TraceRegisterAllocationPhase.java Fri Oct 09 13:36:05 2015 +0200 @@ -31,6 +31,7 @@ import jdk.vm.ci.options.OptionType; import jdk.vm.ci.options.OptionValue; +import com.oracle.graal.compiler.common.BackendOptions; import com.oracle.graal.compiler.common.alloc.RegisterAllocationConfig; import com.oracle.graal.compiler.common.alloc.TraceBuilder; import com.oracle.graal.compiler.common.alloc.TraceBuilder.TraceBuilderResult; @@ -79,6 +80,7 @@ TraceBuilderResult resultTraces = TraceBuilder.computeTraces(startBlock, linearScanOrder); TraceStatisticsPrinter.printTraceStatistics(resultTraces, lirGenRes.getCompilationUnitName()); + boolean neverSpillConstants = BackendOptions.UserOptions.NeverSpillConstants.getValue(); Debug.dump(lir, "Before TraceRegisterAllocation"); int traceNumber = 0; for (List trace : resultTraces.getTraces()) { @@ -91,7 +93,7 @@ if (Options.TraceRAtrivialBlockAllocator.getValue() && isTrivialTrace(lir, trace)) { new TraceTrivialAllocator(resultTraces).apply(target, lirGenRes, codeEmittingOrder, trace, new TraceAllocationContext(spillMoveFactory, registerAllocationConfig), false); } else { - TraceLinearScan allocator = new TraceLinearScan(target, lirGenRes, spillMoveFactory, registerAllocationConfig, trace, resultTraces); + TraceLinearScan allocator = new TraceLinearScan(target, lirGenRes, spillMoveFactory, registerAllocationConfig, trace, resultTraces, neverSpillConstants); allocator.allocate(target, lirGenRes, codeEmittingOrder, linearScanOrder, spillMoveFactory, registerAllocationConfig); } Debug.dump(TRACE_DUMP_LEVEL, trace, "After Trace" + traceNumber + ": " + trace);