mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:57:44 +00:00
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.
This commit is contained in:
parent
f953a70965
commit
6c1fcc5f7e
2 changed files with 4 additions and 3 deletions
|
@ -7,6 +7,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/IntrusiveList.h>
|
||||
#include <AK/NeverDestroyed.h>
|
||||
#include <AK/NonnullOwnPtr.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibJS/Heap/HeapBlock.h>
|
||||
|
@ -61,7 +62,7 @@ class TypeIsolatingCellAllocator {
|
|||
public:
|
||||
using CellType = T;
|
||||
|
||||
CellAllocator allocator { sizeof(T) };
|
||||
NeverDestroyed<CellAllocator> allocator { sizeof(T) };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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<T, typename decltype(T::cell_allocator)::CellType>) {
|
||||
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue