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);
}
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);
}
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);
}
}
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;
}
}
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);
}
Aggregations