Search in sources :

Example 1 with HotSpotSentinelConstant

use of jdk.vm.ci.hotspot.HotSpotSentinelConstant in project graal by oracle.

the class AMD64HotSpotBackend method emitCodePrefix.

/**
 * Emits the code prior to the verified entry point.
 *
 * @param installedCodeOwner see {@link Backend#emitCode}
 */
public void emitCodePrefix(ResolvedJavaMethod installedCodeOwner, CompilationResultBuilder crb, AMD64MacroAssembler asm, RegisterConfig regConfig, Label verifiedEntry) {
    HotSpotProviders providers = getProviders();
    if (installedCodeOwner != null && !installedCodeOwner.isStatic()) {
        crb.recordMark(config.MARKID_UNVERIFIED_ENTRY);
        CallingConvention cc = regConfig.getCallingConvention(HotSpotCallingConventionType.JavaCallee, null, new JavaType[] { providers.getMetaAccess().lookupJavaType(Object.class) }, this);
        // see definition of IC_Klass in
        Register inlineCacheKlass = rax;
        // c1_LIRAssembler_x86.cpp
        Register receiver = asRegister(cc.getArgument(0));
        AMD64Address src = new AMD64Address(receiver, config.hubOffset);
        if (config.useCompressedClassPointers) {
            Register register = r10;
            AMD64HotSpotMove.decodeKlassPointer(crb, asm, register, providers.getRegisters().getHeapBaseRegister(), src, config);
            if (GeneratePIC.getValue(crb.getOptions())) {
                asm.movq(providers.getRegisters().getHeapBaseRegister(), asm.getPlaceholder(-1));
                crb.recordMark(config.MARKID_NARROW_OOP_BASE_ADDRESS);
            } else {
                if (config.narrowKlassBase != 0) {
                    // The heap base register was destroyed above, so restore it
                    asm.movq(providers.getRegisters().getHeapBaseRegister(), config.narrowOopBase);
                }
            }
            asm.cmpq(inlineCacheKlass, register);
        } else {
            asm.cmpq(inlineCacheKlass, src);
        }
        AMD64Call.directConditionalJmp(crb, asm, getForeignCalls().lookupForeignCall(IC_MISS_HANDLER), ConditionFlag.NotEqual);
    }
    asm.align(config.codeEntryAlignment);
    crb.recordMark(config.MARKID_OSR_ENTRY);
    asm.bind(verifiedEntry);
    crb.recordMark(config.MARKID_VERIFIED_ENTRY);
    if (GeneratePIC.getValue(crb.getOptions())) {
        // Check for method state
        HotSpotFrameContext frameContext = (HotSpotFrameContext) crb.frameContext;
        if (!frameContext.isStub) {
            crb.recordInlineDataInCodeWithNote(new HotSpotSentinelConstant(LIRKind.value(AMD64Kind.QWORD), JavaKind.Long), HotSpotConstantLoadAction.MAKE_NOT_ENTRANT);
            asm.movq(AMD64.rax, asm.getPlaceholder(-1));
            asm.testq(AMD64.rax, AMD64.rax);
            AMD64Call.directConditionalJmp(crb, asm, getForeignCalls().lookupForeignCall(WRONG_METHOD_HANDLER), ConditionFlag.NotZero);
        }
    }
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention) Register(jdk.vm.ci.code.Register) ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) HotSpotProviders(org.graalvm.compiler.hotspot.meta.HotSpotProviders) HotSpotSentinelConstant(jdk.vm.ci.hotspot.HotSpotSentinelConstant) AMD64Address(org.graalvm.compiler.asm.amd64.AMD64Address)

Aggregations

CallingConvention (jdk.vm.ci.code.CallingConvention)1 Register (jdk.vm.ci.code.Register)1 ValueUtil.asRegister (jdk.vm.ci.code.ValueUtil.asRegister)1 HotSpotSentinelConstant (jdk.vm.ci.hotspot.HotSpotSentinelConstant)1 AMD64Address (org.graalvm.compiler.asm.amd64.AMD64Address)1 HotSpotProviders (org.graalvm.compiler.hotspot.meta.HotSpotProviders)1