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>
This commit is contained in:
Ulf Hermann 2023-01-26 14:49:59 +01:00
parent 712cdc300a
commit 879a89fcda
4 changed files with 1 additions and 75 deletions

View File

@ -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);

View File

@ -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) {

View File

@ -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;

View File

@ -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();