Search in sources :

Example 11 with CallingConvention

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

the class BitOpsTest method lzcntlMemTest.

@Test
public void lzcntlMemTest() {
    if (lzcntSupported) {
        CodeGenTest test = new CodeGenTest() {

            @Override
            public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
                AMD64Assembler asm = new AMD64Assembler(target);
                Register ret = registerConfig.getReturnRegister(JavaKind.Int);
                try {
                    Field f = IntField.class.getDeclaredField("x");
                    AMD64Address arg = new AMD64Address(asRegister(cc.getArgument(0)), (int) UNSAFE.objectFieldOffset(f));
                    LZCNT.emit(asm, DWORD, ret, arg);
                    asm.ret(0);
                    return asm.close(true);
                } catch (Exception e) {
                    throw new RuntimeException("exception while trying to generate field access:", e);
                }
            }
        };
        assertReturn("intFieldStub", test, 31, new IntField(1));
    }
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention) RegisterConfig(jdk.vm.ci.code.RegisterConfig) Field(java.lang.reflect.Field) Register(jdk.vm.ci.code.Register) ValueUtil.asRegister(jdk.vm.ci.code.ValueUtil.asRegister) AMD64Assembler(org.graalvm.compiler.asm.amd64.AMD64Assembler) TargetDescription(jdk.vm.ci.code.TargetDescription) CompilationResult(org.graalvm.compiler.code.CompilationResult) AMD64Address(org.graalvm.compiler.asm.amd64.AMD64Address) Test(org.junit.Test) AssemblerTest(org.graalvm.compiler.asm.test.AssemblerTest)

Example 12 with CallingConvention

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

the class SimpleAssemblerTest method doubleTest.

@Test
public void doubleTest() {
    CodeGenTest test = new CodeGenTest() {

        @Override
        public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
            AMD64MacroAssembler asm = new AMD64MacroAssembler(target);
            Register ret = registerConfig.getReturnRegister(JavaKind.Double);
            Data data = new SerializableData(JavaConstant.forDouble(84.72), 8);
            DataSectionReference ref = compResult.getDataSection().insertData(data);
            compResult.recordDataPatch(asm.position(), ref);
            asm.movdbl(ret, asm.getPlaceholder(-1));
            asm.ret(0);
            return asm.close(true);
        }
    };
    assertReturn("doubleStub", test, 84.72);
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention) RegisterConfig(jdk.vm.ci.code.RegisterConfig) Register(jdk.vm.ci.code.Register) DataSectionReference(jdk.vm.ci.code.site.DataSectionReference) TargetDescription(jdk.vm.ci.code.TargetDescription) AMD64MacroAssembler(org.graalvm.compiler.asm.amd64.AMD64MacroAssembler) SerializableData(org.graalvm.compiler.code.DataSection.SerializableData) Data(org.graalvm.compiler.code.DataSection.Data) RawData(org.graalvm.compiler.code.DataSection.RawData) CompilationResult(org.graalvm.compiler.code.CompilationResult) SerializableData(org.graalvm.compiler.code.DataSection.SerializableData) Test(org.junit.Test) AssemblerTest(org.graalvm.compiler.asm.test.AssemblerTest)

Example 13 with CallingConvention

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

the class SimpleAssemblerTest method rawDoubleTest.

@Test
public void rawDoubleTest() {
    CodeGenTest test = new CodeGenTest() {

        @Override
        public byte[] generateCode(CompilationResult compResult, TargetDescription target, RegisterConfig registerConfig, CallingConvention cc) {
            AMD64MacroAssembler asm = new AMD64MacroAssembler(target);
            Register ret = registerConfig.getReturnRegister(JavaKind.Double);
            byte[] rawBytes = new byte[8];
            ByteBuffer.wrap(rawBytes).order(ByteOrder.nativeOrder()).putDouble(84.72);
            Data data = new RawData(rawBytes, 8);
            DataSectionReference ref = compResult.getDataSection().insertData(data);
            compResult.recordDataPatch(asm.position(), ref);
            asm.movdbl(ret, asm.getPlaceholder(-1));
            asm.ret(0);
            return asm.close(true);
        }
    };
    assertReturn("doubleStub", test, 84.72);
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention) RawData(org.graalvm.compiler.code.DataSection.RawData) RegisterConfig(jdk.vm.ci.code.RegisterConfig) Register(jdk.vm.ci.code.Register) DataSectionReference(jdk.vm.ci.code.site.DataSectionReference) TargetDescription(jdk.vm.ci.code.TargetDescription) AMD64MacroAssembler(org.graalvm.compiler.asm.amd64.AMD64MacroAssembler) SerializableData(org.graalvm.compiler.code.DataSection.SerializableData) Data(org.graalvm.compiler.code.DataSection.Data) RawData(org.graalvm.compiler.code.DataSection.RawData) CompilationResult(org.graalvm.compiler.code.CompilationResult) Test(org.junit.Test) AssemblerTest(org.graalvm.compiler.asm.test.AssemblerTest)

Example 14 with CallingConvention

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

the class LIRGenerator method emitForeignCall.

@Override
public Variable emitForeignCall(ForeignCallLinkage linkage, LIRFrameState frameState, Value... args) {
    LIRFrameState state = null;
    if (linkage.needsDebugInfo()) {
        if (frameState != null) {
            state = frameState;
        } else {
            assert needOnlyOopMaps();
            state = new LIRFrameState(null, null, null);
        }
    }
    // move the arguments into the correct location
    CallingConvention linkageCc = linkage.getOutgoingCallingConvention();
    res.getFrameMapBuilder().callsMethod(linkageCc);
    assert linkageCc.getArgumentCount() == args.length : "argument count mismatch";
    Value[] argLocations = new Value[args.length];
    for (int i = 0; i < args.length; i++) {
        Value arg = args[i];
        AllocatableValue loc = linkageCc.getArgument(i);
        emitMove(loc, arg);
        argLocations[i] = loc;
    }
    res.setForeignCall(true);
    emitForeignCallOp(linkage, linkageCc.getReturn(), argLocations, linkage.getTemporaries(), state);
    if (isLegal(linkageCc.getReturn())) {
        return emitMove(linkageCc.getReturn());
    } else {
        return null;
    }
}
Also used : CallingConvention(jdk.vm.ci.code.CallingConvention) LIRFrameState(org.graalvm.compiler.lir.LIRFrameState) ConstantValue(org.graalvm.compiler.lir.ConstantValue) LIRValueUtil.isConstantValue(org.graalvm.compiler.lir.LIRValueUtil.isConstantValue) ValueUtil.asAllocatableValue(jdk.vm.ci.code.ValueUtil.asAllocatableValue) Value(jdk.vm.ci.meta.Value) ValueUtil.isAllocatableValue(jdk.vm.ci.code.ValueUtil.isAllocatableValue) AllocatableValue(jdk.vm.ci.meta.AllocatableValue) ValueUtil.asAllocatableValue(jdk.vm.ci.code.ValueUtil.asAllocatableValue) ValueUtil.isAllocatableValue(jdk.vm.ci.code.ValueUtil.isAllocatableValue) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Example 15 with CallingConvention

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

the class SPARCHotSpotForeignCallsProvider 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_sparc.cpp around line 1925
    RegisterValue outgoingException = o0.asValue(LIRKind.fromJavaKind(target.arch, JavaKind.Object));
    RegisterValue outgoingExceptionPc = o1.asValue(LIRKind.value(word));
    RegisterValue incomingException = i0.asValue(LIRKind.fromJavaKind(target.arch, JavaKind.Object));
    RegisterValue incomingExceptionPc = i1.asValue(LIRKind.value(word));
    CallingConvention outgoingExceptionCc = new CallingConvention(0, ILLEGAL, outgoingException, outgoingExceptionPc);
    CallingConvention incomingExceptionCc = new CallingConvention(0, ILLEGAL, incomingException, incomingExceptionPc);
    register(new HotSpotForeignCallLinkageImpl(EXCEPTION_HANDLER, 0L, PRESERVES_REGISTERS, LEAF_NOFP, outgoingExceptionCc, incomingExceptionCc, NOT_REEXECUTABLE, any()));
    register(new HotSpotForeignCallLinkageImpl(EXCEPTION_HANDLER_IN_CALLER, JUMP_ADDRESS, PRESERVES_REGISTERS, LEAF_NOFP, outgoingExceptionCc, incomingExceptionCc, NOT_REEXECUTABLE, any()));
    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