Files
ladybird/Userland/Libraries/LibJS/Heap/BlockAllocator.h
Andreas Kling e9081a2644 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! :^)
2021-05-27 19:56:04 +02:00

29 lines
445 B
C++

/*
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Vector.h>
#include <LibJS/Forward.h>
namespace JS {
class BlockAllocator {
public:
BlockAllocator();
~BlockAllocator();
void* allocate_block(char const* name);
void deallocate_block(void*);
private:
static constexpr size_t max_cached_blocks = 64;
Vector<void*> m_blocks;
};
}