1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:27:43 +00:00

LibJS: Rename Allocator => CellAllocator

Now that we have a BlockAllocator as well, it seems appropriate to name
the allocator-that-allocates-cells something more specific to match.
This commit is contained in:
Andreas Kling 2021-05-27 19:03:41 +02:00
parent e9081a2644
commit 9b699bad94
6 changed files with 24 additions and 24 deletions

View file

@ -1,7 +1,7 @@
set(SOURCES set(SOURCES
AST.cpp AST.cpp
Console.cpp Console.cpp
Heap/Allocator.cpp Heap/CellAllocator.cpp
Heap/BlockAllocator.cpp Heap/BlockAllocator.cpp
Heap/Handle.cpp Heap/Handle.cpp
Heap/HeapBlock.cpp Heap/HeapBlock.cpp

View file

@ -101,7 +101,7 @@
namespace JS { namespace JS {
class ASTNode; class ASTNode;
class Allocator; class CellAllocator;
class BigInt; class BigInt;
class BoundFunction; class BoundFunction;
class Cell; class Cell;

View file

@ -5,23 +5,23 @@
*/ */
#include <AK/Badge.h> #include <AK/Badge.h>
#include <LibJS/Heap/Allocator.h>
#include <LibJS/Heap/BlockAllocator.h> #include <LibJS/Heap/BlockAllocator.h>
#include <LibJS/Heap/CellAllocator.h>
#include <LibJS/Heap/Heap.h> #include <LibJS/Heap/Heap.h>
#include <LibJS/Heap/HeapBlock.h> #include <LibJS/Heap/HeapBlock.h>
namespace JS { namespace JS {
Allocator::Allocator(size_t cell_size) CellAllocator::CellAllocator(size_t cell_size)
: m_cell_size(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()) { if (m_usable_blocks.is_empty()) {
auto block = HeapBlock::create_with_cell_size(heap, m_cell_size); auto block = HeapBlock::create_with_cell_size(heap, m_cell_size);
@ -36,7 +36,7 @@ Cell* Allocator::allocate_cell(Heap& heap)
return cell; return cell;
} }
void Allocator::block_did_become_empty(Badge<Heap>, HeapBlock& block) void CellAllocator::block_did_become_empty(Badge<Heap>, HeapBlock& block)
{ {
auto& heap = block.heap(); auto& heap = block.heap();
block.m_list_node.remove(); block.m_list_node.remove();
@ -45,7 +45,7 @@ void Allocator::block_did_become_empty(Badge<Heap>, HeapBlock& block)
heap.block_allocator().deallocate_block(&block); heap.block_allocator().deallocate_block(&block);
} }
void Allocator::block_did_become_usable(Badge<Heap>, HeapBlock& block) void CellAllocator::block_did_become_usable(Badge<Heap>, HeapBlock& block)
{ {
VERIFY(!block.is_full()); VERIFY(!block.is_full());
m_usable_blocks.append(block); m_usable_blocks.append(block);

View file

@ -14,10 +14,10 @@
namespace JS { namespace JS {
class Allocator { class CellAllocator {
public: public:
Allocator(size_t cell_size); explicit CellAllocator(size_t cell_size);
~Allocator(); ~CellAllocator();
size_t cell_size() const { return m_cell_size; } size_t cell_size() const { return m_cell_size; }

View file

@ -10,7 +10,7 @@
#include <AK/StackInfo.h> #include <AK/StackInfo.h>
#include <AK/TemporaryChange.h> #include <AK/TemporaryChange.h>
#include <LibCore/ElapsedTimer.h> #include <LibCore/ElapsedTimer.h>
#include <LibJS/Heap/Allocator.h> #include <LibJS/Heap/CellAllocator.h>
#include <LibJS/Heap/Handle.h> #include <LibJS/Heap/Handle.h>
#include <LibJS/Heap/Heap.h> #include <LibJS/Heap/Heap.h>
#include <LibJS/Heap/HeapBlock.h> #include <LibJS/Heap/HeapBlock.h>
@ -23,14 +23,14 @@ namespace JS {
Heap::Heap(VM& vm) Heap::Heap(VM& vm)
: m_vm(vm) : m_vm(vm)
{ {
m_allocators.append(make<Allocator>(16)); m_allocators.append(make<CellAllocator>(16));
m_allocators.append(make<Allocator>(32)); m_allocators.append(make<CellAllocator>(32));
m_allocators.append(make<Allocator>(64)); m_allocators.append(make<CellAllocator>(64));
m_allocators.append(make<Allocator>(128)); m_allocators.append(make<CellAllocator>(128));
m_allocators.append(make<Allocator>(256)); m_allocators.append(make<CellAllocator>(256));
m_allocators.append(make<Allocator>(512)); m_allocators.append(make<CellAllocator>(512));
m_allocators.append(make<Allocator>(1024)); m_allocators.append(make<CellAllocator>(1024));
m_allocators.append(make<Allocator>(3072)); m_allocators.append(make<CellAllocator>(3072));
} }
Heap::~Heap() Heap::~Heap()
@ -38,7 +38,7 @@ Heap::~Heap()
collect_garbage(CollectionType::CollectEverything); 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) { for (auto& allocator : m_allocators) {
if (allocator->cell_size() >= cell_size) if (allocator->cell_size() >= cell_size)

View file

@ -13,9 +13,9 @@
#include <AK/Vector.h> #include <AK/Vector.h>
#include <LibCore/Forward.h> #include <LibCore/Forward.h>
#include <LibJS/Forward.h> #include <LibJS/Forward.h>
#include <LibJS/Heap/Allocator.h>
#include <LibJS/Heap/BlockAllocator.h> #include <LibJS/Heap/BlockAllocator.h>
#include <LibJS/Heap/Cell.h> #include <LibJS/Heap/Cell.h>
#include <LibJS/Heap/CellAllocator.h>
#include <LibJS/Heap/Handle.h> #include <LibJS/Heap/Handle.h>
#include <LibJS/Runtime/Object.h> #include <LibJS/Runtime/Object.h>
@ -83,7 +83,7 @@ private:
void mark_live_cells(const HashTable<Cell*>& live_cells); void mark_live_cells(const HashTable<Cell*>& live_cells);
void sweep_dead_cells(bool print_report, const Core::ElapsedTimer&); void sweep_dead_cells(bool print_report, const Core::ElapsedTimer&);
Allocator& allocator_for_size(size_t); CellAllocator& allocator_for_size(size_t);
template<typename Callback> template<typename Callback>
void for_each_block(Callback callback) void for_each_block(Callback callback)
@ -101,7 +101,7 @@ private:
VM& m_vm; VM& m_vm;
Vector<NonnullOwnPtr<Allocator>> m_allocators; Vector<NonnullOwnPtr<CellAllocator>> m_allocators;
HashTable<HandleImpl*> m_handles; HashTable<HandleImpl*> m_handles;
HashTable<MarkedValueList*> m_marked_value_lists; HashTable<MarkedValueList*> m_marked_value_lists;