aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2024-01-08 13:40:12 +0100
committerUlf Hermann <ulf.hermann@qt.io>2024-01-18 14:54:21 +0100
commit4e5c096153b8a5d6e110ef8a6db265b0bc138ce1 (patch)
treeeb91d6c5cd07d880749c587661fd02a92ea64897
parentffc687dca3ce3c37db6f47523881b457ce6ff6b1 (diff)
QtQml: Move type name cache into base CU
Change-Id: Ie3504f16b34859cdef72f8138e6058dcc2d1f58f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r--src/qml/common/qv4compileddata.cpp7
-rw-r--r--src/qml/common/qv4compileddata_p.h11
-rw-r--r--src/qml/jsruntime/qv4executablecompilationunit.cpp2
-rw-r--r--src/qml/jsruntime/qv4executablecompilationunit_p.h21
-rw-r--r--src/qml/jsruntime/qv4function.cpp7
-rw-r--r--src/qml/qml/qqmlengine.cpp2
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp2
-rw-r--r--src/qml/qml/qqmltypedata.cpp7
-rw-r--r--src/qmltest/quicktest.cpp2
9 files changed, 38 insertions, 23 deletions
diff --git a/src/qml/common/qv4compileddata.cpp b/src/qml/common/qv4compileddata.cpp
index 6087db9b92..253c9a5e77 100644
--- a/src/qml/common/qv4compileddata.cpp
+++ b/src/qml/common/qv4compileddata.cpp
@@ -3,6 +3,7 @@
#include "qv4compileddata_p.h"
+#include <private/qqmltypenamecache_p.h>
#include <private/qv4resolvedtypereference_p.h>
#include <QtQml/qqmlfile.h>
@@ -39,6 +40,12 @@ bool ResolvedTypeReferenceMap::addToHash(
return true;
}
+CompilationUnit::CompilationUnit(
+ const Unit *unitData, const QString &fileName, const QString &finalUrlString)
+{
+ setUnitData(unitData, nullptr, fileName, finalUrlString);
+}
+
CompilationUnit::~CompilationUnit()
{
qDeleteAll(resolvedTypes);
diff --git a/src/qml/common/qv4compileddata_p.h b/src/qml/common/qv4compileddata_p.h
index 7e768cd589..5d4c7747d1 100644
--- a/src/qml/common/qv4compileddata_p.h
+++ b/src/qml/common/qv4compileddata_p.h
@@ -1487,6 +1487,7 @@ struct CompilationUnit final : public QQmlRefCounted<CompilationUnit>
QVector<BindingPropertyData> bindingPropertyDataPerObject;
ResolvedTypeReferenceMap resolvedTypes;
+ QQmlRefPointer<QQmlTypeNameCache> typeNameCache;
QQmlPropertyCacheVector propertyCaches;
@@ -1495,12 +1496,6 @@ struct CompilationUnit final : public QQmlRefCounted<CompilationUnit>
public:
using CompiledObject = CompiledData::Object;
- CompilationUnit(const Unit *unitData = nullptr, const QString &fileName = QString(),
- const QString &finalUrlString = QString())
- {
- setUnitData(unitData, nullptr, fileName, finalUrlString);
- }
-
explicit CompilationUnit(const Unit *unitData, const QQmlPrivate::AOTCompiledFunction *aotCompiledFunctions,
const QString &fileName = QString(), const QString &finalUrlString = QString())
: CompilationUnit(unitData, fileName, finalUrlString)
@@ -1508,6 +1503,10 @@ public:
this->aotCompiledFunctions = aotCompiledFunctions;
}
+ Q_QML_EXPORT CompilationUnit(
+ const Unit *unitData = nullptr, const QString &fileName = QString(),
+ const QString &finalUrlString = QString());
+
Q_QML_EXPORT ~CompilationUnit();
const Unit *unitData() const { return data; }
diff --git a/src/qml/jsruntime/qv4executablecompilationunit.cpp b/src/qml/jsruntime/qv4executablecompilationunit.cpp
index efba61b8c9..60af2b2203 100644
--- a/src/qml/jsruntime/qv4executablecompilationunit.cpp
+++ b/src/qml/jsruntime/qv4executablecompilationunit.cpp
@@ -262,8 +262,6 @@ void ExecutableCompilationUnit::clear()
dependentScripts.clear();
- typeNameCache.reset();
-
delete [] runtimeLookups;
runtimeLookups = nullptr;
diff --git a/src/qml/jsruntime/qv4executablecompilationunit_p.h b/src/qml/jsruntime/qv4executablecompilationunit_p.h
index b4d3e413c1..3d9b32d354 100644
--- a/src/qml/jsruntime/qv4executablecompilationunit_p.h
+++ b/src/qml/jsruntime/qv4executablecompilationunit_p.h
@@ -15,14 +15,15 @@
// We mean it.
//
-#include <private/qv4compileddata_p.h>
-#include <private/qv4identifierhash_p.h>
-#include <private/qqmlrefcount_p.h>
#include <private/qintrusivelist_p.h>
+#include <private/qqmlmetatype_p.h>
+#include <private/qqmlnullablevalue_p.h>
#include <private/qqmlpropertycachevector_p.h>
+#include <private/qqmlrefcount_p.h>
#include <private/qqmltype_p.h>
-#include <private/qqmlnullablevalue_p.h>
-#include <private/qqmlmetatype_p.h>
+#include <private/qqmltypenamecache_p.h>
+#include <private/qv4compileddata_p.h>
+#include <private/qv4identifierhash_p.h>
#include <memory>
@@ -78,7 +79,15 @@ public:
QUrl url() const { return m_compilationUnit->url(); }
QUrl finalUrl() const { return m_compilationUnit->finalUrl(); }
- QQmlRefPointer<QQmlTypeNameCache> typeNameCache;
+ QQmlRefPointer<QQmlTypeNameCache> typeNameCache() const
+ {
+ return m_compilationUnit->typeNameCache;
+ }
+
+ void setTypeNameCache(const QQmlRefPointer<QQmlTypeNameCache> &typeNameCache)
+ {
+ m_compilationUnit->typeNameCache = typeNameCache;
+ }
const QQmlPropertyCacheVector *propertyCachesPtr() const
{
diff --git a/src/qml/jsruntime/qv4function.cpp b/src/qml/jsruntime/qv4function.cpp
index 7283565489..2e51366d64 100644
--- a/src/qml/jsruntime/qv4function.cpp
+++ b/src/qml/jsruntime/qv4function.cpp
@@ -148,9 +148,10 @@ Function::Function(ExecutionEngine *engine, ExecutableCompilationUnit *unit,
if (type == 0)
return QQmlType();
+ const auto base = unit->baseCompilationUnit();
const QQmlType qmltype = typeLoader
- ? unit->typeNameCache->query<QQmlImport::AllowRecursion>(
- unit->stringAt(type), typeLoader).type
+ ? base->typeNameCache->query<QQmlImport::AllowRecursion>(
+ base->stringAt(type), typeLoader).type
: QQmlType();
if (!qmltype.isValid() || qmltype.typeId().isValid())
@@ -158,7 +159,7 @@ Function::Function(ExecutionEngine *engine, ExecutableCompilationUnit *unit,
if (!qmltype.isComposite()) {
return qmltype.isInlineComponentType()
- ? unit->qmlTypeForComponent(qmltype.elementName())
+ ? base->qmlTypeForComponent(qmltype.elementName())
: QQmlType();
}
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index 9fb1e19d6a..49093bfdbd 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -1986,7 +1986,7 @@ QQmlEnginePrivate::createInternalContext(const QQmlRefPointer<QV4::ExecutableCom
QQmlRefPointer<QQmlContextData> context;
context = QQmlContextData::createRefCounted(parentContext);
context->setInternal(true);
- context->setImports(unit->typeNameCache);
+ context->setImports(unit->typeNameCache());
context->initFromTypeCompilationUnit(unit, subComponentIndex);
if (isComponentRoot && unit->dependentScripts.size()) {
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index e395787acb..31600e234f 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -1367,7 +1367,7 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo
if (customParser && obj->hasFlag(QV4::CompiledData::Object::HasCustomParserBindings)) {
customParser->engine = QQmlEnginePrivate::get(engine);
- customParser->imports = compilationUnit->typeNameCache.data();
+ customParser->imports = compilationUnit->typeNameCache().data();
QList<const QV4::CompiledData::Binding *> bindings;
const QV4::CompiledData::Object *obj = compilationUnit->objectAt(index);
diff --git a/src/qml/qml/qqmltypedata.cpp b/src/qml/qml/qqmltypedata.cpp
index 5a1df833a6..8d66a265d4 100644
--- a/src/qml/qml/qqmltypedata.cpp
+++ b/src/qml/qml/qqmltypedata.cpp
@@ -239,7 +239,7 @@ QQmlError QQmlTypeData::createTypeAndPropertyCaches(
const QV4::CompiledData::ResolvedTypeReferenceMap &resolvedTypeCache)
{
Q_ASSERT(m_compiledData);
- m_compiledData->typeNameCache = typeNameCache;
+ m_compiledData->setTypeNameCache(typeNameCache);
m_compiledData->setResolvedTypes(resolvedTypeCache);
m_compiledData->setInlineComponentData(m_inlineComponentData);
@@ -570,7 +570,8 @@ void QQmlTypeData::done()
qualifier = qualifier.mid(lastDotIndex+1);
}
- m_compiledData->typeNameCache->add(qualifier.toString(), scriptIndex, enclosingNamespace);
+ m_compiledData->typeNameCache()->add(
+ qualifier.toString(), scriptIndex, enclosingNamespace);
QQmlRefPointer<QQmlScriptData> scriptData = script.script->scriptData();
m_compiledData->dependentScripts << scriptData;
}
@@ -848,7 +849,7 @@ void QQmlTypeData::compile(const QQmlRefPointer<QQmlTypeNameCache> &typeNameCach
m_compiledData = enginePrivate->v4engine()->executableCompilationUnit(
std::move(compilationUnit));
- m_compiledData->typeNameCache = typeNameCache;
+ m_compiledData->setTypeNameCache(typeNameCache);
m_compiledData->setResolvedTypes(*resolvedTypeCache);
*m_compiledData->propertyCachesPtr() = std::move(*compiler.propertyCaches());
Q_ASSERT(m_compiledData->propertyCachesPtr()->count()
diff --git a/src/qmltest/quicktest.cpp b/src/qmltest/quicktest.cpp
index d15dd638b0..c762e34a2e 100644
--- a/src/qmltest/quicktest.cpp
+++ b/src/qmltest/quicktest.cpp
@@ -354,7 +354,7 @@ private:
if (!typeQualifier.isEmpty())
testCaseTypeName = typeQualifier % QLatin1Char('.') % testCaseTypeName;
- testCaseType = compilationUnit->typeNameCache->query(
+ testCaseType = compilationUnit->typeNameCache()->query(
testCaseTypeName, QQmlTypeLoader::get(m_engine)).type;
if (testCaseType.isValid())
break;