diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2023-01-26 14:49:59 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-01-27 19:16:38 +0100 |
commit | 879a89fcda914581ea76f6d9786dc5c2e489991b (patch) | |
tree | 427b98bf81cf98450cd45453926ec9bfde74ecc3 /src/qml | |
parent | 712cdc300a20ee8409aa920e8c30dd1871f5c877 (diff) |
MemoryManager: Remove grayBitmap
We're not using gray items anywhere. There is no need to waste the
memory for the bitmap.
Change-Id: I26983cbc005531184ed955cea6026b9a8c5be910
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/memory/qv4heap_p.h | 6 | ||||
-rw-r--r-- | src/qml/memory/qv4mm.cpp | 55 | ||||
-rw-r--r-- | src/qml/memory/qv4mm_p.h | 6 | ||||
-rw-r--r-- | src/qml/memory/qv4mmdefs_p.h | 9 |
4 files changed, 1 insertions, 75 deletions
diff --git a/src/qml/memory/qv4heap_p.h b/src/qml/memory/qv4heap_p.h index b4bd3c4cd6..41150fd9e1 100644 --- a/src/qml/memory/qv4heap_p.h +++ b/src/qml/memory/qv4heap_p.h @@ -77,12 +77,6 @@ struct Q_QML_EXPORT Base { Q_ASSERT(!Chunk::testBit(c->extendsBitmap, h - c->realBase())); return Chunk::setBit(c->blackBitmap, h - c->realBase()); } - inline void setGrayBit() { - const HeapItem *h = reinterpret_cast<const HeapItem *>(this); - Chunk *c = h->chunk(); - Q_ASSERT(!Chunk::testBit(c->extendsBitmap, h - c->realBase())); - return Chunk::setBit(c->grayBitmap, h - c->realBase()); - } inline bool inUse() const { const HeapItem *h = reinterpret_cast<const HeapItem *>(this); diff --git a/src/qml/memory/qv4mm.cpp b/src/qml/memory/qv4mm.cpp index 3add05b95e..a7892e9729 100644 --- a/src/qml/memory/qv4mm.cpp +++ b/src/qml/memory/qv4mm.cpp @@ -24,7 +24,6 @@ #include "qv4profiling_p.h" #include "qv4mapobject_p.h" #include "qv4setobject_p.h" -#include "qv4writebarrier_p.h" //#define MM_STATS @@ -272,9 +271,6 @@ bool Chunk::sweep(ExecutionEngine *engine) HeapItem *o = realBase(); bool lastSlotFree = false; for (uint i = 0; i < Chunk::EntriesInBitmap; ++i) { -#if WRITEBARRIER(none) - Q_ASSERT((grayBitmap[i] | blackBitmap[i]) == blackBitmap[i]); // check that we don't have gray only objects -#endif quintptr toFree = objectBitmap[i] ^ blackBitmap[i]; Q_ASSERT((toFree & objectBitmap[i]) == toFree); // check all black objects are marked as being used quintptr e = extendsBitmap[i]; @@ -318,7 +314,6 @@ bool Chunk::sweep(ExecutionEngine *engine) - (blackBitmap[i] | e)) * Chunk::SlotSize, Profiling::SmallItem); objectBitmap[i] = blackBitmap[i]; - grayBitmap[i] = 0; hasUsedSlots |= (blackBitmap[i] != 0); extendsBitmap[i] = e; lastSlotFree = !((objectBitmap[i]|extendsBitmap[i]) >> (sizeof(quintptr)*8 - 1)); @@ -368,7 +363,6 @@ void Chunk::freeAll(ExecutionEngine *engine) Q_V4_PROFILE_DEALLOC(engine, (qPopulationCount(objectBitmap[i]|extendsBitmap[i]) - qPopulationCount(e)) * Chunk::SlotSize, Profiling::SmallItem); objectBitmap[i] = 0; - grayBitmap[i] = 0; extendsBitmap[i] = e; o += Chunk::Bits; } @@ -380,36 +374,6 @@ void Chunk::resetBlackBits() memset(blackBitmap, 0, sizeof(blackBitmap)); } -void Chunk::collectGrayItems(MarkStack *markStack) -{ - // DEBUG << "sweeping chunk" << this << (*freeList); - HeapItem *o = realBase(); - for (uint i = 0; i < Chunk::EntriesInBitmap; ++i) { -#if WRITEBARRIER(none) - Q_ASSERT((grayBitmap[i] | blackBitmap[i]) == blackBitmap[i]); // check that we don't have gray only objects -#endif - quintptr toMark = blackBitmap[i] & grayBitmap[i]; // correct for a Steele type barrier - Q_ASSERT((toMark & objectBitmap[i]) == toMark); // check all black objects are marked as being used - // DEBUG << hex << " index=" << i << toFree; - while (toMark) { - uint index = qCountTrailingZeroBits(toMark); - quintptr bit = (static_cast<quintptr>(1) << index); - - toMark ^= bit; // mask out marked slot - // DEBUG << " index" << hex << index << toFree; - - HeapItem *itemToFree = o + index; - Heap::Base *b = *itemToFree; - Q_ASSERT(b->inUse()); - markStack->push(b); - } - grayBitmap[i] = 0; - o += Chunk::Bits; - } - // DEBUG << "swept chunk" << this << "freed" << slotsFreed << "slots."; - -} - void Chunk::sortIntoBins(HeapItem **bins, uint nBins) { // qDebug() << "sortIntoBins:"; @@ -622,13 +586,6 @@ void BlockAllocator::resetBlackBits() c->resetBlackBits(); } -void BlockAllocator::collectGrayItems(MarkStack *markStack) -{ - for (auto c : chunks) - c->collectGrayItems(markStack); - -} - HeapItem *HugeItemAllocator::allocate(size_t size) { MemorySegment *m = nullptr; Chunk *c = nullptr; @@ -698,18 +655,6 @@ void HugeItemAllocator::resetBlackBits() Chunk::clearBit(c.chunk->blackBitmap, c.chunk->first() - c.chunk->realBase()); } -void HugeItemAllocator::collectGrayItems(MarkStack *markStack) -{ - for (auto c : chunks) - // Correct for a Steele type barrier - if (Chunk::testBit(c.chunk->blackBitmap, c.chunk->first() - c.chunk->realBase()) && - Chunk::testBit(c.chunk->grayBitmap, c.chunk->first() - c.chunk->realBase())) { - HeapItem *i = c.chunk->first(); - Heap::Base *b = *i; - b->mark(markStack); - } -} - void HugeItemAllocator::freeAll() { for (auto &c : chunks) { diff --git a/src/qml/memory/qv4mm_p.h b/src/qml/memory/qv4mm_p.h index cb1d2567b3..378b36369d 100644 --- a/src/qml/memory/qv4mm_p.h +++ b/src/qml/memory/qv4mm_p.h @@ -22,10 +22,6 @@ #include <private/qv4mmdefs_p.h> #include <QVector> -#define QV4_MM_MAXBLOCK_SHIFT "QV4_MM_MAXBLOCK_SHIFT" -#define QV4_MM_MAX_CHUNK_SIZE "QV4_MM_MAX_CHUNK_SIZE" -#define QV4_MM_STATS "QV4_MM_STATS" - #define MM_DEBUG 0 QT_BEGIN_NAMESPACE @@ -67,7 +63,6 @@ struct BlockAllocator { void sweep(); void freeAll(); void resetBlackBits(); - void collectGrayItems(MarkStack *markStack); // bump allocations HeapItem *nextFree = nullptr; @@ -89,7 +84,6 @@ struct HugeItemAllocator { void sweep(ClassDestroyStatsCallback classCountPtr); void freeAll(); void resetBlackBits(); - void collectGrayItems(MarkStack *markStack); size_t usedMem() const { size_t used = 0; diff --git a/src/qml/memory/qv4mmdefs_p.h b/src/qml/memory/qv4mmdefs_p.h index c873bfd5f8..a7fc7bb7cb 100644 --- a/src/qml/memory/qv4mmdefs_p.h +++ b/src/qml/memory/qv4mmdefs_p.h @@ -59,7 +59,7 @@ struct Chunk { SlotSizeShift = 5, NumSlots = ChunkSize/SlotSize, BitmapSize = NumSlots/8, - HeaderSize = 4*BitmapSize, + HeaderSize = 3*BitmapSize, DataSize = ChunkSize - HeaderSize, AvailableSlots = DataSize/SlotSize, #if QT_POINTER_SIZE == 8 @@ -71,7 +71,6 @@ struct Chunk { #endif EntriesInBitmap = BitmapSize/sizeof(quintptr) }; - quintptr grayBitmap[BitmapSize/sizeof(quintptr)]; quintptr blackBitmap[BitmapSize/sizeof(quintptr)]; quintptr objectBitmap[BitmapSize/sizeof(quintptr)]; quintptr extendsBitmap[BitmapSize/sizeof(quintptr)]; @@ -152,7 +151,6 @@ struct Chunk { bool sweep(ClassDestroyStatsCallback classCountPtr); void resetBlackBits(); - void collectGrayItems(QV4::MarkStack *markStack); bool sweep(ExecutionEngine *engine); void freeAll(ExecutionEngine *engine); @@ -176,11 +174,6 @@ struct HeapItem { return reinterpret_cast<Chunk *>(reinterpret_cast<quintptr>(this) >> Chunk::ChunkShift << Chunk::ChunkShift); } - bool isGray() const { - Chunk *c = chunk(); - std::ptrdiff_t index = this - c->realBase(); - return Chunk::testBit(c->grayBitmap, index); - } bool isBlack() const { Chunk *c = chunk(); std::ptrdiff_t index = this - c->realBase(); |