use of com.oracle.svm.core.genscavenge.AlignedHeapChunk.AlignedHeader 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.AlignedHeapChunk.AlignedHeader in project graal by oracle.
the class ThreadLocalAllocation method allocateNewArray.
static Object allocateNewArray(DynamicHub hub, int length, ThreadLocalAllocation.Descriptor tlab, boolean rememberedSet) {
DeoptTester.disableDeoptTesting();
log().string("[ThreadLocalAllocation.allocateNewArray: ").string(hub.asClass().getName()).string(" length ").signed(length).string(" in tlab ").hex(tlab).newline();
// Slow-path check if allocation is disallowed.
HeapImpl.exitIfAllocationDisallowed("Heap.allocateNewArray", hub.asClass().getName());
// Policy: Possibly collect before this allocation.
HeapImpl.getHeapImpl().getHeapPolicy().getCollectOnAllocationPolicy().maybeCauseCollection();
UnsignedWord size = LayoutEncoding.getArraySize(hub.getLayoutEncoding(), length);
Object result;
if (size.aboveOrEqual(HeapPolicy.getLargeArrayThreshold())) {
/*
* Check if the array is really too big. This is an optimistic check because the heap
* probably has other objects in it, so the next collection will throw an
* OutOfMemoryError if this object is allocated and survives.
*/
if (size.aboveOrEqual(HeapPolicy.getMaximumHeapSize())) {
throw arrayAllocationTooLarge;
}
/* Large arrays go into their own unaligned chunk. */
UnalignedHeapChunk.UnalignedHeader uChunk = HeapChunkProvider.get().produceUnalignedChunk(size);
result = allocateLargeArray(hub, length, size, uChunk, tlab, rememberedSet);
} else {
/* Small arrays go into the regular aligned chunk. */
AlignedHeader newChunk = prepareNewAllocationChunk(tlab);
result = allocateSmallArray(hub, length, size, tlab, rememberedSet, newChunk);
}
log().string(" ThreadLocalAllocation.allocateNewArray returns ").object(result).string(" .. ").hex(LayoutEncoding.getObjectEnd(result)).string("]").newline();
DeoptTester.enableDeoptTesting();
return result;
}
use of com.oracle.svm.core.genscavenge.AlignedHeapChunk.AlignedHeader in project graal by oracle.
the class ThreadLocalAllocation method disableThreadLocalAllocation.
public static void disableThreadLocalAllocation(IsolateThread vmThread) {
retireToSpace(regularTLAB.getAddress(vmThread), HeapImpl.getHeapImpl().getAllocationSpace());
// Flush the thread-local free list to the global unused list.
for (AlignedHeader alignedChunk = popFromThreadLocalFreeList(); alignedChunk.isNonNull(); alignedChunk = popFromThreadLocalFreeList()) {
HeapChunkProvider.get().consumeAlignedChunk(alignedChunk);
}
retireToSpace(pinnedTLAB.getAddress(vmThread), HeapImpl.getHeapImpl().getOldGeneration().getPinnedFromSpace());
}
use of com.oracle.svm.core.genscavenge.AlignedHeapChunk.AlignedHeader in project graal by oracle.
the class ThreadLocalAllocation method prepareNewAllocationChunk.
/**
* Refill the allocation chunk, i.e.., retire the current allocation chunk (the one in which
* allocation failed) add a new allocation chunk at the front of the TLAB's aligned chunks.
*/
private static AlignedHeader prepareNewAllocationChunk(Descriptor tlab) {
retireAllocationChunk(tlab);
/*
* Get a new chunk, either from the thread-local free list, or if that is empty, from the
* heap chunk provider.
*/
AlignedHeader newChunk = popFromThreadLocalFreeList();
if (newChunk.isNull()) {
newChunk = HeapChunkProvider.get().produceAlignedChunk();
}
/*
* The code to register the new chunk in the TLAB must be in uninterruptible code, so it
* cannot be here.
*/
return newChunk;
}
use of com.oracle.svm.core.genscavenge.AlignedHeapChunk.AlignedHeader in project graal by oracle.
the class ThreadLocalAllocation method pushToThreadLocalFreeList.
/**
* Push an aligned chunk on the thread-local list of free chunks.
*/
@Uninterruptible(reason = "Pushes the free list that is drained, at a safepoint, by garbage collections.")
private static void pushToThreadLocalFreeList(AlignedHeader alignedChunk) {
log().string("[ThreadLocalAllocation.pushToThreadLocalFreeList: alignedChunk: ").hex(alignedChunk).newline();
log().string(" before freeList: ").hex(freeList.get()).newline();
assert alignedChunk.isNonNull() : "Should not push a null chunk on the free list.";
final AlignedHeader head = freeList.get();
alignedChunk.setNext(head);
freeList.set(alignedChunk);
log().string(" after freeList: ").hex(freeList.get()).string("]").newline();
}
Aggregations