diff --git a/Userland/Libraries/LibJS/Heap/Cell.h b/Userland/Libraries/LibJS/Heap/Cell.h index dabd43a47e..6070949786 100644 --- a/Userland/Libraries/LibJS/Heap/Cell.h +++ b/Userland/Libraries/LibJS/Heap/Cell.h @@ -80,6 +80,13 @@ public: visit_impl(value.as_cell()); } + // Allow explicitly ignoring a GC-allocated member in a visit_edges implementation instead + // of just not using it. + template + void ignore(T const&) + { + } + protected: virtual void visit_impl(Cell&) = 0; virtual ~Visitor() = default; diff --git a/Userland/Libraries/LibJS/Runtime/Shape.cpp b/Userland/Libraries/LibJS/Runtime/Shape.cpp index 2e3ab7b415..137e534e22 100644 --- a/Userland/Libraries/LibJS/Runtime/Shape.cpp +++ b/Userland/Libraries/LibJS/Runtime/Shape.cpp @@ -123,6 +123,7 @@ void Shape::visit_edges(Cell::Visitor& visitor) for (auto& it : *m_property_table) it.key.visit_edges(visitor); } + visitor.ignore(m_prototype_transitions); } Optional Shape::lookup(StringOrSymbol const& property_key) const diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp index c1cd73213b..d1aad171fc 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp +++ b/Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp @@ -37,6 +37,7 @@ void EnvironmentSettingsObject::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); visitor.visit(target_browsing_context); + visitor.ignore(m_outstanding_rejected_promises_weak_set); } JS::ExecutionContext& EnvironmentSettingsObject::realm_execution_context() diff --git a/Userland/Libraries/LibWeb/HTML/Worker.cpp b/Userland/Libraries/LibWeb/HTML/Worker.cpp index 93cc7fa2e4..c7b39db477 100644 --- a/Userland/Libraries/LibWeb/HTML/Worker.cpp +++ b/Userland/Libraries/LibWeb/HTML/Worker.cpp @@ -44,6 +44,10 @@ void Worker::visit_edges(Cell::Visitor& visitor) visitor.visit(m_inner_settings); visitor.visit(m_implicit_port); visitor.visit(m_outside_port); + + // These are in a separate VM and shouldn't be visited + visitor.ignore(m_worker_realm); + visitor.ignore(m_worker_scope); } // https://html.spec.whatwg.org/multipage/workers.html#dom-worker