From 6c1fcc5f7e7fc02d5ae12c0c59aa00a9fb666f1a Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 23 Dec 2023 20:00:21 +0100 Subject: [PATCH] LibJS: Actually invoke the type-isolating cell allocators Due to a `requires` mistake, we were always using the fallback size-based cell allocators. Also, now that we start using them, make them NeverDestroyed so we don't try to deallocate them on program exit. --- Userland/Libraries/LibJS/Heap/CellAllocator.h | 3 ++- Userland/Libraries/LibJS/Heap/Heap.h | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibJS/Heap/CellAllocator.h b/Userland/Libraries/LibJS/Heap/CellAllocator.h index 33ad2f2c51..592f54cc10 100644 --- a/Userland/Libraries/LibJS/Heap/CellAllocator.h +++ b/Userland/Libraries/LibJS/Heap/CellAllocator.h @@ -7,6 +7,7 @@ #pragma once #include +#include #include #include #include @@ -61,7 +62,7 @@ class TypeIsolatingCellAllocator { public: using CellType = T; - CellAllocator allocator { sizeof(T) }; + NeverDestroyed allocator { sizeof(T) }; }; } diff --git a/Userland/Libraries/LibJS/Heap/Heap.h b/Userland/Libraries/LibJS/Heap/Heap.h index 57e056ba25..fda95d9266 100644 --- a/Userland/Libraries/LibJS/Heap/Heap.h +++ b/Userland/Libraries/LibJS/Heap/Heap.h @@ -101,9 +101,9 @@ private: Cell* allocate_cell() { will_allocate(sizeof(T)); - if constexpr (requires { T::cell_allocator.allocate_cell(*this); }) { + if constexpr (requires { T::cell_allocator.allocator.get().allocate_cell(*this); }) { if constexpr (IsSame) { - return T::cell_allocator.allocate_cell(*this); + return T::cell_allocator.allocator.get().allocate_cell(*this); } } return allocator_for_size(sizeof(T)).allocate_cell(*this);