mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:57:44 +00:00
LibJS: Recycle up to 64 HeapBlocks to improve performance :^)
This patch adds a BlockAllocator to the GC heap where we now cache up to 64 HeapBlock-sized mmap's that get recycled when allocating HeapBlocks. This improves test-js runtime performance by ~35%, pretty cool! :^)
This commit is contained in:
parent
d2149c153c
commit
e9081a2644
6 changed files with 101 additions and 8 deletions
|
@ -6,6 +6,8 @@
|
|||
|
||||
#include <AK/Badge.h>
|
||||
#include <LibJS/Heap/Allocator.h>
|
||||
#include <LibJS/Heap/BlockAllocator.h>
|
||||
#include <LibJS/Heap/Heap.h>
|
||||
#include <LibJS/Heap/HeapBlock.h>
|
||||
|
||||
namespace JS {
|
||||
|
@ -36,8 +38,11 @@ Cell* Allocator::allocate_cell(Heap& heap)
|
|||
|
||||
void Allocator::block_did_become_empty(Badge<Heap>, HeapBlock& block)
|
||||
{
|
||||
auto& heap = block.heap();
|
||||
block.m_list_node.remove();
|
||||
delete █
|
||||
// NOTE: HeapBlocks are managed by the BlockAllocator, so we don't want to `delete` the block here.
|
||||
block.~HeapBlock();
|
||||
heap.block_allocator().deallocate_block(&block);
|
||||
}
|
||||
|
||||
void Allocator::block_did_become_usable(Badge<Heap>, HeapBlock& block)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue