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/jsapi/qjsvalue_p.h | |
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/jsapi/qjsvalue_p.h')
-rw-r--r-- | src/qml/jsapi/qjsvalue_p.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/qml/jsapi/qjsvalue_p.h b/src/qml/jsapi/qjsvalue_p.h index b95e76e76e..4624652c93 100644 --- a/src/qml/jsapi/qjsvalue_p.h +++ b/src/qml/jsapi/qjsvalue_p.h @@ -150,9 +150,17 @@ public: case QV4::StaticValue::Integer_Type: return encode(qv4Value.integerValue()); case QV4::StaticValue::Managed_Type: { - QV4::Value *m = qv4Value.as<QV4::Managed>()->engine() - ->memoryManager->m_persistentValues->allocate(); + auto managed = qv4Value.as<QV4::Managed>(); + auto engine = managed->engine(); + auto mm = engine->memoryManager; + QV4::Value *m = mm->m_persistentValues->allocate(); Q_ASSERT(m); + // we create a new strong reference to the heap managed object + // to avoid having to rescan the persistent values, we mark it here + QV4::WriteBarrier::markCustom(engine, [&](QV4::MarkStack *stack){ + if constexpr (QV4::WriteBarrier::isInsertionBarrier) + managed->heapObject()->mark(stack); + }); *m = qv4Value; return encodePointer(m, Kind::QV4ValuePtr); } |