mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibJS: GC: Remove clear_all_mark_bits()
Clearing all marked flags has been integrated into the sweep function, saving an additional full iteration over the heap.
This commit is contained in:
parent
b956e2d939
commit
1207187e97
Notes:
sideshowbarker
2024-07-19 08:49:25 +09:00
Author: https://github.com/sunverwerth 🔰 Commit: https://github.com/SerenityOS/serenity/commit/1207187e972 Pull-request: https://github.com/SerenityOS/serenity/pull/1392
2 changed files with 7 additions and 14 deletions
|
@ -66,7 +66,6 @@ void Heap::collect_garbage()
|
|||
HashTable<Cell*> live_cells;
|
||||
visit_live_cells(roots, live_cells);
|
||||
|
||||
clear_all_mark_bits();
|
||||
mark_live_cells(live_cells);
|
||||
sweep_dead_cells();
|
||||
}
|
||||
|
@ -114,15 +113,6 @@ void Heap::visit_live_cells(const HashTable<Cell*>& roots, HashTable<Cell*>& liv
|
|||
#endif
|
||||
}
|
||||
|
||||
void Heap::clear_all_mark_bits()
|
||||
{
|
||||
for (auto& block : m_blocks) {
|
||||
block->for_each_cell([&](Cell* cell) {
|
||||
cell->set_marked(false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void Heap::mark_live_cells(const HashTable<Cell*>& live_cells)
|
||||
{
|
||||
#ifdef HEAP_DEBUG
|
||||
|
@ -147,11 +137,15 @@ void Heap::sweep_dead_cells()
|
|||
#endif
|
||||
for (auto& block : m_blocks) {
|
||||
block->for_each_cell([&](Cell* cell) {
|
||||
if (cell->is_live() && !cell->is_marked()) {
|
||||
if (cell->is_live()) {
|
||||
if (!cell->is_marked()) {
|
||||
#ifdef HEAP_DEBUG
|
||||
dbg() << " ~ " << cell;
|
||||
dbg() << " ~ " << cell;
|
||||
#endif
|
||||
block->deallocate(cell);
|
||||
block->deallocate(cell);
|
||||
} else {
|
||||
cell->set_marked(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -58,7 +58,6 @@ private:
|
|||
|
||||
void collect_roots(HashTable<Cell*>&);
|
||||
void visit_live_cells(const HashTable<Cell*>& roots, HashTable<Cell*>& live_cells);
|
||||
void clear_all_mark_bits();
|
||||
void mark_live_cells(const HashTable<Cell*>& live_cells);
|
||||
void sweep_dead_cells();
|
||||
|
||||
|
|
Loading…
Reference in a new issue