mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 03:47:35 +00:00
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.
This commit is contained in:
parent
57371f7608
commit
c364520c24
10 changed files with 33 additions and 1 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue