mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01: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:
parent
8b1f2e4e24
commit
d234e9ee71
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user