Search in sources :

Example 11 with StackSlot

use of jdk.vm.ci.code.StackSlot in project graal by oracle.

the class SPARCHotSpotBackend method newCompilationResultBuilder.

@Override
public CompilationResultBuilder newCompilationResultBuilder(LIRGenerationResult lirGenRes, FrameMap frameMap, CompilationResult compilationResult, CompilationResultBuilderFactory factory) {
    HotSpotLIRGenerationResult gen = (HotSpotLIRGenerationResult) lirGenRes;
    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);
    // On SPARC we always use stack frames.
    HotSpotFrameContext frameContext = new HotSpotFrameContext(stub != null);
    DataBuilder dataBuilder = new HotSpotDataBuilder(getCodeCache().getTarget());
    OptionValues options = lir.getOptions();
    DebugContext debug = lir.getDebug();
    CompilationResultBuilder crb = factory.createBuilder(getProviders().getCodeCache(), getProviders().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) {
        // Even on sparc we need to save floating point registers
        EconomicSet<Register> destroyedCallerRegisters = gatherDestroyedCallerRegisters(lir);
        EconomicMap<LIRFrameState, SaveRegistersOp> calleeSaveInfo = gen.getCalleeSaveInfo();
        updateStub(stub, destroyedCallerRegisters, calleeSaveInfo, frameMap);
    }
    assert registerSizePredictionValidator(crb, debug);
    return crb;
}
Also used : LIRFrameState(org.graalvm.compiler.lir.LIRFrameState) 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.isRegister(jdk.vm.ci.code.ValueUtil.isRegister) ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) ScratchRegister(org.graalvm.compiler.asm.sparc.SPARCMacroAssembler.ScratchRegister) SPARCAssembler.isGlobalRegister(org.graalvm.compiler.asm.sparc.SPARCAssembler.isGlobalRegister) SPARCAssembler(org.graalvm.compiler.asm.sparc.SPARCAssembler) SPARCMacroAssembler(org.graalvm.compiler.asm.sparc.SPARCMacroAssembler) Assembler(org.graalvm.compiler.asm.Assembler) SaveRegistersOp(org.graalvm.compiler.lir.StandardOp.SaveRegistersOp)

Example 12 with StackSlot

use of jdk.vm.ci.code.StackSlot in project graal by oracle.

the class CollectingObjectReferenceVisitor method verifyValue.

private void verifyValue(CompilationResult compilation, JavaValue expectedValue, ValueInfo actualValue, FrameInfoQueryResult actualFrame, BitSet visitedVirtualObjects) {
    if (ValueUtil.isIllegalJavaValue(expectedValue)) {
        assert actualValue.getType() == ValueType.Illegal;
    } else if (ValueUtil.isConstantJavaValue(expectedValue)) {
        assert actualValue.getType() == ValueType.Constant || actualValue.getType() == ValueType.DefaultConstant;
        JavaConstant expectedConstant = ValueUtil.asConstantJavaValue(expectedValue);
        JavaConstant actualConstant = actualValue.getValue();
        FrameInfoVerifier.verifyConstant(expectedConstant, actualConstant);
    } else if (expectedValue instanceof StackSlot) {
        assert actualValue.getType() == ValueType.StackSlot;
        int expectedOffset = ((StackSlot) expectedValue).getOffset(compilation.getTotalFrameSize());
        long actualOffset = actualValue.getData();
        assert expectedOffset == actualOffset;
    } else if (ValueUtil.isVirtualObject(expectedValue)) {
        assert actualValue.getType() == ValueType.VirtualObject;
        int expectedId = ValueUtil.asVirtualObject(expectedValue).getId();
        long actualId = actualValue.getData();
        assert expectedId == actualId;
        verifyVirtualObject(compilation, ValueUtil.asVirtualObject(expectedValue), actualFrame.getVirtualObjects()[expectedId], actualFrame, visitedVirtualObjects);
    } else {
        throw shouldNotReachHere();
    }
}
Also used : StackSlot(jdk.vm.ci.code.StackSlot) JavaConstant(jdk.vm.ci.meta.JavaConstant) Infopoint(jdk.vm.ci.code.site.Infopoint) DeoptEntryInfopoint(com.oracle.svm.core.deopt.DeoptEntryInfopoint)

Example 13 with StackSlot

use of jdk.vm.ci.code.StackSlot in project graal by oracle.

the class Instance method doState.

private void doState(DebugContext debug, FrameMap frameMap, LIRInstruction op, LIRFrameState state) {
    SubstrateReferenceMap refMap = (SubstrateReferenceMap) state.debugInfo().getReferenceMap();
    /*
         * We want to verify explicit deoptimization entry points, and implicit deoptimization entry
         * points at call sites. Unfortunately, just checking isDeoptEntry gives us false positives
         * for some runtime calls that re-use a state (which is not marked as "during call").
         */
    boolean isDeoptEntry = ((HostedMethod) state.topFrame.getMethod()).compilationInfo.isDeoptEntry(state.topFrame.getBCI(), state.topFrame.duringCall, state.topFrame.rethrowException);
    if (op instanceof DeoptEntryOp || (state.topFrame.duringCall && isDeoptEntry)) {
        BytecodeFrame frame = state.topFrame;
        Map<Integer, Object> allUsedRegisters = refMap.getDebugAllUsedRegisters();
        Map<Integer, Object> allUsedStackSlots = refMap.getDebugAllUsedStackSlots();
        if (allUsedRegisters != null && !allUsedRegisters.isEmpty()) {
            throw shouldNotReachHere("Deoptimization target must not use any registers");
        }
        if (allUsedStackSlots != null) {
            Map<Integer, Object> cleanedStackSlots = new HashMap<>(allUsedStackSlots);
            do {
                /*
                     * Remove stack slot information for all slots which already have a
                     * representative in the bytecode frame.
                     */
                for (JavaValue value : frame.values) {
                    if (value instanceof StackSlot) {
                        StackSlot stackSlot = (StackSlot) value;
                        int offset = stackSlot.getOffset(frameMap.totalFrameSize());
                        debug.log("remove slot %d: %s", offset, stackSlot);
                        cleanedStackSlots.remove(offset);
                    } else if (ValueUtil.isConstantJavaValue(value) || ValueUtil.isIllegalJavaValue(value)) {
                    /* Nothing to do. */
                    } else {
                        throw shouldNotReachHere("unknown value in deopt target: " + value);
                    }
                }
                frame = frame.caller();
            } while (frame != null);
            int firstBci = state.topFrame.getMethod().isSynchronized() ? BytecodeFrame.BEFORE_BCI : 0;
            if (state.topFrame.getBCI() == firstBci && state.topFrame.caller() == null && state.topFrame.duringCall == false && state.topFrame.rethrowException == false) {
                /*
                     * Some stack slots, e.g., the return address and manually allocated stack
                     * memory, are alive the whole method. So all stack slots that are registered
                     * for the method entry are allowed to be registered in all subsequent states.
                     */
                assert op instanceof DeoptEntryOp;
                assert allowedStackSlots == null;
                allowedStackSlots = new HashMap<>(cleanedStackSlots);
            } else {
                if (allowedStackSlots == null) {
                    allowedStackSlots = new HashMap<>();
                }
                for (Integer key : allowedStackSlots.keySet()) {
                    cleanedStackSlots.remove(key);
                }
                if (!cleanedStackSlots.isEmpty()) {
                    throw shouldNotReachHere("unknown values in stack slots: method " + state.topFrame.getMethod().toString() + ", op " + op.id() + " " + op + ": " + cleanedStackSlots);
                }
            }
        }
    }
}
Also used : BytecodeFrame(jdk.vm.ci.code.BytecodeFrame) HashMap(java.util.HashMap) JavaValue(jdk.vm.ci.meta.JavaValue) DeoptEntryOp(com.oracle.svm.core.graal.lir.DeoptEntryOp) StackSlot(jdk.vm.ci.code.StackSlot) SubstrateReferenceMap(com.oracle.svm.core.heap.SubstrateReferenceMap)

Example 14 with StackSlot

use of jdk.vm.ci.code.StackSlot 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 15 with StackSlot

use of jdk.vm.ci.code.StackSlot 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)

Aggregations

StackSlot (jdk.vm.ci.code.StackSlot)21 ValueUtil.isStackSlot (jdk.vm.ci.code.ValueUtil.isStackSlot)8 Register (jdk.vm.ci.code.Register)6 ValueUtil.asStackSlot (jdk.vm.ci.code.ValueUtil.asStackSlot)6 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)5 Value (jdk.vm.ci.meta.Value)4 DebugContext (org.graalvm.compiler.debug.DebugContext)4 CallingConvention (jdk.vm.ci.code.CallingConvention)3 RegisterValue (jdk.vm.ci.code.RegisterValue)3 ValueUtil.asRegister (jdk.vm.ci.code.ValueUtil.asRegister)3 JavaConstant (jdk.vm.ci.meta.JavaConstant)3 Assembler (org.graalvm.compiler.asm.Assembler)3 LIRValueUtil.isVirtualStackSlot (org.graalvm.compiler.lir.LIRValueUtil.isVirtualStackSlot)3 VirtualStackSlot (org.graalvm.compiler.lir.VirtualStackSlot)3 ParameterNode (org.graalvm.compiler.nodes.ParameterNode)3 RegisterSaveLayout (jdk.vm.ci.code.RegisterSaveLayout)2 ValueUtil.asAllocatableValue (jdk.vm.ci.code.ValueUtil.asAllocatableValue)2 Infopoint (jdk.vm.ci.code.site.Infopoint)2 ScratchRegister (org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler.ScratchRegister)2 HotSpotDataBuilder (org.graalvm.compiler.hotspot.HotSpotDataBuilder)2