Search in sources :

Example 11 with ForeignCallLinkage

use of org.graalvm.compiler.core.common.spi.ForeignCallLinkage in project graal by oracle.

the class AMD64HotSpotUnwindOp method emitCode.

@Override
public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
    leaveFrameAndRestoreRbp(crb, masm);
    ForeignCallLinkage linkage = crb.foreignCalls.lookupForeignCall(UNWIND_EXCEPTION_TO_CALLER);
    CallingConvention cc = linkage.getOutgoingCallingConvention();
    assert cc.getArgumentCount() == 2;
    assert exception.equals(cc.getArgument(0));
    // Get return address (is on top of stack after leave).
    Register returnAddress = asRegister(cc.getArgument(1));
    masm.movq(returnAddress, new AMD64Address(rsp, 0));
    AMD64Call.directJmp(crb, masm, linkage);
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention) Register(jdk.vm.ci.code.Register) ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) ForeignCallLinkage(org.graalvm.compiler.core.common.spi.ForeignCallLinkage) AMD64Address(org.graalvm.compiler.asm.amd64.AMD64Address)

Example 12 with ForeignCallLinkage

use of org.graalvm.compiler.core.common.spi.ForeignCallLinkage in project graal by oracle.

the class AArch64HotSpotLIRGenerator method emitUnwind.

@Override
public void emitUnwind(Value exception) {
    ForeignCallLinkage linkage = getForeignCalls().lookupForeignCall(HotSpotBackend.UNWIND_EXCEPTION_TO_CALLER);
    CallingConvention outgoingCc = linkage.getOutgoingCallingConvention();
    assert outgoingCc.getArgumentCount() == 2;
    RegisterValue exceptionParameter = (RegisterValue) outgoingCc.getArgument(0);
    emitMove(exceptionParameter, exception);
    append(new AArch64HotSpotUnwindOp(config, exceptionParameter));
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention) RegisterValue(jdk.vm.ci.code.RegisterValue) ForeignCallLinkage(org.graalvm.compiler.core.common.spi.ForeignCallLinkage) HotSpotForeignCallLinkage(org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage)

Example 13 with ForeignCallLinkage

use of org.graalvm.compiler.core.common.spi.ForeignCallLinkage 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)

Example 14 with ForeignCallLinkage

use of org.graalvm.compiler.core.common.spi.ForeignCallLinkage in project graal by oracle.

the class AArch64HotSpotUnwindOp method emitCode.

@Override
public void emitCode(CompilationResultBuilder crb, AArch64MacroAssembler masm) {
    leaveFrame(crb, masm, /* emitSafepoint */
    false);
    ForeignCallLinkage linkage = crb.foreignCalls.lookupForeignCall(UNWIND_EXCEPTION_TO_CALLER);
    CallingConvention cc = linkage.getOutgoingCallingConvention();
    assert cc.getArgumentCount() == 2;
    assert exception.equals(cc.getArgument(0));
    // Get return address (is in lr after frame leave)
    Register returnAddress = asRegister(cc.getArgument(1));
    masm.movx(returnAddress, lr);
    AArch64Call.directJmp(crb, masm, linkage);
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention) Register(jdk.vm.ci.code.Register) ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) ForeignCallLinkage(org.graalvm.compiler.core.common.spi.ForeignCallLinkage)

Example 15 with ForeignCallLinkage

use of org.graalvm.compiler.core.common.spi.ForeignCallLinkage in project graal by oracle.

the class ForeignCallNode method generate.

@Override
public void generate(NodeLIRBuilderTool gen) {
    ForeignCallLinkage linkage = gen.getLIRGeneratorTool().getForeignCalls().lookupForeignCall(descriptor);
    Value[] operands = operands(gen);
    Value result = gen.getLIRGeneratorTool().emitForeignCall(linkage, gen.state(this), operands);
    if (result != null) {
        gen.setResult(this, result);
    }
}
Also used : Value(jdk.vm.ci.meta.Value) ForeignCallLinkage(org.graalvm.compiler.core.common.spi.ForeignCallLinkage)

Aggregations

ForeignCallLinkage (org.graalvm.compiler.core.common.spi.ForeignCallLinkage)16 CallingConvention (jdk.vm.ci.code.CallingConvention)9 Register (jdk.vm.ci.code.Register)7 RegisterValue (jdk.vm.ci.code.RegisterValue)6 ValueUtil.asRegister (jdk.vm.ci.code.ValueUtil.asRegister)4 Value (jdk.vm.ci.meta.Value)4 HotSpotForeignCallLinkage (org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage)4 Variable (org.graalvm.compiler.lir.Variable)4 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)2 AArch64HotSpotRegisterConfig.inlineCacheRegister (jdk.vm.ci.hotspot.aarch64.AArch64HotSpotRegisterConfig.inlineCacheRegister)1 AArch64HotSpotRegisterConfig.metaspaceMethodRegister (jdk.vm.ci.hotspot.aarch64.AArch64HotSpotRegisterConfig.metaspaceMethodRegister)1 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 SPARCKind (jdk.vm.ci.sparc.SPARCKind)1 ScratchRegister (org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler.ScratchRegister)1 AMD64Address (org.graalvm.compiler.asm.amd64.AMD64Address)1 LIRKind (org.graalvm.compiler.core.common.LIRKind)1 HotSpotForeignCallsProvider (org.graalvm.compiler.hotspot.meta.HotSpotForeignCallsProvider)1 HotSpotProviders (org.graalvm.compiler.hotspot.meta.HotSpotProviders)1 ConstantValue (org.graalvm.compiler.lir.ConstantValue)1 SPARCAddressValue (org.graalvm.compiler.lir.sparc.SPARCAddressValue)1