use of org.graalvm.word.UnsignedWord in project graal by oracle.
the class AlignedHeapChunkMemoryWalkerAccessFeature method getFirstObjectTableLimitOffset.
/**
* What is the limit of the first object table?
*/
@Fold
static UnsignedWord getFirstObjectTableLimitOffset() {
final UnsignedWord fotStart = getFirstObjectTableStartOffset();
/* How big should the table be? */
final UnsignedWord fotSize = getFirstObjectTableSize();
final UnsignedWord fotLimit = fotStart.add(fotSize);
final UnsignedWord alignment = WordFactory.unsigned(ConfigurationValues.getObjectLayout().getAlignment());
return UnsignedUtils.roundUp(fotLimit, alignment);
}
use of org.graalvm.word.UnsignedWord 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 org.graalvm.word.UnsignedWord 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 org.graalvm.word.UnsignedWord in project graal by oracle.
the class CardTable method visitCards.
/**
* Visit the cards in a table.
*/
private static boolean visitCards(Pointer table, UnsignedWord indexLimit, CardTable.Visitor visitor) {
boolean result = true;
result &= visitor.prologue(table, indexLimit);
if (result) {
for (UnsignedWord index = WordFactory.unsigned(0); index.belowThan(indexLimit); index = index.add(1)) {
final int entry = readEntryAtIndex(table, index);
result &= visitor.visitEntry(table, index, entry);
if (!result) {
break;
}
}
}
result &= visitor.epilogue(table, indexLimit);
return result;
}
use of org.graalvm.word.UnsignedWord in project graal by oracle.
the class CardTable method cleanTableToPointer.
/**
* Initialize a table to "clean".
*/
static Pointer cleanTableToPointer(Pointer tableStart, Pointer tableLimit) {
final UnsignedWord tableOffset = tableLimit.subtract(tableStart);
final UnsignedWord indexLimit = CardTable.tableOffsetToIndex(tableOffset);
return CardTable.cleanTableToIndex(tableStart, indexLimit);
}
Aggregations