use of org.graalvm.compiler.lir.LIR in project graal by oracle.
the class AMD64HotSpotLIRGenerator method beforeRegisterAllocation.
@Override
public void beforeRegisterAllocation() {
super.beforeRegisterAllocation();
boolean hasDebugInfo = getResult().getLIR().hasDebugInfo();
AllocatableValue savedRbp = saveRbp.finalize(hasDebugInfo);
if (hasDebugInfo) {
getResult().setDeoptimizationRescueSlot(((AMD64FrameMapBuilder) getResult().getFrameMapBuilder()).allocateDeoptimizationRescueSlot());
}
getResult().setMaxInterpreterFrameSize(debugInfoBuilder.maxInterpreterFrameSize());
for (AMD64HotSpotRestoreRbpOp op : epilogueOps) {
op.setSavedRbp(savedRbp);
}
if (BenchmarkCounters.enabled) {
// ensure that the rescue slot is available
LIRInstruction op = getOrInitRescueSlotOp();
// insert dummy instruction into the start block
LIR lir = getResult().getLIR();
ArrayList<LIRInstruction> instructions = lir.getLIRforBlock(lir.getControlFlowGraph().getStartBlock());
instructions.add(1, op);
lir.getDebug().dump(DebugContext.INFO_LEVEL, lir, "created rescue dummy op");
}
}
use of org.graalvm.compiler.lir.LIR in project graal by oracle.
the class AMD64HotSpotBackend method newCompilationResultBuilder.
@Override
public CompilationResultBuilder newCompilationResultBuilder(LIRGenerationResult lirGenRen, FrameMap frameMap, CompilationResult compilationResult, CompilationResultBuilderFactory factory) {
// Omit the frame if the method:
// - has no spill slots or other slots allocated during register allocation
// - has no callee-saved registers
// - has no incoming arguments passed on the stack
// - has no deoptimization points
// - makes no foreign calls (which require an aligned stack)
HotSpotLIRGenerationResult gen = (HotSpotLIRGenerationResult) lirGenRen;
LIR lir = gen.getLIR();
assert gen.getDeoptimizationRescueSlot() == null || frameMap.frameNeedsAllocating() : "method that can deoptimize must have a frame";
OptionValues options = lir.getOptions();
DebugContext debug = lir.getDebug();
boolean omitFrame = CanOmitFrame.getValue(options) && !frameMap.frameNeedsAllocating() && !lir.hasArgInCallerFrame() && !gen.hasForeignCall();
Stub stub = gen.getStub();
Assembler masm = createAssembler(frameMap);
HotSpotFrameContext frameContext = new HotSpotFrameContext(stub != null, omitFrame);
DataBuilder dataBuilder = new HotSpotDataBuilder(getCodeCache().getTarget());
CompilationResultBuilder crb = factory.createBuilder(getCodeCache(), getForeignCalls(), frameMap, masm, dataBuilder, frameContext, options, debug, compilationResult);
crb.setTotalFrameSize(frameMap.totalFrameSize());
crb.setMaxInterpreterFrameSize(gen.getMaxInterpreterFrameSize());
StackSlot deoptimizationRescueSlot = gen.getDeoptimizationRescueSlot();
if (deoptimizationRescueSlot != null && stub == null) {
crb.compilationResult.setCustomStackAreaOffset(deoptimizationRescueSlot);
}
if (stub != null) {
EconomicSet<Register> destroyedCallerRegisters = gatherDestroyedCallerRegisters(lir);
updateStub(stub, destroyedCallerRegisters, gen.getCalleeSaveInfo(), frameMap);
}
return crb;
}
use of org.graalvm.compiler.lir.LIR in project graal by oracle.
the class Instance method run.
public void run(LIRGenerationResult lirGenRes) {
LIR ir = lirGenRes.getLIR();
DebugContext debug = ir.getDebug();
FrameMap frameMap = lirGenRes.getFrameMap();
for (AbstractBlockBase<?> block : ir.linearScanOrder()) {
for (LIRInstruction op : ir.getLIRforBlock(block)) {
op.forEachState((instruction, state) -> doState(debug, frameMap, instruction, state));
}
}
}
use of org.graalvm.compiler.lir.LIR in project graal by oracle.
the class AArch64HotSpotBackend method newCompilationResultBuilder.
@Override
public CompilationResultBuilder newCompilationResultBuilder(LIRGenerationResult lirGenRen, FrameMap frameMap, CompilationResult compilationResult, CompilationResultBuilderFactory factory) {
HotSpotLIRGenerationResult gen = (HotSpotLIRGenerationResult) lirGenRen;
LIR lir = gen.getLIR();
assert gen.getDeoptimizationRescueSlot() == null || frameMap.frameNeedsAllocating() : "method that can deoptimize must have a frame";
Stub stub = gen.getStub();
Assembler masm = createAssembler(frameMap);
HotSpotFrameContext frameContext = new HotSpotFrameContext(stub != null);
DataBuilder dataBuilder = new HotSpotDataBuilder(getCodeCache().getTarget());
CompilationResultBuilder crb = factory.createBuilder(getCodeCache(), getForeignCalls(), frameMap, masm, dataBuilder, frameContext, lir.getOptions(), lir.getDebug(), compilationResult);
crb.setTotalFrameSize(frameMap.totalFrameSize());
crb.setMaxInterpreterFrameSize(gen.getMaxInterpreterFrameSize());
StackSlot deoptimizationRescueSlot = gen.getDeoptimizationRescueSlot();
if (deoptimizationRescueSlot != null && stub == null) {
crb.compilationResult.setCustomStackAreaOffset(deoptimizationRescueSlot);
}
if (stub != null) {
EconomicSet<Register> destroyedCallerRegisters = gatherDestroyedCallerRegisters(lir);
updateStub(stub, destroyedCallerRegisters, gen.getCalleeSaveInfo(), frameMap);
}
return crb;
}
use of org.graalvm.compiler.lir.LIR in project graal by oracle.
the class TraceBuilderPhase method run.
@Override
protected void run(TargetDescription target, LIRGenerationResult lirGenRes, AllocationContext context) {
AbstractBlockBase<?>[] linearScanOrder = lirGenRes.getLIR().linearScanOrder();
AbstractBlockBase<?> startBlock = linearScanOrder[0];
LIR lir = lirGenRes.getLIR();
assert startBlock.equals(lir.getControlFlowGraph().getStartBlock());
final TraceBuilderResult traceBuilderResult = getTraceBuilderResult(lir, startBlock, linearScanOrder);
DebugContext debug = lir.getDebug();
if (debug.isLogEnabled(DebugContext.BASIC_LEVEL)) {
ArrayList<Trace> traces = traceBuilderResult.getTraces();
for (int i = 0; i < traces.size(); i++) {
Trace trace = traces.get(i);
debug.log(DebugContext.BASIC_LEVEL, "Trace %5d: %s%s", i, trace, isTrivialTrace(lirGenRes.getLIR(), trace) ? " (trivial)" : "");
}
}
TraceStatisticsPrinter.printTraceStatistics(debug, traceBuilderResult, lirGenRes.getCompilationUnitName());
debug.dump(DebugContext.VERBOSE_LEVEL, traceBuilderResult, "TraceBuilderResult");
context.contextAdd(traceBuilderResult);
}
Aggregations