use of com.oracle.svm.core.log.Log in project graal by oracle.
the class AlignedHeapChunkMemoryWalkerAccessFeature method walkDirtyObjectsOfAlignedHeapChunk.
/**
* Walk the dirty Objects in this chunk, passing each to a Visitor.
*/
static boolean walkDirtyObjectsOfAlignedHeapChunk(AlignedHeader that, ObjectVisitor visitor, boolean clean) {
final Log trace = Log.noopLog().string("[AlignedHeapChunk.walkDirtyObjects:");
trace.string(" that: ").hex(that).string(" clean: ").bool(clean);
/* Iterate through the cards looking for dirty cards. */
final Pointer cardTableStart = getCardTableStart(that);
final Pointer fotStart = getFirstObjectTableStart(that);
final Pointer objectsStart = getAlignedHeapChunkStart(that);
final Pointer objectsLimit = that.getTop();
final UnsignedWord memorySize = objectsLimit.subtract(objectsStart);
final UnsignedWord indexLimit = CardTable.indexLimitForMemorySize(memorySize);
trace.string(" objectsStart: ").hex(objectsStart).string(" objectsLimit: ").hex(objectsLimit).string(" indexLimit: ").unsigned(indexLimit);
for (UnsignedWord index = WordFactory.zero(); index.belowThan(indexLimit); index = index.add(1)) {
trace.newline().string(" ").string(" index: ").unsigned(index);
/* If the card is dirty, visit the objects it covers. */
if (CardTable.isDirtyEntryAtIndex(cardTableStart, index)) {
final Pointer cardLimit = CardTable.indexToMemoryPointer(objectsStart, index.add(1));
final Pointer crossingOntoPointer = FirstObjectTable.getPreciseFirstObjectPointer(fotStart, objectsStart, objectsLimit, index);
final Object crossingOntoObject = crossingOntoPointer.toObject();
if (trace.isEnabled()) {
final Pointer cardStart = CardTable.indexToMemoryPointer(objectsStart, index);
trace.string(" ").string(" cardStart: ").hex(cardStart);
trace.string(" cardLimit: ").hex(cardLimit);
trace.string(" crossingOntoObject: ").object(crossingOntoObject);
trace.string(" end: ").hex(LayoutEncoding.getObjectEnd(crossingOntoObject));
if (LayoutEncoding.isArray(crossingOntoObject)) {
trace.string(" array length: ").signed(KnownIntrinsics.readArrayLength(crossingOntoObject));
}
}
trace.newline();
/*
* Iterate through the objects on that card. Find the start of the
* imprecisely-marked card.
*/
final Pointer impreciseStart = FirstObjectTable.getImpreciseFirstObjectPointer(fotStart, objectsStart, objectsLimit, index);
/*
* Walk the objects to the end of an object, even if that is past cardLimit, because
* these are imprecise cards.
*/
Pointer ptr = impreciseStart;
final Pointer walkLimit = PointerUtils.min(cardLimit, objectsLimit);
trace.string(" ");
trace.string(" impreciseStart: ").hex(impreciseStart);
trace.string(" walkLimit: ").hex(walkLimit);
while (ptr.belowThan(walkLimit)) {
trace.newline().string(" ");
trace.string(" ptr: ").hex(ptr);
final Object obj = ptr.toObject();
final Pointer objEnd = LayoutEncoding.getObjectEnd(obj);
trace.string(" obj: ").object(obj);
trace.string(" objEnd: ").hex(objEnd);
/* Visit the object. */
if (!visitor.visitObjectInline(obj)) {
final Log failureLog = Log.log().string("[AlignedHeapChunk.walkDirtyObjects:");
failureLog.string(" visitor.visitObject fails").string(" obj: ").object(obj).string("]").newline();
return false;
}
ptr = objEnd;
}
if (clean) {
CardTable.cleanEntryAtIndex(cardTableStart, index);
}
}
}
trace.string("]").newline();
return true;
}
use of com.oracle.svm.core.log.Log in project graal by oracle.
the class CardTable method verifyCleanCards.
/*
* Verification.
*/
/**
* Check that every clean card indicates an object with no pointers to young space.
*/
private static boolean verifyCleanCards(Pointer ctStart, Pointer fotStart, Pointer objectsStart, Pointer objectsLimit) {
final Log trace = Log.noopLog().string("[CardTable.verifyCleanCards:");
trace.string(" ctStart: ").hex(ctStart).string(" fotStart: ").hex(fotStart).string(" objectsStart: ").hex(objectsStart).string(" objectsLimit: ").hex(objectsLimit);
/* Walk the remembered set entries. */
final UnsignedWord indexLimit = FirstObjectTable.getTableSizeForMemoryPointers(objectsStart, objectsLimit);
for (UnsignedWord index = WordFactory.zero(); index.belowThan(indexLimit); index = index.add(1)) {
trace.newline().string(" index: ").unsigned(index);
if (FirstObjectTable.isUninitializedIndex(fotStart, index)) {
final Log failure = Log.log().string("[CardTable.verifyCleanCards: ");
failure.string(" reached uninitialized first object table entry").string("]").newline();
return false;
}
final boolean isClean = isCleanEntryAtIndex(ctStart, index);
if (!isClean) {
continue;
}
/* Find the imprecise bounds represented by the card. */
final Pointer impreciseStart = FirstObjectTable.getImpreciseFirstObjectPointer(fotStart, objectsStart, objectsLimit, index);
final Pointer cardLimit = indexToMemoryPointer(objectsStart, index.add(1));
final Pointer walkLimit = PointerUtils.min(cardLimit, objectsLimit);
trace.string(" impreciseStart: ").hex(impreciseStart).string(" cardLimit: ").hex(cardLimit).string(" walkLimit: ").hex(walkLimit);
/*
* Walk the objects to the end of an object, even if that is past cardLimit, because
* these are imprecise cards.
*/
Pointer ptr = impreciseStart;
while (ptr.belowThan(walkLimit)) {
trace.newline().string(" ").string(" ptr: ").hex(ptr);
final Object obj = ptr.toObject();
trace.string(" obj: ").object(obj);
if (LayoutEncoding.isArray(obj)) {
trace.string(" length: ").signed(KnownIntrinsics.readArrayLength(obj));
}
final boolean containsYoung = getReferenceToYoungObjectVisitor().containsReferenceToYoungObject(obj);
/* Return early on failure. */
if (containsYoung) {
/* { WITNESS */
final boolean witnessForDebugging = true;
final Log witness = (witnessForDebugging ? Log.log() : HeapImpl.getHeapImpl().getHeapVerifierImpl().getTraceLog());
witness.string("[CardTable.verifyCleanCards:").string(" objectsStart: ").hex(objectsStart).string(" objectsLimit: ").hex(objectsLimit).string(" indexLimit: ").unsigned(indexLimit).newline();
witness.string(" index: ").unsigned(index);
final Pointer cardStart = indexToMemoryPointer(objectsStart, index);
witness.string(" cardStart: ").hex(cardStart).string(" cardLimit: ").hex(cardLimit).string(" walkLimit: ").hex(walkLimit).string(" fotEntry: ");
FirstObjectTable.TestingBackDoor.indexToLog(fotStart, witness, index);
witness.string(" isClean: ").bool(isClean).newline();
final Pointer crossingOntoPointer = FirstObjectTable.getPreciseFirstObjectPointer(fotStart, objectsStart, objectsLimit, index);
final Object crossingOntoObject = crossingOntoPointer.toObject();
witness.string(" crossingOntoObject: ").object(crossingOntoObject).string(" end: ").hex(LayoutEncoding.getObjectEnd(crossingOntoObject));
if (LayoutEncoding.isArray(crossingOntoObject)) {
witness.string(" array length: ").signed(KnownIntrinsics.readArrayLength(crossingOntoObject));
}
witness.string(" impreciseStart: ").hex(impreciseStart).newline();
witness.string(" obj: ").object(obj).string(" end: ").hex(LayoutEncoding.getObjectEnd(obj));
if (LayoutEncoding.isArray(obj)) {
witness.string(" array length: ").signed(KnownIntrinsics.readArrayLength(obj));
}
witness.newline();
HeapChunk.Header<?> objChunk = AlignedHeapChunk.getEnclosingAlignedHeapChunk(obj);
witness.string(" objChunk: ").hex(objChunk).string(" objChunk space: ").string(objChunk.getSpace().getName()).string(" contains young: ").bool(containsYoung).newline();
/* Repeat the search for old-to-young references, this time as a witness. */
getReferenceToYoungObjectVisitor().witnessReferenceToYoungObject(obj);
witness.string(" returns false for index: ").unsigned(index).string("]").newline();
/* } WITNESS */
return false;
}
ptr = LayoutEncoding.getObjectEnd(obj);
}
}
trace.string("]").newline();
return true;
}
use of com.oracle.svm.core.log.Log in project graal by oracle.
the class CardTable method verify.
/*
* Verification.
*/
/**
* Check that:
* <ul>
* <li>every clean card indicates an object with no pointers to young space.</li>
* <li>that every object with a pointer to young space has a corresponding marked card.</li>
* </ul>
* I would like to check that every dirty card has a pointer to young space, but a card may be
* dirtied by the storing of a null, which doesn't point to young space. For extra credit, make
* {@link #getMemoryBytesPerEntry} 8 so there's at most one object per card to weed out
* ambiguous marked cards.
*/
protected static boolean verify(Pointer ctStart, Pointer fotStart, Pointer objectsStart, Pointer objectsLimit) {
final Log trace = Log.noopLog().string("[CardTable.verify: ");
trace.string(" ctStart: ").hex(ctStart).string(" fotStart: ").hex(fotStart).string(" objectsStart: ").hex(objectsStart).string(" objectsLimit: ").hex(objectsLimit).newline();
if (!verifyCleanCards(ctStart, fotStart, objectsStart, objectsLimit)) {
final Log verifyLog = Log.log().string("[CardTableTable.verify:");
verifyLog.string(" fails verifyCleanCards").string("]").newline();
return false;
}
if (!verifyDirtyCards(ctStart, objectsStart, objectsLimit)) {
final Log verifyLog = Log.log().string("[CardTable.verify:");
verifyLog.string(" fails verifyCleanCards").string("]").newline();
return false;
}
trace.string("]").newline();
return true;
}
use of com.oracle.svm.core.log.Log in project graal by oracle.
the class DiscoverableReferenceProcessing method addToDiscoveredReferences.
private static void addToDiscoveredReferences(DiscoverableReference dr) {
final Log trace = Log.noopLog().string("[DiscoverableReference.addToDiscoveredReferences:").string(" this: ").object(dr).string(" referent: ").hex(dr.getReferentPointer());
if (dr.getIsDiscovered()) {
/*
* This DiscoverableReference is already on the discovered list. Don't add it again or
* the list gets broken.
*/
trace.string(" already on list]").newline();
return;
}
trace.newline().string(" [adding to list:").string(" oldList: ").object(getDiscoveredList());
setDiscoveredList(dr.prependToDiscoveredReference(getDiscoveredList()));
trace.string(" new list: ").object(getDiscoveredList()).string("]");
trace.string("]").newline();
}
use of com.oracle.svm.core.log.Log in project graal by oracle.
the class DiscoverableReferenceProcessing method processReferent.
/**
* Determine if a referent is live, and adjust it as necessary.
*/
private static boolean processReferent(DiscoverableReference dr) {
final Log trace = Log.noopLog().string("[DiscoverableReference.processReferent:").string(" this: ").object(dr);
final Pointer refPointer = dr.getReferentPointer();
trace.string(" referent: ").hex(refPointer);
if (refPointer.isNull()) {
/* If the referent is null don't look at it further. */
trace.string(" null referent").string("]").newline();
return false;
}
/* Read the header. */
final UnsignedWord header = ObjectHeader.readHeaderFromPointer(refPointer);
/* It might be a forwarding pointer. */
if (ObjectHeaderImpl.getObjectHeaderImpl().isForwardedHeader(header)) {
/* If the referent got forwarded, then update the referent. */
final Pointer forwardedPointer = ObjectHeaderImpl.getObjectHeaderImpl().getForwardingPointer(header);
dr.setReferentPointer(forwardedPointer);
trace.string(" forwarded header: updated referent: ").hex(forwardedPointer).string("]").newline();
return true;
}
/*
* It's a real object. See if the referent has survived.
*/
final Object refObject = refPointer.toObject();
if (HeapImpl.getHeapImpl().hasSurvivedThisCollection(refObject)) {
/* The referent has survived, it does not need to be updated. */
trace.string(" referent will survive: not updated").string("]").newline();
return true;
}
/*
* Otherwise, referent has not survived.
*
* Note that we must use the Object-level store here, not the Pointer-level store: the
* static analysis must see that the field can be null. This means that we get a write
* barrier for this store.
*/
dr.clear();
trace.string(" has not survived: nulled referent").string("]").newline();
return false;
}
Aggregations