From e19750538268c4d45fc6c60d2c90b17dd25c81e8 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Fri, 9 Feb 2024 21:29:26 +0100 Subject: Prepare for white allocations during gc (1/9): Write barrier for Lookups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lookups can (and do) reference HeapItems. This was safe in a non-incremental gc world, as Lookups are always reachable via their containing CompilationUnits, which are part of the root set. However, when using an incremental gc, an already marked Lookup might reference a new heap item, which then becomes otherwise unreachable. This is alleviated by the fact that Lookups generally either refer to something already existing or a freshly allocated string. The latter however is only safe when we can rely on black allocations during gc, and the former is somewhat reckless. Remedy this by employing the WriteBarrier for Lookups. We wrap all HeapItems in a helper class, which -while trivial itself- can't be used for direct assignments. Intead, it employs a set method which ensures that the WriteBarrier is used. Task-number: QTBUG-121910 Change-Id: I6a0ede66ad044076d2e87f134bc95686cb586aee Reviewed-by: Olivier De Cannière Reviewed-by: Sami Shalayel Reviewed-by: Ulf Hermann --- src/qml/qml/qqml.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/qml/qml/qqml.cpp') diff --git a/src/qml/qml/qqml.cpp b/src/qml/qml/qqml.cpp index 23cea45f9d..be41216e54 100644 --- a/src/qml/qml/qqml.cpp +++ b/src/qml/qml/qqml.cpp @@ -2009,9 +2009,9 @@ static void initTypeWrapperLookup( wrapper = l->qmlContextPropertyGetter(l, context->engine->handle(), wrapper); l->qmlContextPropertyGetter = qmlContextPropertyGetter; if (qmlContextPropertyGetter == QV4::QQmlContextWrapper::lookupSingleton) - l->qmlContextSingletonLookup.singletonObject = wrapper->heapObject(); + l->qmlContextSingletonLookup.singletonObject.set(scope.engine, wrapper->heapObject()); else if (qmlContextPropertyGetter == QV4::QQmlContextWrapper::lookupType) - l->qmlTypeLookup.qmlTypeWrapper = wrapper->heapObject(); + l->qmlTypeLookup.qmlTypeWrapper.set(scope.engine, wrapper->heapObject()); return; } scope.engine->throwTypeError(); @@ -2082,7 +2082,7 @@ void AOTCompiledContext::initLoadAttachedLookup( scope, QV4::QQmlTypeWrapper::create(scope.engine, object, type, QV4::Heap::QQmlTypeWrapper::ExcludeEnums)); - l->qmlTypeLookup.qmlTypeWrapper = wrapper->d(); + l->qmlTypeLookup.qmlTypeWrapper.set(scope.engine, wrapper->d()); l->getter = QV4::QObjectWrapper::lookupAttached; } @@ -2093,7 +2093,7 @@ bool AOTCompiledContext::loadTypeLookup(uint index, void *target) const return false; const QV4::Heap::QQmlTypeWrapper *typeWrapper = static_cast( - l->qmlTypeLookup.qmlTypeWrapper); + l->qmlTypeLookup.qmlTypeWrapper.get()); QMetaType metaType = typeWrapper->type().typeId(); *static_cast(target) -- cgit v1.2.3