summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibTest
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-10-02 16:35:55 +0200
committerAndreas Kling <kling@serenityos.org>2021-10-02 16:39:28 +0200
commit6a1b82df2b9c176c46be3fd89ad78184a5a4f55c (patch)
tree288ff50f216094ba6d393d7001dee036a92a2df3 /Userland/Libraries/LibTest
parentf290c59dd82b3ae59bdb7c10bd7026788b879b8d (diff)
downloadserenity-6a1b82df2b9c176c46be3fd89ad78184a5a4f55c.zip
LibJS: Put zombie cell tracking code behind a compile-time flag
Since this is a debug-only feature, let's not have it impact GC marking performance when you don't need it.
Diffstat (limited to 'Userland/Libraries/LibTest')
-rw-r--r--Userland/Libraries/LibTest/JavaScriptTestRunner.h5
-rw-r--r--Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp4
2 files changed, 9 insertions, 0 deletions
diff --git a/Userland/Libraries/LibTest/JavaScriptTestRunner.h b/Userland/Libraries/LibTest/JavaScriptTestRunner.h
index 641b4e8a3d..da826093d2 100644
--- a/Userland/Libraries/LibTest/JavaScriptTestRunner.h
+++ b/Userland/Libraries/LibTest/JavaScriptTestRunner.h
@@ -113,7 +113,9 @@ 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;
+#ifdef JS_TRACK_ZOMBIE_CELLS
extern bool g_zombify_dead_cells;
+#endif
extern bool g_run_bytecode;
extern bool g_dump_bytecode;
extern String g_currently_running_test;
@@ -284,7 +286,10 @@ 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);
+
+#ifdef JS_TRACK_ZOMBIE_CELLS
interpreter->heap().set_zombify_dead_cells(g_zombify_dead_cells);
+#endif
if (g_run_file) {
auto result = g_run_file(test_path, *interpreter);
diff --git a/Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp b/Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp
index 2a7355b41c..7fb9dbe8b1 100644
--- a/Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp
+++ b/Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp
@@ -18,7 +18,9 @@ namespace JS {
RefPtr<::JS::VM> g_vm;
bool g_collect_on_every_allocation = false;
+#ifdef JS_TRACK_ZOMBIE_CELLS
bool g_zombify_dead_cells = false;
+#endif
bool g_run_bytecode = false;
bool g_dump_bytecode = false;
String g_currently_running_test;
@@ -110,7 +112,9 @@ int main(int argc, char** argv)
});
args_parser.add_option(print_json, "Show results as JSON", "json", 'j');
args_parser.add_option(g_collect_on_every_allocation, "Collect garbage after every allocation", "collect-often", 'g');
+#ifdef JS_TRACK_ZOMBIE_CELLS
args_parser.add_option(g_zombify_dead_cells, "Zombify dead cells (to catch missing GC marks)", "zombify-dead-cells", 'z');
+#endif
args_parser.add_option(g_run_bytecode, "Use the bytecode interpreter", "run-bytecode", 'b');
args_parser.add_option(g_dump_bytecode, "Dump the bytecode", "dump-bytecode", 'd');
args_parser.add_option(test_glob, "Only run tests matching the given glob", "filter", 'f', "glob");