mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 13:50:00 +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:
parent
8b1f2e4e24
commit
d234e9ee71
Notes:
github-actions[bot]
2025-11-01 07:42:15 +00:00
Author: https://github.com/awesomekling
Commit: d234e9ee71
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6657
2 changed files with 10 additions and 0 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue