diff options
author | Ulf Hermann <[email protected]> | 2024-09-18 10:14:13 +0200 |
---|---|---|
committer | Ulf Hermann <[email protected]> | 2024-09-20 18:55:30 +0200 |
commit | e1a0eb98e60588862d79fa074b65217a96bdaab5 (patch) | |
tree | aafe7ef524916441b7a094523d68a8ebdc7d47b4 /src/qml/jsruntime/qv4executablecompilationunit_p.h | |
parent | 9855d7477163cc56742a1766d35346d8058f2794 (diff) |
QtQml: Decouple JavaScript library CUs from engines
In order to re-use the compilation units for JavaScript libraries, we
need to eliminate the "m_value" member they are carrying, indirectly.
The values are tied to specific engines and invalid in others.
Luckily, we already have two suitable places to store such values:
1. In case of a "native" module without a compilation unit we have the
nativeModules hash in ExecutionEngine.
2. In case of a module or library backed by a CU we have the "module"
member of ExecutableCompilationUnit. This can currently only hold
modules but there is no reason why it wouldn't hold JavaScript
libraries equally well.
By using the "empty" V4 value we can also get rid of the m_loaded bool.
As a drive by, correct the QQmlScriptBlob::isNative() misnomer. We don't
want to know whether the script is native (for any value of that), but
rather whether it has a value.
Pick-to: 6.8
Fixes: QTBUG-129052
Change-Id: I284823f4aa26e46dec8328f88f65877f59e40f79
Reviewed-by: Fabian Kosmale <[email protected]>
Diffstat (limited to 'src/qml/jsruntime/qv4executablecompilationunit_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4executablecompilationunit_p.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4executablecompilationunit_p.h b/src/qml/jsruntime/qv4executablecompilationunit_p.h index 930e138732..b7a52523fb 100644 --- a/src/qml/jsruntime/qv4executablecompilationunit_p.h +++ b/src/qml/jsruntime/qv4executablecompilationunit_p.h @@ -188,8 +188,11 @@ public: QString translateFrom(TranslationDataIndex index) const; - Heap::Module *module() const { return m_module; } - void setModule(Heap::Module *module) { m_module = module; } + Heap::Module *module() const; + void setModule(Heap::Module *module); + + ReturnedValue value() const { return m_valueOrModule.asReturnedValue(); } + void setValue(const QV4::Value &value) { m_valueOrModule = value; } const CompiledData::Unit *unitData() const { return m_compilationUnit->data; } @@ -233,7 +236,7 @@ private: friend struct ExecutionEngine; QQmlRefPointer<CompiledData::CompilationUnit> m_compilationUnit; - Heap::Module *m_module = nullptr; + Value m_valueOrModule = QV4::Value::emptyValue(); struct ResolveSetEntry { |