LibJS: Add magical "$gc" function that can be called to trigger GC

This will be immensely useful for testing.
This commit is contained in:
Andreas Kling 2020-03-09 21:27:52 +01:00
parent 1382dbc5e1
commit 15d8b9c671
Notes: sideshowbarker 2024-07-19 08:48:02 +09:00

View file

@ -46,6 +46,11 @@ Value FunctionDeclaration::execute(Interpreter& interpreter) const
Value CallExpression::execute(Interpreter& interpreter) const
{
if (name() == "$gc") {
interpreter.heap().collect_garbage();
return js_undefined();
}
auto callee = interpreter.global_object().get(name());
ASSERT(callee.is_object());
auto* callee_object = callee.as_object();