use of org.graalvm.word.UnsignedWord in project graal by oracle.
the class HeapVerifierImpl method noReferencesOutsideHeap.
/**
* For debugging: look for objects with interior references to outside the heap.
*
* That includes: references that are to zapped objects, and references that aren't to the heap.
*/
private boolean noReferencesOutsideHeap(Object obj) {
final Log trace = getTraceLog();
trace.string("[HeapVerifierImpl.noReferencesToZappedObjectsVerifier:");
trace.string(" obj: ").object(obj).string(" obj.getClass: ").string(obj.getClass().getName());
final ObjectHeaderImpl ohi = ObjectHeaderImpl.getObjectHeaderImpl();
final UnsignedWord header = ObjectHeaderImpl.readHeaderFromObjectCarefully(obj);
trace.string(" header: ").hex(header).string(" objectHeader: ").string(ohi.toStringFromObject(obj));
final Pointer objPointer = Word.objectToUntrackedPointer(obj);
trace.string(" objPointer: ").hex(objPointer);
boolean result = InteriorObjRefWalker.walkObject(obj, noReferencesOutsideHeapVisitor);
if (!result) {
try (Log witness = getWitnessLog()) {
witness.string("[HeapVerifierImpl.noReferencesOutsideHeap:").string(" cause: ").string(getCause());
witness.string(" obj: ").string(obj.getClass().getName()).string("@").hex(objPointer);
witness.string(" header: ").hex(header).string(" objectHeader: ").string(ohi.toStringFromObject(obj)).string("]").newline();
}
}
trace.string(" returns: ").bool(result).string("]").newline();
return result;
}
use of org.graalvm.word.UnsignedWord in project graal by oracle.
the class ObjectHeaderImpl method classifyHeader.
/**
* Debugging: Classifies a header so I can decide how much to trust it.
*
* <ul>
* <li>Negative results fail in one way or another.</li>
* <li>Positive results mean the header was valid.</li>
* </ul>
*/
public static int classifyHeader(UnsignedWord header) {
/* Check for total failures. */
if (header.equal(WordFactory.zero())) {
return -1_000_000;
}
if (header.equal(HeapPolicy.getProducedHeapChunkZapValue())) {
return -2_000_000;
}
if (header.equal(HeapPolicy.getConsumedHeapChunkZapValue())) {
return -3_000_000;
}
/* Tease the header apart into the DynamicHub bits and the header bits. */
final UnsignedWord headerBits = ObjectHeaderImpl.getHeaderBitsFromHeaderCarefully(header);
final int headerBitsClassification;
if (headerBits.equal(NO_REMEMBERED_SET_ALIGNED)) {
headerBitsClassification = 1;
} else if (headerBits.equal(CARD_REMEMBERED_SET_ALIGNED)) {
headerBitsClassification = 2;
} else if (headerBits.equal(NO_REMEMBERED_SET_UNALIGNED)) {
headerBitsClassification = 3;
} else if (headerBits.equal(CARD_REMEMBERED_SET_UNALIGNED)) {
headerBitsClassification = 4;
} else if (headerBits.equal(BOOT_IMAGE)) {
headerBitsClassification = 5;
} else if (headerBits.equal(FORWARDED)) {
headerBitsClassification = 6;
} else {
headerBitsClassification = -1;
}
final DynamicHub hub = ObjectHeader.dynamicHubFromObjectHeader(header);
final int hubClassification = HeapVerifierImpl.classifyObject(hub);
return ((1000 * hubClassification) + headerBitsClassification);
}
use of org.graalvm.word.UnsignedWord in project graal by oracle.
the class ObjectHeaderImpl method readHeaderFromPointerCarefully.
public static UnsignedWord readHeaderFromPointerCarefully(Pointer p) {
VMError.guarantee(!p.isNull(), "ObjectHeader.readHeaderFromPointerCarefully: p: null");
VMError.guarantee(p.notEqual(HeapPolicy.getProducedHeapChunkZapValue()), "ObjectHeader.readHeaderFromPointerCarefully: p: producedZapValue");
VMError.guarantee(p.notEqual(HeapPolicy.getConsumedHeapChunkZapValue()), "ObjectHeader.readHeaderFromPointerCarefully: p: consumedZapValue");
final UnsignedWord header = readHeaderFromPointer(p);
VMError.guarantee(header.notEqual(WordFactory.zero()), "ObjectHeader.readHeaderFromPointerCarefully: header: 0");
VMError.guarantee(header.notEqual(HeapPolicy.getProducedHeapChunkZapValue()), "ObjectHeader.readHeaderFromPointerCarefully: header: producedZapValue");
VMError.guarantee(header.notEqual(HeapPolicy.getConsumedHeapChunkZapValue()), "ObjectHeader.readHeaderFromPointerCarefully: header: consumedZapValue");
return header;
}
use of org.graalvm.word.UnsignedWord in project graal by oracle.
the class ObjectHeaderImpl method isPointerToForwardedObjectCarefully.
protected boolean isPointerToForwardedObjectCarefully(Pointer p) {
final UnsignedWord header = readHeaderFromPointerCarefully(p);
final boolean result = isForwardedHeaderCarefully(header);
return result;
}
use of org.graalvm.word.UnsignedWord in project graal by oracle.
the class OldGeneration method promoteUnalignedObjectChunk.
private Object promoteUnalignedObjectChunk(Object original) {
final Log trace = Log.noopLog().string("[OldGeneration.promoteUnalignedObjectChunk:").string(" original: ").object(original);
assert ObjectHeaderImpl.getObjectHeaderImpl().isUnalignedObject(original);
final UnalignedHeapChunk.UnalignedHeader uChunk = UnalignedHeapChunk.getEnclosingUnalignedHeapChunk(original);
final Space originalSpace = uChunk.getSpace();
trace.string(" originalSpace: ").string(originalSpace.getName());
if (shouldPromoteFrom(originalSpace)) {
trace.string(" promoting");
/*
* Since the object does not move when an UnalignedChunk is promoted, there is no need
* to return a possible copy.
*/
if (HeapOptions.TraceObjectPromotion.getValue()) {
final Log promotionTrace = Log.log().string("[OldGeneration.promoteUnalignedObjectChunk:").string(" original: ").object(original);
final UnsignedWord size = LayoutEncoding.getSizeFromObject(original);
promotionTrace.string(" size: ").unsigned(size).string("]").newline();
}
getToSpace().promoteUnalignedHeapChunk(uChunk);
} else {
trace.string(" not promoting");
}
trace.string(" returns: ").object(original);
if (trace.isEnabled()) {
final UnalignedHeapChunk.UnalignedHeader resultChunk = UnalignedHeapChunk.getEnclosingUnalignedHeapChunk(original);
final Space resultSpace = resultChunk.getSpace();
trace.string(" resultSpace: ").string(resultSpace.getName());
}
trace.string("]").newline();
return original;
}
Aggregations