From 299699f1ff5db3df34d109b00a04639df9a81c90 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Sun, 26 Apr 2009 16:06:15 -0600 Subject: [PATCH] fix stack unwinding for new calling convention (2nd try) --- src/compile.cpp | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/compile.cpp b/src/compile.cpp index 95b8b424af..e5d71eaf10 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -1314,36 +1314,37 @@ findUnwindTarget(MyThread* t, void** targetIp, void** targetBase, void* handler = findExceptionHandler(t, method, ip); - t->arch->nextFrame(&stack, &base); - - void* canonicalStack = stackForFrame(t, stack, method); - if (handler) { - void** sp = static_cast(canonicalStack) + *targetIp = handler; + *targetBase = base; + + t->arch->nextFrame(&stack, &base); + + void** sp = static_cast(stackForFrame(t, stack, method)) + t->arch->frameReturnAddressSize(); + *targetStack = sp; + sp[localOffset(t, localSize(t, method), method) / BytesPerWord] = t->exception; t->exception = 0; - - *targetIp = handler; - *targetBase = base; - *targetStack = sp; } else { + t->arch->nextFrame(&stack, &base); + ip = t->arch->frameIp(stack); + if (methodFlags(t, method) & ACC_SYNCHRONIZED) { object lock; if (methodFlags(t, method) & ACC_STATIC) { lock = methodClass(t, method); } else { lock = *localObject - (t, canonicalStack, method, savedTargetIndex(t, method)); + (t, stackForFrame(t, stack, method), method, + savedTargetIndex(t, method)); } release(t, lock); } - - ip = t->arch->frameIp(stack); } } else { *targetIp = ip; @@ -4457,15 +4458,15 @@ finish(MyThread* t, Allocator* allocator, Context* context) (&byteArrayBody(t, methodSpec(t, context->method), 0))); // for debugging: - if (//false and + if (false and strcmp (reinterpret_cast (&byteArrayBody(t, className(t, methodClass(t, context->method)), 0)), - "java/lang/Long") == 0 and + "java/lang/Throwable") == 0 and strcmp (reinterpret_cast (&byteArrayBody(t, methodName(t, context->method), 0)), - "toString") == 0) + "printStackTrace") == 0) { trap(); }