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/qv4heap_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/qv4heap_p.h')
-rw-r--r-- | src/qml/memory/qv4heap_p.h | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/qml/memory/qv4heap_p.h b/src/qml/memory/qv4heap_p.h index 5a3797f397..f5172ec83c 100644 --- a/src/qml/memory/qv4heap_p.h +++ b/src/qml/memory/qv4heap_p.h @@ -52,6 +52,7 @@ #include <QtCore/QString> #include <private/qv4global_p.h> +#include <private/qv4mmdefs_p.h> #include <QSharedPointer> // To check if Heap::Base::init is called (meaning, all subclasses did their init and called their @@ -109,17 +110,23 @@ struct Q_QML_EXPORT Base { return reinterpret_cast<VTable *>(mm_data & PointerMask); } inline bool isMarked() const { - return mm_data & MarkBit; + const HeapItem *h = reinterpret_cast<const HeapItem *>(this); + Chunk *c = h->chunk(); + Q_ASSERT(!Chunk::testBit(c->extendsBitmap, h - c->realBase())); + return Chunk::testBit(c->blackBitmap, h - c->realBase()); } inline void setMarkBit() { - mm_data |= MarkBit; - } - inline void clearMarkBit() { - mm_data &= ~MarkBit; + 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->blackBitmap, h - c->realBase()); } inline bool inUse() const { - return !(mm_data & NotInUse); + const HeapItem *h = reinterpret_cast<const HeapItem *>(this); + Chunk *c = h->chunk(); + Q_ASSERT(!Chunk::testBit(c->extendsBitmap, h - c->realBase())); + return Chunk::testBit(c->objectBitmap, h - c->realBase()); } Base *nextFree() { |