1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:48:11 +00:00

LibJS: Put zombie cell tracking code behind a compile-time flag

Since this is a debug-only feature, let's not have it impact GC marking
performance when you don't need it.
This commit is contained in:
Andreas Kling 2021-10-02 16:35:55 +02:00
parent f290c59dd8
commit 6a1b82df2b
13 changed files with 76 additions and 8 deletions

View file

@ -184,11 +184,13 @@ public:
return;
dbgln_if(HEAP_DEBUG, " ! {}", &cell);
#ifdef JS_TRACK_ZOMBIE_CELLS
if (cell.state() == Cell::State::Zombie) {
dbgln("BUG! Marking a zombie cell, {} @ {:p}", cell.class_name(), &cell);
cell.vm().dump_backtrace();
VERIFY_NOT_REACHED();
}
#endif
cell.set_marked(true);
cell.visit_edges(*this);
@ -230,12 +232,16 @@ void Heap::sweep_dead_cells(bool print_report, const Core::ElapsedTimer& measure
dbgln_if(HEAP_DEBUG, " ~ {}", cell);
if (should_store_swept_cells)
swept_cells.append(cell);
#ifdef JS_TRACK_ZOMBIE_CELLS
if (m_zombify_dead_cells) {
cell->set_state(Cell::State::Zombie);
cell->did_become_zombie();
} else {
#endif
block.deallocate(cell);
#ifdef JS_TRACK_ZOMBIE_CELLS
}
#endif
++collected_cells;
collected_cell_bytes += block.cell_size();
} else {