use of com.oracle.svm.core.genscavenge.UnalignedHeapChunk.UnalignedHeader 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 com.oracle.svm.core.genscavenge.UnalignedHeapChunk.UnalignedHeader in project graal by oracle.
the class ThreadLocalAllocation method retireToSpace.
static void retireToSpace(Descriptor tlab, Space space) {
log().string("[ThreadLocalAllocator.retireToSpace: tlab ").hex(tlab).string(" space ").string(space.getName()).newline();
retireAllocationChunk(tlab);
AlignedHeader alignedChunk = tlab.getAlignedChunk();
UnalignedHeader unalignedChunk = tlab.getUnalignedChunk();
tlab.setAlignedChunk(WordFactory.nullPointer());
tlab.setUnalignedChunk(WordFactory.nullPointer());
while (alignedChunk.isNonNull()) {
AlignedHeader next = alignedChunk.getNext();
alignedChunk.setNext(WordFactory.nullPointer());
log().string(" aligned chunk ").hex(alignedChunk).newline();
space.appendAlignedHeapChunk(alignedChunk);
if (!HeapImpl.getHeapImpl().isYoungGeneration(space)) {
log().string(" setting up remembered set for ").hex(alignedChunk).newline();
AlignedHeapChunk.constructRememberedSetOfAlignedHeapChunk(alignedChunk);
}
alignedChunk = next;
}
while (unalignedChunk.isNonNull()) {
UnalignedHeader next = unalignedChunk.getNext();
unalignedChunk.setNext(WordFactory.nullPointer());
log().string(" unaligned chunk ").hex(unalignedChunk).newline();
space.appendUnalignedHeapChunk(unalignedChunk);
unalignedChunk = next;
}
log().string(" ThreadLocalAllocator.retireToSpace ]").newline();
}
use of com.oracle.svm.core.genscavenge.UnalignedHeapChunk.UnalignedHeader in project graal by oracle.
the class ThreadLocalAllocation method releaseMemory.
/**
* Releases all the memory allocated in this TLAB, without any safety checks that the memory is
* no longer referenced from other objects.
*/
public static void releaseMemory(Descriptor tlab) {
log().string("[ThreadLocalAllocator.releaseMemory: tlab ").hex(tlab).newline();
retireAllocationChunk(tlab);
AlignedHeader alignedChunk = tlab.getAlignedChunk();
UnalignedHeader unalignedChunk = tlab.getUnalignedChunk();
tlab.setAlignedChunk(WordFactory.nullPointer());
tlab.setUnalignedChunk(WordFactory.nullPointer());
while (alignedChunk.isNonNull()) {
AlignedHeader next = alignedChunk.getNext();
/*
* TODO: Should this do a full clean of the header, remembered set, and optionally zap
* the contents, or just set the next pointer to null?
*/
HeapChunkProvider.resetAlignedHeader(alignedChunk);
log().string(" aligned chunk ").hex(alignedChunk).newline();
// Put the chunk on a free list.
pushToThreadLocalFreeList(alignedChunk);
alignedChunk = next;
}
while (unalignedChunk.isNonNull()) {
UnalignedHeader next = unalignedChunk.getNext();
unalignedChunk.setNext(WordFactory.nullPointer());
log().string(" unaligned chunk ").hex(alignedChunk).newline();
HeapChunkProvider.get().consumeUnalignedChunk(unalignedChunk);
unalignedChunk = next;
}
log().string(" ]").newline();
}
use of com.oracle.svm.core.genscavenge.UnalignedHeapChunk.UnalignedHeader in project graal by oracle.
the class HeapChunkProvider method produceUnalignedChunk.
/**
* Produce an UnalignedHeapChunk from the operating system.
*/
UnalignedHeader produceUnalignedChunk(UnsignedWord objectSize) {
UnsignedWord chunkSize = UnalignedHeapChunk.getChunkSizeForObject(objectSize);
log().string("[HeapChunkProvider.produceUnalignedChunk objectSize: ").unsigned(objectSize).string(" chunkSize: ").hex(chunkSize).newline();
noteFirstAllocationTime();
UnalignedHeader result = (UnalignedHeader) ConfigurationValues.getOSInterface().allocateVirtualMemory(chunkSize, false);
if (result.isNull()) {
throw AllocatorOutOfMemoryError.throwError("No virtual memory for unaligned chunk");
}
initializeChunk(result, chunkSize);
resetUnalignedChunk(result);
assert objectSize.belowOrEqual(HeapChunk.availableObjectMemory(result)) : "UnalignedHeapChunk insufficient for requested object";
if (HeapPolicy.getZapProducedHeapChunks()) {
zap(result, HeapPolicy.getProducedHeapChunkZapValue());
}
HeapPolicy.bytesAllocatedSinceLastCollection.addAndGet(chunkSize);
log().string(" returns ").hex(result).string(" ]").newline();
return result;
}
Aggregations