Search in sources :

Example 16 with CallingConvention

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

the class SPARCHotSpotUnwindOp method emitCode.

@Override
public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) {
    // This Frame is left but the called unwind (which is sibling) method needs the exception as
    // input in i0
    masm.mov(o0, i0);
    leaveFrame(crb);
    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 o7 after leave).
    Register returnAddress = asRegister(cc.getArgument(1));
    masm.add(o7, SPARCAssembler.PC_RETURN_OFFSET, returnAddress);
    Register scratch = g5;
    SPARCCall.indirectJmp(crb, masm, scratch, 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 17 with CallingConvention

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

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

the class SPARCHotSpotLIRGenerator method emitUnwind.

@Override
public void emitUnwind(Value exception) {
    ForeignCallLinkage linkage = getForeignCalls().lookupForeignCall(HotSpotBackend.UNWIND_EXCEPTION_TO_CALLER);
    CallingConvention linkageCc = linkage.getOutgoingCallingConvention();
    assert linkageCc.getArgumentCount() == 2;
    RegisterValue exceptionParameter = (RegisterValue) linkageCc.getArgument(0);
    emitMove(exceptionParameter, exception);
    append(new SPARCHotSpotUnwindOp(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 19 with CallingConvention

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

the class SPARCHotSpotNodeLIRBuilder method emitJumpToExceptionHandlerInCaller.

@Override
public void emitJumpToExceptionHandlerInCaller(ValueNode handlerInCallerPc, ValueNode exception, ValueNode exceptionPc) {
    Variable handler = gen.load(operand(handlerInCallerPc));
    ForeignCallLinkage linkage = gen.getForeignCalls().lookupForeignCall(EXCEPTION_HANDLER_IN_CALLER);
    CallingConvention linkageCc = linkage.getOutgoingCallingConvention();
    assert linkageCc.getArgumentCount() == 2;
    RegisterValue exceptionFixed = (RegisterValue) linkageCc.getArgument(0);
    RegisterValue exceptionPcFixed = (RegisterValue) linkageCc.getArgument(1);
    gen.emitMove(exceptionFixed, operand(exception));
    gen.emitMove(exceptionPcFixed, operand(exceptionPc));
    Register thread = getGen().getProviders().getRegisters().getThreadRegister();
    SPARCHotSpotJumpToExceptionHandlerInCallerOp op = new SPARCHotSpotJumpToExceptionHandlerInCallerOp(handler, exceptionFixed, exceptionPcFixed, getGen().config.threadIsMethodHandleReturnOffset, thread);
    append(op);
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention) RegisterValue(jdk.vm.ci.code.RegisterValue) Variable(org.graalvm.compiler.lir.Variable) Register(jdk.vm.ci.code.Register) ForeignCallLinkage(org.graalvm.compiler.core.common.spi.ForeignCallLinkage)

Example 20 with CallingConvention

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

the class AMD64HotSpotForeignCallsProvider 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()
    // in templateInterpreter_x86_64.cpp around line 1923
    RegisterValue exception = rax.asValue(LIRKind.reference(word));
    RegisterValue exceptionPc = rdx.asValue(LIRKind.value(word));
    CallingConvention exceptionCc = new CallingConvention(0, ILLEGAL, exception, exceptionPc);
    register(new HotSpotForeignCallLinkageImpl(EXCEPTION_HANDLER, 0L, PRESERVES_REGISTERS, LEAF_NOFP, exceptionCc, null, NOT_REEXECUTABLE, any()));
    register(new HotSpotForeignCallLinkageImpl(EXCEPTION_HANDLER_IN_CALLER, JUMP_ADDRESS, PRESERVES_REGISTERS, LEAF_NOFP, exceptionCc, null, NOT_REEXECUTABLE, any()));
    link(new AMD64MathStub(ARITHMETIC_LOG_STUB, options, providers, registerStubCall(ARITHMETIC_LOG_STUB, REEXECUTABLE, LEAF, NO_LOCATIONS)));
    link(new AMD64MathStub(ARITHMETIC_LOG10_STUB, options, providers, registerStubCall(ARITHMETIC_LOG10_STUB, REEXECUTABLE, LEAF, NO_LOCATIONS)));
    link(new AMD64MathStub(ARITHMETIC_SIN_STUB, options, providers, registerStubCall(ARITHMETIC_SIN_STUB, REEXECUTABLE, LEAF, NO_LOCATIONS)));
    link(new AMD64MathStub(ARITHMETIC_COS_STUB, options, providers, registerStubCall(ARITHMETIC_COS_STUB, REEXECUTABLE, LEAF, NO_LOCATIONS)));
    link(new AMD64MathStub(ARITHMETIC_TAN_STUB, options, providers, registerStubCall(ARITHMETIC_TAN_STUB, REEXECUTABLE, LEAF, NO_LOCATIONS)));
    link(new AMD64MathStub(ARITHMETIC_EXP_STUB, options, providers, registerStubCall(ARITHMETIC_EXP_STUB, REEXECUTABLE, LEAF, NO_LOCATIONS)));
    link(new AMD64MathStub(ARITHMETIC_POW_STUB, options, providers, registerStubCall(ARITHMETIC_POW_STUB, REEXECUTABLE, LEAF, NO_LOCATIONS)));
    if (config.useCRC32Intrinsics) {
        // This stub does callee saving
        registerForeignCall(UPDATE_BYTES_CRC32, config.updateBytesCRC32Stub, NativeCall, PRESERVES_REGISTERS, LEAF_NOFP, NOT_REEXECUTABLE, any());
    }
    if (config.useCRC32CIntrinsics) {
        registerForeignCall(UPDATE_BYTES_CRC32C, config.updateBytesCRC32C, NativeCall, PRESERVES_REGISTERS, LEAF_NOFP, 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)

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