aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2024-02-29 14:35:58 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2024-03-05 14:06:28 +0100
commit688c98a12da19a88becc152f832beb5c5a01ec47 (patch)
treec131e7d2eeb9f17fdb2f40bf8beb7cc315a691ee /src/qml/jsruntime
parent205d1474c365965c125101457f8ad89889f53f3a (diff)
Prepare for white allocation during gc (0/9): Engine
When inserting compilation units into the engine, we don't have any write barrier, as those are treaded as roots. However, we still have to be careful when an executable compilation unit is created while the gc is already ongoing. Thus, when we insert a CU into the engine, we mark it. Change-Id: I5e7c7e9518190dd6943cf57b0a82229d6be8d3b9 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r--src/qml/jsruntime/qv4engine.cpp17
-rw-r--r--src/qml/jsruntime/qv4engine_p.h6
2 files changed, 17 insertions, 6 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 6f91712bb4..09c763e956 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -2123,8 +2123,23 @@ QQmlRefPointer<ExecutableCompilationUnit> ExecutionEngine::executableCompilation
return *it;
}
- return *m_compilationUnits.insert(
+ auto executableUnit = m_compilationUnits.insert(
url, ExecutableCompilationUnit::create(std::move(unit), this));
+ // runtime data should not be initialized yet, so we don't need to mark the CU
+ Q_ASSERT(!(*executableUnit)->runtimeStrings);
+ return *executableUnit;
+}
+
+QQmlRefPointer<ExecutableCompilationUnit> ExecutionEngine::insertCompilationUnit(QQmlRefPointer<CompiledData::CompilationUnit> &&unit) {
+ QUrl url = unit->finalUrl();
+ auto executableUnit = ExecutableCompilationUnit::create(std::move(unit), this);
+ /* Compilation Units stored in the engine are part of the gc roots,
+ so we don't trigger any write-barrier when they are added. Use
+ markCustom to make sure they are still marked when we insert them */
+ QV4::WriteBarrier::markCustom(this, [&executableUnit](QV4::MarkStack *ms) {
+ executableUnit->markObjects(ms);
+ });
+ return *m_compilationUnits.insert(std::move(url), std::move(executableUnit));
}
void ExecutionEngine::trimCompilationUnits()
diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h
index 1f4622d154..102700e25b 100644
--- a/src/qml/jsruntime/qv4engine_p.h
+++ b/src/qml/jsruntime/qv4engine_p.h
@@ -759,11 +759,7 @@ public:
QQmlRefPointer<QV4::CompiledData::CompilationUnit> &&unit);
QQmlRefPointer<ExecutableCompilationUnit> insertCompilationUnit(
- QQmlRefPointer<QV4::CompiledData::CompilationUnit> &&unit) {
- QUrl url = unit->finalUrl();
- return *m_compilationUnits.insert(
- std::move(url), ExecutableCompilationUnit::create(std::move(unit), this));
- }
+ QQmlRefPointer<QV4::CompiledData::CompilationUnit> &&unit);
QMultiHash<QUrl, QQmlRefPointer<ExecutableCompilationUnit>> compilationUnits() const
{