1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-21 14:25:07 +00:00
serenity/Userland/Libraries/LibJS/Heap
Andreas Kling 3c74dc9f4d LibJS: Segregate GC-allocated objects by type
This patch adds two macros to declare per-type allocators:

- JS_DECLARE_ALLOCATOR(TypeName)
- JS_DEFINE_ALLOCATOR(TypeName)

When used, they add a type-specific CellAllocator that the Heap will
delegate allocation requests to.

The result of this is that GC objects of the same type always end up
within the same HeapBlock, drastically reducing the ability to perform
type confusion attacks.

It also improves HeapBlock utilization, since each block now has cells
sized exactly to the type used within that block. (Previously we only
had a handful of block sizes available, and most GC allocations ended
up with a large amount of slack in their tails.)

There is a small performance hit from this, but I'm sure we can make
up for it elsewhere.

Note that the old size-based allocators still exist, and we fall back
to them for any type that doesn't have its own CellAllocator.
2023-11-19 12:10:31 +01:00
..
BlockAllocator.cpp Everywhere: Replace uses of __serenity__ with AK_OS_SERENITY 2022-10-10 12:23:12 +02:00
BlockAllocator.h Libraries: Use default constructors/destructors in LibJS 2022-03-16 16:19:40 +00:00
Cell.cpp LibJS: Make Cell::initialize() return void 2023-08-08 07:39:11 +02:00
Cell.h AK+LibJS: Introduce JS::HeapFunction 2023-08-19 05:03:17 +02:00
CellAllocator.cpp LibJS: Use default instead of an empty constructor/destructor 2021-09-16 17:17:13 +02:00
CellAllocator.h LibJS: Segregate GC-allocated objects by type 2023-11-19 12:10:31 +01:00
DeferGC.h LibJS: Make GC deferral friendship based 2023-09-25 13:19:25 +02:00
GCPtr.h AK: Rename GenericTraits to DefaultTraits 2023-11-09 10:05:51 -05:00
Handle.cpp LibJS: Add source location for Handle nodes in GC graph dumper output 2023-09-24 14:55:32 +02:00
Handle.h AK: Rename GenericTraits to DefaultTraits 2023-11-09 10:05:51 -05:00
Heap.cpp LibJS: Segregate GC-allocated objects by type 2023-11-19 12:10:31 +01:00
Heap.h LibJS: Segregate GC-allocated objects by type 2023-11-19 12:10:31 +01:00
HeapBlock.cpp LibJS: Resolve a circular include problem between HeapBlock and Cell 2023-07-11 09:38:37 +03:30
HeapBlock.h LibJS: Resolve a circular include problem between HeapBlock and Cell 2023-07-11 09:38:37 +03:30
HeapFunction.h LibJS: Declare HeapFunction::function() with [[nodiscard]] 2023-09-26 19:42:59 +02:00
HeapRoot.h LibJS: Add source location for Handle nodes in GC graph dumper output 2023-09-24 14:55:32 +02:00
Internals.h LibJS: Lower HeapBlock size to 4 KiB 2023-11-19 12:10:31 +01:00
MarkedVector.cpp LibJS: Let MarkedVector<T> inherit from Vector and handle Cell* + Value 2022-02-09 12:25:27 +00:00
MarkedVector.h LibJS: Add source location for Handle nodes in GC graph dumper output 2023-09-24 14:55:32 +02:00