Search in sources :

Example 21 with CallingConvention

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

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

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

the class AArch64HotSpotForeignCallsProvider method initialize.

@Override
public void initialize(HotSpotProviders providers, OptionValues options) {
    GraalHotSpotVMConfig config = runtime.getVMConfig();
    TargetDescription target = providers.getCodeCache().getTarget();
    PlatformKind word = target.arch.getWordKind();
    // The calling convention for the exception handler stub is (only?) defined in
    // TemplateInterpreterGenerator::generate_throw_exception()
    RegisterValue exception = r0.asValue(LIRKind.reference(word));
    RegisterValue exceptionPc = r3.asValue(LIRKind.value(word));
    CallingConvention exceptionCc = new CallingConvention(0, ILLEGAL, exception, exceptionPc);
    register(new HotSpotForeignCallLinkageImpl(HotSpotBackend.EXCEPTION_HANDLER, 0L, PRESERVES_REGISTERS, LEAF, exceptionCc, null, NOT_REEXECUTABLE, any()));
    register(new HotSpotForeignCallLinkageImpl(HotSpotBackend.EXCEPTION_HANDLER_IN_CALLER, JUMP_ADDRESS, PRESERVES_REGISTERS, LEAF, exceptionCc, null, NOT_REEXECUTABLE, any()));
    // These stubs do callee saving
    if (config.useCRC32Intrinsics) {
        registerForeignCall(UPDATE_BYTES_CRC32, config.updateBytesCRC32Stub, NativeCall, PRESERVES_REGISTERS, LEAF, NOT_REEXECUTABLE, any());
    }
    if (config.useCRC32CIntrinsics) {
        registerForeignCall(UPDATE_BYTES_CRC32C, config.updateBytesCRC32C, NativeCall, PRESERVES_REGISTERS, LEAF, NOT_REEXECUTABLE, any());
    }
    super.initialize(providers, options);
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention) RegisterValue(jdk.vm.ci.code.RegisterValue) HotSpotForeignCallLinkageImpl(org.graalvm.compiler.hotspot.HotSpotForeignCallLinkageImpl) TargetDescription(jdk.vm.ci.code.TargetDescription) PlatformKind(jdk.vm.ci.meta.PlatformKind) GraalHotSpotVMConfig(org.graalvm.compiler.hotspot.GraalHotSpotVMConfig)

Example 24 with CallingConvention

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

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

the class AssemblerTest method assembleMethod.

@SuppressWarnings("try")
protected InstalledCode assembleMethod(Method m, CodeGenTest test) {
    ResolvedJavaMethod method = getMetaAccess().lookupJavaMethod(m);
    OptionValues options = getInitialOptions();
    DebugContext debug = getDebugContext(options);
    try (DebugContext.Scope s = debug.scope("assembleMethod", method, codeCache)) {
        RegisterConfig registerConfig = codeCache.getRegisterConfig();
        CompilationIdentifier compilationId = backend.getCompilationIdentifier(method);
        StructuredGraph graph = new StructuredGraph.Builder(options, debug).method(method).compilationId(compilationId).build();
        CallingConvention cc = backend.newLIRGenerationResult(compilationId, null, null, graph, null).getCallingConvention();
        CompilationResult compResult = new CompilationResult(graph.compilationId());
        byte[] targetCode = test.generateCode(compResult, codeCache.getTarget(), registerConfig, cc);
        compResult.setTargetCode(targetCode, targetCode.length);
        compResult.setTotalFrameSize(0);
        compResult.close();
        InstalledCode code = backend.addInstalledCode(debug, method, asCompilationRequest(compilationId), compResult);
        for (DisassemblerProvider dis : GraalServices.load(DisassemblerProvider.class)) {
            String disasm1 = dis.disassembleCompiledCode(codeCache, compResult);
            Assert.assertTrue(compResult.toString(), disasm1 == null || disasm1.length() > 0);
            String disasm2 = dis.disassembleInstalledCode(codeCache, compResult, code);
            Assert.assertTrue(code.toString(), disasm2 == null || disasm2.length() > 0);
        }
        return code;
    } catch (Throwable e) {
        throw debug.handle(e);
    }
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention) RegisterConfig(jdk.vm.ci.code.RegisterConfig) CompilationIdentifier(org.graalvm.compiler.core.common.CompilationIdentifier) OptionValues(org.graalvm.compiler.options.OptionValues) DebugContext(org.graalvm.compiler.debug.DebugContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) DisassemblerProvider(org.graalvm.compiler.code.DisassemblerProvider) InstalledCode(jdk.vm.ci.code.InstalledCode) CompilationResult(org.graalvm.compiler.code.CompilationResult) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

CallingConvention (jdk.vm.ci.code.CallingConvention)36 Register (jdk.vm.ci.code.Register)20 TargetDescription (jdk.vm.ci.code.TargetDescription)14 ValueUtil.asRegister (jdk.vm.ci.code.ValueUtil.asRegister)14 RegisterConfig (jdk.vm.ci.code.RegisterConfig)13 CompilationResult (org.graalvm.compiler.code.CompilationResult)12 RegisterValue (jdk.vm.ci.code.RegisterValue)11 AssemblerTest (org.graalvm.compiler.asm.test.AssemblerTest)11 Test (org.junit.Test)11 AMD64Assembler (org.graalvm.compiler.asm.amd64.AMD64Assembler)9 ForeignCallLinkage (org.graalvm.compiler.core.common.spi.ForeignCallLinkage)9 AMD64Address (org.graalvm.compiler.asm.amd64.AMD64Address)6 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)5 Value (jdk.vm.ci.meta.Value)5 Field (java.lang.reflect.Field)4 StackSlot (jdk.vm.ci.code.StackSlot)3 PlatformKind (jdk.vm.ci.meta.PlatformKind)3 GraalHotSpotVMConfig (org.graalvm.compiler.hotspot.GraalHotSpotVMConfig)3 HotSpotForeignCallLinkage (org.graalvm.compiler.hotspot.HotSpotForeignCallLinkage)3 HotSpotForeignCallLinkageImpl (org.graalvm.compiler.hotspot.HotSpotForeignCallLinkageImpl)3