Search in sources :

Example 11 with LIR

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");
    }
}
Also used : LIR(org.graalvm.compiler.lir.LIR) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Example 12 with LIR

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;
}
Also used : OptionValues(org.graalvm.compiler.options.OptionValues) HotSpotLIRGenerationResult(org.graalvm.compiler.hotspot.HotSpotLIRGenerationResult) HotSpotDataBuilder(org.graalvm.compiler.hotspot.HotSpotDataBuilder) Stub(org.graalvm.compiler.hotspot.stubs.Stub) StackSlot(jdk.vm.ci.code.StackSlot) DebugContext(org.graalvm.compiler.debug.DebugContext) CompilationResultBuilder(org.graalvm.compiler.lir.asm.CompilationResultBuilder) LIR(org.graalvm.compiler.lir.LIR) HotSpotDataBuilder(org.graalvm.compiler.hotspot.HotSpotDataBuilder) DataBuilder(org.graalvm.compiler.lir.asm.DataBuilder) Register(jdk.vm.ci.code.Register) ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) Assembler(org.graalvm.compiler.asm.Assembler) AMD64MacroAssembler(org.graalvm.compiler.asm.amd64.AMD64MacroAssembler)

Example 13 with LIR

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));
        }
    }
}
Also used : FrameMap(org.graalvm.compiler.lir.framemap.FrameMap) LIR(org.graalvm.compiler.lir.LIR) LIRInstruction(org.graalvm.compiler.lir.LIRInstruction) DebugContext(org.graalvm.compiler.debug.DebugContext)

Example 14 with LIR

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;
}
Also used : CompilationResultBuilder(org.graalvm.compiler.lir.asm.CompilationResultBuilder) LIR(org.graalvm.compiler.lir.LIR) HotSpotDataBuilder(org.graalvm.compiler.hotspot.HotSpotDataBuilder) DataBuilder(org.graalvm.compiler.lir.asm.DataBuilder) Register(jdk.vm.ci.code.Register) ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) ScratchRegister(org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler.ScratchRegister) HotSpotLIRGenerationResult(org.graalvm.compiler.hotspot.HotSpotLIRGenerationResult) HotSpotDataBuilder(org.graalvm.compiler.hotspot.HotSpotDataBuilder) Stub(org.graalvm.compiler.hotspot.stubs.Stub) StackSlot(jdk.vm.ci.code.StackSlot) AArch64Assembler(org.graalvm.compiler.asm.aarch64.AArch64Assembler) AArch64MacroAssembler(org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler) Assembler(org.graalvm.compiler.asm.Assembler)

Example 15 with LIR

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);
}
Also used : TraceUtil.isTrivialTrace(org.graalvm.compiler.lir.alloc.trace.TraceUtil.isTrivialTrace) Trace(org.graalvm.compiler.core.common.alloc.Trace) LIR(org.graalvm.compiler.lir.LIR) DebugContext(org.graalvm.compiler.debug.DebugContext) TraceBuilderResult(org.graalvm.compiler.core.common.alloc.TraceBuilderResult) AbstractBlockBase(org.graalvm.compiler.core.common.cfg.AbstractBlockBase)

Aggregations

LIR (org.graalvm.compiler.lir.LIR)22 DebugContext (org.graalvm.compiler.debug.DebugContext)11 LIRInstruction (org.graalvm.compiler.lir.LIRInstruction)6 Assembler (org.graalvm.compiler.asm.Assembler)4 Trace (org.graalvm.compiler.core.common.alloc.Trace)4 HotSpotLIRGenerationResult (org.graalvm.compiler.hotspot.HotSpotLIRGenerationResult)4 Stub (org.graalvm.compiler.hotspot.stubs.Stub)4 CompilationResultBuilder (org.graalvm.compiler.lir.asm.CompilationResultBuilder)4 DataBuilder (org.graalvm.compiler.lir.asm.DataBuilder)4 OptionValues (org.graalvm.compiler.options.OptionValues)4 Register (jdk.vm.ci.code.Register)3 StackSlot (jdk.vm.ci.code.StackSlot)3 ValueUtil.asRegister (jdk.vm.ci.code.ValueUtil.asRegister)3 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)3 TraceBuilderResult (org.graalvm.compiler.core.common.alloc.TraceBuilderResult)3 AbstractBlockBase (org.graalvm.compiler.core.common.cfg.AbstractBlockBase)3 HotSpotDataBuilder (org.graalvm.compiler.hotspot.HotSpotDataBuilder)3 AMD64MacroAssembler (org.graalvm.compiler.asm.amd64.AMD64MacroAssembler)2 Indent (org.graalvm.compiler.debug.Indent)2 FrameMapBuilder (org.graalvm.compiler.lir.framemap.FrameMapBuilder)2