diff --git a/src/compile.cpp b/src/compile.cpp index a1c11cfa81..f09917e268 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -3793,6 +3793,13 @@ compareMethodBounds(Thread* t, object a, object b) (&singletonValue(t, methodCompiled(t, b), 0)); } +unsigned +frameObjectMapSize(MyThread* t, object method, object map) +{ + int size = frameSize(t, method); + return ceiling(intArrayLength(t, map) * size, 32 + size); +} + object finish(MyThread* t, Context* context, const char* name) { @@ -3836,6 +3843,8 @@ finish(MyThread* t, Context* context, const char* name) TraceElement* elements[context->traceLogCount]; unsigned index = 0; for (TraceElement* p = context->traceLog; p; p = p->next) { + assert(t, index < context->traceLogCount); + elements[index++] = p; p->addressValue = p->address->value(c); @@ -3855,6 +3864,9 @@ finish(MyThread* t, Context* context, const char* name) + ceiling(context->traceLogCount * size, 32), false); + assert(t, intArrayLength(t, map) == context->traceLogCount + + frameObjectMapSize(t, context->method, map)); + for (unsigned i = 0; i < context->traceLogCount; ++i) { TraceElement* p = elements[i]; @@ -4302,8 +4314,7 @@ unsigned frameMapIndex(MyThread* t, object method, int32_t offset) { object map = codePool(t, methodCode(t, method)); - unsigned mapSize = ceiling - (intArrayLength(t, map), (32 / frameSize(t, method)) + 1); + unsigned mapSize = frameObjectMapSize(t, method, map); unsigned indexSize = intArrayLength(t, map) - mapSize; unsigned bottom = 0; diff --git a/src/machine.h b/src/machine.h index d6d95c920b..2f2350c18a 100644 --- a/src/machine.h +++ b/src/machine.h @@ -2258,6 +2258,7 @@ inline object makeSingleton(Thread* t, unsigned count) { object o = makeSingleton(t, count + singletonMaskSize(count), true); + assert(t, singletonLength(t, o) == count + singletonMaskSize(t, o)); if (count) { singletonMask(t, o)[0] = 1; }