js: Exercise the garbage collector a little bit

This commit is contained in:
Andreas Kling 2020-03-08 19:59:59 +01:00
parent 63e4b744ed
commit d9126b1ad5

View file

@ -33,6 +33,8 @@
int main()
{
// function foo() { return 1 + 2; }
// foo();
auto program = make<JS::Program>();
auto block = make<JS::BlockStatement>();
@ -55,5 +57,14 @@ int main()
dbg() << "Interpreter returned " << result;
printf("%s\n", result.to_string().characters());
interpreter.heap().allocate<JS::Object>();
dbg() << "Collecting garbage...";
interpreter.heap().collect_garbage();
interpreter.global_object().put("foo", JS::Value(123));
dbg() << "Collecting garbage after overwriting global_object.foo...";
interpreter.heap().collect_garbage();
return 0;
}