diff options
| author | Fabian Kosmale <fabian.kosmale@qt.io> | 2024-02-09 21:21:05 +0100 |
|---|---|---|
| committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2024-03-05 14:06:29 +0100 |
| commit | d6d224892e6672dc3ed8f027b54277fe8a7971f9 (patch) | |
| tree | f30ec487e8b33f972a542ff5b7735940b4515a1e /src/qml/jsruntime/qv4engine.cpp | |
| parent | 61d7cf160f750bbef10c770997b839ee3e7c354e (diff) | |
Prepare for white allocations during gc (9/9): ExecutableCompilationUnit
ExecutableCompilationUnits are meant to be part of the roots as far as
the gc is concerned. However, they can be created at any point in time,
notably also while the GC is running. This was safe so far because all
allocations are black, and the compilation unit will only reference
freshly allocated heap items. As we want to move away from that pattern,
we have to change this:
We could use the typical combination of QV4::Scope and usage of the
WriteBarrier, however that would add overhead for a very uncommon case
(except when using QV4_MM_AGGRESSIVE_GC). Instead, we temporarily block
the garbage collection, reset the state of an ongoing garbage collection
and at the end of the setup of the ExecutableCompilationUnit, we mark
the ExecutableCompilationUnit if the GC was already running.
Introduce a new blocked state (CriticalSection) to distinguish between
the normal blocked state (gc is running) and the new state where we must
not even run an incremental gc to completion until the section has
finished.
Task-number: QTBUG-121910
Change-Id: I1dba3cc8a4f8d2b741a1a5e84fdfe7736b08e166
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4engine.cpp')
| -rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 1e72e0e29b..391ea62b50 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -371,8 +371,8 @@ ExecutionEngine::ExecutionEngine(QJSEngine *jsEngine) memoryManager = new QV4::MemoryManager(this); // we don't want to run the gc while the initial setup is not done; not even in aggressive mode - memoryManager->gcBlocked = true; - auto cleanup = qScopeGuard([this] { memoryManager->gcBlocked = false; } ); + memoryManager->gcBlocked = MemoryManager::InCriticalSection; + auto cleanup = qScopeGuard([this] { memoryManager->gcBlocked = MemoryManager::Unblocked; } ); // reserve space for the JS stack // we allow it to grow to a bit more than m_maxJSStackSize, as we can overshoot due to ScopedValues // allocated outside of JIT'ed methods. |
