diff options
author | Andreas Kling <kling@serenityos.org> | 2020-03-16 19:18:46 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-03-16 19:18:46 +0100 |
commit | cb2e7d1c5f702cd80171ace1b201f382aa69f9d5 (patch) | |
tree | fcc493db644c2c045667087ec5816de84fb44626 /Userland | |
parent | ab404a2f8861a30ccc8e200ca06399b23add453c (diff) | |
download | serenity-cb2e7d1c5f702cd80171ace1b201f382aa69f9d5.zip |
LibJS+js: Add a debug option (js -g) to GC after every allocation
This is very useful for discovering collector bugs.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/js.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Userland/js.cpp b/Userland/js.cpp index 9725bcbf90..9cc0f6ab32 100644 --- a/Userland/js.cpp +++ b/Userland/js.cpp @@ -41,10 +41,12 @@ int main(int argc, char** argv) { bool dump_ast = false; + bool gc_on_every_allocation = false; const char* script_path = nullptr; Core::ArgsParser args_parser; args_parser.add_option(dump_ast, "Dump the AST", "ast-dump", 'A'); + args_parser.add_option(gc_on_every_allocation, "GC on every allocation", "gc-on-every-allocation", 'g'); args_parser.add_positional_argument(script_path, "Path to script file", "script"); args_parser.parse(argc, argv); @@ -56,6 +58,7 @@ int main(int argc, char** argv) auto file_contents = file->read_all(); JS::Interpreter interpreter; + interpreter.heap().set_should_collect_on_every_allocation(gc_on_every_allocation); auto program = JS::Parser(JS::Lexer(file_contents)).parse_program(); |