Search in sources :

Example 1 with RawData

use of org.graalvm.compiler.code.DataSection.RawData 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)

Aggregations

CallingConvention (jdk.vm.ci.code.CallingConvention)1 Register (jdk.vm.ci.code.Register)1 RegisterConfig (jdk.vm.ci.code.RegisterConfig)1 TargetDescription (jdk.vm.ci.code.TargetDescription)1 DataSectionReference (jdk.vm.ci.code.site.DataSectionReference)1 AMD64MacroAssembler (org.graalvm.compiler.asm.amd64.AMD64MacroAssembler)1 AssemblerTest (org.graalvm.compiler.asm.test.AssemblerTest)1 CompilationResult (org.graalvm.compiler.code.CompilationResult)1 Data (org.graalvm.compiler.code.DataSection.Data)1 RawData (org.graalvm.compiler.code.DataSection.RawData)1 SerializableData (org.graalvm.compiler.code.DataSection.SerializableData)1 Test (org.junit.Test)1