1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:28:12 +00:00

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.
This commit is contained in:
davidot 2022-02-04 16:12:39 +01:00 committed by Andreas Kling
parent 794d79e315
commit 8da6c01d8f
13 changed files with 1 additions and 107 deletions

View file

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

View file

@ -190,14 +190,6 @@ public:
return;
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.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) {
if (!cell->is_marked()) {
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
++collected_cells;
collected_cell_bytes += block.cell_size();
} else {

View file

@ -63,13 +63,6 @@ public:
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; }
#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_destroy_handle(Badge<HandleImpl>, HandleImpl&);
@ -132,10 +125,6 @@ private:
bool m_should_gc_when_deferral_ends { false };
bool m_collecting_garbage { false };
#ifdef JS_TRACK_ZOMBIE_CELLS
bool m_zombify_dead_cells { false };
#endif
};
}

View file

@ -35,13 +35,6 @@ public:
private:
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 };
struct FinalizationRecord {

View file

@ -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);
}
#ifdef JS_TRACK_ZOMBIE_CELLS
void Shape::did_become_zombie()
{
revoke_weak_ptrs();
}
#endif
}

View file

@ -89,10 +89,6 @@ private:
virtual const char* class_name() const override { return "Shape"; }
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_prototype_transition(Object* prototype);

View file

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

View file

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

View file

@ -30,13 +30,6 @@ public:
virtual void remove_dead_cells(Badge<Heap>) override;
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
};

View file

@ -116,9 +116,6 @@ static consteval size_t __testjs_last()
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 String g_currently_running_test;
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);
#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);
if (result.is_error() && result.error() == RunFileHookResult::SkipFile) {

View file

@ -19,9 +19,6 @@ 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;
String g_currently_running_test;
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(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(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");

View file

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

View file

@ -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_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');
#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_positional_argument(script_paths, "Path to script files", "scripts", Core::ArgsParser::Required::No);
args_parser.parse(arguments);
@ -1416,9 +1412,6 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
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);
#ifdef JS_TRACK_ZOMBIE_CELLS
interpreter->heap().set_zombify_dead_cells(zombify_dead_cells);
#endif
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());
interpreter->global_object().console().set_client(console_client);
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) {
sigint_handler();