mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-26 19:29:16 +00:00
LibJS: Protect function call "this" and arguments from GC
This patch adds a CallFrame stack to Interpreter, which keeps track of the "this" value and all argument values passed in function calls. Interpreter::gather_roots() scans the call stack, making sure that all argument values get marked. :^)
This commit is contained in:
@@ -151,9 +151,13 @@ void Interpreter::gather_roots(Badge<Heap>, HashTable<Cell*>& roots)
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& this_value : m_this_stack) {
|
||||
if (this_value.is_cell())
|
||||
roots.set(this_value.as_cell());
|
||||
for (auto& call_frame : m_call_stack) {
|
||||
if (call_frame.this_value.is_cell())
|
||||
roots.set(call_frame.this_value.as_cell());
|
||||
for (auto& argument : call_frame.arguments) {
|
||||
if (argument.is_cell())
|
||||
roots.set(argument.as_cell());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user