use of org.graalvm.word.Pointer in project graal by oracle.
the class ThreadLocalAllocation method retireAllocationChunk.
/**
* Retire the current allocation chunk of current TLAB.
*/
@Uninterruptible(reason = "Modifies TLAB")
private static void retireAllocationChunk(Descriptor tlab) {
Pointer allocationTop = tlab.getAllocationTop(TOP_IDENTITY);
if (allocationTop.isNonNull()) {
AlignedHeader alignedChunk = tlab.getAlignedChunk();
assert alignedChunk.getTop().isNull();
assert alignedChunk.getEnd().equal(tlab.getAllocationEnd(END_IDENTITY));
/*
* While the aligned chunk is the allocation chunk its top value is always 'null' and it
* doesn't reflect the upper limit of allocated memory. The 'top' is stored in the TLAB
* and only set in the top aligned chunk when it is retired.
*/
alignedChunk.setTop(allocationTop);
tlab.setAllocationTop(WordFactory.nullPointer(), TOP_IDENTITY);
tlab.setAllocationEnd(WordFactory.nullPointer(), END_IDENTITY);
}
}
use of org.graalvm.word.Pointer in project graal by oracle.
the class ThreadLocalAllocation method allocateNewInstanceUninterruptibly.
@Uninterruptible(reason = "Holds uninitialized memory, modifies TLAB")
private static Object allocateNewInstanceUninterruptibly(DynamicHub hub, ThreadLocalAllocation.Descriptor tlab, boolean rememberedSet, UnsignedWord size, AlignedHeader newChunk) {
registerNewAllocationChunk(tlab, newChunk);
/*
* Allocate the memory. We must have a chunk, because we just registered one and we are
* still in the same block of uninterruptible code.
*/
Pointer memory = allocateMemory(tlab, size);
assert memory.isNonNull();
/* Install the DynamicHub and zero the fields. */
return KnownIntrinsics.formatObject(memory, hub.asClass(), rememberedSet);
}
use of org.graalvm.word.Pointer in project graal by oracle.
the class ThreadLocalAllocation method getObjectBytes.
/**
* Returns the total memory used by the TLAB in bytes. It counts only the memory actually used,
* not the total committed memory.
*/
public static UnsignedWord getObjectBytes(Descriptor tlab) {
Log log = log();
log.newline();
log.string("[ThreadLocalAllocator.usedMemory: tlab ").hex(tlab).newline();
AlignedHeader aChunk = tlab.getAlignedChunk();
UnsignedWord alignedUsedMemory = WordFactory.zero();
while (aChunk.isNonNull()) {
AlignedHeader next = aChunk.getNext();
Pointer start = AlignedHeapChunk.getAlignedHeapChunkStart(aChunk);
/* The allocation top has a null top; the TLAB is the one advancing the top pointer. */
Pointer top = aChunk.getTop().isNull() ? tlab.getAllocationTop(TOP_IDENTITY) : aChunk.getTop();
UnsignedWord aChunkUsedMemory = top.subtract(start);
alignedUsedMemory = alignedUsedMemory.add(aChunkUsedMemory);
log.string(" aligned chunk: ").hex(aChunk).string(" | used memory: ").unsigned(aChunkUsedMemory).newline();
aChunk = next;
}
UnsignedWord unalignedUsedMemory = WordFactory.zero();
UnalignedHeader uChunk = tlab.getUnalignedChunk();
while (uChunk.isNonNull()) {
UnalignedHeader next = uChunk.getNext();
UnsignedWord uChunkUsedMemory = UnalignedHeapChunk.usedObjectMemoryOfUnalignedHeapChunk(uChunk);
unalignedUsedMemory = unalignedUsedMemory.add(uChunkUsedMemory);
log.string(" unaligned chunk ").hex(uChunk).string(" | used memory: ").unsigned(uChunkUsedMemory).newline();
uChunk = next;
}
UnsignedWord tlabUsedMemory = alignedUsedMemory.add(unalignedUsedMemory);
log.newline();
log.string(" aligned used memory: ").unsigned(alignedUsedMemory).newline();
log.string(" unaligned used memory: ").unsigned(unalignedUsedMemory).newline();
log.string(" TLAB used memory: ").unsigned(tlabUsedMemory).newline();
log.string(" ]").newline();
return tlabUsedMemory;
}
use of org.graalvm.word.Pointer in project graal by oracle.
the class UnalignedHeapChunkMemoryWalkerAccessFeature method dirtyCardForObjectOfUnalignedHeapChunk.
/**
* 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 dirtyCardForObjectOfUnalignedHeapChunk(Object obj) {
final UnalignedHeader chunk = getEnclosingUnalignedHeapChunk(obj);
final Pointer rememberedSetStart = getCardTableStart(chunk);
final UnsignedWord objectIndex = getObjectIndex();
CardTable.dirtyEntryAtIndex(rememberedSetStart, objectIndex);
}
use of org.graalvm.word.Pointer 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;
}
Aggregations