use of org.graalvm.word.Pointer in project graal by oracle.
the class CardTable method verifyDirtyCards.
/**
* Check that that every object with a pointer to young space has a corresponding dirty card.
*/
private static boolean verifyDirtyCards(Pointer ctStart, Pointer objectsStart, Pointer objectsLimit) {
final Log trace = Log.noopLog().string("[CardTable.verifyDirtyCards:");
trace.string(" ctStart: ").hex(ctStart).string(" objectsStart: ").hex(objectsStart).string(" objectsLimit: ").hex(objectsLimit);
/* Walk the objects */
Pointer ptr = objectsStart;
while (ptr.belowThan(objectsLimit)) {
final Object obj = ptr.toObject();
final boolean containsYoung = containsReferenceToYoungSpace(obj);
if (containsYoung) {
final UnsignedWord index = memoryPointerToIndex(objectsStart, objectsLimit, ptr);
final boolean isClean = isCleanEntryAtIndex(ctStart, index);
if (isClean) {
/* { WITNESS */
final boolean witnessForDebugging = true;
final Log witness = (witnessForDebugging ? Log.log() : HeapImpl.getHeapImpl().getHeapVerifierImpl().getTraceLog());
witness.string("[CardTable.verifyDirtyCards:").string(" objectsStart: ").hex(objectsStart).string(" objectsLimit: ").hex(objectsLimit).newline();
witness.string(" obj: ").object(obj).string(" contains young: ").bool(containsYoung).string(" but index: ").unsigned(index).string(" is clean.").string(" returns false").string("]").newline();
/* Return early on failure. */
return false;
}
}
ptr = LayoutEncoding.getObjectEnd(obj);
}
trace.string("]").newline();
return true;
}
use of org.graalvm.word.Pointer in project graal by oracle.
the class DiscoverableReferenceProcessing method verify.
public static boolean verify(DiscoverableReference dr) {
final Pointer refPointer = dr.getReferentPointer();
final int refClassification = HeapVerifierImpl.classifyPointer(refPointer);
if (refClassification < 0) {
final Log witness = Log.log();
witness.string("[DiscoverableReference.verify:");
witness.string(" epoch: ").unsigned(HeapImpl.getHeapImpl().getGCImpl().getCollectionEpoch());
witness.string(" refClassification: ").signed(refClassification);
witness.string("]").newline();
assert (!(refClassification < 0)) : "Bad referent.";
return false;
}
/* Figure out where the referent is. */
final HeapImpl heap = HeapImpl.getHeapImpl();
final YoungGeneration youngGen = heap.getYoungGeneration();
final OldGeneration oldGen = heap.getOldGeneration();
final boolean refNull = refPointer.isNull();
final boolean refBootImage = (!refNull) && HeapVerifierImpl.slowlyFindPointerInBootImage(refPointer);
final boolean refYoung = (!refNull) && youngGen.slowlyFindPointer(refPointer);
final boolean refOldFrom = (!refNull) && oldGen.slowlyFindPointerInFromSpace(refPointer);
final boolean refOldTo = (!refNull) && oldGen.slowlyFindPointerInToSpace(refPointer);
final boolean refOldPinnedFrom = (!refNull) && oldGen.slowlyFindPointerInPinnedFromSpace(refPointer);
final boolean refOldPinnedTo = (!refNull) && oldGen.slowlyFindPointerInPinnedToSpace(refPointer);
/* The referent might already have survived, or might not have. */
if (!(refNull || refYoung || refBootImage || refOldFrom || refOldPinnedFrom)) {
final Log witness = Log.log();
witness.string("[DiscoverableReference.verify:");
witness.string(" epoch: ").unsigned(HeapImpl.getHeapImpl().getGCImpl().getCollectionEpoch());
witness.string(" refBootImage: ").bool(refBootImage);
witness.string(" refYoung: ").bool(refYoung);
witness.string(" refOldFrom: ").bool(refOldFrom);
witness.string(" refOldPinnedFrom: ").bool(refOldPinnedFrom);
witness.string(" referent should be in heap.");
witness.string("]").newline();
return false;
}
assert (!(refOldTo || refOldPinnedTo)) : "referent should be in the heap.";
return true;
}
use of org.graalvm.word.Pointer in project graal by oracle.
the class GarbageCollectorManagementFactory method blackenBootImageRoots.
@SuppressWarnings("try")
private void blackenBootImageRoots() {
final Log trace = Log.noopLog().string("[blackenBootImageRoots:").newline();
try (Timer bbirt = blackenBootImageRootsTimer.open()) {
try (GreyToBlackObjRefVisitor.Counters gtborv = greyToBlackObjRefVisitor.openCounters()) {
/* Walk through the native image heap roots. */
Pointer cur = Word.objectToUntrackedPointer(NativeImageInfo.firstWritableReferenceObject);
final Pointer last = Word.objectToUntrackedPointer(NativeImageInfo.lastWritableReferenceObject);
while (cur.belowOrEqual(last)) {
Object obj = cur.toObject();
if (obj != null) {
greyToBlackObjectVisitor.visitObjectInline(obj);
}
cur = LayoutEncoding.getObjectEnd(obj);
}
}
}
trace.string("]").newline();
}
use of org.graalvm.word.Pointer in project graal by oracle.
the class HeapVerifierImpl method noReferencesToForwardedObjectsVerifier.
/* Look for objects with forwarded headers. */
private boolean noReferencesToForwardedObjectsVerifier(Object obj) {
final Log trace = getTraceLog();
trace.string("[HeapVerifierImpl.noReferencesToForwardedObjectsVerifier:");
trace.string(" obj: ").object(obj);
final UnsignedWord header = ObjectHeaderImpl.readHeaderFromObjectCarefully(obj);
trace.string(" header: ").hex(header);
final Pointer objPointer = Word.objectToUntrackedPointer(obj);
trace.string(" objPointer: ").hex(objPointer);
boolean result = InteriorObjRefWalker.walkObject(obj, noReferencesToForwardedObjectsVisitor);
if (!result) {
try (Log witness = getWitnessLog()) {
witness.string("[HeapVerifierImpl.noReferencesToForwardedObjectsVerifier:").string(" cause: ").string(getCause()).string(" obj: ").object(obj).string("]").newline();
}
}
trace.string("]").newline();
return result;
}
use of org.graalvm.word.Pointer 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;
}
Aggregations