summaryrefslogtreecommitdiff
path: root/Libraries/LibJS
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-09-21 14:35:19 +0200
committerAndreas Kling <kling@serenityos.org>2020-09-21 14:35:19 +0200
commitc8baf29d82ca4db83f32a54015a3c5e92e20930e (patch)
tree1a2b1dc60a7e3ffaf6a711ac0fd195ffa2ca2fb9 /Libraries/LibJS
parentdf3ff76815893104eb1c2686c4e51d70793c28f3 (diff)
downloadserenity-c8baf29d82ca4db83f32a54015a3c5e92e20930e.zip
LibJS: Assert if garbage collection is restarted while ongoing
We can't GC while we're already in GC. Assert if this happens.
Diffstat (limited to 'Libraries/LibJS')
-rw-r--r--Libraries/LibJS/Heap/Heap.cpp3
-rw-r--r--Libraries/LibJS/Heap/Heap.h2
2 files changed, 5 insertions, 0 deletions
diff --git a/Libraries/LibJS/Heap/Heap.cpp b/Libraries/LibJS/Heap/Heap.cpp
index a4a131fe5c..1bfa91e54e 100644
--- a/Libraries/LibJS/Heap/Heap.cpp
+++ b/Libraries/LibJS/Heap/Heap.cpp
@@ -89,6 +89,9 @@ Cell* Heap::allocate_cell(size_t size)
void Heap::collect_garbage(CollectionType collection_type, bool print_report)
{
+ ASSERT(!m_collecting_garbage);
+ TemporaryChange change(m_collecting_garbage, true);
+
Core::ElapsedTimer collection_measurement_timer;
collection_measurement_timer.start();
if (collection_type == CollectionType::CollectGarbage) {
diff --git a/Libraries/LibJS/Heap/Heap.h b/Libraries/LibJS/Heap/Heap.h
index b1381a8dae..0d727210a4 100644
--- a/Libraries/LibJS/Heap/Heap.h
+++ b/Libraries/LibJS/Heap/Heap.h
@@ -109,6 +109,8 @@ private:
size_t m_gc_deferrals { 0 };
bool m_should_gc_when_deferral_ends { false };
+
+ bool m_collecting_garbage { false };
};
}