use of org.graalvm.word.Pointer in project graal by oracle.
the class AlignedHeapChunkMemoryWalkerAccessFeature method dirtyCardForObjectOfAlignedHeapChunk.
/**
* Dirty the card corresponding to the given Object.
*
* This has to be fast, because it is used by the post-write barrier.
*/
public static void dirtyCardForObjectOfAlignedHeapChunk(Object obj) {
final AlignedHeader chunk = getEnclosingAlignedHeapChunk(obj);
final Pointer cardTableStart = getCardTableStart(chunk);
final UnsignedWord index = getObjectIndex(chunk, obj);
CardTable.dirtyEntryAtIndex(cardTableStart, index);
}
use of org.graalvm.word.Pointer in project graal by oracle.
the class AlignedHeapChunkMemoryWalkerAccessFeature method verifyOnlyCleanCards.
/**
* Verify that there are only clean cards for the given chunk.
*/
static boolean verifyOnlyCleanCards(AlignedHeader that) {
final Log trace = Log.noopLog().string("[AlignedHeapChunk.verifyOnlyCleanCards:");
trace.string(" that: ").hex(that);
boolean result = true;
/* Iterate through the cards looking for dirty cards. */
final Pointer cardTableStart = getCardTableStart(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)) {
if (CardTable.isDirtyEntryAtIndex(cardTableStart, index)) {
result = false;
final Log witness = Log.log().string("[AlignedHeapChunk.verifyOnlyCleanCards:");
witness.string(" that: ").hex(that).string(" dirty card at index: ").unsigned(index).string("]").newline();
}
}
trace.string(" returns: ").bool(result).string("]").newline();
return result;
}
use of org.graalvm.word.Pointer in project graal by oracle.
the class AlignedHeapChunkMemoryWalkerAccessFeature method verifyHeaders.
/**
* Verify that all the objects have headers that say they are aligned.
*/
private static boolean verifyHeaders(AlignedHeader that) {
final Log trace = Log.noopLog().string("[AlignedHeapChunk.verifyHeaders: ").string(" that: ").hex(that);
/* Get the Object at the offset, or null. */
Pointer current = getAlignedHeapChunkStart(that);
while (current.belowThan(that.getTop())) {
trace.newline().string(" current: ").hex(current);
final UnsignedWord header = ObjectHeader.readHeaderFromPointer(current);
if (!ObjectHeaderImpl.getObjectHeaderImpl().isAlignedHeader(header)) {
trace.string(" does not have an aligned header: ").hex(header).string(" returns: false").string("]").newline();
return false;
}
/*
* Step over the object. This does not deal with forwarded objects, but I have already
* checked that the header is an aligned header.
*/
current = LayoutEncoding.getObjectEnd(current.toObject());
}
trace.string(" returns: true]").newline();
return true;
}
use of org.graalvm.word.Pointer in project graal by oracle.
the class AlignedHeapChunkMemoryWalkerAccessFeature method cleanRememberedSetOfAlignedHeapChunk.
/**
* Clean the remembered set for an AlignedHeapChunk.
*/
static void cleanRememberedSetOfAlignedHeapChunk(AlignedHeader that) {
final Log trace = Log.noopLog().string("[AlignedHeapChunk.cleanRememberedSet:");
trace.string(" that: ").hex(that);
final Pointer cardTableStart = getCardTableStart(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);
CardTable.cleanTableToIndex(cardTableStart, indexLimit);
trace.string("]").newline();
}
use of org.graalvm.word.Pointer in project graal by oracle.
the class AlignedHeapChunkMemoryWalkerAccessFeature method setUpRememberedSetForObjectOfAlignedHeapChunk.
/**
* Initialize the remembered set for a particular object, if this chunk has a remembered set.
*/
static void setUpRememberedSetForObjectOfAlignedHeapChunk(AlignedHeader that, Object obj) {
VMOperation.guaranteeInProgress("Should only be called from the collector.");
/*
* There is only a remembered set maintained in the old To-Space. Testing against the Young
* space compiles to a test against a constant.
*/
final HeapImpl heap = HeapImpl.getHeapImpl();
if (!heap.isYoungGeneration(that.getSpace())) {
/*
* The card remembered set table should already be clean, but the first object table
* needs to be set up.
*/
final Pointer fotStart = getFirstObjectTableStart(that);
final Pointer memoryStart = getAlignedHeapChunkStart(that);
final Pointer objStart = Word.objectToUntrackedPointer(obj);
/* Interruptible does not apply because I am in the collector. */
final Pointer objEnd = LayoutEncoding.getObjectEnd(obj);
FirstObjectTable.setTableForObject(fotStart, memoryStart, objStart, objEnd);
/* Note that the object is aligned, and that it has a card remembered set. */
ObjectHeaderImpl.getObjectHeaderImpl().setCardRememberedSetAligned(obj);
}
}
Aggregations