diff --git a/Userland/Libraries/LibJS/CMakeLists.txt b/Userland/Libraries/LibJS/CMakeLists.txt index e5e6641bd7..751550a685 100644 --- a/Userland/Libraries/LibJS/CMakeLists.txt +++ b/Userland/Libraries/LibJS/CMakeLists.txt @@ -1,7 +1,7 @@ set(SOURCES AST.cpp Console.cpp - Heap/Allocator.cpp + Heap/CellAllocator.cpp Heap/BlockAllocator.cpp Heap/Handle.cpp Heap/HeapBlock.cpp diff --git a/Userland/Libraries/LibJS/Forward.h b/Userland/Libraries/LibJS/Forward.h index 3d5737ec85..835d2b84a4 100644 --- a/Userland/Libraries/LibJS/Forward.h +++ b/Userland/Libraries/LibJS/Forward.h @@ -101,7 +101,7 @@ namespace JS { class ASTNode; -class Allocator; +class CellAllocator; class BigInt; class BoundFunction; class Cell; diff --git a/Userland/Libraries/LibJS/Heap/Allocator.cpp b/Userland/Libraries/LibJS/Heap/CellAllocator.cpp similarity index 75% rename from Userland/Libraries/LibJS/Heap/Allocator.cpp rename to Userland/Libraries/LibJS/Heap/CellAllocator.cpp index 2c6588b4d8..63e6e38fcf 100644 --- a/Userland/Libraries/LibJS/Heap/Allocator.cpp +++ b/Userland/Libraries/LibJS/Heap/CellAllocator.cpp @@ -5,23 +5,23 @@ */ #include -#include #include +#include #include #include namespace JS { -Allocator::Allocator(size_t cell_size) +CellAllocator::CellAllocator(size_t cell_size) : m_cell_size(cell_size) { } -Allocator::~Allocator() +CellAllocator::~CellAllocator() { } -Cell* Allocator::allocate_cell(Heap& heap) +Cell* CellAllocator::allocate_cell(Heap& heap) { if (m_usable_blocks.is_empty()) { auto block = HeapBlock::create_with_cell_size(heap, m_cell_size); @@ -36,7 +36,7 @@ Cell* Allocator::allocate_cell(Heap& heap) return cell; } -void Allocator::block_did_become_empty(Badge, HeapBlock& block) +void CellAllocator::block_did_become_empty(Badge, HeapBlock& block) { auto& heap = block.heap(); block.m_list_node.remove(); @@ -45,7 +45,7 @@ void Allocator::block_did_become_empty(Badge, HeapBlock& block) heap.block_allocator().deallocate_block(&block); } -void Allocator::block_did_become_usable(Badge, HeapBlock& block) +void CellAllocator::block_did_become_usable(Badge, HeapBlock& block) { VERIFY(!block.is_full()); m_usable_blocks.append(block); diff --git a/Userland/Libraries/LibJS/Heap/Allocator.h b/Userland/Libraries/LibJS/Heap/CellAllocator.h similarity index 92% rename from Userland/Libraries/LibJS/Heap/Allocator.h rename to Userland/Libraries/LibJS/Heap/CellAllocator.h index b98a70cee4..de1663b6fd 100644 --- a/Userland/Libraries/LibJS/Heap/Allocator.h +++ b/Userland/Libraries/LibJS/Heap/CellAllocator.h @@ -14,10 +14,10 @@ namespace JS { -class Allocator { +class CellAllocator { public: - Allocator(size_t cell_size); - ~Allocator(); + explicit CellAllocator(size_t cell_size); + ~CellAllocator(); size_t cell_size() const { return m_cell_size; } diff --git a/Userland/Libraries/LibJS/Heap/Heap.cpp b/Userland/Libraries/LibJS/Heap/Heap.cpp index afeb56e41b..11042ea5e9 100644 --- a/Userland/Libraries/LibJS/Heap/Heap.cpp +++ b/Userland/Libraries/LibJS/Heap/Heap.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include @@ -23,14 +23,14 @@ namespace JS { Heap::Heap(VM& vm) : m_vm(vm) { - m_allocators.append(make(16)); - m_allocators.append(make(32)); - m_allocators.append(make(64)); - m_allocators.append(make(128)); - m_allocators.append(make(256)); - m_allocators.append(make(512)); - m_allocators.append(make(1024)); - m_allocators.append(make(3072)); + m_allocators.append(make(16)); + m_allocators.append(make(32)); + m_allocators.append(make(64)); + m_allocators.append(make(128)); + m_allocators.append(make(256)); + m_allocators.append(make(512)); + m_allocators.append(make(1024)); + m_allocators.append(make(3072)); } Heap::~Heap() @@ -38,7 +38,7 @@ Heap::~Heap() collect_garbage(CollectionType::CollectEverything); } -ALWAYS_INLINE Allocator& Heap::allocator_for_size(size_t cell_size) +ALWAYS_INLINE CellAllocator& Heap::allocator_for_size(size_t cell_size) { for (auto& allocator : m_allocators) { if (allocator->cell_size() >= cell_size) diff --git a/Userland/Libraries/LibJS/Heap/Heap.h b/Userland/Libraries/LibJS/Heap/Heap.h index 8e61391574..6e45121241 100644 --- a/Userland/Libraries/LibJS/Heap/Heap.h +++ b/Userland/Libraries/LibJS/Heap/Heap.h @@ -13,9 +13,9 @@ #include #include #include -#include #include #include +#include #include #include @@ -83,7 +83,7 @@ private: void mark_live_cells(const HashTable& live_cells); void sweep_dead_cells(bool print_report, const Core::ElapsedTimer&); - Allocator& allocator_for_size(size_t); + CellAllocator& allocator_for_size(size_t); template void for_each_block(Callback callback) @@ -101,7 +101,7 @@ private: VM& m_vm; - Vector> m_allocators; + Vector> m_allocators; HashTable m_handles; HashTable m_marked_value_lists;