use of org.graalvm.word.UnsignedWord in project graal by oracle.
the class UnalignedHeapChunkMemoryWalkerAccessFeature method verifyOnlyCleanCardsOfUnalignedHeapChunk.
/**
* Verify that there are only clean cards in the remembered set of the given chunk.
*/
static boolean verifyOnlyCleanCardsOfUnalignedHeapChunk(UnalignedHeader that) {
final Log trace = Log.noopLog().string("[UnalignedHeapChunk.verifyOnlyCleanCards:");
trace.string(" that: ").hex(that);
boolean result = true;
// Iterate through the cards looking for dirty cards.
final Pointer rememberedSetStart = getCardTableStart(that);
final UnsignedWord objectIndex = getObjectIndex();
if (CardTable.isDirtyEntryAtIndex(rememberedSetStart, objectIndex)) {
result = false;
final Log witness = Log.log().string("[UnalignedHeapChunk.verifyOnlyCleanCards:");
witness.string(" that: ").hex(that).string(" dirty card at index: ").unsigned(objectIndex).string("]").newline();
}
trace.string(" returns: ").bool(result).string("]").newline();
return result;
}
use of org.graalvm.word.UnsignedWord in project graal by oracle.
the class UnalignedHeapChunkMemoryWalkerAccessFeature method getCardTableSize.
/**
* How big is the card table?
*/
@Fold
static UnsignedWord getCardTableSize() {
// A "table" of one entry.
final UnsignedWord requiredSize = CardTable.tableSizeForMemorySize(WordFactory.unsigned(1));
final UnsignedWord alignment = WordFactory.unsigned(ConfigurationValues.getObjectLayout().getAlignment());
return UnsignedUtils.roundUp(requiredSize, alignment);
}
use of org.graalvm.word.UnsignedWord in project graal by oracle.
the class UnalignedHeapChunkMemoryWalkerAccessFeature method verifyRememberedSet.
/**
* Verify the remembered set of the given chunk.
*/
private static boolean verifyRememberedSet(UnalignedHeader that) {
// Only chunks in the old from space have a remembered set.
final HeapImpl heap = HeapImpl.getHeapImpl();
final OldGeneration oldGen = heap.getOldGeneration();
if (that.getSpace() == oldGen.getFromSpace()) {
// Check if there are cross-generational pointers ...
final Pointer objStart = getUnalignedStart(that);
final Object obj = objStart.toObject();
final boolean containsYoungReferences = CardTable.containsReferenceToYoungSpace(obj);
// ... and if so, that the chunk is marked as dirty.
if (containsYoungReferences) {
final Pointer rememberedSet = getCardTableStart(that);
final UnsignedWord objectIndex = getObjectIndex();
final boolean isDirty = CardTable.isDirtyEntryAtIndex(rememberedSet, objectIndex);
if (!isDirty) {
final Log witness = HeapImpl.getHeapImpl().getHeapVerifierImpl().getWitnessLog().string("[UnalignedHeapChunk.verify:");
witness.string(" that: ").hex(that);
witness.string(" containsYoungReferences implies isDirty").string("]").newline();
return false;
}
}
}
return true;
}
use of org.graalvm.word.UnsignedWord in project graal by oracle.
the class UnalignedHeapChunkMemoryWalkerAccessFeature method verifyUnalignedHeapChunk.
/**
* Verify an UnalignedHeapChunk, called from sub-class verify methods.
*/
private static boolean verifyUnalignedHeapChunk(UnalignedHeader that, Pointer start) {
VMOperation.guaranteeInProgress("Should only be called as a VMOperation.");
// The object in this chunk should not be forwarded,
// and should be the only object in the chunk.
final Log trace = HeapImpl.getHeapImpl().getHeapVerifierImpl().getTraceLog().string("[UnalignedHeapChunk.verifyUnalignedHeapChunk");
trace.string(" that: ").hex(that).string(" start: ").hex(start).string(" top: ").hex(that.getTop()).string(" end: ").hex(that.getEnd()).newline();
final UnsignedWord objHeader = ObjectHeader.readHeaderFromPointer(start);
final ObjectHeaderImpl ohi = ObjectHeaderImpl.getObjectHeaderImpl();
// The object should not be forwarded.
if (ohi.isForwardedHeader(objHeader)) {
final Log witness = HeapImpl.getHeapImpl().getHeapVerifierImpl().getWitnessLog().string("[UnalignedHeapChunk.verify:");
witness.string(" that: ").hex(that).string(" start: ").hex(start).string(" top: ").hex(that.getTop()).string(" end: ").hex(that.getEnd());
witness.string(" space: ").string(that.getSpace().getName());
witness.string(" objHeader: ").string(ohi.toStringFromHeader(objHeader));
witness.string(" should not be forwarded").string("]").newline();
return false;
}
// The object should be marked as being unaligned.
if (!ohi.isUnalignedHeader(objHeader)) {
final Log witness = HeapImpl.getHeapImpl().getHeapVerifierImpl().getWitnessLog().string("[UnalignedHeapChunk.verify:");
witness.string(" that: ").hex(that).string(" start: ").hex(start).string(" end: ").hex(that.getEnd());
witness.string(" space: ").string(that.getSpace().getName());
witness.string(" obj: ").hex(start).string(" objHeader: ").hex(objHeader);
witness.string(" does not have an unaligned header").string("]").newline();
return false;
}
// The object should be the only object in the chunk.
final Object obj = start.toObject();
final Pointer objEnd = LayoutEncoding.getObjectEnd(obj);
if (objEnd.notEqual(that.getTop())) {
final Log witness = HeapImpl.getHeapImpl().getHeapVerifierImpl().getWitnessLog().string("[UnalignedHeapChunk.verify:");
witness.string(" that: ").hex(that).string(" start: ").hex(start).string(" end: ").hex(that.getEnd());
witness.string(" space: ").string(that.getSpace().getName());
witness.string(" obj: ").object(obj).string(" objEnd: ").hex(objEnd);
witness.string(" should be the only object in the chunk").string("]").newline();
return false;
}
if (!verifyRememberedSet(that)) {
final Log witnessLog = HeapImpl.getHeapImpl().getHeapVerifierImpl().getWitnessLog().string("[UnalignedHeadChunk remembered set fails to verify");
witnessLog.string(" that: ").hex(that).string(" remembered set fails to verify.").string("]").newline();
}
// Verify the super-class.
final boolean result = verifyHeapChunk(that, start);
trace.string(" returns: ").bool(result).string("]").newline();
return result;
}
use of org.graalvm.word.UnsignedWord in project graal by oracle.
the class UnalignedHeapChunkMemoryWalkerAccessFeature method walkDirtyObjectsOfUnalignedHeapChunk.
/**
* Walk the dirty Objects in this chunk, passing each to a Visitor.
*/
public static boolean walkDirtyObjectsOfUnalignedHeapChunk(UnalignedHeader that, ObjectVisitor visitor, boolean clean) {
final Log trace = Log.noopLog().string("[UnalignedHeapChunk.walkDirtyObjects:");
trace.string(" clean: ").bool(clean).string(" that: ").hex(that).string(" ");
boolean result = true;
final Pointer rememberedSetStart = getCardTableStart(that);
final UnsignedWord objectIndex = getObjectIndex();
trace.string(" rememberedSetStart: ").hex(rememberedSetStart).string(" objectIndex: ").unsigned(objectIndex);
// If the card for this chunk is dirty, visit the object.
if (CardTable.isDirtyEntryAtIndex(rememberedSetStart, objectIndex)) {
final Pointer objectsStart = getUnalignedStart(that);
final Object obj = objectsStart.toObject();
trace.string(" obj: ").object(obj);
// Visit the object.
if (!visitor.visitObjectInline(obj)) {
result = false;
}
if (clean) {
CardTable.cleanEntryAtIndex(rememberedSetStart, objectIndex);
}
}
trace.string(" returns: ").bool(result).string("]").newline();
return result;
}
Aggregations