Search in sources :

Example 1 with DataSectionReference

use of jdk.vm.ci.code.site.DataSectionReference 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 2 with DataSectionReference

use of jdk.vm.ci.code.site.DataSectionReference 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 3 with DataSectionReference

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

the class InstalledCodeBuilder method patchData.

private void patchData(AMD64InstructionPatcher patcher) {
    for (DataPatch dataPatch : compilation.getDataPatches()) {
        DataSectionReference ref = (DataSectionReference) dataPatch.reference;
        int pcDisplacement = constantsOffset + ref.getOffset() - dataPatch.pcOffset;
        patcher.findPatchData(dataPatch.pcOffset, pcDisplacement).apply(compiledBytes);
    }
}
Also used : DataPatch(jdk.vm.ci.code.site.DataPatch) DataSectionReference(jdk.vm.ci.code.site.DataSectionReference) Infopoint(jdk.vm.ci.code.site.Infopoint)

Example 4 with DataSectionReference

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

the class DataSection method insertData.

/**
 * Inserts a {@link Data} item into the data section. If the item is already in the data
 * section, the same {@link DataSectionReference} is returned.
 *
 * @param data the {@link Data} item to be inserted
 * @return a unique {@link DataSectionReference} identifying the {@link Data} item
 */
public DataSectionReference insertData(Data data) {
    checkOpen();
    synchronized (data) {
        if (data.ref == null) {
            data.ref = new DataSectionReference();
            dataItems.add(data);
        }
        return data.ref;
    }
}
Also used : DataSectionReference(jdk.vm.ci.code.site.DataSectionReference)

Example 5 with DataSectionReference

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

the class CompilationResultBuilder method recordDataSectionReference.

public AbstractAddress recordDataSectionReference(Data data) {
    assert data != null;
    DataSectionReference reference = compilationResult.getDataSection().insertData(data);
    int instructionStart = asm.position();
    compilationResult.recordDataPatch(instructionStart, reference);
    return asm.getPlaceholder(instructionStart);
}
Also used : DataSectionReference(jdk.vm.ci.code.site.DataSectionReference)

Aggregations

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