Merge branch 'master' of oss.readytalk.com:/var/local/git/avian

This commit is contained in:
Joel Dice 2009-07-20 08:27:17 -06:00
commit 8662361f71
2 changed files with 49 additions and 36 deletions

View File

@ -2118,8 +2118,13 @@ allocate3(Thread* t, Allocator* allocator, Machine::AllocationType type,
// another thread wants to enter the exclusive state, either for a // another thread wants to enter the exclusive state, either for a
// collection or some other reason. We give it a chance here. // collection or some other reason. We give it a chance here.
ENTER(t, Thread::IdleState); ENTER(t, Thread::IdleState);
while (t->m->exclusive) {
t->m->stateLock->wait(t->systemThread, 0);
}
} }
do {
switch (type) { switch (type) {
case Machine::MovableAllocation: case Machine::MovableAllocation:
if (t->heapIndex + ceiling(sizeInBytes, BytesPerWord) if (t->heapIndex + ceiling(sizeInBytes, BytesPerWord)
@ -2142,7 +2147,8 @@ allocate3(Thread* t, Allocator* allocator, Machine::AllocationType type,
break; break;
case Machine::FixedAllocation: case Machine::FixedAllocation:
if (t->m->fixedFootprint + sizeInBytes > FixedFootprintThresholdInBytes) { if (t->m->fixedFootprint + sizeInBytes > FixedFootprintThresholdInBytes)
{
t->heap = 0; t->heap = 0;
} }
break; break;
@ -2152,10 +2158,13 @@ allocate3(Thread* t, Allocator* allocator, Machine::AllocationType type,
} }
if (t->heap == 0) { if (t->heap == 0) {
// fprintf(stderr, "gc"); // fprintf(stderr, "gc");
// vmPrintTrace(t); // vmPrintTrace(t);
collect(t, Heap::MinorCollection); collect(t, Heap::MinorCollection);
} }
} while (type == Machine::MovableAllocation
and t->heapIndex + ceiling(sizeInBytes, BytesPerWord)
> ThreadHeapSizeInWords);
switch (type) { switch (type) {
case Machine::MovableAllocation: { case Machine::MovableAllocation: {
@ -2832,13 +2841,6 @@ collect(Thread* t, Heap::CollectionType type)
postCollect(m->rootThread); postCollect(m->rootThread);
for (object f = m->finalizeQueue; f; f = finalizerNext(t, f)) {
void (*function)(Thread*, object);
memcpy(&function, &finalizerFinalize(t, f), BytesPerWord);
function(t, finalizerTarget(t, f));
}
m->finalizeQueue = 0;
killZombies(t, m->rootThread); killZombies(t, m->rootThread);
for (unsigned i = 0; i < m->heapPoolIndex; ++i) { for (unsigned i = 0; i < m->heapPoolIndex; ++i) {
@ -2851,6 +2853,14 @@ collect(Thread* t, Heap::CollectionType type)
#ifdef VM_STRESS #ifdef VM_STRESS
if (not stress) t->stress = false; if (not stress) t->stress = false;
#endif #endif
object f = m->finalizeQueue;
m->finalizeQueue = 0;
for (; f; f = finalizerNext(t, f)) {
void (*function)(Thread*, object);
memcpy(&function, &finalizerFinalize(t, f), BytesPerWord);
function(t, finalizerTarget(t, f));
}
} }
void void

View File

@ -1519,6 +1519,9 @@ allocate3(Thread* t, Allocator* allocator, Machine::AllocationType type,
inline object inline object
allocateSmall(Thread* t, unsigned sizeInBytes) allocateSmall(Thread* t, unsigned sizeInBytes)
{ {
assert(t, t->heapIndex + ceiling(sizeInBytes, BytesPerWord)
<= ThreadHeapSizeInWords);
object o = reinterpret_cast<object>(t->heap + t->heapIndex); object o = reinterpret_cast<object>(t->heap + t->heapIndex);
t->heapIndex += ceiling(sizeInBytes, BytesPerWord); t->heapIndex += ceiling(sizeInBytes, BytesPerWord);
cast<object>(o, 0) = 0; cast<object>(o, 0) = 0;