diff options
author | Andreas Kling <kling@serenityos.org> | 2021-09-11 16:44:40 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-11 16:52:03 +0200 |
commit | c364520c2402b4b395f4e43fcfe3d4af4d546810 (patch) | |
tree | 0de3e6d60caea72831f3807b473b20d1bb2acdf5 /Userland/Utilities/js.cpp | |
parent | 57371f7608b0d3251be03192e03a70b8b36ea3f2 (diff) | |
download | serenity-c364520c2402b4b395f4e43fcfe3d4af4d546810.zip |
LibJS+js+test-js: Add GC debug mode that keeps cells "alive" as zombies
This patch adds a `-z` option to js and test-js. When run in this mode,
garbage cells are never actually destroyed. We instead keep them around
in a special zombie state.
This allows us to validate that zombies don't get marked in future GC
scans (since there were not supposed to be any more references!) :^)
Cells get notified when they become a zombie (via did_become_zombie())
and this is used by WeakContainer cells to deregister themselves from
the heap.
Diffstat (limited to 'Userland/Utilities/js.cpp')
-rw-r--r-- | Userland/Utilities/js.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp index 0e152b7e08..25dd94ef7b 100644 --- a/Userland/Utilities/js.cpp +++ b/Userland/Utilities/js.cpp @@ -1079,6 +1079,7 @@ public: int main(int argc, char** argv) { bool gc_on_every_allocation = false; + bool zombify_dead_cells = false; bool disable_syntax_highlight = false; Vector<String> script_paths; @@ -1091,6 +1092,7 @@ int main(int argc, char** argv) args_parser.add_option(s_as_module, "Treat as module", "as-module", 'm'); args_parser.add_option(s_print_last_result, "Print last result", "print-last-result", 'l'); args_parser.add_option(gc_on_every_allocation, "GC on every allocation", "gc-on-every-allocation", 'g'); + args_parser.add_option(zombify_dead_cells, "Zombify dead cells (to catch missing GC marks)", "zombify-dead-cells", 'z'); args_parser.add_option(disable_syntax_highlight, "Disable live syntax highlighting", "no-syntax-highlight", 's'); args_parser.add_positional_argument(script_paths, "Path to script files", "scripts", Core::ArgsParser::Required::No); args_parser.parse(argc, argv); @@ -1131,6 +1133,7 @@ int main(int argc, char** argv) ReplConsoleClient console_client(interpreter->global_object().console()); interpreter->global_object().console().set_client(console_client); interpreter->heap().set_should_collect_on_every_allocation(gc_on_every_allocation); + interpreter->heap().set_zombify_dead_cells(zombify_dead_cells); interpreter->vm().set_underscore_is_last_value(true); s_editor = Line::Editor::construct(); @@ -1334,6 +1337,7 @@ int main(int argc, char** argv) ReplConsoleClient console_client(interpreter->global_object().console()); interpreter->global_object().console().set_client(console_client); interpreter->heap().set_should_collect_on_every_allocation(gc_on_every_allocation); + interpreter->heap().set_zombify_dead_cells(zombify_dead_cells); signal(SIGINT, [](int) { sigint_handler(); |