mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 06:58:11 +00:00
LibJS: GC should gather roots from all active interpreters
If we are in a nested execution context, we shouldn't only mark things used by the active interpreter.
This commit is contained in:
parent
31bb107922
commit
fbe2907510
5 changed files with 11 additions and 5 deletions
|
@ -105,9 +105,7 @@ void Heap::collect_garbage(CollectionType collection_type, bool print_report)
|
||||||
|
|
||||||
void Heap::gather_roots(HashTable<Cell*>& roots)
|
void Heap::gather_roots(HashTable<Cell*>& roots)
|
||||||
{
|
{
|
||||||
if (auto* interpreter = vm().interpreter_if_exists())
|
vm().gather_roots(roots);
|
||||||
interpreter->gather_roots({}, roots);
|
|
||||||
|
|
||||||
gather_conservative_roots(roots);
|
gather_conservative_roots(roots);
|
||||||
|
|
||||||
for (auto* handle : m_handles)
|
for (auto* handle : m_handles)
|
||||||
|
|
|
@ -223,7 +223,7 @@ Symbol* Interpreter::get_global_symbol(const String& description)
|
||||||
return new_global_symbol;
|
return new_global_symbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Interpreter::gather_roots(Badge<Heap>, HashTable<Cell*>& roots)
|
void Interpreter::gather_roots(HashTable<Cell*>& roots)
|
||||||
{
|
{
|
||||||
roots.set(m_exception);
|
roots.set(m_exception);
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ public:
|
||||||
|
|
||||||
Symbol* get_global_symbol(const String& description);
|
Symbol* get_global_symbol(const String& description);
|
||||||
|
|
||||||
void gather_roots(Badge<Heap>, HashTable<Cell*>&);
|
void gather_roots(HashTable<Cell*>&);
|
||||||
|
|
||||||
void enter_scope(const ScopeNode&, ArgumentVector, ScopeType, GlobalObject&);
|
void enter_scope(const ScopeNode&, ArgumentVector, ScopeType, GlobalObject&);
|
||||||
void exit_scope(const ScopeNode&);
|
void exit_scope(const ScopeNode&);
|
||||||
|
|
|
@ -82,4 +82,10 @@ VM::InterpreterScope::~InterpreterScope()
|
||||||
m_interpreter.vm().pop_interpreter(m_interpreter);
|
m_interpreter.vm().pop_interpreter(m_interpreter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VM::gather_roots(HashTable<Cell*>& roots)
|
||||||
|
{
|
||||||
|
for (auto* interpreter : m_interpreters)
|
||||||
|
interpreter->gather_roots(roots);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,8 @@ public:
|
||||||
Interpreter& m_interpreter;
|
Interpreter& m_interpreter;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void gather_roots(HashTable<Cell*>&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VM();
|
VM();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue