aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/memory/qv4mmdefs_p.h
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2023-11-21 19:36:26 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2023-12-20 08:38:26 +0100
commitb9d37a328ba09bcb2a7a95b5778cb8c63d0ace26 (patch)
tree340739253c3e15f0b6c051434d94061e8e3385c6 /src/qml/memory/qv4mmdefs_p.h
parentd08ede57dd530a67c3420b3858fe39bf1e5eb598 (diff)
Long live incremental garbage collection in QML!
The design of the garbage collector is described in src/qml/memory/design.md. The gc and gcdone test helpers are adjusted to drive the gc to completion, even when in incremental mode. Parts of tst_qv4mm and tst_qqmlqt need to run with the incremental gc disabled, as they call gc inside QML and assumes that the GC finishes before returning. Initial-patch-by: Rafal Chomentowski <rafal.chomentowski@ge.com> Task-number: QTBUG-119274 Change-Id: I1d94f41bc7a434fad67de0fd46454b6db285f2eb Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/memory/qv4mmdefs_p.h')
-rw-r--r--src/qml/memory/qv4mmdefs_p.h17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/qml/memory/qv4mmdefs_p.h b/src/qml/memory/qv4mmdefs_p.h
index a7fc7bb7cb..277b1adcc5 100644
--- a/src/qml/memory/qv4mmdefs_p.h
+++ b/src/qml/memory/qv4mmdefs_p.h
@@ -21,6 +21,8 @@
QT_BEGIN_NAMESPACE
+class QDeadlineTimer;
+
namespace QV4 {
struct MarkStack;
@@ -229,7 +231,7 @@ Q_STATIC_ASSERT((1 << Chunk::BitShift) == Chunk::Bits);
struct Q_QML_PRIVATE_EXPORT MarkStack {
MarkStack(ExecutionEngine *engine);
- ~MarkStack() { drain(); }
+ ~MarkStack() { /* we drain manually */ }
void push(Heap::Base *m) {
*(m_top++) = m;
@@ -250,17 +252,28 @@ struct Q_QML_PRIVATE_EXPORT MarkStack {
}
}
+ bool isEmpty() const { return m_top == m_base; }
+
+ qptrdiff remainingBeforeSoftLimit() const
+ {
+ return m_softLimit - m_top;
+ }
+
ExecutionEngine *engine() const { return m_engine; }
+ void drain();
+ enum class DrainState { Ongoing, Complete };
+ DrainState drain(QDeadlineTimer deadline);
private:
Heap::Base *pop() { return *(--m_top); }
- void drain();
Heap::Base **m_top = nullptr;
Heap::Base **m_base = nullptr;
Heap::Base **m_softLimit = nullptr;
Heap::Base **m_hardLimit = nullptr;
+
ExecutionEngine *m_engine = nullptr;
+
quintptr m_drainRecursion = 0;
};