use of jdk.vm.ci.hotspot.HotSpotConstant 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));
}
}
Aggregations