src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/alloc/trace/TraceRegisterAllocationPhase.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Cdiff src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/alloc/trace/TraceRegisterAllocationPhase.java

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/alloc/trace/TraceRegisterAllocationPhase.java

Print this page

        

*** 34,48 **** import org.graalvm.compiler.lir.LIRInstruction; import org.graalvm.compiler.lir.alloc.trace.TraceAllocationPhase.TraceAllocationContext; import org.graalvm.compiler.lir.gen.LIRGenerationResult; import org.graalvm.compiler.lir.gen.LIRGeneratorTool.MoveFactory; import org.graalvm.compiler.lir.phases.AllocationPhase; ! import org.graalvm.compiler.lir.ssi.SSIUtil; ! import org.graalvm.compiler.lir.ssi.SSIVerifier; import org.graalvm.compiler.options.Option; import org.graalvm.compiler.options.OptionType; - import org.graalvm.compiler.options.StableOptionValue; import jdk.vm.ci.code.TargetDescription; import jdk.vm.ci.meta.AllocatableValue; /** --- 34,47 ---- import org.graalvm.compiler.lir.LIRInstruction; import org.graalvm.compiler.lir.alloc.trace.TraceAllocationPhase.TraceAllocationContext; import org.graalvm.compiler.lir.gen.LIRGenerationResult; import org.graalvm.compiler.lir.gen.LIRGeneratorTool.MoveFactory; import org.graalvm.compiler.lir.phases.AllocationPhase; ! import org.graalvm.compiler.lir.ssa.SSAUtil; import org.graalvm.compiler.options.Option; + import org.graalvm.compiler.options.OptionKey; import org.graalvm.compiler.options.OptionType; import jdk.vm.ci.code.TargetDescription; import jdk.vm.ci.meta.AllocatableValue; /**
*** 53,69 **** public final class TraceRegisterAllocationPhase extends AllocationPhase { public static class Options { // @formatter:off @Option(help = "Use inter-trace register hints.", type = OptionType.Debug) ! public static final StableOptionValue<Boolean> TraceRAuseInterTraceHints = new StableOptionValue<>(true); @Option(help = "Share information about spilled values to other traces.", type = OptionType.Debug) ! public static final StableOptionValue<Boolean> TraceRAshareSpillInformation = new StableOptionValue<>(true); @Option(help = "Reuse spill slots for global move resolution cycle breaking.", type = OptionType.Debug) ! public static final StableOptionValue<Boolean> TraceRAreuseStackSlotsForMoveResolutionCycleBreaking = new StableOptionValue<>(true); @Option(help = "Cache stack slots globally (i.e. a variable always gets the same slot in every trace).", type = OptionType.Debug) ! public static final StableOptionValue<Boolean> TraceRACacheStackSlots = new StableOptionValue<>(true); // @formatter:on } private static final TraceGlobalMoveResolutionPhase TRACE_GLOBAL_MOVE_RESOLUTION_PHASE = new TraceGlobalMoveResolutionPhase(); --- 52,68 ---- public final class TraceRegisterAllocationPhase extends AllocationPhase { public static class Options { // @formatter:off @Option(help = "Use inter-trace register hints.", type = OptionType.Debug) ! public static final OptionKey<Boolean> TraceRAuseInterTraceHints = new OptionKey<>(true); @Option(help = "Share information about spilled values to other traces.", type = OptionType.Debug) ! public static final OptionKey<Boolean> TraceRAshareSpillInformation = new OptionKey<>(true); @Option(help = "Reuse spill slots for global move resolution cycle breaking.", type = OptionType.Debug) ! public static final OptionKey<Boolean> TraceRAreuseStackSlotsForMoveResolutionCycleBreaking = new OptionKey<>(true); @Option(help = "Cache stack slots globally (i.e. a variable always gets the same slot in every trace).", type = OptionType.Debug) ! public static final OptionKey<Boolean> TraceRACacheStackSlots = new OptionKey<>(true); // @formatter:on } private static final TraceGlobalMoveResolutionPhase TRACE_GLOBAL_MOVE_RESOLUTION_PHASE = new TraceGlobalMoveResolutionPhase();
*** 76,99 **** @SuppressWarnings("try") protected void run(TargetDescription target, LIRGenerationResult lirGenRes, AllocationContext context) { MoveFactory spillMoveFactory = context.spillMoveFactory; RegisterAllocationConfig registerAllocationConfig = context.registerAllocationConfig; LIR lir = lirGenRes.getLIR(); - assert SSIVerifier.verify(lir) : "LIR not in SSI form."; TraceBuilderResult resultTraces = context.contextLookup(TraceBuilderResult.class); ! ! TraceAllocationContext traceContext = new TraceAllocationContext(spillMoveFactory, registerAllocationConfig, resultTraces); ! AllocatableValue[] cachedStackSlots = Options.TraceRACacheStackSlots.getValue() ? new AllocatableValue[lir.numVariables()] : null; // currently this is not supported boolean neverSpillConstant = false; ! final TraceRegisterAllocationPolicy plan = DefaultTraceRegisterAllocationPolicy.allocationPolicy(target, lirGenRes, spillMoveFactory, registerAllocationConfig, cachedStackSlots, ! resultTraces, neverSpillConstant); Debug.dump(Debug.INFO_LOG_LEVEL, lir, "Before TraceRegisterAllocation"); ! try (Scope s0 = Debug.scope("AllocateTraces", resultTraces)) { for (Trace trace : resultTraces.getTraces()) { tracesCounter.increment(); TraceAllocationPhase<TraceAllocationContext> allocator = plan.selectStrategy(trace); try (Indent i = Debug.logAndIndent("Allocating Trace%d: %s (%s)", trace.getId(), trace, allocator); Scope s = Debug.scope("AllocateTrace", trace)) { allocator.apply(target, lirGenRes, trace, traceContext); --- 75,98 ---- @SuppressWarnings("try") protected void run(TargetDescription target, LIRGenerationResult lirGenRes, AllocationContext context) { MoveFactory spillMoveFactory = context.spillMoveFactory; RegisterAllocationConfig registerAllocationConfig = context.registerAllocationConfig; LIR lir = lirGenRes.getLIR(); TraceBuilderResult resultTraces = context.contextLookup(TraceBuilderResult.class); ! GlobalLivenessInfo livenessInfo = context.contextLookup(GlobalLivenessInfo.class); ! assert livenessInfo != null; ! TraceAllocationContext traceContext = new TraceAllocationContext(spillMoveFactory, registerAllocationConfig, resultTraces, livenessInfo); ! AllocatableValue[] cachedStackSlots = Options.TraceRACacheStackSlots.getValue(lir.getOptions()) ? new AllocatableValue[lir.numVariables()] : null; // currently this is not supported boolean neverSpillConstant = false; ! final TraceRegisterAllocationPolicy plan = DefaultTraceRegisterAllocationPolicy.allocationPolicy(target, lirGenRes, spillMoveFactory, registerAllocationConfig, cachedStackSlots, resultTraces, ! neverSpillConstant, livenessInfo, lir.getOptions()); Debug.dump(Debug.INFO_LOG_LEVEL, lir, "Before TraceRegisterAllocation"); ! try (Scope s0 = Debug.scope("AllocateTraces", resultTraces, livenessInfo)) { for (Trace trace : resultTraces.getTraces()) { tracesCounter.increment(); TraceAllocationPhase<TraceAllocationContext> allocator = plan.selectStrategy(trace); try (Indent i = Debug.logAndIndent("Allocating Trace%d: %s (%s)", trace.getId(), trace, allocator); Scope s = Debug.scope("AllocateTrace", trace)) { allocator.apply(target, lirGenRes, trace, traceContext);
*** 106,134 **** unnumberInstructions(lir); Debug.dump(Debug.INFO_LOG_LEVEL, lir, "After trace allocation"); } TRACE_GLOBAL_MOVE_RESOLUTION_PHASE.apply(target, lirGenRes, traceContext); ! deconstructSSIForm(lir); } /** ! * Remove Phi/Sigma In/Out. ! * ! * Note: Incoming Values are needed for the RegisterVerifier, otherwise SIGMAs/PHIs where the ! * Out and In value matches (ie. there is no resolution move) are falsely detected as errors. */ ! @SuppressWarnings("try") ! private static void deconstructSSIForm(LIR lir) { for (AbstractBlockBase<?> block : lir.getControlFlowGraph().getBlocks()) { ! try (Indent i = Debug.logAndIndent("Fixup Block %s", block)) { ! if (block.getPredecessorCount() != 0) { ! SSIUtil.removeIncoming(lir, block); ! } else { ! assert lir.getControlFlowGraph().getStartBlock().equals(block); } - SSIUtil.removeOutgoing(lir, block); } } } private static void unnumberInstructions(LIR lir) { --- 105,127 ---- unnumberInstructions(lir); Debug.dump(Debug.INFO_LOG_LEVEL, lir, "After trace allocation"); } TRACE_GLOBAL_MOVE_RESOLUTION_PHASE.apply(target, lirGenRes, traceContext); ! deconstructSSAForm(lir); } /** ! * Remove Phi In/Out. */ ! private static void deconstructSSAForm(LIR lir) { for (AbstractBlockBase<?> block : lir.getControlFlowGraph().getBlocks()) { ! if (SSAUtil.isMerge(block)) { ! SSAUtil.phiIn(lir, block).clearIncomingValues(); ! for (AbstractBlockBase<?> pred : block.getPredecessors()) { ! SSAUtil.phiOut(lir, pred).clearOutgoingValues(); } } } } private static void unnumberInstructions(LIR lir) {
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/alloc/trace/TraceRegisterAllocationPhase.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File