summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-10-04 18:11:54 +0200
committerAndreas Kling <kling@serenityos.org>2020-10-04 19:25:49 +0200
commit2852ce4954f76f657d0170b162bff12836d27e40 (patch)
treefc1f1f3f6fa40f1a196c5c7888f52c24dccf9213 /Libraries
parentad0d377e4c6d9ddfc6d9da7e7e3fe1dd55a7eb38 (diff)
downloadserenity-2852ce4954f76f657d0170b162bff12836d27e40.zip
LibJS: Always inline HeapBlock::allocate()
This thing is so simple and sits on the hot path so just inline it.
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibJS/Heap/HeapBlock.cpp7
-rw-r--r--Libraries/LibJS/Heap/HeapBlock.h8
2 files changed, 7 insertions, 8 deletions
diff --git a/Libraries/LibJS/Heap/HeapBlock.cpp b/Libraries/LibJS/Heap/HeapBlock.cpp
index 8388934ae4..250fcd6d3c 100644
--- a/Libraries/LibJS/Heap/HeapBlock.cpp
+++ b/Libraries/LibJS/Heap/HeapBlock.cpp
@@ -73,13 +73,6 @@ HeapBlock::HeapBlock(Heap& heap, size_t cell_size)
m_freelist = next;
}
-Cell* HeapBlock::allocate()
-{
- if (!m_freelist)
- return nullptr;
- return exchange(m_freelist, m_freelist->next);
-}
-
void HeapBlock::deallocate(Cell* cell)
{
ASSERT(cell->is_live());
diff --git a/Libraries/LibJS/Heap/HeapBlock.h b/Libraries/LibJS/Heap/HeapBlock.h
index 3de49c5e28..5b1a4c361b 100644
--- a/Libraries/LibJS/Heap/HeapBlock.h
+++ b/Libraries/LibJS/Heap/HeapBlock.h
@@ -42,7 +42,13 @@ public:
size_t cell_size() const { return m_cell_size; }
size_t cell_count() const { return (block_size - sizeof(HeapBlock)) / m_cell_size; }
- Cell* allocate();
+ ALWAYS_INLINE Cell* allocate()
+ {
+ if (!m_freelist)
+ return nullptr;
+ return exchange(m_freelist, m_freelist->next);
+ }
+
void deallocate(Cell*);
template<typename Callback>