Search in sources :

Example 1 with HotSpotForeignCallsProvider

use of org.graalvm.compiler.hotspot.meta.HotSpotForeignCallsProvider in project graal by oracle.

the class AMD64HotSpotBackend method emitCodeSuffix.

/**
 * @param installedCodeOwner see {@link Backend#emitCode}
 */
public void emitCodeSuffix(ResolvedJavaMethod installedCodeOwner, CompilationResultBuilder crb, AMD64MacroAssembler asm, FrameMap frameMap) {
    HotSpotProviders providers = getProviders();
    HotSpotFrameContext frameContext = (HotSpotFrameContext) crb.frameContext;
    if (!frameContext.isStub) {
        HotSpotForeignCallsProvider foreignCalls = providers.getForeignCalls();
        crb.recordMark(config.MARKID_EXCEPTION_HANDLER_ENTRY);
        AMD64Call.directCall(crb, asm, foreignCalls.lookupForeignCall(EXCEPTION_HANDLER), null, false, null);
        crb.recordMark(config.MARKID_DEOPT_HANDLER_ENTRY);
        AMD64Call.directCall(crb, asm, foreignCalls.lookupForeignCall(DEOPTIMIZATION_HANDLER), null, false, null);
    } else {
        if (frameContext.omitFrame) {
            // Cannot access slots in caller's frame if my frame is omitted
            assert !frameMap.accessesCallerFrame();
        }
    }
}
Also used : HotSpotProviders(org.graalvm.compiler.hotspot.meta.HotSpotProviders) HotSpotForeignCallsProvider(org.graalvm.compiler.hotspot.meta.HotSpotForeignCallsProvider)

Example 2 with HotSpotForeignCallsProvider

use of org.graalvm.compiler.hotspot.meta.HotSpotForeignCallsProvider in project graal by oracle.

the class SPARCHotSpotBackend method emitCode.

@Override
public void emitCode(CompilationResultBuilder crb, LIR lir, ResolvedJavaMethod installedCodeOwner) {
    SPARCMacroAssembler masm = (SPARCMacroAssembler) crb.asm;
    // TODO: (sa) Fold the two traversals into one
    stuffDelayedControlTransfers(lir);
    int constantSize = calculateConstantSize(lir);
    boolean canUseImmediateConstantLoad = constantSize < (1 << 13);
    masm.setImmediateConstantLoad(canUseImmediateConstantLoad);
    FrameMap frameMap = crb.frameMap;
    RegisterConfig regConfig = frameMap.getRegisterConfig();
    Label unverifiedStub = installedCodeOwner == null || installedCodeOwner.isStatic() ? null : new Label();
    for (int i = 0; i < 2; i++) {
        if (i > 0) {
            crb.resetForEmittingCode();
            lir.resetLabels();
            resetDelayedControlTransfers(lir);
        }
        // Emit the prefix
        if (unverifiedStub != null) {
            crb.recordMark(config.MARKID_UNVERIFIED_ENTRY);
            // We need to use JavaCall here because we haven't entered the frame yet.
            CallingConvention cc = regConfig.getCallingConvention(HotSpotCallingConventionType.JavaCall, null, new JavaType[] { getProviders().getMetaAccess().lookupJavaType(Object.class) }, this);
            // see MacroAssembler::ic_call
            Register inlineCacheKlass = g5;
            try (ScratchRegister sc = masm.getScratchRegister()) {
                Register scratch = sc.getRegister();
                Register receiver = asRegister(cc.getArgument(0));
                SPARCAddress src = new SPARCAddress(receiver, config.hubOffset);
                masm.ldx(src, scratch);
                masm.cmp(scratch, inlineCacheKlass);
            }
            BPCC.emit(masm, Xcc, NotEqual, NOT_ANNUL, PREDICT_NOT_TAKEN, unverifiedStub);
            // delay slot
            masm.nop();
        }
        masm.align(config.codeEntryAlignment);
        crb.recordMark(config.MARKID_OSR_ENTRY);
        crb.recordMark(config.MARKID_VERIFIED_ENTRY);
        // Emit code for the LIR
        crb.emit(lir);
    }
    profileInstructions(lir, crb);
    HotSpotFrameContext frameContext = (HotSpotFrameContext) crb.frameContext;
    HotSpotForeignCallsProvider foreignCalls = getProviders().getForeignCalls();
    if (!frameContext.isStub) {
        crb.recordMark(config.MARKID_EXCEPTION_HANDLER_ENTRY);
        SPARCCall.directCall(crb, masm, foreignCalls.lookupForeignCall(EXCEPTION_HANDLER), null, null);
        crb.recordMark(config.MARKID_DEOPT_HANDLER_ENTRY);
        SPARCCall.directCall(crb, masm, foreignCalls.lookupForeignCall(DEOPTIMIZATION_HANDLER), null, null);
    } else {
    // No need to emit the stubs for entries back into the method since
    // it has no calls that can cause such "return" entries
    }
    if (unverifiedStub != null) {
        masm.bind(unverifiedStub);
        try (ScratchRegister sc = masm.getScratchRegister()) {
            Register scratch = sc.getRegister();
            SPARCCall.indirectJmp(crb, masm, scratch, foreignCalls.lookupForeignCall(IC_MISS_HANDLER));
        }
    }
    masm.peephole();
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention) RegisterConfig(jdk.vm.ci.code.RegisterConfig) ScratchRegister(org.graalvm.compiler.asm.sparc.SPARCMacroAssembler.ScratchRegister) SPARCFrameMap(org.graalvm.compiler.lir.sparc.SPARCFrameMap) FrameMap(org.graalvm.compiler.lir.framemap.FrameMap) Label(org.graalvm.compiler.asm.Label) 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) SPARCMacroAssembler(org.graalvm.compiler.asm.sparc.SPARCMacroAssembler) HotSpotForeignCallsProvider(org.graalvm.compiler.hotspot.meta.HotSpotForeignCallsProvider) SPARCAddress(org.graalvm.compiler.asm.sparc.SPARCAddress)

Example 3 with HotSpotForeignCallsProvider

use of org.graalvm.compiler.hotspot.meta.HotSpotForeignCallsProvider in project graal by oracle.

the class SPARCHotSpotBackendFactory method createBackend.

@Override
public HotSpotBackend createBackend(HotSpotGraalRuntimeProvider runtime, CompilerConfiguration compilerConfiguration, HotSpotJVMCIRuntimeProvider jvmciRuntime, HotSpotBackend host) {
    assert host == null;
    GraalHotSpotVMConfig config = runtime.getVMConfig();
    JVMCIBackend jvmci = jvmciRuntime.getHostJVMCIBackend();
    HotSpotRegistersProvider registers = createRegisters();
    HotSpotMetaAccessProvider metaAccess = (HotSpotMetaAccessProvider) jvmci.getMetaAccess();
    HotSpotCodeCacheProvider codeCache = (HotSpotCodeCacheProvider) jvmci.getCodeCache();
    TargetDescription target = codeCache.getTarget();
    HotSpotConstantReflectionProvider constantReflection = (HotSpotConstantReflectionProvider) jvmci.getConstantReflection();
    HotSpotConstantFieldProvider constantFieldProvider = new HotSpotGraalConstantFieldProvider(config, metaAccess);
    Value[] nativeABICallerSaveRegisters = createNativeABICallerSaveRegisters(config, codeCache.getRegisterConfig());
    HotSpotWordTypes wordTypes = new HotSpotWordTypes(metaAccess, target.wordJavaKind);
    HotSpotForeignCallsProvider foreignCalls = new SPARCHotSpotForeignCallsProvider(jvmciRuntime, runtime, metaAccess, codeCache, wordTypes, nativeABICallerSaveRegisters);
    LoweringProvider lowerer = createLowerer(runtime, metaAccess, foreignCalls, registers, constantReflection, target);
    HotSpotStampProvider stampProvider = new HotSpotStampProvider();
    Providers p = new Providers(metaAccess, codeCache, constantReflection, constantFieldProvider, foreignCalls, lowerer, null, stampProvider);
    HotSpotSnippetReflectionProvider snippetReflection = new HotSpotSnippetReflectionProvider(runtime, constantReflection, wordTypes);
    BytecodeProvider bytecodeProvider = new ClassfileBytecodeProvider(metaAccess, snippetReflection);
    HotSpotReplacementsImpl replacements = new HotSpotReplacementsImpl(runtime.getOptions(), p, snippetReflection, bytecodeProvider, target);
    Plugins plugins = createGraphBuilderPlugins(compilerConfiguration, config, metaAccess, constantReflection, foreignCalls, lowerer, stampProvider, snippetReflection, replacements, wordTypes);
    replacements.setGraphBuilderPlugins(plugins);
    HotSpotSuitesProvider suites = createSuites(config, runtime, compilerConfiguration, plugins, replacements);
    HotSpotProviders providers = new HotSpotProviders(metaAccess, codeCache, constantReflection, constantFieldProvider, foreignCalls, lowerer, replacements, suites, registers, snippetReflection, wordTypes, plugins);
    return createBackend(config, runtime, providers);
}
Also used : ClassfileBytecodeProvider(org.graalvm.compiler.replacements.classfile.ClassfileBytecodeProvider) HotSpotCodeCacheProvider(jdk.vm.ci.hotspot.HotSpotCodeCacheProvider) JVMCIBackend(jdk.vm.ci.runtime.JVMCIBackend) TargetDescription(jdk.vm.ci.code.TargetDescription) HotSpotProviders(org.graalvm.compiler.hotspot.meta.HotSpotProviders) BytecodeProvider(org.graalvm.compiler.bytecode.BytecodeProvider) ClassfileBytecodeProvider(org.graalvm.compiler.replacements.classfile.ClassfileBytecodeProvider) HotSpotConstantFieldProvider(org.graalvm.compiler.hotspot.meta.HotSpotConstantFieldProvider) LoweringProvider(org.graalvm.compiler.nodes.spi.LoweringProvider) HotSpotLoweringProvider(org.graalvm.compiler.hotspot.meta.HotSpotLoweringProvider) HotSpotProviders(org.graalvm.compiler.hotspot.meta.HotSpotProviders) Providers(org.graalvm.compiler.phases.util.Providers) HotSpotMetaAccessProvider(jdk.vm.ci.hotspot.HotSpotMetaAccessProvider) HotSpotSnippetReflectionProvider(org.graalvm.compiler.hotspot.meta.HotSpotSnippetReflectionProvider) HotSpotReplacementsImpl(org.graalvm.compiler.hotspot.HotSpotReplacementsImpl) HotSpotWordTypes(org.graalvm.compiler.hotspot.word.HotSpotWordTypes) HotSpotRegistersProvider(org.graalvm.compiler.hotspot.meta.HotSpotRegistersProvider) HotSpotSuitesProvider(org.graalvm.compiler.hotspot.meta.HotSpotSuitesProvider) AddressLoweringHotSpotSuitesProvider(org.graalvm.compiler.hotspot.meta.AddressLoweringHotSpotSuitesProvider) Value(jdk.vm.ci.meta.Value) HotSpotConstantReflectionProvider(jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider) HotSpotGraalConstantFieldProvider(org.graalvm.compiler.hotspot.meta.HotSpotGraalConstantFieldProvider) HotSpotForeignCallsProvider(org.graalvm.compiler.hotspot.meta.HotSpotForeignCallsProvider) GraalHotSpotVMConfig(org.graalvm.compiler.hotspot.GraalHotSpotVMConfig) HotSpotStampProvider(org.graalvm.compiler.hotspot.meta.HotSpotStampProvider) SPARCGraphBuilderPlugins(org.graalvm.compiler.replacements.sparc.SPARCGraphBuilderPlugins) HotSpotGraphBuilderPlugins(org.graalvm.compiler.hotspot.meta.HotSpotGraphBuilderPlugins) Plugins(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)

Example 4 with HotSpotForeignCallsProvider

use of org.graalvm.compiler.hotspot.meta.HotSpotForeignCallsProvider in project graal by oracle.

the class AArch64HotSpotBackend method emitCodeSuffix.

private void emitCodeSuffix(CompilationResultBuilder crb, AArch64MacroAssembler masm, FrameMap frameMap) {
    HotSpotProviders providers = getProviders();
    HotSpotFrameContext frameContext = (HotSpotFrameContext) crb.frameContext;
    if (!frameContext.isStub) {
        HotSpotForeignCallsProvider foreignCalls = providers.getForeignCalls();
        try (ScratchRegister sc = masm.getScratchRegister()) {
            Register scratch = sc.getRegister();
            crb.recordMark(config.MARKID_EXCEPTION_HANDLER_ENTRY);
            ForeignCallLinkage linkage = foreignCalls.lookupForeignCall(EXCEPTION_HANDLER);
            Register helper = AArch64Call.isNearCall(linkage) ? null : scratch;
            AArch64Call.directCall(crb, masm, linkage, helper, null);
        }
        crb.recordMark(config.MARKID_DEOPT_HANDLER_ENTRY);
        ForeignCallLinkage linkage = foreignCalls.lookupForeignCall(DEOPTIMIZATION_HANDLER);
        // Warning: the argument is an offset from the instruction!
        masm.adr(lr, 0);
        AArch64Call.directJmp(crb, masm, linkage);
    } else {
        // it has no calls that can cause such "return" entries
        assert !frameMap.accessesCallerFrame();
    }
}
Also used : ScratchRegister(org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler.ScratchRegister) Register(jdk.vm.ci.code.Register) ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) ScratchRegister(org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler.ScratchRegister) HotSpotProviders(org.graalvm.compiler.hotspot.meta.HotSpotProviders) ForeignCallLinkage(org.graalvm.compiler.core.common.spi.ForeignCallLinkage) HotSpotForeignCallsProvider(org.graalvm.compiler.hotspot.meta.HotSpotForeignCallsProvider)

Aggregations

HotSpotForeignCallsProvider (org.graalvm.compiler.hotspot.meta.HotSpotForeignCallsProvider)4 HotSpotProviders (org.graalvm.compiler.hotspot.meta.HotSpotProviders)3 Register (jdk.vm.ci.code.Register)2 ValueUtil.asRegister (jdk.vm.ci.code.ValueUtil.asRegister)2 CallingConvention (jdk.vm.ci.code.CallingConvention)1 RegisterConfig (jdk.vm.ci.code.RegisterConfig)1 TargetDescription (jdk.vm.ci.code.TargetDescription)1 ValueUtil.isRegister (jdk.vm.ci.code.ValueUtil.isRegister)1 HotSpotCodeCacheProvider (jdk.vm.ci.hotspot.HotSpotCodeCacheProvider)1 HotSpotConstantReflectionProvider (jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider)1 HotSpotMetaAccessProvider (jdk.vm.ci.hotspot.HotSpotMetaAccessProvider)1 Value (jdk.vm.ci.meta.Value)1 JVMCIBackend (jdk.vm.ci.runtime.JVMCIBackend)1 Label (org.graalvm.compiler.asm.Label)1 ScratchRegister (org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler.ScratchRegister)1 SPARCAddress (org.graalvm.compiler.asm.sparc.SPARCAddress)1 SPARCAssembler.isGlobalRegister (org.graalvm.compiler.asm.sparc.SPARCAssembler.isGlobalRegister)1 SPARCMacroAssembler (org.graalvm.compiler.asm.sparc.SPARCMacroAssembler)1 ScratchRegister (org.graalvm.compiler.asm.sparc.SPARCMacroAssembler.ScratchRegister)1 BytecodeProvider (org.graalvm.compiler.bytecode.BytecodeProvider)1