use of org.graalvm.compiler.code.DataSection.SerializableData in project graal by oracle.
the class HotSpotDataBuilder method createDataItem.
@Override
public Data createDataItem(Constant constant) {
if (JavaConstant.isNull(constant)) {
boolean compressed = COMPRESSED_NULL.equals(constant);
int size = compressed ? 4 : target.wordSize;
return ZeroData.create(size, size);
} else if (constant instanceof VMConstant) {
VMConstant vmConstant = (VMConstant) constant;
if (!(constant instanceof HotSpotConstant)) {
throw new GraalError(String.valueOf(constant));
}
HotSpotConstant c = (HotSpotConstant) vmConstant;
int size = c.isCompressed() ? 4 : target.wordSize;
return new Data(size, size) {
@Override
protected void emit(ByteBuffer buffer, Patches patches) {
int position = buffer.position();
if (getSize() == Integer.BYTES) {
buffer.putInt(0xDEADDEAD);
} else {
buffer.putLong(0xDEADDEADDEADDEADL);
}
patches.registerPatch(position, vmConstant);
}
};
} else if (constant instanceof SerializableConstant) {
SerializableConstant s = (SerializableConstant) constant;
return new SerializableData(s);
} else {
throw new GraalError(String.valueOf(constant));
}
}
use of org.graalvm.compiler.code.DataSection.SerializableData 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);
}
Aggregations