Search in sources :

Example 51 with DebugContext

use of org.graalvm.compiler.debug.DebugContext in project graal by oracle.

the class TraceAllocationPhase method apply.

@SuppressWarnings("try")
public final void apply(TargetDescription target, LIRGenerationResult lirGenRes, Trace trace, C context, boolean dumpTrace) {
    DebugContext debug = lirGenRes.getLIR().getDebug();
    try (DebugContext.Scope s = debug.scope(getName(), this)) {
        try (DebugCloseable a = timer.start(debug);
            DebugCloseable c = memUseTracker.start(debug)) {
            if (dumpTrace) {
                if (debug.isDumpEnabled(DebugContext.DETAILED_LEVEL)) {
                    debug.dump(DebugContext.DETAILED_LEVEL, trace, "Before %s (Trace%s: %s)", getName(), trace.getId(), trace);
                }
            }
            run(target, lirGenRes, trace, context);
            allocatedTraces.increment(debug);
            if (dumpTrace) {
                if (debug.isDumpEnabled(DebugContext.VERBOSE_LEVEL)) {
                    debug.dump(DebugContext.VERBOSE_LEVEL, trace, "After %s (Trace%s: %s)", getName(), trace.getId(), trace);
                }
            }
        }
    } catch (Throwable e) {
        throw debug.handle(e);
    }
}
Also used : DebugContext(org.graalvm.compiler.debug.DebugContext) DebugCloseable(org.graalvm.compiler.debug.DebugCloseable)

Example 52 with DebugContext

use of org.graalvm.compiler.debug.DebugContext in project graal by oracle.

the class TraceBuilderPhase method getTraceBuilderResult.

private static TraceBuilderResult getTraceBuilderResult(LIR lir, AbstractBlockBase<?> startBlock, AbstractBlockBase<?>[] linearScanOrder) {
    TraceBuilderResult.TrivialTracePredicate pred = getTrivialTracePredicate(lir);
    OptionValues options = lir.getOptions();
    TraceBuilder selectedTraceBuilder = Options.TraceBuilding.getValue(options);
    DebugContext debug = lir.getDebug();
    debug.log(DebugContext.BASIC_LEVEL, "Building Traces using %s", selectedTraceBuilder);
    switch(Options.TraceBuilding.getValue(options)) {
        case SingleBlock:
            return SingleBlockTraceBuilder.computeTraces(debug, startBlock, linearScanOrder, pred);
        case BiDirectional:
            return BiDirectionalTraceBuilder.computeTraces(debug, startBlock, linearScanOrder, pred);
        case UniDirectional:
            return UniDirectionalTraceBuilder.computeTraces(debug, startBlock, linearScanOrder, pred);
    }
    throw GraalError.shouldNotReachHere("Unknown trace building algorithm: " + Options.TraceBuilding.getValue(options));
}
Also used : OptionValues(org.graalvm.compiler.options.OptionValues) TrivialTracePredicate(org.graalvm.compiler.core.common.alloc.TraceBuilderResult.TrivialTracePredicate) SingleBlockTraceBuilder(org.graalvm.compiler.core.common.alloc.SingleBlockTraceBuilder) UniDirectionalTraceBuilder(org.graalvm.compiler.core.common.alloc.UniDirectionalTraceBuilder) BiDirectionalTraceBuilder(org.graalvm.compiler.core.common.alloc.BiDirectionalTraceBuilder) DebugContext(org.graalvm.compiler.debug.DebugContext) TraceBuilderResult(org.graalvm.compiler.core.common.alloc.TraceBuilderResult)

Example 53 with DebugContext

use of org.graalvm.compiler.debug.DebugContext in project graal by oracle.

the class TraceGlobalMoveResolutionPhase method resolve.

public static void resolve(TargetDescription target, LIRGenerationResult lirGenRes, TraceAllocationContext context) {
    LIR lir = lirGenRes.getLIR();
    DebugContext debug = lir.getDebug();
    debug.dump(DebugContext.VERBOSE_LEVEL, lir, "Before TraceGlobalMoveResultion");
    MoveFactory spillMoveFactory = context.spillMoveFactory;
    resolveGlobalDataFlow(context.resultTraces, lirGenRes, spillMoveFactory, target.arch, context.livenessInfo, context.registerAllocationConfig);
}
Also used : LIR(org.graalvm.compiler.lir.LIR) DebugContext(org.graalvm.compiler.debug.DebugContext) MoveFactory(org.graalvm.compiler.lir.gen.LIRGeneratorTool.MoveFactory)

Example 54 with DebugContext

use of org.graalvm.compiler.debug.DebugContext in project graal by oracle.

the class TraceGlobalMoveResolutionPhase method interTraceEdge.

@SuppressWarnings("try")
private static void interTraceEdge(TraceBuilderResult resultTraces, GlobalLivenessInfo livenessInfo, LIR lir, TraceGlobalMoveResolver moveResolver, AbstractBlockBase<?> fromBlock, AbstractBlockBase<?> toBlock) {
    DebugContext debug = lir.getDebug();
    try (Indent indent0 = debug.logAndIndent("Handle trace edge from %s (Trace%d) to %s (Trace%d)", fromBlock, resultTraces.getTraceForBlock(fromBlock).getId(), toBlock, resultTraces.getTraceForBlock(toBlock).getId())) {
        final ArrayList<LIRInstruction> instructions;
        final int insertIdx;
        if (fromBlock.getSuccessorCount() == 1) {
            instructions = lir.getLIRforBlock(fromBlock);
            insertIdx = instructions.size() - 1;
        } else {
            assert toBlock.getPredecessorCount() == 1;
            instructions = lir.getLIRforBlock(toBlock);
            insertIdx = 1;
        }
        moveResolver.setInsertPosition(instructions, insertIdx);
        resolveEdge(lir, livenessInfo, moveResolver, fromBlock, toBlock);
        moveResolver.resolveAndAppendMoves();
    }
}
Also used : Indent(org.graalvm.compiler.debug.Indent) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 55 with DebugContext

use of org.graalvm.compiler.debug.DebugContext 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

DebugContext (org.graalvm.compiler.debug.DebugContext)234 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)87 OptionValues (org.graalvm.compiler.options.OptionValues)50 Indent (org.graalvm.compiler.debug.Indent)37 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)31 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)29 Test (org.junit.Test)27 Node (org.graalvm.compiler.graph.Node)24 PhaseContext (org.graalvm.compiler.phases.tiers.PhaseContext)24 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)22 LIRInstruction (org.graalvm.compiler.lir.LIRInstruction)20 Scope (org.graalvm.compiler.debug.DebugContext.Scope)18 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)18 DebugDumpScope (org.graalvm.compiler.debug.DebugDumpScope)17 ValueNode (org.graalvm.compiler.nodes.ValueNode)16 FixedNode (org.graalvm.compiler.nodes.FixedNode)14 CompilationResult (org.graalvm.compiler.code.CompilationResult)13 ParameterNode (org.graalvm.compiler.nodes.ParameterNode)13 GraphBuilderConfiguration (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration)12 LIR (org.graalvm.compiler.lir.LIR)11