summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-03-08 19:59:59 +0100
committerAndreas Kling <kling@serenityos.org>2020-03-08 19:59:59 +0100
commitd9126b1ad55267652511eab7f73f36f4a3b3ce8e (patch)
tree979d49bd05b22d4ca76423245d289c2859a272d8 /Userland
parent63e4b744ed176890465d5920b2421a48b193e978 (diff)
downloadserenity-d9126b1ad55267652511eab7f73f36f4a3b3ce8e.zip
js: Exercise the garbage collector a little bit
Diffstat (limited to 'Userland')
-rw-r--r--Userland/js.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/Userland/js.cpp b/Userland/js.cpp
index 876d1ae0f5..8e5249009a 100644
--- a/Userland/js.cpp
+++ b/Userland/js.cpp
@@ -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;
}