never trigger a GC due to an immortal allocation

This commit is contained in:
Joel Dice 2008-11-23 11:48:39 -07:00
parent fb9b2bf173
commit 207f093464

View File

@ -2052,24 +2052,33 @@ allocate3(Thread* t, Allocator* allocator, Machine::AllocationType type,
// collection or some other reason. We give it a chance here.
ENTER(t, Thread::IdleState);
}
switch (type) {
case Machine::MovableAllocation:
if (t->heapIndex + ceiling(sizeInBytes, BytesPerWord)
> ThreadHeapSizeInWords)
{
t->heap = 0;
if (t->m->heapPoolIndex < ThreadHeapPoolSize) {
t->heap = static_cast<uintptr_t*>
(t->m->heap->tryAllocate(ThreadHeapSizeInBytes));
if (t->heap) {
t->m->heapPool[t->m->heapPoolIndex++] = t->heap;
t->heapOffset += t->heapIndex;
t->heapIndex = 0;
}
}
}
break;
if (type == Machine::FixedAllocation) {
case Machine::FixedAllocation:
if (t->m->fixedFootprint + sizeInBytes > FixedFootprintThresholdInBytes) {
t->heap = 0;
}
} else if (t->heapIndex + ceiling(sizeInBytes, BytesPerWord)
> ThreadHeapSizeInWords)
{
t->heap = 0;
if (t->m->heapPoolIndex < ThreadHeapPoolSize) {
t->heap = static_cast<uintptr_t*>
(t->m->heap->tryAllocate(ThreadHeapSizeInBytes));
if (t->heap) {
t->m->heapPool[t->m->heapPoolIndex++] = t->heap;
t->heapOffset += t->heapIndex;
t->heapIndex = 0;
}
}
break;
case Machine::ImmortalAllocation:
break;
}
if (t->heap == 0) {