summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-05-27 19:03:41 +0200
committerAndreas Kling <kling@serenityos.org>2021-05-27 19:56:12 +0200
commit9b699bad943bc7b45d63f7893c87cc454f361106 (patch)
tree2c1542e7c0dd46580f0bb66683e8e2a5e28eb8b4 /Userland/Libraries/LibJS
parente9081a264404f2f2c8bba1820c3878eb1cd2de85 (diff)
downloadserenity-9b699bad943bc7b45d63f7893c87cc454f361106.zip
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.
Diffstat (limited to 'Userland/Libraries/LibJS')
-rw-r--r--Userland/Libraries/LibJS/CMakeLists.txt2
-rw-r--r--Userland/Libraries/LibJS/Forward.h2
-rw-r--r--Userland/Libraries/LibJS/Heap/CellAllocator.cpp (renamed from Userland/Libraries/LibJS/Heap/Allocator.cpp)12
-rw-r--r--Userland/Libraries/LibJS/Heap/CellAllocator.h (renamed from Userland/Libraries/LibJS/Heap/Allocator.h)6
-rw-r--r--Userland/Libraries/LibJS/Heap/Heap.cpp20
-rw-r--r--Userland/Libraries/LibJS/Heap/Heap.h6
6 files changed, 24 insertions, 24 deletions
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
index 2c6588b4d8..63e6e38fcf 100644
--- a/Userland/Libraries/LibJS/Heap/Allocator.cpp
+++ b/Userland/Libraries/LibJS/Heap/CellAllocator.cpp
@@ -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);
diff --git a/Userland/Libraries/LibJS/Heap/Allocator.h b/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 <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)
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 <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;