mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:27:35 +00:00
LibJS: Assert if garbage collection is restarted while ongoing
We can't GC while we're already in GC. Assert if this happens.
This commit is contained in:
parent
df3ff76815
commit
c8baf29d82
2 changed files with 5 additions and 0 deletions
|
@ -89,6 +89,9 @@ Cell* Heap::allocate_cell(size_t size)
|
||||||
|
|
||||||
void Heap::collect_garbage(CollectionType collection_type, bool print_report)
|
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;
|
Core::ElapsedTimer collection_measurement_timer;
|
||||||
collection_measurement_timer.start();
|
collection_measurement_timer.start();
|
||||||
if (collection_type == CollectionType::CollectGarbage) {
|
if (collection_type == CollectionType::CollectGarbage) {
|
||||||
|
|
|
@ -109,6 +109,8 @@ private:
|
||||||
|
|
||||||
size_t m_gc_deferrals { 0 };
|
size_t m_gc_deferrals { 0 };
|
||||||
bool m_should_gc_when_deferral_ends { false };
|
bool m_should_gc_when_deferral_ends { false };
|
||||||
|
|
||||||
|
bool m_collecting_garbage { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue