summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Heap/Heap.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-03-21 11:49:18 +0100
committerAndreas Kling <kling@serenityos.org>2020-03-21 11:49:18 +0100
commit6c3afca6866023b12c5f9d220cbedccd002bfd60 (patch)
tree2d5cd4f4feb1e8d31ca6e3501fb1718312fe2d26 /Libraries/LibJS/Heap/Heap.cpp
parent2106dafd62822ba1af0f3c74a742756c969501f3 (diff)
downloadserenity-6c3afca6866023b12c5f9d220cbedccd002bfd60.zip
LibJS: Round cell sizes up to a multiple of 16 bytes
This increases HeapBlock utilization significantly (and reduces overall memory usage.)
Diffstat (limited to 'Libraries/LibJS/Heap/Heap.cpp')
-rw-r--r--Libraries/LibJS/Heap/Heap.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/Libraries/LibJS/Heap/Heap.cpp b/Libraries/LibJS/Heap/Heap.cpp
index beb7403284..b289116647 100644
--- a/Libraries/LibJS/Heap/Heap.cpp
+++ b/Libraries/LibJS/Heap/Heap.cpp
@@ -60,7 +60,8 @@ Cell* Heap::allocate_cell(size_t size)
return cell;
}
- auto block = HeapBlock::create_with_cell_size(*this, size);
+ size_t cell_size = round_up_to_power_of_two(size, 16);
+ auto block = HeapBlock::create_with_cell_size(*this, cell_size);
auto* cell = block->allocate();
m_blocks.append(move(block));
return cell;