mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-05 01:10:24 +00:00
LibGC: Add GC::Heap::the()
There's only ever one GC::Heap per process, so let's have a way to find it even when you have no context.
This commit is contained in:
committed by
Andreas Kling
parent
8b1f2e4e24
commit
d234e9ee71
Notes:
github-actions[bot]
2025-11-01 07:42:15 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/d234e9ee716 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6657
@@ -30,10 +30,18 @@
|
||||
|
||||
namespace GC {
|
||||
|
||||
static Heap* s_the;
|
||||
|
||||
Heap& Heap::the()
|
||||
{
|
||||
return *s_the;
|
||||
}
|
||||
|
||||
Heap::Heap(void* private_data, AK::Function<void(HashMap<Cell*, GC::HeapRoot>&)> gather_embedder_roots)
|
||||
: HeapBase(private_data)
|
||||
, m_gather_embedder_roots(move(gather_embedder_roots))
|
||||
{
|
||||
s_the = this;
|
||||
static_assert(HeapBlock::min_possible_cell_size <= 32, "Heap Cell tracking uses too much data!");
|
||||
m_size_based_cell_allocators.append(make<CellAllocator>(64));
|
||||
m_size_based_cell_allocators.append(make<CellAllocator>(96));
|
||||
|
||||
@@ -38,6 +38,8 @@ public:
|
||||
explicit Heap(void* private_data, AK::Function<void(HashMap<Cell*, GC::HeapRoot>&)> gather_embedder_roots);
|
||||
~Heap();
|
||||
|
||||
static Heap& the();
|
||||
|
||||
template<typename T, typename... Args>
|
||||
Ref<T> allocate(Args&&... args)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user