aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2024-01-08 14:03:06 +0100
committerUlf Hermann <ulf.hermann@qt.io>2024-01-13 16:03:59 +0100
commit2996fb835962750845702db4a9ded257f3f1a9b0 (patch)
treeb43a3aa62128ee22eb29715c9db6892db5be3381
parentc225e23e00bc539daefa357f687fe4a1b51ade9f (diff)
QtQml: Move property caches into base CU
Change-Id: I1567c9d3d61312e98200fb0854d7fcf111983948 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r--src/qml/common/qv4compileddata_p.h8
-rw-r--r--src/qml/jsruntime/qv4executablecompilationunit.cpp2
-rw-r--r--src/qml/jsruntime/qv4executablecompilationunit_p.h19
-rw-r--r--src/qml/qml/qqmlmetatypedata.cpp2
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp4
-rw-r--r--src/qml/qml/qqmlpropertyvalidator.cpp7
-rw-r--r--src/qml/qml/qqmltypedata.cpp16
7 files changed, 40 insertions, 18 deletions
diff --git a/src/qml/common/qv4compileddata_p.h b/src/qml/common/qv4compileddata_p.h
index 0adac2874c..bd94332f76 100644
--- a/src/qml/common/qv4compileddata_p.h
+++ b/src/qml/common/qv4compileddata_p.h
@@ -33,6 +33,7 @@
#include <private/qendian_p.h>
#include <private/qqmlnullablevalue_p.h>
+#include <private/qqmlpropertycachevector_p.h>
#include <private/qqmlrefcount_p.h>
#include <private/qqmltype_p.h>
#include <private/qv4compilationunitmapper_p.h>
@@ -1483,6 +1484,8 @@ struct CompilationUnit final : public QQmlRefCounted<CompilationUnit>
ResolvedTypeReferenceMap resolvedTypes;
+ QQmlPropertyCacheVector propertyCaches;
+
public:
using CompiledObject = CompiledData::Object;
@@ -1618,6 +1621,11 @@ public:
ResolvedTypeReference *resolvedType(int id) const { return resolvedTypes.value(id); }
ResolvedTypeReference *resolvedType(QMetaType type) const;
+ QQmlPropertyCache::ConstPtr rootPropertyCache() const
+ {
+ return propertyCaches.at(/*root object*/0);
+ }
+
private:
QString m_fileName; // initialized from data->sourceFileIndex
QString m_finalUrlString; // initialized from data->finalUrlIndex
diff --git a/src/qml/jsruntime/qv4executablecompilationunit.cpp b/src/qml/jsruntime/qv4executablecompilationunit.cpp
index ffd8b787e1..b6eb5298db 100644
--- a/src/qml/jsruntime/qv4executablecompilationunit.cpp
+++ b/src/qml/jsruntime/qv4executablecompilationunit.cpp
@@ -374,7 +374,7 @@ QQmlRefPointer<ExecutableCompilationUnit> ExecutableCompilationUnit::create(
void ExecutableCompilationUnit::finalizeCompositeType(const QQmlType &type)
{
// Add to type registry of composites
- if (propertyCaches.needsVMEMetaObject(/*root object*/0)) {
+ if (m_compilationUnit->propertyCaches.needsVMEMetaObject(/*root object*/0)) {
// qmlType is only valid for types that have references to themselves.
if (type.isValid()) {
qmlType = type;
diff --git a/src/qml/jsruntime/qv4executablecompilationunit_p.h b/src/qml/jsruntime/qv4executablecompilationunit_p.h
index d1504079b4..e0365b6fd8 100644
--- a/src/qml/jsruntime/qv4executablecompilationunit_p.h
+++ b/src/qml/jsruntime/qv4executablecompilationunit_p.h
@@ -78,12 +78,23 @@ public:
QUrl url() const { return m_compilationUnit->url(); }
QUrl finalUrl() const { return m_compilationUnit->finalUrl(); }
- // QML specific fields
- QQmlPropertyCacheVector propertyCaches;
- QQmlPropertyCache::ConstPtr rootPropertyCache() const { return propertyCaches.at(/*root object*/0); }
-
QQmlRefPointer<QQmlTypeNameCache> typeNameCache;
+ const QQmlPropertyCacheVector *propertyCachesPtr() const
+ {
+ return &m_compilationUnit->propertyCaches;
+ }
+
+ QQmlPropertyCacheVector *propertyCachesPtr()
+ {
+ return &m_compilationUnit->propertyCaches;
+ }
+
+ QQmlPropertyCache::ConstPtr rootPropertyCache() const
+ {
+ return m_compilationUnit->rootPropertyCache();
+ }
+
// mapping from component object index (CompiledData::Unit object index that points to component) to identifier hash of named objects
// this is initialized on-demand by QQmlContextData
QHash<int, IdentifierHash> namedObjectsPerComponentCache;
diff --git a/src/qml/qml/qqmlmetatypedata.cpp b/src/qml/qml/qqmlmetatypedata.cpp
index a8f064f41b..f8e420dc2d 100644
--- a/src/qml/qml/qqmlmetatypedata.cpp
+++ b/src/qml/qml/qqmlmetatypedata.cpp
@@ -246,7 +246,7 @@ static QQmlPropertyCache::ConstPtr propertyCacheForPotentialInlineComponentType(
// this is an inline component, and what we have in the iterator is currently the parent compilation unit
for (auto &&icDatum: (*iter)->inlineComponentData())
if (icDatum.qmlType.typeId() == t)
- return (*iter)->propertyCaches.at(icDatum.objectIndex);
+ return (*iter)->propertyCachesPtr()->at(icDatum.objectIndex);
}
return (*iter)->rootPropertyCache();
}
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index 792c654f5c..3a7ad4fd1e 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -58,7 +58,7 @@ QQmlObjectCreator::QQmlObjectCreator(
QQmlIncubatorPrivate *incubator)
: phase(Startup)
, compilationUnit(compilationUnit)
- , propertyCaches(&compilationUnit->propertyCaches)
+ , propertyCaches(compilationUnit->propertyCachesPtr())
, sharedState(new QQmlObjectCreatorSharedState, QQmlRefPointer<QQmlObjectCreatorSharedState>::Adopt)
, topLevelCreator(true)
, isContextObject(true)
@@ -88,7 +88,7 @@ QQmlObjectCreator::QQmlObjectCreator(QQmlRefPointer<QQmlContextData> parentConte
QQmlObjectCreatorSharedState *inheritedSharedState, bool isContextObject)
: phase(Startup)
, compilationUnit(compilationUnit)
- , propertyCaches(&compilationUnit->propertyCaches)
+ , propertyCaches(compilationUnit->propertyCachesPtr())
, sharedState(inheritedSharedState)
, topLevelCreator(false)
, isContextObject(isContextObject)
diff --git a/src/qml/qml/qqmlpropertyvalidator.cpp b/src/qml/qml/qqmlpropertyvalidator.cpp
index d971753e86..8b0e340736 100644
--- a/src/qml/qml/qqmlpropertyvalidator.cpp
+++ b/src/qml/qml/qqmlpropertyvalidator.cpp
@@ -35,7 +35,7 @@ QQmlPropertyValidator::QQmlPropertyValidator(
, compilationUnit(compilationUnit)
, imports(imports)
, qmlUnit(compilationUnit->unitData())
- , propertyCaches(compilationUnit->propertyCaches)
+ , propertyCaches(*compilationUnit->propertyCachesPtr())
, bindingPropertyDataPerObject(&compilationUnit->baseCompilationUnit()->bindingPropertyDataPerObject)
{
bindingPropertyDataPerObject->resize(compilationUnit->objectCount());
@@ -639,7 +639,7 @@ bool QQmlPropertyValidator::canCoerce(QMetaType to, QQmlPropertyCache::ConstPtr
// Therefore we need to check the ICs here
for (const auto& icDatum : compilationUnit->inlineComponentData()) {
if (icDatum.qmlType.typeId() == to) {
- toMo = compilationUnit->propertyCaches.at(icDatum.objectIndex);
+ toMo = compilationUnit->propertyCachesPtr()->at(icDatum.objectIndex);
break;
}
}
@@ -749,7 +749,8 @@ QQmlError QQmlPropertyValidator::validateObjectBinding(const QQmlPropertyData *p
// Therefore we need to check the ICs here
for (const auto& icDatum: compilationUnit->inlineComponentData()) {
if (icDatum.qmlType.typeId() == property->propType()) {
- propertyMetaObject = compilationUnit->propertyCaches.at(icDatum.objectIndex);
+ propertyMetaObject
+ = compilationUnit->propertyCachesPtr()->at(icDatum.objectIndex);
break;
}
}
diff --git a/src/qml/qml/qqmltypedata.cpp b/src/qml/qml/qqmltypedata.cpp
index b0d1b82829..d17ac219e7 100644
--- a/src/qml/qml/qqmltypedata.cpp
+++ b/src/qml/qml/qqmltypedata.cpp
@@ -249,7 +249,7 @@ QQmlError QQmlTypeData::createTypeAndPropertyCaches(
{
QQmlPropertyCacheCreator<QV4::ExecutableCompilationUnit> propertyCacheCreator(
- &m_compiledData->propertyCaches, &pendingGroupPropertyBindings, engine,
+ m_compiledData->propertyCachesPtr(), &pendingGroupPropertyBindings, engine,
m_compiledData.data(), m_importCache.data(), typeClassName());
QQmlError error = propertyCacheCreator.verifyNoICCycle();
@@ -263,19 +263,21 @@ QQmlError QQmlTypeData::createTypeAndPropertyCaches(
return result.error;
} else {
QQmlComponentAndAliasResolver resolver(
- m_compiledData.data(), engine, &m_compiledData->propertyCaches);
+ m_compiledData.data(), engine, m_compiledData->propertyCachesPtr());
if (const QQmlError error = resolver.resolve(result.processedRoot);
error.isValid()) {
return error;
}
- pendingGroupPropertyBindings.resolveMissingPropertyCaches(&m_compiledData->propertyCaches);
+ pendingGroupPropertyBindings.resolveMissingPropertyCaches(
+ m_compiledData->propertyCachesPtr());
pendingGroupPropertyBindings.clear(); // anything that can be processed is now processed
}
} while (result.canResume);
}
- pendingGroupPropertyBindings.resolveMissingPropertyCaches(&m_compiledData->propertyCaches);
+ pendingGroupPropertyBindings.resolveMissingPropertyCaches(
+ m_compiledData->propertyCachesPtr());
return QQmlError();
}
@@ -848,8 +850,8 @@ void QQmlTypeData::compile(const QQmlRefPointer<QQmlTypeNameCache> &typeNameCach
std::move(compilationUnit));
m_compiledData->typeNameCache = typeNameCache;
m_compiledData->setResolvedTypes(*resolvedTypeCache);
- m_compiledData->propertyCaches = std::move(*compiler.propertyCaches());
- Q_ASSERT(m_compiledData->propertyCaches.count()
+ *m_compiledData->propertyCachesPtr() = std::move(*compiler.propertyCaches());
+ Q_ASSERT(m_compiledData->propertyCachesPtr()->count()
== static_cast<int>(m_compiledData->objectCount()));
}
@@ -985,7 +987,7 @@ QQmlError QQmlTypeData::buildTypeResolutionCaches(
Q_ASSERT(!icName.isEmpty());
const auto compilationUnit = resolvedType->typeData->compilationUnit();
- ref->setTypePropertyCache(compilationUnit->propertyCaches.at(
+ ref->setTypePropertyCache(compilationUnit->propertyCachesPtr()->at(
compilationUnit->inlineComponentId(icName)));
ref->setType(qmlType);
Q_ASSERT(ref->type().isInlineComponentType());