diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2023-12-21 16:53:36 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2024-01-10 11:22:37 +0100 |
commit | be6d1499af75228341227d15441284e07cfe1e41 (patch) | |
tree | 99c5b1e3dc7f1b99d8c141f1b8138feacd29e020 /src/qml/jsruntime/qv4executablecompilationunit_p.h | |
parent | cfdc612c3022b3f35545fd5e4e0bcd2661f657f1 (diff) |
QtQml: Always link executable CU on creation
We don't want floating unlinked executable CUs. They should always be
tied to an engine, and the engine should not change. This gives us one
definite point where to register them with the engine (to be done in
subsequent change).
Unfortunately, due to the refcounting, we need to remove the engine from
any still-referenced CUs when the engine itself is destructed. We will
be able to drop the refcounting and make the engine fully own its
executable CUs once we can hold base CUs in most places.
Change-Id: I9a53e83d5c4746c2b2bca896b51baa4fe7fee757
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4executablecompilationunit_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4executablecompilationunit_p.h | 44 |
1 files changed, 17 insertions, 27 deletions
diff --git a/src/qml/jsruntime/qv4executablecompilationunit_p.h b/src/qml/jsruntime/qv4executablecompilationunit_p.h index f52989ec25..69cac2974c 100644 --- a/src/qml/jsruntime/qv4executablecompilationunit_p.h +++ b/src/qml/jsruntime/qv4executablecompilationunit_p.h @@ -100,22 +100,8 @@ public: friend class QQmlRefPointer<ExecutableCompilationUnit>; static QQmlRefPointer<ExecutableCompilationUnit> create( - QQmlRefPointer<CompiledData::CompilationUnit> &&compilationUnit) - { - return QQmlRefPointer<ExecutableCompilationUnit>( - new ExecutableCompilationUnit(std::move(compilationUnit)), - QQmlRefPointer<ExecutableCompilationUnit>::Adopt); - } - - static QQmlRefPointer<ExecutableCompilationUnit> create() - { - return QQmlRefPointer<ExecutableCompilationUnit>( - new ExecutableCompilationUnit( - QQmlRefPointer<CompiledData::CompilationUnit>( - new CompiledData::CompilationUnit, - QQmlRefPointer<CompiledData::CompilationUnit>::Adopt)), - QQmlRefPointer<ExecutableCompilationUnit>::Adopt); - } + QQmlRefPointer<CompiledData::CompilationUnit> &&compilationUnit, + ExecutionEngine *engine); QIntrusiveListNode nextCompilationUnit; ExecutionEngine *engine = nullptr; @@ -200,8 +186,6 @@ public: return -1; } - std::unique_ptr<CompilationUnitMapper> backingFile; - // --- interface for QQmlPropertyCacheCreator using CompiledObject = const CompiledData::Object; using CompiledFunction = const CompiledData::Function; @@ -306,7 +290,7 @@ public: } QStringList moduleRequests() const; - Heap::Module *instantiate(ExecutionEngine *engine); + Heap::Module *instantiate(); const Value *resolveExport(QV4::String *exportName) { QVector<ResolveSetEntry> resolveSet; @@ -327,16 +311,8 @@ public: void evaluate(); void evaluateModuleRequests(); - QV4::Function *linkToEngine(QV4::ExecutionEngine *engine); - void unlink(); - void markObjects(MarkStack *markStack); - bool loadFromDisk(const QUrl &url, const QDateTime &sourceTimeStamp, QString *errorString); - - static QString localCacheFilePath(const QUrl &url); - bool saveToDisk(const QUrl &unitUrl, QString *errorString); - QString bindingValueAsString(const CompiledData::Binding *binding) const; double bindingValueAsNumber(const CompiledData::Binding *binding) const { @@ -371,6 +347,20 @@ public: return m_compilationUnit; } + QV4::Function *rootFunction() + { + if (!runtimeStrings) + populate(); + + const auto *data = unitData(); + return data->indexOfRootFunction != -1 + ? runtimeFunctions[data->indexOfRootFunction] + : nullptr; + } + + void populate(); + void clear(); + protected: quint32 totalStringCount() const { return unitData()->stringTableSize; } |