fix continuations=true build

This commit is contained in:
Joel Dice 2011-01-27 11:54:41 -07:00
parent 5cedcf7833
commit b7157c802a
5 changed files with 44 additions and 27 deletions

View File

@ -2133,14 +2133,14 @@ makeCurrentContinuation(MyThread* t, void** targetIp, void** targetStack)
object c = makeContinuation object c = makeContinuation
(t, 0, context, method, ip, (t, 0, context, method, ip,
((frameSize (frameSize
+ t->arch->frameFooterSize() + t->arch->frameFooterSize()
+ t->arch->returnAddressOffset() + t->arch->returnAddressOffset()
- t->arch->frameReturnAddressSize()) * BytesPerWord), - t->arch->frameReturnAddressSize()) * BytesPerWord,
((frameSize (frameSize
+ t->arch->frameFooterSize() + t->arch->frameFooterSize()
+ t->arch->framePointerOffset() + t->arch->framePointerOffset()
- t->arch->frameReturnAddressSize()) * BytesPerWord), - t->arch->frameReturnAddressSize()) * BytesPerWord,
totalSize); totalSize);
memcpy(&continuationBody(t, c, 0), top, totalSize * BytesPerWord); memcpy(&continuationBody(t, c, 0), top, totalSize * BytesPerWord);
@ -6780,6 +6780,8 @@ callContinuation(MyThread* t, object continuation, object result,
t->trace->nativeMethod = 0; t->trace->nativeMethod = 0;
t->trace->targetMethod = 0; t->trace->targetMethod = 0;
popResources(t);
transition(t, ip, stack, continuation, t->trace); transition(t, ip, stack, continuation, t->trace);
vmJump(ip, stack, t, reinterpret_cast<uintptr_t>(result), 0); vmJump(ip, stack, t, reinterpret_cast<uintptr_t>(result), 0);
@ -6857,6 +6859,10 @@ jumpAndInvoke(MyThread* t, object method, void* stack, ...)
RUNTIME_ARRAY_BODY(arguments)[i] = va_arg(a, uintptr_t); RUNTIME_ARRAY_BODY(arguments)[i] = va_arg(a, uintptr_t);
} }
va_end(a); va_end(a);
assert(t, t->exception == 0);
popResources(t);
vmJumpAndInvoke vmJumpAndInvoke
(t, reinterpret_cast<void*>(methodAddress(t, method)), (t, reinterpret_cast<void*>(methodAddress(t, method)),

View File

@ -59,11 +59,13 @@ LOCAL(vmInvoke_continuationTest):
#endif #endif
movq %r10,(%rsp,%rdi,1) movq %r10,(%rsp,%rdi,1)
#ifdef AVIAN_USE_FRAME_POINTER
// save the current base pointer in the frame and update it // save the current base pointer in the frame and update it
movq CONTINUATION_FRAME_POINTER_OFFSET(%rcx),%rdi movq CONTINUATION_FRAME_POINTER_OFFSET(%rcx),%rdi
movq %rbp,(%rsp,%rdi,1) movq %rbp,(%rsp,%rdi,1)
addq %rsp,%rdi addq %rsp,%rdi
movq %rdi,%rbp movq %rdi,%rbp
#endif
// consume the continuation // consume the continuation
movq CONTINUATION_NEXT(%rcx),%rdi movq CONTINUATION_NEXT(%rcx),%rdi
@ -151,11 +153,13 @@ LOCAL(vmInvoke_offset):
#endif #endif
movl %esi,(%esp,%edi,1) movl %esi,(%esp,%edi,1)
#ifdef AVIAN_USE_FRAME_POINTER
// save the current base pointer in the frame and update it // save the current base pointer in the frame and update it
movl CONTINUATION_FRAME_POINTER_OFFSET(%ecx),%edi movl CONTINUATION_FRAME_POINTER_OFFSET(%ecx),%edi
movl %ebp,(%esp,%edi,1) movl %ebp,(%esp,%edi,1)
addl %esp,%edi addl %esp,%edi
movl %edi,%ebp movl %edi,%ebp
#endif
// consume the continuation // consume the continuation
movl CONTINUATION_NEXT(%ecx),%edi movl CONTINUATION_NEXT(%ecx),%edi

View File

@ -2843,28 +2843,19 @@ makeNewGeneral(Thread* t, object class_)
return instance; return instance;
} }
void NO_RETURN void
throw_(Thread* t, object e) popResources(Thread* t)
{ {
assert(t, t->exception == 0); while (t->resource != t->checkpoint->resource) {
Thread::Checkpoint* checkpoint = t->checkpoint;
expect(t, not checkpoint->noThrow);
t->exception = e;
while (t->resource != checkpoint->resource) {
Thread::Resource* r = t->resource; Thread::Resource* r = t->resource;
t->resource = r->next; t->resource = r->next;
fprintf(stderr, "unwind resource %p %p %p\n", r,
reinterpret_cast<void**>(r)[0],
reinterpret_cast<void***>(r)[0][0]);
r->release(); r->release();
} }
t->protector = checkpoint->protector; t->protector = t->checkpoint->protector;
checkpoint->unwind();
abort(t);
} }
object object

View File

@ -2572,8 +2572,24 @@ makeThrowable(Thread* t, Machine::Type type, const char* format, ...)
return r; return r;
} }
void NO_RETURN void
throw_(Thread* t, object e); popResources(Thread* t);
inline void NO_RETURN
throw_(Thread* t, object e)
{
assert(t, t->exception == 0);
expect(t, not t->checkpoint->noThrow);
t->exception = e;
popResources(t);
t->checkpoint->unwind();
abort(t);
}
inline void NO_RETURN inline void NO_RETURN
throwNew(Thread* t, Machine::Type type) throwNew(Thread* t, Machine::Type type)

View File

@ -3029,7 +3029,7 @@ class MyArchitecture: public Assembler::Architecture {
} }
virtual int framePointerOffset() { virtual int framePointerOffset() {
return -1; return UseFramePointer ? -1 : 0;
} }
virtual void plan virtual void plan