Search in sources :

Example 1 with CallingConvention

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

Example 2 with CallingConvention

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

the class AArch64HotSpotNodeLIRBuilder method emitPrologue.

@Override
protected void emitPrologue(StructuredGraph graph) {
    CallingConvention incomingArguments = gen.getResult().getCallingConvention();
    Value[] params = new Value[incomingArguments.getArgumentCount() + 2];
    for (int i = 0; i < incomingArguments.getArgumentCount(); i++) {
        params[i] = incomingArguments.getArgument(i);
        if (isStackSlot(params[i])) {
            StackSlot slot = ValueUtil.asStackSlot(params[i]);
            if (slot.isInCallerFrame() && !gen.getResult().getLIR().hasArgInCallerFrame()) {
                gen.getResult().getLIR().setHasArgInCallerFrame();
            }
        }
    }
    params[params.length - 2] = fp.asValue(LIRKind.value(AArch64Kind.QWORD));
    params[params.length - 1] = lr.asValue(LIRKind.value(AArch64Kind.QWORD));
    gen.emitIncomingValues(params);
    for (ParameterNode param : graph.getNodes(ParameterNode.TYPE)) {
        Value paramValue = params[param.index()];
        assert paramValue.getValueKind().equals(getLIRGeneratorTool().getLIRKind(param.stamp(NodeView.DEFAULT))) : paramValue.getValueKind() + " != " + param.stamp(NodeView.DEFAULT);
        setResult(param, gen.emitMove(paramValue));
    }
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) RegisterValue(jdk.vm.ci.code.RegisterValue) Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) ValueUtil.isStackSlot(jdk.vm.ci.code.ValueUtil.isStackSlot) StackSlot(jdk.vm.ci.code.StackSlot)

Example 3 with CallingConvention

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

the class AArch64HotSpotNodeLIRBuilder 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 outgoingCc = linkage.getOutgoingCallingConvention();
    assert outgoingCc.getArgumentCount() == 2;
    RegisterValue exceptionFixed = (RegisterValue) outgoingCc.getArgument(0);
    RegisterValue exceptionPcFixed = (RegisterValue) outgoingCc.getArgument(1);
    gen.emitMove(exceptionFixed, operand(exception));
    gen.emitMove(exceptionPcFixed, operand(exceptionPc));
    Register thread = getGen().getProviders().getRegisters().getThreadRegister();
    AArch64HotSpotJumpToExceptionHandlerInCallerOp op = new AArch64HotSpotJumpToExceptionHandlerInCallerOp(handler, exceptionFixed, exceptionPcFixed, getGen().config.threadIsMethodHandleReturnOffset, thread, getGen().config);
    append(op);
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention) RegisterValue(jdk.vm.ci.code.RegisterValue) Variable(org.graalvm.compiler.lir.Variable) AArch64HotSpotRegisterConfig.inlineCacheRegister(jdk.vm.ci.hotspot.aarch64.AArch64HotSpotRegisterConfig.inlineCacheRegister) Register(jdk.vm.ci.code.Register) AArch64HotSpotRegisterConfig.metaspaceMethodRegister(jdk.vm.ci.hotspot.aarch64.AArch64HotSpotRegisterConfig.metaspaceMethodRegister) ForeignCallLinkage(org.graalvm.compiler.core.common.spi.ForeignCallLinkage)

Example 4 with CallingConvention

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

the class AMD64HotSpotLIRGenerator 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 AMD64HotSpotUnwindOp(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 5 with CallingConvention

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

the class AArch64HotSpotBackend method emitCodePrefix.

private void emitCodePrefix(CompilationResultBuilder crb, ResolvedJavaMethod installedCodeOwner, AArch64MacroAssembler masm, RegisterConfig regConfig, Label verifiedStub) {
    HotSpotProviders providers = getProviders();
    if (installedCodeOwner != null && !isStatic(installedCodeOwner.getModifiers())) {
        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 c1_LIRAssembler_aarch64.cpp
        // equal to scratch(1) careful!
        Register inlineCacheKlass = AArch64HotSpotRegisterConfig.inlineCacheRegister;
        Register receiver = asRegister(cc.getArgument(0));
        int transferSize = config.useCompressedClassPointers ? 4 : 8;
        AArch64Address klassAddress = masm.makeAddress(receiver, config.hubOffset, transferSize);
        // Are r10 and r11 available scratch registers here? One would hope so.
        Register klass = r10;
        if (config.useCompressedClassPointers) {
            masm.ldr(32, klass, klassAddress);
            AArch64HotSpotMove.decodeKlassPointer(masm, klass, klass, providers.getRegisters().getHeapBaseRegister(), config.getKlassEncoding());
        } else {
            masm.ldr(64, klass, klassAddress);
        }
        masm.cmp(64, inlineCacheKlass, klass);
        /*
             * Conditional jumps have a much lower range than unconditional ones, which can be a
             * problem because the miss handler could be out of range.
             */
        masm.branchConditionally(AArch64Assembler.ConditionFlag.EQ, verifiedStub);
        AArch64Call.directJmp(crb, masm, getForeignCalls().lookupForeignCall(IC_MISS_HANDLER));
    }
    masm.align(config.codeEntryAlignment);
    crb.recordMark(config.MARKID_OSR_ENTRY);
    masm.bind(verifiedStub);
    crb.recordMark(config.MARKID_VERIFIED_ENTRY);
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention) 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) AArch64Address(org.graalvm.compiler.asm.aarch64.AArch64Address)

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