GC bugfixes

This commit is contained in:
Joel Dice 2009-05-17 17:43:48 -06:00
parent 8463bb4056
commit 398dec58bb
2 changed files with 43 additions and 38 deletions

View File

@ -431,7 +431,7 @@ localOffset(MyThread* t, int v, object method)
- v - 1) : - v - 1) :
(frameSize (frameSize
+ parameterFootprint + parameterFootprint
- v - 1)) * BytesPerWord; - v - 1));
assert(t, offset >= 0); assert(t, offset >= 0);
return offset; return offset;
@ -441,14 +441,13 @@ int
localOffsetFromStack(MyThread* t, int index, object method) localOffsetFromStack(MyThread* t, int index, object method)
{ {
return localOffset(t, index, method) return localOffset(t, index, method)
+ (t->arch->frameReturnAddressSize() * BytesPerWord); + t->arch->frameReturnAddressSize();
} }
object* object*
localObject(MyThread* t, void* stack, object method, unsigned index) localObject(MyThread* t, void* stack, object method, unsigned index)
{ {
return reinterpret_cast<object*> return static_cast<object*>(stack) + localOffsetFromStack(t, index, method);
(static_cast<uint8_t*>(stack) + localOffsetFromStack(t, index, method));
} }
int int
@ -1400,8 +1399,7 @@ findUnwindTarget(MyThread* t, void** targetIp, void** targetBase,
*targetStack = sp; *targetStack = sp;
sp[localOffset(t, localSize(t, method), method) / BytesPerWord] sp[localOffset(t, localSize(t, method), method)] = t->exception;
= t->exception;
t->exception = 0; t->exception = 0;
} else { } else {
@ -1432,7 +1430,8 @@ findUnwindTarget(MyThread* t, void** targetIp, void** targetBase,
- t->arch->argumentFootprint(methodParameterFootprint(t, method)) - t->arch->argumentFootprint(methodParameterFootprint(t, method))
- stackOffsetFromFrame(t, method); - stackOffsetFromFrame(t, method);
t->exceptionOffset = localOffset(t, localSize(t, method), method); t->exceptionOffset
= localOffset(t, localSize(t, method), method) * BytesPerWord;
break; break;
} else { } else {
releaseLock(t, method, releaseLock(t, method,
@ -3814,9 +3813,8 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
PROTECT(t, class_); PROTECT(t, class_);
unsigned offset unsigned offset
= (localOffset = localOffset
(t, localSize(t, context->method) + c->topOfStack(), (t, localSize(t, context->method) + c->topOfStack(), context->method)
context->method) / BytesPerWord)
+ t->arch->frameReturnAddressSize(); + t->arch->frameReturnAddressSize();
Compiler::Operand* result = c->call Compiler::Operand* result = c->call
@ -5197,7 +5195,6 @@ visitArguments(MyThread* t, Heap::Visitor* v, void* stack, object method)
break; break;
} }
} }
} }
void void
@ -5214,15 +5211,15 @@ visitStack(MyThread* t, Heap::Visitor* v)
object targetMethod = (trace ? trace->targetMethod : 0); object targetMethod = (trace ? trace->targetMethod : 0);
while (stack) { while (stack) {
if (targetMethod) {
visitArguments(t, v, stack, targetMethod);
targetMethod = 0;
}
object method = methodForIp(t, ip); object method = methodForIp(t, ip);
if (method) { if (method) {
PROTECT(t, method); PROTECT(t, method);
if (targetMethod) {
visitArguments(t, v, stack, targetMethod);
targetMethod = 0;
}
t->arch->nextFrame(&stack, &base); t->arch->nextFrame(&stack, &base);
visitStackAndLocals(t, v, stack, method, ip); visitStackAndLocals(t, v, stack, method, ip);
@ -5246,34 +5243,37 @@ visitStack(MyThread* t, Heap::Visitor* v)
void void
walkContinuationBody(MyThread* t, Heap::Walker* w, object c, int start) walkContinuationBody(MyThread* t, Heap::Walker* w, object c, int start)
{ {
const int ContinuationReferenceCount = 3; const int BodyOffset = ContinuationBody / BytesPerWord;
int bodyStart = max(0, start - ContinuationReferenceCount);
object method = static_cast<object> object method = static_cast<object>
(t->m->heap->follow(continuationMethod(t, c))); (t->m->heap->follow(continuationMethod(t, c)));
unsigned count = frameMapSizeInBits(t, method); int count = frameMapSizeInBits(t, method);
if (count) { if (count) {
int stack = BodyOffset
+ (continuationFramePointerOffset(t, c) / BytesPerWord)
- t->arch->framePointerOffset()
- stackOffsetFromFrame(t, method);
int first = stack + localOffsetFromStack(t, count - 1, method);
if (start > first) {
count -= start - first;
}
object map = codePool(t, methodCode(t, method)); object map = codePool(t, methodCode(t, method));
int index = frameMapIndex int index = frameMapIndex
(t, method, difference (t, method, difference
(continuationAddress(t, c), (continuationAddress(t, c),
reinterpret_cast<void*>(methodAddress(t, method)))); reinterpret_cast<void*>(methodAddress(t, method))));
for (unsigned i = bodyStart; i < count; ++i) { for (int i = count - 1; i >= 0; --i) {
int j = index + i; int j = index + i;
if ((intArrayBody(t, map, j / 32) if ((intArrayBody(t, map, j / 32)
& (static_cast<int32_t>(1) << (j % 32)))) & (static_cast<int32_t>(1) << (j % 32))))
{ {
if (not w->visit if (not w->visit(stack + localOffsetFromStack(t, i, method))) {
((continuationFramePointerOffset(t, c) / BytesPerWord)
- t->arch->framePointerOffset()
- stackOffsetFromFrame(t, method)
+ localOffsetFromStack(t, i, method)))
{
return; return;
} }
} }
} }
} }
@ -5417,7 +5417,7 @@ class ArgumentList {
MyProtector(ArgumentList* list): Protector(list->t), list(list) { } MyProtector(ArgumentList* list): Protector(list->t), list(list) { }
virtual void visit(Heap::Visitor* v) { virtual void visit(Heap::Visitor* v) {
for (unsigned i = list->position; i < list->size; ++i) { for (unsigned i = 0; i < list->position; ++i) {
if (list->objectMask[i]) { if (list->objectMask[i]) {
v->visit(reinterpret_cast<object*>(list->array + i)); v->visit(reinterpret_cast<object*>(list->array + i));
} }
@ -5658,6 +5658,7 @@ class MyProcessor: public Processor {
v->visit(&objectPools); v->visit(&objectPools);
v->visit(&staticTableArray); v->visit(&staticTableArray);
v->visit(&virtualThunks); v->visit(&virtualThunks);
v->visit(&receiveMethod);
} }
for (MyThread::CallTrace* trace = t->trace; trace; trace = trace->next) { for (MyThread::CallTrace* trace = t->trace; trace; trace = trace->next) {

View File

@ -196,7 +196,7 @@ visitRoots(Thread* t, Heap::Visitor* v)
} }
} }
void bool
walk(Thread*, Heap::Walker* w, uint32_t* mask, unsigned fixedSize, walk(Thread*, Heap::Walker* w, uint32_t* mask, unsigned fixedSize,
unsigned arrayElementSize, unsigned arrayLength, unsigned start) unsigned arrayElementSize, unsigned arrayLength, unsigned start)
{ {
@ -207,7 +207,7 @@ walk(Thread*, Heap::Walker* w, uint32_t* mask, unsigned fixedSize,
for (unsigned i = start; i < fixedSizeInWords; ++i) { for (unsigned i = start; i < fixedSizeInWords; ++i) {
if (mask[i / 32] & (static_cast<uint32_t>(1) << (i % 32))) { if (mask[i / 32] & (static_cast<uint32_t>(1) << (i % 32))) {
if (not w->visit(i)) { if (not w->visit(i)) {
return; return false;
} }
} }
} }
@ -240,12 +240,14 @@ walk(Thread*, Heap::Walker* w, uint32_t* mask, unsigned fixedSize,
if (not w->visit if (not w->visit
(fixedSizeInWords + (i * arrayElementSizeInWords) + j)) (fixedSizeInWords + (i * arrayElementSizeInWords) + j))
{ {
return; return false;
} }
} }
} }
} }
} }
return true;
} }
void void
@ -2784,6 +2786,8 @@ walk(Thread* t, Heap::Walker* w, object o, unsigned start)
object objectMask = static_cast<object> object objectMask = static_cast<object>
(t->m->heap->follow(classObjectMask(t, class_))); (t->m->heap->follow(classObjectMask(t, class_)));
bool more = true;
if (objectMask) { if (objectMask) {
unsigned fixedSize = classFixedSize(t, class_); unsigned fixedSize = classFixedSize(t, class_);
unsigned arrayElementSize = classArrayElementSize(t, class_); unsigned arrayElementSize = classArrayElementSize(t, class_);
@ -2795,20 +2799,20 @@ walk(Thread* t, Heap::Walker* w, object o, unsigned start)
memcpy(mask, &intArrayBody(t, objectMask, 0), memcpy(mask, &intArrayBody(t, objectMask, 0),
intArrayLength(t, objectMask) * 4); intArrayLength(t, objectMask) * 4);
::walk(t, w, mask, fixedSize, arrayElementSize, arrayLength, start); more = ::walk(t, w, mask, fixedSize, arrayElementSize, arrayLength, start);
} else if (classFlags(t, class_) & SingletonFlag) { } else if (classFlags(t, class_) & SingletonFlag) {
unsigned length = singletonLength(t, o); unsigned length = singletonLength(t, o);
if (length) { if (length) {
::walk(t, w, singletonMask(t, o), more = ::walk(t, w, singletonMask(t, o),
(singletonCount(t, o) + 2) * BytesPerWord, 0, 0, start); (singletonCount(t, o) + 2) * BytesPerWord, 0, 0, start);
} else if (start == 0) { } else if (start == 0) {
w->visit(0); more = w->visit(0);
} }
} else if (start == 0) { } else if (start == 0) {
w->visit(0); more = w->visit(0);
} }
if (classFlags(t, class_) & ContinuationFlag) { if (more and classFlags(t, class_) & ContinuationFlag) {
t->m->processor->walkContinuationBody(t, w, o, start); t->m->processor->walkContinuationBody(t, w, o, start);
} }
} }