mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-23 13:05:12 +00:00
LibJS: Prune WeakContainers before freeing HeapBlocks
WeakContainers need to look at the Cell::State bits to know if their weak pointees got swept by garbage collection. So we must do this before potentially freeing one or more HeapBlocks by notifying the allocator that a block became empty.
This commit is contained in:
parent
13138811df
commit
2495460f6e
Notes:
sideshowbarker
2024-07-18 02:55:33 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/2495460f6ed
1 changed files with 3 additions and 3 deletions
|
@ -254,6 +254,9 @@ void Heap::sweep_dead_cells(bool print_report, const Core::ElapsedTimer& measure
|
|||
return IterationDecision::Continue;
|
||||
});
|
||||
|
||||
for (auto& weak_container : m_weak_containers)
|
||||
weak_container.remove_dead_cells({});
|
||||
|
||||
for (auto* block : empty_blocks) {
|
||||
dbgln_if(HEAP_DEBUG, " - HeapBlock empty @ {}: cell_size={}", block, block->cell_size());
|
||||
allocator_for_size(block->cell_size()).block_did_become_empty({}, *block);
|
||||
|
@ -264,9 +267,6 @@ void Heap::sweep_dead_cells(bool print_report, const Core::ElapsedTimer& measure
|
|||
allocator_for_size(block->cell_size()).block_did_become_usable({}, *block);
|
||||
}
|
||||
|
||||
for (auto& weak_container : m_weak_containers)
|
||||
weak_container.remove_dead_cells({});
|
||||
|
||||
if constexpr (HEAP_DEBUG) {
|
||||
for_each_block([&](auto& block) {
|
||||
dbgln(" > Live HeapBlock @ {}: cell_size={}", &block, block.cell_size());
|
||||
|
|
Loading…
Add table
Reference in a new issue