浏览代码

LibJS: Remove the JS_TRACK_ZOMBIE_CELLS option

This feature had bitrotted somewhat and would trigger errors because
PrimitiveStrings were "destroyed" but because of this mode they were not
removed from the string cache. Even fixing that case running test-js
with the options still failed in more places.
davidot 3 年之前
父节点
当前提交
8da6c01d8f

+ 0 - 9
Userland/Libraries/LibJS/Heap/Cell.h

@@ -24,18 +24,9 @@ public:
     bool is_marked() const { return m_mark; }
     bool is_marked() const { return m_mark; }
     void set_marked(bool b) { m_mark = b; }
     void set_marked(bool b) { m_mark = b; }
 
 
-#ifdef JS_TRACK_ZOMBIE_CELLS
-    virtual void did_become_zombie()
-    {
-    }
-#endif
-
     enum class State {
     enum class State {
         Live,
         Live,
         Dead,
         Dead,
-#ifdef JS_TRACK_ZOMBIE_CELLS
-        Zombie,
-#endif
     };
     };
 
 
     State state() const { return m_state; }
     State state() const { return m_state; }

+ 1 - 18
Userland/Libraries/LibJS/Heap/Heap.cpp

@@ -190,14 +190,6 @@ public:
             return;
             return;
         dbgln_if(HEAP_DEBUG, "  ! {}", &cell);
         dbgln_if(HEAP_DEBUG, "  ! {}", &cell);
 
 
-#ifdef JS_TRACK_ZOMBIE_CELLS
-        if (cell.state() == Cell::State::Zombie) {
-            dbgln("BUG! Marking a zombie cell, {} @ {:p}", cell.class_name(), &cell);
-            cell.vm().dump_backtrace();
-            VERIFY_NOT_REACHED();
-        }
-#endif
-
         cell.set_marked(true);
         cell.set_marked(true);
         cell.visit_edges(*this);
         cell.visit_edges(*this);
     }
     }
@@ -234,16 +226,7 @@ void Heap::sweep_dead_cells(bool print_report, const Core::ElapsedTimer& measure
         block.template for_each_cell_in_state<Cell::State::Live>([&](Cell* cell) {
         block.template for_each_cell_in_state<Cell::State::Live>([&](Cell* cell) {
             if (!cell->is_marked()) {
             if (!cell->is_marked()) {
                 dbgln_if(HEAP_DEBUG, "  ~ {}", cell);
                 dbgln_if(HEAP_DEBUG, "  ~ {}", cell);
-#ifdef JS_TRACK_ZOMBIE_CELLS
-                if (m_zombify_dead_cells) {
-                    cell->set_state(Cell::State::Zombie);
-                    cell->did_become_zombie();
-                } else {
-#endif
-                    block.deallocate(cell);
-#ifdef JS_TRACK_ZOMBIE_CELLS
-                }
-#endif
+                block.deallocate(cell);
                 ++collected_cells;
                 ++collected_cells;
                 collected_cell_bytes += block.cell_size();
                 collected_cell_bytes += block.cell_size();
             } else {
             } else {

+ 0 - 11
Userland/Libraries/LibJS/Heap/Heap.h

@@ -63,13 +63,6 @@ public:
     bool should_collect_on_every_allocation() const { return m_should_collect_on_every_allocation; }
     bool should_collect_on_every_allocation() const { return m_should_collect_on_every_allocation; }
     void set_should_collect_on_every_allocation(bool b) { m_should_collect_on_every_allocation = b; }
     void set_should_collect_on_every_allocation(bool b) { m_should_collect_on_every_allocation = b; }
 
 
-#ifdef JS_TRACK_ZOMBIE_CELLS
-    void set_zombify_dead_cells(bool b)
-    {
-        m_zombify_dead_cells = b;
-    }
-#endif
-
     void did_create_handle(Badge<HandleImpl>, HandleImpl&);
     void did_create_handle(Badge<HandleImpl>, HandleImpl&);
     void did_destroy_handle(Badge<HandleImpl>, HandleImpl&);
     void did_destroy_handle(Badge<HandleImpl>, HandleImpl&);
 
 
@@ -132,10 +125,6 @@ private:
     bool m_should_gc_when_deferral_ends { false };
     bool m_should_gc_when_deferral_ends { false };
 
 
     bool m_collecting_garbage { false };
     bool m_collecting_garbage { false };
-
-#ifdef JS_TRACK_ZOMBIE_CELLS
-    bool m_zombify_dead_cells { false };
-#endif
 };
 };
 
 
 }
 }

+ 0 - 7
Userland/Libraries/LibJS/Runtime/FinalizationRegistry.h

@@ -35,13 +35,6 @@ public:
 private:
 private:
     virtual void visit_edges(Visitor& visitor) override;
     virtual void visit_edges(Visitor& visitor) override;
 
 
-#ifdef JS_TRACK_ZOMBIE_CELLS
-    virtual void did_become_zombie() override
-    {
-        deregister();
-    }
-#endif
-
     FunctionObject* m_cleanup_callback { nullptr };
     FunctionObject* m_cleanup_callback { nullptr };
 
 
     struct FinalizationRecord {
     struct FinalizationRecord {

+ 0 - 7
Userland/Libraries/LibJS/Runtime/Shape.cpp

@@ -247,11 +247,4 @@ FLATTEN void Shape::add_property_without_transition(PropertyKey const& property_
     add_property_without_transition(property_name.to_string_or_symbol(), attributes);
     add_property_without_transition(property_name.to_string_or_symbol(), attributes);
 }
 }
 
 
-#ifdef JS_TRACK_ZOMBIE_CELLS
-void Shape::did_become_zombie()
-{
-    revoke_weak_ptrs();
-}
-#endif
-
 }
 }

+ 0 - 4
Userland/Libraries/LibJS/Runtime/Shape.h

@@ -89,10 +89,6 @@ private:
     virtual const char* class_name() const override { return "Shape"; }
     virtual const char* class_name() const override { return "Shape"; }
     virtual void visit_edges(Visitor&) override;
     virtual void visit_edges(Visitor&) override;
 
 
-#ifdef JS_TRACK_ZOMBIE_CELLS
-    virtual void did_become_zombie() override;
-#endif
-
     Shape* get_or_prune_cached_forward_transition(TransitionKey const&);
     Shape* get_or_prune_cached_forward_transition(TransitionKey const&);
     Shape* get_or_prune_cached_prototype_transition(Object* prototype);
     Shape* get_or_prune_cached_prototype_transition(Object* prototype);
 
 

+ 0 - 7
Userland/Libraries/LibJS/Runtime/WeakMap.h

@@ -30,13 +30,6 @@ public:
     virtual void remove_dead_cells(Badge<Heap>) override;
     virtual void remove_dead_cells(Badge<Heap>) override;
 
 
 private:
 private:
-#ifdef JS_TRACK_ZOMBIE_CELLS
-    virtual void did_become_zombie() override
-    {
-        deregister();
-    }
-#endif
-
     void visit_edges(Visitor&) override;
     void visit_edges(Visitor&) override;
 
 
     HashMap<Cell*, Value> m_values; // This stores Cell pointers instead of Object pointers to aide with sweeping
     HashMap<Cell*, Value> m_values; // This stores Cell pointers instead of Object pointers to aide with sweeping

+ 0 - 7
Userland/Libraries/LibJS/Runtime/WeakRef.h

@@ -32,13 +32,6 @@ public:
 private:
 private:
     virtual void visit_edges(Visitor&) override;
     virtual void visit_edges(Visitor&) override;
 
 
-#ifdef JS_TRACK_ZOMBIE_CELLS
-    virtual void did_become_zombie() override
-    {
-        deregister();
-    }
-#endif
-
     Object* m_value { nullptr };
     Object* m_value { nullptr };
     u32 m_last_execution_generation { 0 };
     u32 m_last_execution_generation { 0 };
 };
 };

+ 0 - 7
Userland/Libraries/LibJS/Runtime/WeakSet.h

@@ -30,13 +30,6 @@ public:
     virtual void remove_dead_cells(Badge<Heap>) override;
     virtual void remove_dead_cells(Badge<Heap>) override;
 
 
 private:
 private:
-#ifdef JS_TRACK_ZOMBIE_CELLS
-    virtual void did_become_zombie() override
-    {
-        deregister();
-    }
-#endif
-
     HashTable<Cell*> m_values; // This stores Cell pointers instead of Object pointers to aide with sweeping
     HashTable<Cell*> m_values; // This stores Cell pointers instead of Object pointers to aide with sweeping
 };
 };
 
 

+ 0 - 7
Userland/Libraries/LibTest/JavaScriptTestRunner.h

@@ -116,9 +116,6 @@ static consteval size_t __testjs_last()
 static constexpr auto TOP_LEVEL_TEST_NAME = "__$$TOP_LEVEL$$__";
 static constexpr auto TOP_LEVEL_TEST_NAME = "__$$TOP_LEVEL$$__";
 extern RefPtr<JS::VM> g_vm;
 extern RefPtr<JS::VM> g_vm;
 extern bool g_collect_on_every_allocation;
 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_run_bytecode;
 extern String g_currently_running_test;
 extern String g_currently_running_test;
 struct FunctionWithLength {
 struct FunctionWithLength {
@@ -291,10 +288,6 @@ inline JSFileResult TestRunner::run_file_test(const String& test_path)
 
 
     interpreter->heap().set_should_collect_on_every_allocation(g_collect_on_every_allocation);
     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) {
     if (g_run_file) {
         auto result = g_run_file(test_path, *interpreter);
         auto result = g_run_file(test_path, *interpreter);
         if (result.is_error() && result.error() == RunFileHookResult::SkipFile) {
         if (result.is_error() && result.error() == RunFileHookResult::SkipFile) {

+ 0 - 6
Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp

@@ -19,9 +19,6 @@ namespace JS {
 
 
 RefPtr<::JS::VM> g_vm;
 RefPtr<::JS::VM> g_vm;
 bool g_collect_on_every_allocation = false;
 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_run_bytecode = false;
 String g_currently_running_test;
 String g_currently_running_test;
 HashMap<String, FunctionWithLength> s_exposed_global_functions;
 HashMap<String, FunctionWithLength> s_exposed_global_functions;
@@ -112,9 +109,6 @@ int main(int argc, char** argv)
     });
     });
     args_parser.add_option(print_json, "Show results as JSON", "json", 'j');
     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');
     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_run_bytecode, "Use the bytecode interpreter", "run-bytecode", 'b');
     args_parser.add_option(JS::Bytecode::g_dump_bytecode, "Dump the bytecode", "dump-bytecode", 'd');
     args_parser.add_option(JS::Bytecode::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");
     args_parser.add_option(test_glob, "Only run tests matching the given glob", "filter", 'f', "glob");

+ 0 - 7
Userland/Libraries/LibWeb/Bindings/Wrapper.h

@@ -24,13 +24,6 @@ protected:
         : Object(prototype)
         : Object(prototype)
     {
     {
     }
     }
-
-#ifdef JS_TRACK_ZOMBIE_CELLS
-    virtual void did_become_zombie() override
-    {
-        revoke_weak_ptrs();
-    }
-#endif
 };
 };
 
 
 }
 }

+ 0 - 10
Userland/Utilities/js.cpp

@@ -1370,10 +1370,6 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
     args_parser.add_option(s_strip_ansi, "Disable ANSI colors", "disable-ansi-colors", 'c');
     args_parser.add_option(s_strip_ansi, "Disable ANSI colors", "disable-ansi-colors", 'c');
     args_parser.add_option(s_disable_source_location_hints, "Disable source location hints", "disable-source-location-hints", 'h');
     args_parser.add_option(s_disable_source_location_hints, "Disable source location hints", "disable-source-location-hints", 'h');
     args_parser.add_option(gc_on_every_allocation, "GC on every allocation", "gc-on-every-allocation", 'g');
     args_parser.add_option(gc_on_every_allocation, "GC on every allocation", "gc-on-every-allocation", 'g');
-#ifdef JS_TRACK_ZOMBIE_CELLS
-    bool zombify_dead_cells = false;
-    args_parser.add_option(zombify_dead_cells, "Zombify dead cells (to catch missing GC marks)", "zombify-dead-cells", 'z');
-#endif
     args_parser.add_option(disable_syntax_highlight, "Disable live syntax highlighting", "no-syntax-highlight", 's');
     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.add_positional_argument(script_paths, "Path to script files", "scripts", Core::ArgsParser::Required::No);
     args_parser.parse(arguments);
     args_parser.parse(arguments);
@@ -1416,9 +1412,6 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
         ReplConsoleClient console_client(interpreter->global_object().console());
         ReplConsoleClient console_client(interpreter->global_object().console());
         interpreter->global_object().console().set_client(console_client);
         interpreter->global_object().console().set_client(console_client);
         interpreter->heap().set_should_collect_on_every_allocation(gc_on_every_allocation);
         interpreter->heap().set_should_collect_on_every_allocation(gc_on_every_allocation);
-#ifdef JS_TRACK_ZOMBIE_CELLS
-        interpreter->heap().set_zombify_dead_cells(zombify_dead_cells);
-#endif
 
 
         auto& global_environment = interpreter->realm().global_environment();
         auto& global_environment = interpreter->realm().global_environment();
 
 
@@ -1630,9 +1623,6 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
         ReplConsoleClient console_client(interpreter->global_object().console());
         ReplConsoleClient console_client(interpreter->global_object().console());
         interpreter->global_object().console().set_client(console_client);
         interpreter->global_object().console().set_client(console_client);
         interpreter->heap().set_should_collect_on_every_allocation(gc_on_every_allocation);
         interpreter->heap().set_should_collect_on_every_allocation(gc_on_every_allocation);
-#ifdef JS_TRACK_ZOMBIE_CELLS
-        interpreter->heap().set_zombify_dead_cells(zombify_dead_cells);
-#endif
 
 
         signal(SIGINT, [](int) {
         signal(SIGINT, [](int) {
             sigint_handler();
             sigint_handler();