mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 01:27:42 +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
|
@ -111,6 +111,7 @@ static consteval size_t __testjs_last() { return (AK::Detail::IntegralConstant<s
|
|||
static constexpr auto TOP_LEVEL_TEST_NAME = "__$$TOP_LEVEL$$__";
|
||||
extern RefPtr<JS::VM> g_vm;
|
||||
extern bool g_collect_on_every_allocation;
|
||||
extern bool g_zombify_dead_cells;
|
||||
extern bool g_run_bytecode;
|
||||
extern bool g_dump_bytecode;
|
||||
extern String g_currently_running_test;
|
||||
|
@ -266,6 +267,7 @@ inline JSFileResult TestRunner::run_file_test(const String& test_path)
|
|||
JS::VM::InterpreterExecutionScope scope(*interpreter);
|
||||
|
||||
interpreter->heap().set_should_collect_on_every_allocation(g_collect_on_every_allocation);
|
||||
interpreter->heap().set_zombify_dead_cells(g_zombify_dead_cells);
|
||||
|
||||
if (g_run_file) {
|
||||
auto result = g_run_file(test_path, *interpreter);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue