diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2024-09-18 10:14:13 +0200 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2024-09-20 18:55:30 +0200 |
| commit | e1a0eb98e60588862d79fa074b65217a96bdaab5 (patch) | |
| tree | aafe7ef524916441b7a094523d68a8ebdc7d47b4 /src/qml/jsruntime/qv4executablecompilationunit.cpp | |
| 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 <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4executablecompilationunit.cpp')
| -rw-r--r-- | src/qml/jsruntime/qv4executablecompilationunit.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4executablecompilationunit.cpp b/src/qml/jsruntime/qv4executablecompilationunit.cpp index 5e9361a066..bb05d623e3 100644 --- a/src/qml/jsruntime/qv4executablecompilationunit.cpp +++ b/src/qml/jsruntime/qv4executablecompilationunit.cpp @@ -299,8 +299,8 @@ void ExecutableCompilationUnit::markObjects(QV4::MarkStack *markStack) const runtimeLookups[i].markObjects(markStack); } - if (auto mod = module()) - mod->mark(markStack); + if (Heap::Base *v = m_valueOrModule.heapObject()) + v->mark(markStack); } IdentifierHash ExecutableCompilationUnit::createNamedObjectsPerComponent(int componentObjectIndex) @@ -705,6 +705,18 @@ QString ExecutableCompilationUnit::translateFrom(TranslationDataIndex index) con #endif } +Heap::Module *ExecutableCompilationUnit::module() const +{ + if (const Module *m = m_valueOrModule.as<QV4::Module>()) + return m->d(); + return nullptr; +} + +void ExecutableCompilationUnit::setModule(Heap::Module *module) +{ + m_valueOrModule = module; +} + } // namespace QV4 QT_END_NAMESPACE |
