use of org.graalvm.word.Pointer in project graal by oracle.
the class ObjectHeaderImpl method installForwardingPointer.
/*
* Forwarding pointer methods.
*/
/**
* Install in an Object, a forwarding pointer to a different Object.
*/
protected void installForwardingPointer(Object original, Object copy) {
assert !isPointerToForwardedObject(Word.objectToUntrackedPointer(original));
/* Turn the copy Object into a Pointer, and encode that as a forwarding pointer. */
final Pointer unforwardedPointer = Word.objectToUntrackedPointer(copy);
final UnsignedWord forwarder = createForwardingPointer(unforwardedPointer);
writeHeaderToObject(original, forwarder);
assert isPointerToForwardedObject(Word.objectToUntrackedPointer(original));
}
use of org.graalvm.word.Pointer in project graal by oracle.
the class PathExhibitor method findPathInStack.
protected StackElement findPathInStack(final Object obj) {
stackFrameVisitor.initialize(obj);
Pointer sp = readCallerStackPointer();
CodePointer ip = readReturnAddress();
JavaStackWalker.walkCurrentThread(sp, ip, stackFrameVisitor);
final StackElement result = frameSlotVisitor.getElement();
return result;
}
use of org.graalvm.word.Pointer in project graal by oracle.
the class PathExhibitor method findPathInBootImageHeap.
protected PathElement findPathInBootImageHeap(final Object targetObject, final Object firstObject, final Object lastObject) {
if ((firstObject == null) || (lastObject == null)) {
return null;
}
final Pointer targetPointer = Word.objectToUntrackedPointer(targetObject);
final Pointer firstPointer = Word.objectToUntrackedPointer(firstObject);
final Pointer lastPointer = Word.objectToUntrackedPointer(lastObject);
Pointer current = firstPointer;
while (current.belowOrEqual(lastPointer)) {
final Object bihObject = current.toObject();
// I am not interested in references from path elements.
if (!checkForInterference(bihObject)) {
bootImageHeapObjRefVisitor.initialize(current, targetPointer);
if (!InteriorObjRefWalker.walkObject(bihObject, bootImageHeapObjRefVisitor)) {
break;
}
}
current = LayoutEncoding.getObjectEnd(bihObject);
}
return bootImageHeapObjRefVisitor.getElement();
}
use of org.graalvm.word.Pointer in project graal by oracle.
the class GreyObjectsWalker method walkAlignedGreyObjects.
private boolean walkAlignedGreyObjects(final ObjectVisitor visitor) {
final Log trace = Log.noopLog().string("[Space.GreyObjectsWalker.walkAlignedGreyObjects:");
/* Locals that start from the snapshot. */
AlignedHeapChunk.AlignedHeader aChunk = WordFactory.nullPointer();
Pointer aOffset = WordFactory.nullPointer();
if (getAlignedHeapChunk().isNull() && getAlignedTop().isNull()) {
/* If the snapshot is empty, then I have to walk from the beginning of the Space. */
aChunk = space.getFirstAlignedHeapChunk();
aOffset = (aChunk.isNonNull() ? AlignedHeapChunk.getAlignedHeapChunkStart(aChunk) : WordFactory.nullPointer());
} else {
/* Otherwise walk Objects that arrived after the snapshot. */
aChunk = getAlignedHeapChunk();
aOffset = getAlignedTop();
}
/* Visit Objects in the AlignedChunks. */
while (aChunk.isNonNull()) {
trace.newline().string(" aChunk: ").hex(aChunk).string(" aOffset: ").hex(aOffset);
if (!AlignedHeapChunk.walkObjectsFrom(aChunk, aOffset, visitor)) {
/* Log the failure. */
Log.log().string("[Space.GreyObjectsWalker.walkAlignedGreyObjects: aChunk.walkObject fails.]").newline();
return false;
}
/* Move the scan point. */
setAlignedHeapChunk(aChunk);
setAlignedTop(aChunk.getTop());
trace.string(" moved aligned scan point to: ").string(" alignedChunk: ").hex(getAlignedHeapChunk()).string(" alignedTop: ").hex(getAlignedTop());
/* Step to the next AlignedChunk. */
aChunk = aChunk.getNext();
aOffset = (aChunk.isNonNull() ? AlignedHeapChunk.getAlignedHeapChunkStart(aChunk) : WordFactory.nullPointer());
}
trace.string(" returns true").string("]").newline();
return true;
}
use of org.graalvm.word.Pointer in project graal by oracle.
the class HeapChunk method availableObjectMemory.
/**
* How much space is available for objects in a HeapChunk?
*/
@Uninterruptible(reason = "Called from uninterruptible code.")
public static UnsignedWord availableObjectMemory(Header<?> that) {
final Pointer top = that.getTop();
final Pointer end = that.getEnd();
return end.subtract(top);
}
Aggregations