mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:37: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:
parent
e9081a2644
commit
9b699bad94
6 changed files with 24 additions and 24 deletions
|
@ -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
|
||||
|
|
|
@ -101,7 +101,7 @@
|
|||
namespace JS {
|
||||
|
||||
class ASTNode;
|
||||
class Allocator;
|
||||
class CellAllocator;
|
||||
class BigInt;
|
||||
class BoundFunction;
|
||||
class Cell;
|
||||
|
|
|
@ -5,23 +5,23 @@
|
|||
*/
|
||||
|
||||
#include <AK/Badge.h>
|
||||
#include <LibJS/Heap/Allocator.h>
|
||||
#include <LibJS/Heap/BlockAllocator.h>
|
||||
#include <LibJS/Heap/CellAllocator.h>
|
||||
#include <LibJS/Heap/Heap.h>
|
||||
#include <LibJS/Heap/HeapBlock.h>
|
||||
|
||||
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<Heap>, HeapBlock& block)
|
||||
void CellAllocator::block_did_become_empty(Badge<Heap>, HeapBlock& block)
|
||||
{
|
||||
auto& heap = block.heap();
|
||||
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);
|
||||
}
|
||||
|
||||
void Allocator::block_did_become_usable(Badge<Heap>, HeapBlock& block)
|
||||
void CellAllocator::block_did_become_usable(Badge<Heap>, HeapBlock& block)
|
||||
{
|
||||
VERIFY(!block.is_full());
|
||||
m_usable_blocks.append(block);
|
|
@ -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; }
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
#include <AK/StackInfo.h>
|
||||
#include <AK/TemporaryChange.h>
|
||||
#include <LibCore/ElapsedTimer.h>
|
||||
#include <LibJS/Heap/Allocator.h>
|
||||
#include <LibJS/Heap/CellAllocator.h>
|
||||
#include <LibJS/Heap/Handle.h>
|
||||
#include <LibJS/Heap/Heap.h>
|
||||
#include <LibJS/Heap/HeapBlock.h>
|
||||
|
@ -23,14 +23,14 @@ namespace JS {
|
|||
Heap::Heap(VM& vm)
|
||||
: m_vm(vm)
|
||||
{
|
||||
m_allocators.append(make<Allocator>(16));
|
||||
m_allocators.append(make<Allocator>(32));
|
||||
m_allocators.append(make<Allocator>(64));
|
||||
m_allocators.append(make<Allocator>(128));
|
||||
m_allocators.append(make<Allocator>(256));
|
||||
m_allocators.append(make<Allocator>(512));
|
||||
m_allocators.append(make<Allocator>(1024));
|
||||
m_allocators.append(make<Allocator>(3072));
|
||||
m_allocators.append(make<CellAllocator>(16));
|
||||
m_allocators.append(make<CellAllocator>(32));
|
||||
m_allocators.append(make<CellAllocator>(64));
|
||||
m_allocators.append(make<CellAllocator>(128));
|
||||
m_allocators.append(make<CellAllocator>(256));
|
||||
m_allocators.append(make<CellAllocator>(512));
|
||||
m_allocators.append(make<CellAllocator>(1024));
|
||||
m_allocators.append(make<CellAllocator>(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)
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
#include <AK/Vector.h>
|
||||
#include <LibCore/Forward.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibJS/Heap/Allocator.h>
|
||||
#include <LibJS/Heap/BlockAllocator.h>
|
||||
#include <LibJS/Heap/Cell.h>
|
||||
#include <LibJS/Heap/CellAllocator.h>
|
||||
#include <LibJS/Heap/Handle.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
|
||||
|
@ -83,7 +83,7 @@ private:
|
|||
void mark_live_cells(const HashTable<Cell*>& 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<typename Callback>
|
||||
void for_each_block(Callback callback)
|
||||
|
@ -101,7 +101,7 @@ private:
|
|||
|
||||
VM& m_vm;
|
||||
|
||||
Vector<NonnullOwnPtr<Allocator>> m_allocators;
|
||||
Vector<NonnullOwnPtr<CellAllocator>> m_allocators;
|
||||
HashTable<HandleImpl*> m_handles;
|
||||
|
||||
HashTable<MarkedValueList*> m_marked_value_lists;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue