diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2023-11-21 19:36:26 +0100 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2023-12-20 08:38:26 +0100 |
commit | b9d37a328ba09bcb2a7a95b5778cb8c63d0ace26 (patch) | |
tree | 340739253c3e15f0b6c051434d94061e8e3385c6 /src/qml/jsruntime/qv4persistent.cpp | |
parent | d08ede57dd530a67c3420b3858fe39bf1e5eb598 (diff) |
Long live incremental garbage collection in QML!
The design of the garbage collector is described in
src/qml/memory/design.md.
The gc and gcdone test helpers are adjusted to drive the gc to
completion, even when in incremental mode.
Parts of tst_qv4mm and tst_qqmlqt need to run with the incremental gc
disabled, as they call gc inside QML and assumes that the GC finishes
before returning.
Initial-patch-by: Rafal Chomentowski <rafal.chomentowski@ge.com>
Task-number: QTBUG-119274
Change-Id: I1d94f41bc7a434fad67de0fd46454b6db285f2eb
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4persistent.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4persistent.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4persistent.cpp b/src/qml/jsruntime/qv4persistent.cpp index 75353935a1..3cbaec1dac 100644 --- a/src/qml/jsruntime/qv4persistent.cpp +++ b/src/qml/jsruntime/qv4persistent.cpp @@ -171,7 +171,7 @@ Value *PersistentValueStorage::allocate() Value *v = p->values + p->header.freeList; p->header.freeList = v->int_32(); - if (p->header.freeList != -1 && p != firstPage) { + if (p->header.freeList != -1 && p != firstPage && !engine->isGCOngoing) { unlink(p); insertInFront(this, p); } @@ -304,6 +304,10 @@ void PersistentValue::set(ExecutionEngine *engine, const Value &value) { if (!val) val = engine->memoryManager->m_persistentValues->allocate(); + QV4::WriteBarrier::markCustom(engine, [&](QV4::MarkStack *stack){ + if (QV4::WriteBarrier::isInsertionBarrier && value.isManaged()) + stack->push(value.heapObject()); + }); *val = value; } @@ -311,6 +315,13 @@ void PersistentValue::set(ExecutionEngine *engine, ReturnedValue value) { if (!val) val = engine->memoryManager->m_persistentValues->allocate(); + QV4::WriteBarrier::markCustom(engine, [&](QV4::MarkStack *stack){ + if constexpr (!QV4::WriteBarrier::isInsertionBarrier) + return; + auto val = Value::fromReturnedValue(value); + if (val.isManaged()) + stack->push(val.heapObject()); + }); *val = value; } @@ -318,6 +329,11 @@ void PersistentValue::set(ExecutionEngine *engine, Heap::Base *obj) { if (!val) val = engine->memoryManager->m_persistentValues->allocate(); + QV4::WriteBarrier::markCustom(engine, [&](QV4::MarkStack *stack){ + if constexpr (QV4::WriteBarrier::isInsertionBarrier) + stack->push(obj); + }); + *val = obj; } |