From 7ed14948b9ff11aaed63fa692a5649fe9fe1e8aa Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 16 Jun 2009 13:41:31 -0600 Subject: [PATCH] re-initialize frame maps for exception handlers on every iteration of the frame map calculation loop This fixes incorrect frame map calcuation which may lead to crashes during garbage collection from an exception handler. --- src/compile.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/compile.cpp b/src/compile.cpp index 5e4b523ba5..947a2a9fe3 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -548,6 +548,7 @@ enum Event { IpEvent, MarkEvent, ClearEvent, + InitEvent, TraceEvent }; @@ -4388,6 +4389,14 @@ calculateFrameMaps(MyThread* t, Context* context, uintptr_t* originalRoots, clearBit(roots, i); } break; + case InitEvent: { + unsigned reference = context->eventLog.get2(eventIndex); + eventIndex += 2; + + uintptr_t* tableRoots = context->rootTable + (reference * mapSize); + memcpy(roots, tableRoots, mapSize * BytesPerWord); + } break; + case TraceEvent: { TraceElement* te; context->eventLog.get(eventIndex, &te, BytesPerWord); if (DebugFrameMaps) { @@ -4711,16 +4720,8 @@ compile(MyThread* t, Allocator* allocator, Context* context) uint8_t stackMap[codeMaxStack(t, methodCode(t, context->method))]; Frame frame2(&frame, stackMap); - uintptr_t* roots = context->rootTable - + (start * frameMapSizeInWords(t, context->method)); - - for (unsigned i = 0; i < localSize(t, context->method); ++ i) { - if (getBit(roots, i)) { - frame2.set(i, Frame::Object); - } else { - frame2.set(i, Frame::Integer); - } - } + context->eventLog.append(InitEvent); + context->eventLog.append2(start); for (unsigned i = 1; i < codeMaxStack(t, methodCode(t, context->method));