diff --git a/Userland/Libraries/LibJS/Heap/BlockAllocator.cpp b/Userland/Libraries/LibJS/Heap/BlockAllocator.cpp index 634e3f457bf..3fcaf9c7cc9 100644 --- a/Userland/Libraries/LibJS/Heap/BlockAllocator.cpp +++ b/Userland/Libraries/LibJS/Heap/BlockAllocator.cpp @@ -22,9 +22,6 @@ namespace JS { -// NOTE: If this changes, we need to update the mmap() code to ensure correct alignment. -static_assert(HeapBlock::block_size == 4096); - BlockAllocator::~BlockAllocator() { for (auto* block : m_blocks) { diff --git a/Userland/Libraries/LibJS/Heap/HeapBlock.cpp b/Userland/Libraries/LibJS/Heap/HeapBlock.cpp index b1a65440790..ccbe0bbbdae 100644 --- a/Userland/Libraries/LibJS/Heap/HeapBlock.cpp +++ b/Userland/Libraries/LibJS/Heap/HeapBlock.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Andreas Kling + * Copyright (c) 2020-2024, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ @@ -18,6 +18,8 @@ namespace JS { +size_t HeapBlockBase::block_size = PAGE_SIZE; + NonnullOwnPtr HeapBlock::create_with_cell_size(Heap& heap, CellAllocator& cell_allocator, size_t cell_size, [[maybe_unused]] char const* class_name) { char const* name = nullptr; diff --git a/Userland/Libraries/LibJS/Heap/Internals.h b/Userland/Libraries/LibJS/Heap/Internals.h index 08d20537d01..2bb809bb908 100644 --- a/Userland/Libraries/LibJS/Heap/Internals.h +++ b/Userland/Libraries/LibJS/Heap/Internals.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Andreas Kling + * Copyright (c) 2020-2024, Andreas Kling * Copyright (c) 2020-2023, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause @@ -33,7 +33,7 @@ class HeapBlockBase { AK_MAKE_NONCOPYABLE(HeapBlockBase); public: - static constexpr auto block_size = 4 * KiB; + static size_t block_size; static HeapBlockBase* from_cell(Cell const* cell) { return reinterpret_cast(bit_cast(cell) & ~(HeapBlockBase::block_size - 1));