mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:17:45 +00:00
LibJS: Use dbgln_if in Heap.cpp
This commit is contained in:
parent
e8ef10e2a6
commit
c0c4e99c74
1 changed files with 10 additions and 30 deletions
|
@ -127,9 +127,7 @@ __attribute__((no_sanitize("address"))) void Heap::gather_conservative_roots(Has
|
||||||
{
|
{
|
||||||
FlatPtr dummy;
|
FlatPtr dummy;
|
||||||
|
|
||||||
#if HEAP_DEBUG
|
dbgln_if(HEAP_DEBUG, "gather_conservative_roots:");
|
||||||
dbgln("gather_conservative_roots:");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
jmp_buf buf;
|
jmp_buf buf;
|
||||||
setjmp(buf);
|
setjmp(buf);
|
||||||
|
@ -158,21 +156,15 @@ __attribute__((no_sanitize("address"))) void Heap::gather_conservative_roots(Has
|
||||||
for (auto possible_pointer : possible_pointers) {
|
for (auto possible_pointer : possible_pointers) {
|
||||||
if (!possible_pointer)
|
if (!possible_pointer)
|
||||||
continue;
|
continue;
|
||||||
#if HEAP_DEBUG
|
dbgln_if(HEAP_DEBUG, " ? {}", (const void*)possible_pointer);
|
||||||
dbgln(" ? {}", (const void*)possible_pointer);
|
|
||||||
#endif
|
|
||||||
auto* possible_heap_block = HeapBlock::from_cell(reinterpret_cast<const Cell*>(possible_pointer));
|
auto* possible_heap_block = HeapBlock::from_cell(reinterpret_cast<const Cell*>(possible_pointer));
|
||||||
if (all_live_heap_blocks.contains(possible_heap_block)) {
|
if (all_live_heap_blocks.contains(possible_heap_block)) {
|
||||||
if (auto* cell = possible_heap_block->cell_from_possible_pointer(possible_pointer)) {
|
if (auto* cell = possible_heap_block->cell_from_possible_pointer(possible_pointer)) {
|
||||||
if (cell->is_live()) {
|
if (cell->is_live()) {
|
||||||
#if HEAP_DEBUG
|
dbgln_if(HEAP_DEBUG, " ?-> {}", (const void*)cell);
|
||||||
dbgln(" ?-> {}", (const void*)cell);
|
|
||||||
#endif
|
|
||||||
roots.set(cell);
|
roots.set(cell);
|
||||||
} else {
|
} else {
|
||||||
#if HEAP_DEBUG
|
dbgln_if(HEAP_DEBUG, " #-> {}", (const void*)cell);
|
||||||
dbgln(" #-> {}", (const void*)cell);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,9 +179,7 @@ public:
|
||||||
{
|
{
|
||||||
if (cell->is_marked())
|
if (cell->is_marked())
|
||||||
return;
|
return;
|
||||||
#if HEAP_DEBUG
|
dbgln_if(HEAP_DEBUG, " ! {}", cell);
|
||||||
dbgln(" ! {}", cell);
|
|
||||||
#endif
|
|
||||||
cell->set_marked(true);
|
cell->set_marked(true);
|
||||||
cell->visit_edges(*this);
|
cell->visit_edges(*this);
|
||||||
}
|
}
|
||||||
|
@ -197,9 +187,7 @@ public:
|
||||||
|
|
||||||
void Heap::mark_live_cells(const HashTable<Cell*>& roots)
|
void Heap::mark_live_cells(const HashTable<Cell*>& roots)
|
||||||
{
|
{
|
||||||
#if HEAP_DEBUG
|
dbgln_if(HEAP_DEBUG, "mark_live_cells:");
|
||||||
dbgln("mark_live_cells:");
|
|
||||||
#endif
|
|
||||||
MarkingVisitor visitor;
|
MarkingVisitor visitor;
|
||||||
for (auto* root : roots)
|
for (auto* root : roots)
|
||||||
visitor.visit(root);
|
visitor.visit(root);
|
||||||
|
@ -207,9 +195,7 @@ void Heap::mark_live_cells(const HashTable<Cell*>& roots)
|
||||||
|
|
||||||
void Heap::sweep_dead_cells(bool print_report, const Core::ElapsedTimer& measurement_timer)
|
void Heap::sweep_dead_cells(bool print_report, const Core::ElapsedTimer& measurement_timer)
|
||||||
{
|
{
|
||||||
#if HEAP_DEBUG
|
dbgln_if(HEAP_DEBUG, "sweep_dead_cells:");
|
||||||
dbgln("sweep_dead_cells:");
|
|
||||||
#endif
|
|
||||||
Vector<HeapBlock*, 32> empty_blocks;
|
Vector<HeapBlock*, 32> empty_blocks;
|
||||||
Vector<HeapBlock*, 32> full_blocks_that_became_usable;
|
Vector<HeapBlock*, 32> full_blocks_that_became_usable;
|
||||||
|
|
||||||
|
@ -224,9 +210,7 @@ void Heap::sweep_dead_cells(bool print_report, const Core::ElapsedTimer& measure
|
||||||
block.for_each_cell([&](Cell* cell) {
|
block.for_each_cell([&](Cell* cell) {
|
||||||
if (cell->is_live()) {
|
if (cell->is_live()) {
|
||||||
if (!cell->is_marked()) {
|
if (!cell->is_marked()) {
|
||||||
#if HEAP_DEBUG
|
dbgln_if(HEAP_DEBUG, " ~ {}", cell);
|
||||||
dbgln(" ~ {}", cell);
|
|
||||||
#endif
|
|
||||||
block.deallocate(cell);
|
block.deallocate(cell);
|
||||||
++collected_cells;
|
++collected_cells;
|
||||||
collected_cell_bytes += block.cell_size();
|
collected_cell_bytes += block.cell_size();
|
||||||
|
@ -246,16 +230,12 @@ void Heap::sweep_dead_cells(bool print_report, const Core::ElapsedTimer& measure
|
||||||
});
|
});
|
||||||
|
|
||||||
for (auto* block : empty_blocks) {
|
for (auto* block : empty_blocks) {
|
||||||
#if HEAP_DEBUG
|
dbgln_if(HEAP_DEBUG, " - HeapBlock empty @ {}: cell_size={}", block, block->cell_size());
|
||||||
dbgln(" - HeapBlock empty @ {}: cell_size={}", block, block->cell_size());
|
|
||||||
#endif
|
|
||||||
allocator_for_size(block->cell_size()).block_did_become_empty({}, *block);
|
allocator_for_size(block->cell_size()).block_did_become_empty({}, *block);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto* block : full_blocks_that_became_usable) {
|
for (auto* block : full_blocks_that_became_usable) {
|
||||||
#if HEAP_DEBUG
|
dbgln_if(HEAP_DEBUG, " - HeapBlock usable again @ {}: cell_size={}", block, block->cell_size());
|
||||||
dbgln(" - HeapBlock usable again @ {}: cell_size={}", block, block->cell_size());
|
|
||||||
#endif
|
|
||||||
allocator_for_size(block->cell_size()).block_did_become_usable({}, *block);
|
allocator_for_size(block->cell_size()).block_did_become_usable({}, *block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue