Search in sources :

Example 1 with TraceAllocationContext

use of org.graalvm.compiler.lir.alloc.trace.TraceAllocationPhase.TraceAllocationContext in project graal by oracle.

the class TraceRegisterAllocationPhase method run.

@Override
@SuppressWarnings("try")
protected void run(TargetDescription target, LIRGenerationResult lirGenRes, AllocationContext context) {
    MoveFactory spillMoveFactory = context.spillMoveFactory;
    RegisterAllocationConfig registerAllocationConfig = context.registerAllocationConfig;
    LIR lir = lirGenRes.getLIR();
    DebugContext debug = lir.getDebug();
    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());
    try (DebugContext.Scope s0 = debug.scope("AllocateTraces", resultTraces, livenessInfo)) {
        for (Trace trace : resultTraces.getTraces()) {
            tracesCounter.increment(debug);
            TraceAllocationPhase<TraceAllocationContext> allocator = plan.selectStrategy(trace);
            try (Indent i = debug.logAndIndent("Allocating Trace%d: %s (%s)", trace.getId(), trace, allocator);
                DebugContext.Scope s = debug.scope("AllocateTrace", trace)) {
                allocator.apply(target, lirGenRes, trace, traceContext);
            }
        }
    } catch (Throwable e) {
        throw debug.handle(e);
    }
    TraceGlobalMoveResolutionPhase.resolve(target, lirGenRes, traceContext);
    deconstructSSAForm(lir);
}
Also used : Indent(org.graalvm.compiler.debug.Indent) DebugContext(org.graalvm.compiler.debug.DebugContext) TraceAllocationContext(org.graalvm.compiler.lir.alloc.trace.TraceAllocationPhase.TraceAllocationContext) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) Trace(org.graalvm.compiler.core.common.alloc.Trace) LIR(org.graalvm.compiler.lir.LIR) RegisterAllocationConfig(org.graalvm.compiler.core.common.alloc.RegisterAllocationConfig) TraceBuilderResult(org.graalvm.compiler.core.common.alloc.TraceBuilderResult) MoveFactory(org.graalvm.compiler.lir.gen.LIRGeneratorTool.MoveFactory)

Aggregations

AllocatableValue (jdk.vm.ci.meta.AllocatableValue)1 RegisterAllocationConfig (org.graalvm.compiler.core.common.alloc.RegisterAllocationConfig)1 Trace (org.graalvm.compiler.core.common.alloc.Trace)1 TraceBuilderResult (org.graalvm.compiler.core.common.alloc.TraceBuilderResult)1 DebugContext (org.graalvm.compiler.debug.DebugContext)1 Indent (org.graalvm.compiler.debug.Indent)1 LIR (org.graalvm.compiler.lir.LIR)1 TraceAllocationContext (org.graalvm.compiler.lir.alloc.trace.TraceAllocationPhase.TraceAllocationContext)1 MoveFactory (org.graalvm.compiler.lir.gen.LIRGeneratorTool.MoveFactory)1