LibJS: Use a Function to indirectly let Heap visit VM's GC roots

This allows the heap to mark cells that it needs to mark as roots
without needing to directly reference the VM.
This commit is contained in:
Shannon Booth 2024-11-14 20:17:33 +13:00 committed by Andreas Kling
commit ae6d105f41
Notes: github-actions[bot] 2024-11-14 14:39:45 +00:00
3 changed files with 10 additions and 5 deletions

View file

@ -62,7 +62,9 @@ static constexpr auto make_single_ascii_character_strings(IndexSequence<code_poi
static constexpr auto single_ascii_character_strings = make_single_ascii_character_strings(MakeIndexSequence<128>());
VM::VM(OwnPtr<CustomData> custom_data, ErrorMessages error_messages)
: m_heap(*this)
: m_heap(*this, [this](HashMap<Cell*, JS::HeapRoot>& roots) {
gather_roots(roots);
})
, m_error_messages(move(error_messages))
, m_custom_data(move(custom_data))
{