use of com.oracle.svm.core.genscavenge.AlignedHeapChunk.AlignedHeader 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.AlignedHeapChunk.AlignedHeader in project graal by oracle.
the class HeapChunkProvider method popUnusedAlignedChunk.
/**
* Pop a chunk from the global linked list of unused chunks. Returns {@code null} if the list is
* empty.
* <p>
* This method uses compareAndSet to protect itself from races with competing pop operations,
* but it is <em>not</em> safe with respect to competing pushes. Since pushes can happen during
* garbage collections, I avoid the ABA problem by making the kernel of this method
* uninterruptible so it can not be interrupted by a safepoint.
*
* Note the asymmetry with {@link #popUnusedAlignedChunk()}, which does not use a global free
* list.
*/
private AlignedHeader popUnusedAlignedChunk() {
log().string(" old list top: ").hex(unusedAlignedChunks.get()).string(" list bytes ").signed(bytesInUnusedAlignedChunks.get()).newline();
AlignedHeader result = popUnusedAlignedChunkUninterruptibly();
if (result.isNull()) {
/* Unused list is empty. */
return WordFactory.nullPointer();
} else {
/* Successfully popped an unused chunk from the list. */
bytesInUnusedAlignedChunks.subtractAndGet(HeapPolicy.getAlignedHeapChunkSize());
log().string(" new list top: ").hex(unusedAlignedChunks.get()).string(" list bytes ").signed(bytesInUnusedAlignedChunks.get()).newline();
return result;
}
}
use of com.oracle.svm.core.genscavenge.AlignedHeapChunk.AlignedHeader in project graal by oracle.
the class HeapChunkProvider method produceAlignedChunk.
/**
* Produce a new AlignedHeapChunk, either from the free list or from the operating system.
*/
AlignedHeader produceAlignedChunk() {
UnsignedWord chunkSize = HeapPolicy.getAlignedHeapChunkSize();
log().string("[HeapChunkProvider.produceAlignedChunk chunk size: ").unsigned(chunkSize).newline();
AlignedHeader result = popUnusedAlignedChunk();
log().string(" unused chunk: ").hex(result).newline();
if (result.isNull()) {
/* Unused list was empty, need to allocate memory. */
noteFirstAllocationTime();
result = (AlignedHeader) ConfigurationValues.getOSInterface().allocateVirtualMemoryAligned(chunkSize, HeapPolicy.getAlignedHeapChunkAlignment());
if (result.isNull()) {
throw AllocatorOutOfMemoryError.throwError("No virtual memory for aligned chunk");
}
log().string(" new chunk: ").hex(result).newline();
initializeChunk(result, chunkSize);
resetAlignedHeapChunk(result);
}
assert result.getTop().equal(AlignedHeapChunk.getAlignedHeapChunkStart(result));
assert result.getEnd().equal(HeapChunk.asPointer(result).add(chunkSize));
if (HeapPolicy.getZapProducedHeapChunks()) {
zap(result, HeapPolicy.getProducedHeapChunkZapValue());
}
HeapPolicy.bytesAllocatedSinceLastCollection.addAndGet(chunkSize);
log().string(" result chunk: ").hex(result).string(" ]").newline();
return result;
}
Aggregations