diff --git a/src/compile.cpp b/src/compile.cpp index 4c68c5bf95..3bfb70e480 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -131,7 +131,8 @@ compareIpToMethodBounds(Thread* t, intptr_t ip, object method) if (ip < start) { return -1; - } else if (ip < start + static_cast(compiledSize(start))) + } else if (ip < start + static_cast + (compiledSize(start) + BytesPerWord)) { return 0; } else { @@ -536,6 +537,7 @@ class Context { method(method), bootContext(bootContext), objectPool(0), + objectPoolCount(0), traceLog(0), traceLogCount(0), visitTable(makeVisitTable(t, &zone, method)), @@ -553,6 +555,7 @@ class Context { method(0), bootContext(0), objectPool(0), + objectPoolCount(0), traceLog(0), traceLogCount(0), visitTable(0), @@ -574,6 +577,7 @@ class Context { object method; BootContext* bootContext; PoolElement* objectPool; + unsigned objectPoolCount; TraceElement* traceLog; unsigned traceLogCount; uint16_t* visitTable; @@ -653,6 +657,8 @@ class Frame { (context->zone.allocate(sizeof(PoolElement))) PoolElement(t, o, context->objectPool); + ++ context->objectPoolCount; + return c->address(context->objectPool); } } @@ -3811,16 +3817,18 @@ finish(MyThread* t, Allocator* allocator, Context* context) unsigned codeSize = c->compile(); uintptr_t* code = static_cast - (allocator->allocate(pad(codeSize) + BytesPerWord)); + (allocator->allocate(pad(codeSize) + pad(c->poolSize()) + BytesPerWord)); code[0] = codeSize; uint8_t* start = reinterpret_cast(code + 1); if (context->objectPool) { object pool = allocate3 (t, allocator, Machine::ImmortalAllocation, - FixedSizeOfArray + c->poolSize() + BytesPerWord, true); + FixedSizeOfArray + ((context->objectPoolCount + 1) * BytesPerWord), + true); - initArray(t, pool, (c->poolSize() / BytesPerWord) + 1, false); + initArray(t, pool, context->objectPoolCount + 1, false); + mark(t, pool, 0); set(t, pool, ArrayBody, objectPools(t)); objectPools(t) = pool; @@ -5169,7 +5177,7 @@ getThunk(MyThread* t, Thunk thunk) MyProcessor* p = processor(t); return reinterpret_cast - (p->thunkTable + ((thunk * p->thunkSize) / BytesPerWord)); + (p->thunkTable + (thunk * p->thunkSize)); } void