From 933f80f345cb04df6ecafe9c76f262553a5a198c Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 20 Dec 2023 15:47:43 +0100 Subject: QtQml: Move engine-specific data out of base compilation unit We want to re-use the base compilation unit for different engines. To do that, we cannot have data in there that belongs to a specific engine. Pick-to: 6.7 Task-number: QTBUG-120189 Change-Id: I8e43e7ec6c1cd33249dc4ed15fec16babc6d06fb Reviewed-by: Fabian Kosmale --- src/qml/common/qv4compileddata_p.h | 64 ++++++-------------------------------- 1 file changed, 9 insertions(+), 55 deletions(-) (limited to 'src/qml/common') diff --git a/src/qml/common/qv4compileddata_p.h b/src/qml/common/qv4compileddata_p.h index 1a97ddc5a5..f033a43aaa 100644 --- a/src/qml/common/qv4compileddata_p.h +++ b/src/qml/common/qv4compileddata_p.h @@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE // Also change the comment behind the number to describe the latest change. This has the added // benefit that if another patch changes the version too, it will result in a merge conflict, and // not get removed silently. -#define QV4_DATA_STRUCTURE_VERSION 0x3E // Add Translator pragma +#define QV4_DATA_STRUCTURE_VERSION 0x3F // Refactor compilation units class QIODevice; class QQmlTypeNameCache; @@ -1421,48 +1421,7 @@ using DependentTypesHasher = std::function; // This is how this hooks into the existing structures: -struct CompilationUnitBase -{ - Q_DISABLE_COPY(CompilationUnitBase) - - CompilationUnitBase() = default; - ~CompilationUnitBase() = default; - - CompilationUnitBase(CompilationUnitBase &&other) noexcept { *this = std::move(other); } - - CompilationUnitBase &operator=(CompilationUnitBase &&other) noexcept - { - if (this != &other) { - runtimeStrings = other.runtimeStrings; - other.runtimeStrings = nullptr; - constants = other.constants; - other.constants = nullptr; - runtimeRegularExpressions = other.runtimeRegularExpressions; - other.runtimeRegularExpressions = nullptr; - runtimeClasses = other.runtimeClasses; - other.runtimeClasses = nullptr; - imports = other.imports; - other.imports = nullptr; - } - return *this; - } - - // pointers either to data->constants() or little-endian memory copy. - Heap::String **runtimeStrings = nullptr; // Array - const StaticValue* constants = nullptr; - QV4::StaticValue *runtimeRegularExpressions = nullptr; - Heap::InternalClass **runtimeClasses = nullptr; - const StaticValue** imports = nullptr; -}; - -Q_STATIC_ASSERT(std::is_standard_layout::value); -Q_STATIC_ASSERT(offsetof(CompilationUnitBase, runtimeStrings) == 0); -Q_STATIC_ASSERT(offsetof(CompilationUnitBase, constants) == sizeof(QV4::Heap::String **)); -Q_STATIC_ASSERT(offsetof(CompilationUnitBase, runtimeRegularExpressions) == offsetof(CompilationUnitBase, constants) + sizeof(const StaticValue *)); -Q_STATIC_ASSERT(offsetof(CompilationUnitBase, runtimeClasses) == offsetof(CompilationUnitBase, runtimeRegularExpressions) + sizeof(const StaticValue *)); -Q_STATIC_ASSERT(offsetof(CompilationUnitBase, imports) == offsetof(CompilationUnitBase, runtimeClasses) + sizeof(const StaticValue *)); - -struct CompilationUnit : public CompilationUnitBase +struct CompilationUnit { Q_DISABLE_COPY(CompilationUnit) @@ -1470,6 +1429,9 @@ struct CompilationUnit : public CompilationUnitBase const QmlUnit *qmlData = nullptr; QStringList dynamicStrings; const QQmlPrivate::AOTCompiledFunction *aotCompiledFunctions = nullptr; + + // pointers either to data->constants() or little-endian memory copy. + const StaticValue *constants = nullptr; public: using CompiledObject = CompiledData::Object; @@ -1501,9 +1463,6 @@ public: delete [] constants; constants = nullptr; #endif - - delete [] imports; - imports = nullptr; } CompilationUnit(CompilationUnit &&other) noexcept @@ -1519,15 +1478,15 @@ public: qmlData = other.qmlData; other.qmlData = nullptr; dynamicStrings = std::move(other.dynamicStrings); - aotCompiledFunctions = other.aotCompiledFunctions; other.dynamicStrings.clear(); + aotCompiledFunctions = other.aotCompiledFunctions; + other.aotCompiledFunctions = nullptr; + constants = other.constants; + other.constants = nullptr; m_fileName = std::move(other.m_fileName); other.m_fileName.clear(); m_finalUrlString = std::move(other.m_finalUrlString); other.m_finalUrlString.clear(); - m_module = other.m_module; - other.m_module = nullptr; - CompilationUnitBase::operator=(std::move(other)); } return *this; } @@ -1577,9 +1536,6 @@ public: QString fileName() const { return m_fileName; } QString finalUrlString() const { return m_finalUrlString; } - Heap::Module *module() const { return m_module; } - void setModule(Heap::Module *module) { m_module = module; } - QString bindingValueAsString(const CompiledData::Binding *binding) const { using namespace CompiledData; @@ -1621,8 +1577,6 @@ public: private: QString m_fileName; // initialized from data->sourceFileIndex QString m_finalUrlString; // initialized from data->finalUrlIndex - - Heap::Module *m_module = nullptr; }; class SaveableUnitPointer -- cgit v1.2.3