use of org.graalvm.word.WordBase in project graal by oracle.
the class VMThreadLocalInfosFeature method dumpToLog.
public static void dumpToLog(Log log, IsolateThread thread) {
for (VMThreadLocalInfo info : ImageSingletons.lookup(VMThreadLocalInfos.class).infos) {
log.signed(info.offset).string(" (").signed(info.sizeInBytes).string(" bytes): ").string(info.name).string(" = ");
if (info.threadLocalClass == FastThreadLocalInt.class) {
int value = primitiveData(thread).readInt(WordFactory.signed(info.offset));
log.signed(value).string(" ").zhex(value);
} else if (info.threadLocalClass == FastThreadLocalLong.class) {
long value = primitiveData(thread).readLong(WordFactory.signed(info.offset));
log.signed(value).string(" ").zhex(value);
} else if (info.threadLocalClass == FastThreadLocalWord.class) {
WordBase value = primitiveData(thread).readWord(WordFactory.signed(info.offset));
log.signed(value).string(" ").zhex(value.rawValue());
} else if (info.threadLocalClass == FastThreadLocalObject.class) {
Object value = objectData(thread).readObject(WordFactory.signed(info.offset));
if (value == null) {
log.string("null");
} else {
log.string(value.getClass().getName()).string(" ").zhex(Word.objectToUntrackedPointer(value).rawValue());
}
} else if (info.threadLocalClass == FastThreadLocalBytes.class) {
log.indent(true);
log.hexdump(primitiveData(thread).add(WordFactory.signed(info.offset)), 8, info.sizeInBytes / 8);
log.indent(false);
} else {
log.string("unknown class ").string(info.threadLocalClass.getName());
}
log.newline();
}
}
use of org.graalvm.word.WordBase in project graal by oracle.
the class AllocationSnippets method formatObjectImpl.
private static Object formatObjectImpl(Pointer memory, DynamicHub hub, UnsignedWord size, @ConstantParameter boolean constantSize, @ConstantParameter boolean fillContents, boolean rememberedSet) {
if (fillContents) {
emitPrefetchAllocate(memory, false);
}
WordBase header = ObjectHeaderImpl.getObjectHeaderImpl().formatHub(hub, rememberedSet, false);
memory.writeWord(ConfigurationValues.getObjectLayout().getHubOffset(), header, LocationIdentity.INIT_LOCATION);
if (fillContents) {
UnsignedWord offset = WordFactory.unsigned(ConfigurationValues.getObjectLayout().getFirstFieldOffset());
if (constantSize && ((size.subtract(offset).unsignedDivide(ConfigurationValues.getTarget().wordSize)).belowOrEqual(SubstrateOptions.MaxUnrolledObjectZeroingStores.getValue()))) {
ExplodeLoopNode.explodeLoop();
}
while (offset.belowThan(size)) {
memory.writeWord(offset, WordFactory.zero(), LocationIdentity.INIT_LOCATION);
offset = offset.add(ConfigurationValues.getTarget().wordSize);
}
}
return memory.toObjectNonNull();
}
use of org.graalvm.word.WordBase in project graal by oracle.
the class WordTest method cast.
@Snippet
public static long cast(long input) {
WordBase base = WordFactory.signed(input);
UnsignedWord unsigned = (UnsignedWord) base;
Pointer pointer = (Pointer) unsigned;
Word word = (Word) pointer;
return word.rawValue();
}
use of org.graalvm.word.WordBase in project graal by oracle.
the class NativeImageHeap method writeConstant.
private void writeConstant(RelocatableBuffer buffer, int index, JavaKind kind, Object value, ObjectInfo info) {
if (value instanceof RelocatedPointer) {
addNonDataRelocation(buffer, index, (RelocatedPointer) value);
return;
}
final JavaConstant con;
if (value instanceof WordBase) {
con = JavaConstant.forIntegerKind(FrameAccess.getWordKind(), ((WordBase) value).rawValue());
} else if (value == null && kind == FrameAccess.getWordKind()) {
con = JavaConstant.forIntegerKind(FrameAccess.getWordKind(), 0);
} else {
assert kind == JavaKind.Object || value != null : "primitive value must not be null";
con = SubstrateObjectConstant.forBoxedValue(kind, value);
}
write(buffer, index, con, info);
}
use of org.graalvm.word.WordBase in project graal by oracle.
the class NativeImageHeap method writeReference.
void writeReference(RelocatableBuffer buffer, int index, Object target, Object reason) {
assert !(target instanceof WordBase) : "word values are not references";
mustBeAligned(index);
if (target != null) {
ObjectInfo targetInfo = objects.get(target);
verifyTargetDidNotChange(target, reason, targetInfo);
if (useHeapBase()) {
CompressEncoding compressEncoding = ImageSingletons.lookup(CompressEncoding.class);
int shift = compressEncoding.getShift();
writePointer(buffer, index, targetInfo.getOffsetInSection() >>> shift);
} else {
buffer.addDirectRelocationWithoutAddend(index, objectSize(), target);
}
}
}
Aggregations