diff --git a/Libraries/LibJS/Heap/Heap.cpp b/Libraries/LibJS/Heap/Heap.cpp index 9f9cb02c154..a4a131fe5cd 100644 --- a/Libraries/LibJS/Heap/Heap.cpp +++ b/Libraries/LibJS/Heap/Heap.cpp @@ -105,9 +105,7 @@ void Heap::collect_garbage(CollectionType collection_type, bool print_report) void Heap::gather_roots(HashTable& roots) { - if (auto* interpreter = vm().interpreter_if_exists()) - interpreter->gather_roots({}, roots); - + vm().gather_roots(roots); gather_conservative_roots(roots); for (auto* handle : m_handles) diff --git a/Libraries/LibJS/Interpreter.cpp b/Libraries/LibJS/Interpreter.cpp index 3165c8dd479..56386e9ea5b 100644 --- a/Libraries/LibJS/Interpreter.cpp +++ b/Libraries/LibJS/Interpreter.cpp @@ -223,7 +223,7 @@ Symbol* Interpreter::get_global_symbol(const String& description) return new_global_symbol; } -void Interpreter::gather_roots(Badge, HashTable& roots) +void Interpreter::gather_roots(HashTable& roots) { roots.set(m_exception); diff --git a/Libraries/LibJS/Interpreter.h b/Libraries/LibJS/Interpreter.h index b356adfbede..86a90bdc514 100644 --- a/Libraries/LibJS/Interpreter.h +++ b/Libraries/LibJS/Interpreter.h @@ -135,7 +135,7 @@ public: Symbol* get_global_symbol(const String& description); - void gather_roots(Badge, HashTable&); + void gather_roots(HashTable&); void enter_scope(const ScopeNode&, ArgumentVector, ScopeType, GlobalObject&); void exit_scope(const ScopeNode&); diff --git a/Libraries/LibJS/Runtime/VM.cpp b/Libraries/LibJS/Runtime/VM.cpp index 41b1e46ec45..3a221d98628 100644 --- a/Libraries/LibJS/Runtime/VM.cpp +++ b/Libraries/LibJS/Runtime/VM.cpp @@ -82,4 +82,10 @@ VM::InterpreterScope::~InterpreterScope() m_interpreter.vm().pop_interpreter(m_interpreter); } +void VM::gather_roots(HashTable& roots) +{ + for (auto* interpreter : m_interpreters) + interpreter->gather_roots(roots); +} + } diff --git a/Libraries/LibJS/Runtime/VM.h b/Libraries/LibJS/Runtime/VM.h index d2623982197..dd1b333cc0a 100644 --- a/Libraries/LibJS/Runtime/VM.h +++ b/Libraries/LibJS/Runtime/VM.h @@ -53,6 +53,8 @@ public: Interpreter& m_interpreter; }; + void gather_roots(HashTable&); + private: VM();