aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4propertykey_p.h
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2023-11-21 19:36:26 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2023-12-20 08:38:26 +0100
commitb9d37a328ba09bcb2a7a95b5778cb8c63d0ace26 (patch)
tree340739253c3e15f0b6c051434d94061e8e3385c6 /src/qml/jsruntime/qv4propertykey_p.h
parentd08ede57dd530a67c3420b3858fe39bf1e5eb598 (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/qv4propertykey_p.h')
-rw-r--r--src/qml/jsruntime/qv4propertykey_p.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4propertykey_p.h b/src/qml/jsruntime/qv4propertykey_p.h
index 0b8ad084d2..d6d15e402d 100644
--- a/src/qml/jsruntime/qv4propertykey_p.h
+++ b/src/qml/jsruntime/qv4propertykey_p.h
@@ -14,6 +14,7 @@
// We mean it.
//
+#include <private/qv4writebarrier_p.h>
#include <private/qv4global_p.h>
#include <private/qv4staticvalue_p.h>
#include <QtCore/qhashfunctions.h>
@@ -70,11 +71,18 @@ public:
// We cannot #include the declaration of Heap::StringOrSymbol here.
// Therefore we do some gymnastics to enforce the type safety.
- template<typename StringOrSymbol = Heap::StringOrSymbol>
- static PropertyKey fromStringOrSymbol(StringOrSymbol *b)
+ template<typename StringOrSymbol = Heap::StringOrSymbol, typename Engine = QV4::EngineBase>
+ static PropertyKey fromStringOrSymbol(Engine *engine, StringOrSymbol *b)
{
static_assert(std::is_base_of_v<Heap::StringOrSymbol, StringOrSymbol>);
PropertyKey key;
+ QV4::WriteBarrier::markCustom(engine, [&](QV4::MarkStack *stack) {
+ if constexpr (QV4::WriteBarrier::isInsertionBarrier) {
+ // treat this as an insertion - the StringOrSymbol becomes reachable
+ // via the propertykey, so we consequently need to mark it durnig gc
+ b->mark(stack);
+ }
+ });
key.val.setM(b);
Q_ASSERT(key.isManaged());
return key;