From 4754a92b75d22ebcc9a29b2a239c4d0010a75d99 Mon Sep 17 00:00:00 2001 From: Joshua Warner Date: Fri, 27 Jun 2014 21:48:48 -0600 Subject: [PATCH] split code.stackMap out of code.pool use --- src/compile.cpp | 71 ++++--------------------------------------------- src/machine.cpp | 4 +-- src/types.def | 1 + 3 files changed, 8 insertions(+), 68 deletions(-) diff --git a/src/compile.cpp b/src/compile.cpp index 2df4854e04..9fe0873fd6 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -6844,7 +6844,7 @@ finish(MyThread* t, FixedAllocator* allocator, Context* context) object code = context->method->code(); code = reinterpret_cast(makeCode - (t, 0, newExceptionHandlerTable, cast(t, newLineNumberTable), + (t, 0, 0, newExceptionHandlerTable, cast(t, newLineNumberTable), reinterpret_cast(start), codeSize, codeMaxStack(t, code), codeMaxLocals(t, code), 0)); @@ -6877,7 +6877,7 @@ finish(MyThread* t, FixedAllocator* allocator, Context* context) object map = makeSimpleFrameMapTable( t, context, start, RUNTIME_ARRAY_BODY(elements), index); - set(t, context->method->code(), CodePool, map); + set(t, context->method->code(), CodeStackMap, map); } logCompile @@ -7385,73 +7385,12 @@ findFrameMapInSimpleTable(MyThread* t, GcMethod* method, object table, abort(t); } -unsigned -findFrameMap(MyThread* t, void* stack, GcMethod* method, object table, - unsigned pathIndex) -{ - if (pathIndex) { - FrameMapTablePath* path = reinterpret_cast - (&byteArrayBody(t, table, pathIndex)); - - void* address = static_cast(stack)[path->stackIndex]; - uint8_t* base = reinterpret_cast(methodAddress(t, method)); - for (unsigned i = 0; i < path->elementCount; ++i) { - if (address == base + path->elements[i]) { - return i + (path->elementCount * findFrameMap - (t, stack, method, table, path->next)); - } - } - - abort(t); - } else { - return 0; - } -} - void -findFrameMapInGeneralTable(MyThread* t, void* stack, GcMethod* method, - object table, int32_t offset, int32_t** map, - unsigned* start) -{ - FrameMapTableHeader* header = reinterpret_cast - (&byteArrayBody(t, table, 0)); - - FrameMapTableIndexElement* index - = reinterpret_cast - (&byteArrayBody(t, table, sizeof(FrameMapTableHeader))); - - *map = reinterpret_cast(index + header->indexCount); - - unsigned bottom = 0; - unsigned top = header->indexCount; - for (unsigned span = top - bottom; span; span = top - bottom) { - unsigned middle = bottom + (span / 2); - FrameMapTableIndexElement* v = index + middle; - - if (offset == v->offset) { - *start = v->base + (findFrameMap(t, stack, method, table, v->path) - * frameMapSizeInBits(t, method)); - return; - } else if (offset < v->offset) { - top = middle; - } else { - bottom = middle + 1; - } - } - - abort(t); -} - -void -findFrameMap(MyThread* t, void* stack, GcMethod* method, int32_t offset, +findFrameMap(MyThread* t, void* stack UNUSED, GcMethod* method, int32_t offset, int32_t** map, unsigned* start) { - object table = codePool(t, method->code()); - if (objectClass(t, table) == type(t, GcIntArray::Type)) { - findFrameMapInSimpleTable(t, method, table, offset, map, start); - } else { - findFrameMapInGeneralTable(t, stack, method, table, offset, map, start); - } + object table = reinterpret_cast(codeStackMap(t, method->code())); + findFrameMapInSimpleTable(t, method, table, offset, map, start); } void diff --git a/src/machine.cpp b/src/machine.cpp index 64c4c9bca5..d7c3464314 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -1914,7 +1914,7 @@ parseCode(Thread* t, Stream& s, GcSingleton* pool) fprintf(stderr, " code: maxStack %d maxLocals %d length %d\n", maxStack, maxLocals, length); } - object code = reinterpret_cast(makeCode(t, reinterpret_cast(pool), 0, 0, 0, 0, maxStack, maxLocals, length)); + object code = reinterpret_cast(makeCode(t, reinterpret_cast(pool), 0, 0, 0, 0, 0, maxStack, maxLocals, length)); s.read(&codeBody(t, code, 0), length); PROTECT(t, code); @@ -2935,7 +2935,7 @@ boot(Thread* t) m->processor->boot(t, 0, 0); - { object bootCode = reinterpret_cast(makeCode(t, 0, 0, 0, 0, 0, 0, 0, 1)); + { object bootCode = reinterpret_cast(makeCode(t, 0, 0, 0, 0, 0, 0, 0, 0, 1)); codeBody(t, bootCode, 0) = impdep1; object bootMethod = reinterpret_cast(makeMethod (t, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, bootCode)); diff --git a/src/types.def b/src/types.def index 46c4d98cdb..1287048a42 100644 --- a/src/types.def +++ b/src/types.def @@ -328,6 +328,7 @@ (type code avian/Code (object pool) + (intArray stackMap) (object exceptionHandlerTable) (lineNumberTable lineNumberTable) (intptr_t compiled)