LibGC: Add GC::RootHashMap<...> template container

This is a GC-aware wrapper around AK::HashMap. Entry values are treated
as GC roots, much like the GC::RootVector we already had.

We also provide GC::OrderedRootHashMap as a convenience.
This commit is contained in:
Andreas Kling 2025-05-03 11:59:17 +02:00 committed by Andreas Kling
commit 11ece7de10
Notes: github-actions[bot] 2025-05-03 15:34:58 +00:00
6 changed files with 122 additions and 0 deletions

View file

@ -282,6 +282,9 @@ void Heap::gather_roots(HashMap<Cell*, HeapRoot>& roots)
for (auto& vector : m_root_vectors)
vector.gather_roots(roots);
for (auto& hash_map : m_root_hash_maps)
hash_map.gather_roots(roots);
if constexpr (HEAP_DEBUG) {
dbgln("gather_roots:");
for (auto* root : roots.keys())