diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-01-03 11:49:15 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-01-25 08:30:43 +0000 |
commit | a31a5a43b364ab70f10a7619234492dedd8c8dfe (patch) | |
tree | 1c524f22222465886e4ba867e7aa865b8decf140 /src/qml/memory/qv4mmdefs_p.h | |
parent | 8cdd25357d29b958686089efcaaa5460a9855beb (diff) |
New garbage collector
This is a block based allocator. We allocate HeapItems
from 64k Chunks (except for huge items that get their
own chunk). The allocator is block based, and aims to
defragment when sweep'ing the blocks.
The mark bit is now stored in the Chunk header, not
inline in the object anymore.
Change-Id: I2845f8b73dd496911ba50b868d54d144501d41e4
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/memory/qv4mmdefs_p.h')
-rw-r--r-- | src/qml/memory/qv4mmdefs_p.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/qml/memory/qv4mmdefs_p.h b/src/qml/memory/qv4mmdefs_p.h index 4bfbfadde6..588ae21ee0 100644 --- a/src/qml/memory/qv4mmdefs_p.h +++ b/src/qml/memory/qv4mmdefs_p.h @@ -131,6 +131,8 @@ struct Chunk { } static void setBits(quintptr *bitmap, size_t index, size_t nBits) { // Q_ASSERT(index >= HeaderSize/SlotSize && index + nBits <= ChunkSize/SlotSize); + if (!nBits) + return; bitmap += index >> BitShift; index &= (Bits - 1); while (1) { @@ -171,6 +173,11 @@ struct Chunk { } return usedSlots; } + + void sweep(); + void freeAll(); + + void sortIntoBins(HeapItem **bins, uint nBins); }; struct HeapItem { @@ -209,7 +216,7 @@ struct HeapItem { void setAllocatedSlots(size_t nSlots) { // Q_ASSERT(size && !(size % sizeof(HeapItem))); Chunk *c = chunk(); - uint index = this - c->realBase(); + size_t index = this - c->realBase(); // Q_ASSERT(!Chunk::testBit(c->objectBitmap, index)); Chunk::setBit(c->objectBitmap, index); Chunk::setBits(c->extendsBitmap, index + 1, nSlots - 1); |