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);
}
}
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));
}
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);
}
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();
}
}
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);
}
Aggregations