Truly independent web browser
LibGC+Everywhere: Remove what the collector scanned besides the stack
Andreas Kling5cde1701f4c1
diff --git a/Libraries/LibGC/CAPI.cpp b/Libraries/LibGC/CAPI.cppindex 0479f52dd50..191506fb305 100644--- a/Libraries/LibGC/CAPI.cpp+++ b/Libraries/LibGC/CAPI.cpp@@ -406,11 +406,6 @@ void gc_visitor_visit_ephemeron(GCVisitor* visitor, GCCell* key, uint64_t const*as_visitor(visitor).visit_ephemeron(*from_gc_cell(key), *reinterpret_cast<NanBoxedValue const*>(value));}-void gc_visitor_visit_possible_values(GCVisitor* visitor, uint8_t const* data, size_t size)-{- as_visitor(visitor).visit_possible_values(ReadonlyBytes { data, size });-}-bool gc_primitive_storage_allocate(size_t size, bool zero_fill, GCPrimitiveStorageHandle* out_handle, GCPrimitiveStorageLayout* out_layout){auto& storage = PrimitiveStorage::the();diff --git a/Libraries/LibGC/CAPI.h b/Libraries/LibGC/CAPI.hindex df2a3b2ee5e..9751418488a 100644--- a/Libraries/LibGC/CAPI.h+++ b/Libraries/LibGC/CAPI.h@@ -192,8 +192,6 @@ GC_API void gc_visitor_visit_cells(GCVisitor*, GCCell* const*, size_t count);GC_API void gc_visitor_visit_values(GCVisitor*, uint64_t const*, size_t count);// Visits a NaN-boxed value that is reachable only while key is, such as a WeakMap entry's.GC_API void gc_visitor_visit_ephemeron(GCVisitor*, GCCell* key, uint64_t const* value);-// Treats every aligned word in the range as a possible pointer to a cell or NaN-boxed cell value.-GC_API void gc_visitor_visit_possible_values(GCVisitor*, uint8_t const*, size_t size);// Primitive storage holds byte buffers inside the cage that starts at gc_primitive_storage_cage_base(), so that the// interpreter can reach any of their bytes as a cage offset masked with primitive_storage_cage_offset_mask. Like thediff --git a/Libraries/LibGC/CMakeLists.txt b/Libraries/LibGC/CMakeLists.txtindex 50329c3c646..2efa3551bad 100644--- a/Libraries/LibGC/CMakeLists.txt+++ b/Libraries/LibGC/CMakeLists.txt@@ -3,7 +3,6 @@ set(SOURCESCAPI.cppCell.cppCellAllocator.cpp- ConservativeVector.cppCrossHeapMember.cppRoot.cppRootHashMap.cppdiff --git a/Libraries/LibGC/Cell.h b/Libraries/LibGC/Cell.hindex b4862c72f52..48a85ddb483 100644--- a/Libraries/LibGC/Cell.h+++ b/Libraries/LibGC/Cell.h@@ -280,8 +280,6 @@ public:{}- virtual void visit_possible_values(ReadonlyBytes) = 0;-// Visits a value that is reachable only while key is, such as a WeakMap entry's. Only marking tells them apart.// The caller must drop its entries whose key died, or the next collection reads a freed key.virtual void visit_ephemeron(Cell& key, NanBoxedValue const& value);diff --git a/Libraries/LibGC/ConservativeVector.cpp b/Libraries/LibGC/ConservativeVector.cppdeleted file mode 100644index 6fd8b8a9b98..00000000000--- a/Libraries/LibGC/ConservativeVector.cpp+++ /dev/null@@ -1,28 +0,0 @@-/*- * Copyright (c) 2024, Andreas Kling <[email protected]>- *- * SPDX-License-Identifier: BSD-2-Clause- */--#include <LibGC/ConservativeVector.h>-#include <LibGC/Heap.h>--namespace GC {--ConservativeVectorBase::ConservativeVectorBase()- : ConservativeVectorBase(Heap::the())-{-}--ConservativeVectorBase::ConservativeVectorBase(Heap& heap)- : m_heap(&heap)-{- m_heap->did_create_conservative_vector({}, *this);-}--ConservativeVectorBase::~ConservativeVectorBase()-{- m_heap->did_destroy_conservative_vector({}, *this);-}--}diff --git a/Libraries/LibGC/ConservativeVector.h b/Libraries/LibGC/ConservativeVector.hdeleted file mode 100644index d36dbf521b8..00000000000--- a/Libraries/LibGC/ConservativeVector.h+++ /dev/null@@ -1,88 +0,0 @@-/*- * Copyright (c) 2024, Andreas Kling <[email protected]>- *- * SPDX-License-Identifier: BSD-2-Clause- */--#pragma once--#include <AK/IntrusiveList.h>-#include <AK/Vector.h>-#include <LibGC/Forward.h>--namespace GC {--class GC_API ConservativeVectorBase {- AK_MAKE_NONCOPYABLE(ConservativeVectorBase);--public:- virtual ReadonlySpan<FlatPtr> possible_values() const = 0;--protected:- ConservativeVectorBase();- explicit ConservativeVectorBase(Heap&);- ~ConservativeVectorBase();-- Heap* m_heap { nullptr };- IntrusiveListNode<ConservativeVectorBase> m_list_node;--public:- using List = IntrusiveList<&ConservativeVectorBase::m_list_node>;-};--template<typename T, size_t inline_capacity>-requires(!IsPreciselyTracedCellPointer<T>) class GC_API ConservativeVector final- : public ConservativeVectorBase- , public Vector<T, inline_capacity> {--public:- ConservativeVector()- : ConservativeVectorBase()- {- }-- ConservativeVector(Vector<T, inline_capacity> const& other)- : ConservativeVectorBase()- , Vector<T, inline_capacity>(other)- {- }-- ConservativeVector(Vector<T, inline_capacity>&& other)- : ConservativeVectorBase()- , Vector<T, inline_capacity>(move(other))- {- }-- ~ConservativeVector() = default;-- ConservativeVector(ConservativeVector const& other)- : ConservativeVectorBase(*other.m_heap)- , Vector<T, inline_capacity>(other)- {- }-- ConservativeVector(ConservativeVector&& other)- : ConservativeVectorBase(*other.m_heap)- , Vector<T, inline_capacity>(move(static_cast<Vector<T, inline_capacity>&>(other)))- {- }-- ConservativeVector& operator=(ConservativeVector const& other)- {- if (&other == this)- return *this;- Vector<T, inline_capacity>::operator=(other);- return *this;- }-- virtual ReadonlySpan<FlatPtr> possible_values() const override- {- static_assert(sizeof(T) >= sizeof(FlatPtr));- return ReadonlySpan<FlatPtr> {- reinterpret_cast<FlatPtr const*>(this->data()),- this->size() * sizeof(T) / sizeof(FlatPtr),- };- }-};--}diff --git a/Libraries/LibGC/Forward.h b/Libraries/LibGC/Forward.hindex 6623e81ab6b..d8250922acb 100644--- a/Libraries/LibGC/Forward.h+++ b/Libraries/LibGC/Forward.h@@ -74,14 +74,6 @@ class Member;template<class T>class NonnullMember;-// The cell pointers that are traced precisely. Ptr and Ref belong in RootVector rather than conservative storage, and-// members only in cells.-template<typename T>-concept IsPreciselyTracedCellPointer = IsSpecializationOf<RemoveCVReference<T>, Ptr> || IsSpecializationOf<RemoveCVReference<T>, Ref> || IsSpecializationOf<RemoveCVReference<T>, Member> || IsSpecializationOf<RemoveCVReference<T>, NonnullMember>;--template<class T, size_t inline_capacity = 0>-requires(!IsPreciselyTracedCellPointer<T>) class ConservativeVector;-template<class T>class HeapVector;diff --git a/Libraries/LibGC/Heap.cpp b/Libraries/LibGC/Heap.cppindex e274c50c752..9c8ab4609e9 100644--- a/Libraries/LibGC/Heap.cpp+++ b/Libraries/LibGC/Heap.cpp@@ -122,7 +122,6 @@ struct PhaseTimings {// gather_conservative_roots() subphases.i64 conservative_register_scan_us { 0 };i64 conservative_stack_scan_us { 0 };- i64 conservative_vector_scan_us { 0 };i64 conservative_cell_lookup_us { 0 };// mark_live_cells() subphases.@@ -207,7 +206,6 @@ void print_gc_report(i64 total_us, size_t live_block_count)dbgln(" conservative roots {:>10} us ({:>5.1f}%)", t.gather_conservative_roots_us, pct(t.gather_conservative_roots_us));dbgln(" register scan {:>10} us ({:>5.1f}%)", t.conservative_register_scan_us, pct(t.conservative_register_scan_us));dbgln(" stack scan {:>10} us ({:>5.1f}%)", t.conservative_stack_scan_us, pct(t.conservative_stack_scan_us));- dbgln(" conservative-vector scan {:>10} us ({:>5.1f}%)", t.conservative_vector_scan_us, pct(t.conservative_vector_scan_us));dbgln(" cell lookup {:>10} us ({:>5.1f}%)", t.conservative_cell_lookup_us, pct(t.conservative_cell_lookup_us));dbgln(" explicit roots {:>10} us ({:>5.1f}%)", t.gather_explicit_roots_us, pct(t.gather_explicit_roots_us));dbgln(" mark_live_cells {:>10} us ({:>5.1f}%)", t.mark_live_cells_us, pct(t.mark_live_cells_us));@@ -554,28 +552,6 @@ static void add_possible_value(PossiblePointers& possible_pointers, FlatPtr datapossible_pointers.pointers.set(possible_pointer, move(origin));}-// Adds the possible values in the captures of an AK::Function that a cell visits. Its captures start 8-byte aligned, but-// may end with a lone compressed cell pointer, as a capture of nothing but one member does. That one is no half of a-// whole word, so it is added on its own. A member elsewhere in the captures is either half of one of the whole words.-static void add_possible_captured_values(PossiblePointers& possible_pointers, ReadonlyBytes bytes, PossiblePointerBounds const& bounds)-{- HeapRoot const origin { .type = HeapRoot::Type::AKFunctionCapturedPointer };- ASSERT(reinterpret_cast<FlatPtr>(bytes.data()) % alignof(FlatPtr) == 0);- auto const* words = reinterpret_cast<FlatPtr const*>(bytes.data());- auto word_count = bytes.size() / sizeof(FlatPtr);- for (size_t i = 0; i < word_count; ++i)- add_possible_value(possible_pointers, words[i], origin, bounds);-- // NB: Anything shorter than 4 bytes past the last whole word is too short to be a member, and anything that is a- // member is 4-byte aligned.- auto tail = bytes.slice(word_count * sizeof(FlatPtr));- if (tail.size() >= sizeof(u32)) {- u32 compressed;- memcpy(&compressed, tail.data(), sizeof(compressed));- add_possible_compressed_pointer(possible_pointers, compressed, origin, bounds);- }-}-template<typename Callback>static void for_each_cell_among_possible_pointers(HashTable<HeapBlock*> const& all_live_heap_blocks, PossiblePointers& possible_pointers, Callback callback){@@ -601,10 +577,8 @@ static void for_each_cell_among_possible_pointers(HashTable<HeapBlock*> const& aclass GraphConstructorVisitor final : public Cell::Visitor {public:- explicit GraphConstructorVisitor(Heap& heap, HashMap<Cell*, HeapRoot> const& roots)- : m_heap(heap)+ explicit GraphConstructorVisitor(HashMap<Cell*, HeapRoot> const& roots){- m_possible_pointer_bounds = PossiblePointerBounds::current();m_work_queue.ensure_capacity(roots.size());for (auto& [root, root_origin] : roots) {@@ -633,25 +607,6 @@ public:visit(value);}- virtual void visit_possible_values(ReadonlyBytes bytes) override- {- PossiblePointers possible_pointers;-- add_possible_captured_values(possible_pointers, bytes, m_possible_pointer_bounds);-- for_each_cell_among_possible_pointers(m_heap.m_live_heap_blocks, possible_pointers, [&](Cell* cell, auto&, FlatPtr) {- if (cell->state() != Cell::State::Live)- return;-- if (m_node_being_visited)- m_node_being_visited->edges.set(reinterpret_cast<FlatPtr>(cell));-- if (m_graph.get(reinterpret_cast<FlatPtr>(cell)).has_value())- return;- m_work_queue.append(*cell);- });- }-void visit_all_cells(){while (!m_work_queue.is_empty()) {@@ -697,9 +652,6 @@ private:GraphNode* m_node_being_visited { nullptr };Vector<Ref<Cell>> m_work_queue;HashMap<FlatPtr, GraphNode> m_graph;-- Heap& m_heap;- PossiblePointerBounds m_possible_pointer_bounds;};NO_SANITIZE_ADDRESS AK::JsonObject Heap::dump_graph()@@ -731,7 +683,7 @@ AK::JsonObject Heap::build_graph(ReadonlySpan<FlatPtr> callee_saved_registers)HashMap<Cell*, HeapRoot> roots;Vector<StackFrameInfo> stack_frames;gather_roots(origin, roots, &stack_frames);- GraphConstructorVisitor visitor(*this, roots);+ GraphConstructorVisitor visitor(roots);visitor.visit_all_cells();auto graph = visitor.dump();@@ -752,12 +704,8 @@ AK::JsonObject Heap::build_graph(ReadonlySpan<FlatPtr> callee_saved_registers)String Heap::describe_root(HeapRoot const& root){switch (root.type) {- case HeapRoot::Type::ConservativeVector:- return "ConservativeVector"_string;case HeapRoot::Type::CrossHeapMember:return "CrossHeapMember"_string;- case HeapRoot::Type::AKFunctionCapturedPointer:- return "AKFunctionCapturedPointer"_string;case HeapRoot::Type::Root:return MUST(String::formatted("Root {} {}:{}", root.location->function_name(), root.location->filename(), root.location->line_number()));case HeapRoot::Type::RootVector:@@ -779,25 +727,18 @@ String Heap::describe_root(HeapRoot const& root)// Visits every reachable cell breadth first, so the parent it records for each is on a shortest path from a root.class RetainingPathVisitor final : public Cell::Visitor {public:- struct Node {- Cell* parent { nullptr };- Heap::RetainingEdgeKind edge_kind { Heap::RetainingEdgeKind::Precise };- };-- RetainingPathVisitor(Heap& heap, HashMap<Cell*, HeapRoot> const& roots)- : m_heap(heap)- , m_possible_pointer_bounds(PossiblePointerBounds::current())+ explicit RetainingPathVisitor(HashMap<Cell*, HeapRoot> const& roots){m_queue.ensure_capacity(roots.size());for (auto& [root, root_origin] : roots) {- m_nodes.set(root, {});+ m_parents.set(root, nullptr);m_queue.append(*root);}}virtual void visit_impl(Cell& cell) override{- reach(cell, Heap::RetainingEdgeKind::Precise);+ reach(cell);}virtual void visit_impl(ReadonlySpan<NanBoxedValue> values) override@@ -806,17 +747,6 @@ public:visit(value);}- virtual void visit_possible_values(ReadonlyBytes bytes) override- {- PossiblePointers possible_pointers;- add_possible_captured_values(possible_pointers, bytes, m_possible_pointer_bounds);- for_each_cell_among_possible_pointers(m_heap.m_live_heap_blocks, possible_pointers, [&](Cell* cell, auto& candidates, FlatPtr) {- if (cell->state() != Cell::State::Live)- return;- reach(*cell, &candidates == &possible_pointers.compressed_pointers ? Heap::RetainingEdgeKind::ConservativeHalf : Heap::RetainingEdgeKind::ConservativeWord);- });- }-void visit_all_cells(){for (size_t i = 0; i < m_queue.size(); ++i) {@@ -828,20 +758,18 @@ public:}ReadonlySpan<Ref<Cell>> cells() const { return m_queue; }- Node const& node(Cell& cell) const { return *m_nodes.get(&cell); }+ Cell* parent(Cell& cell) const { return *m_parents.get(&cell); }private:- void reach(Cell& cell, Heap::RetainingEdgeKind edge_kind)+ void reach(Cell& cell){- if (m_nodes.contains(&cell))+ if (m_parents.contains(&cell))return;- m_nodes.set(&cell, { m_cell_being_visited, edge_kind });+ m_parents.set(&cell, m_cell_being_visited);m_queue.append(cell);}- Heap& m_heap;- PossiblePointerBounds m_possible_pointer_bounds;- HashMap<Cell*, Node> m_nodes;+ HashMap<Cell*, Cell*> m_parents;Vector<Ref<Cell>> m_queue;Cell* m_cell_being_visited { nullptr };};@@ -867,7 +795,7 @@ Vector<Heap::RetainingPath> Heap::build_retaining_paths(ReadonlySpan<FlatPtr> caHashMap<Cell*, HeapRoot> roots;gather_roots(origin, roots);- RetainingPathVisitor visitor(*this, roots);+ RetainingPathVisitor visitor(roots);visitor.visit_all_cells();Vector<RetainingPath> paths;@@ -878,14 +806,14 @@ Vector<Heap::RetainingPath> Heap::build_retaining_paths(ReadonlySpan<FlatPtr> cacontinue;Vector<Cell*> path_cells;- for (Cell* step = cell.ptr(); step; step = visitor.node(*step).parent)+ for (Cell* step = cell.ptr(); step; step = visitor.parent(*step))path_cells.append(step);RetainingPath path { .root = *roots.get(path_cells.last()), .steps = {} };path.steps.ensure_capacity(path_cells.size());for (size_t i = path_cells.size(); i > 0; --i) {auto& step = *path_cells[i - 1];- path.steps.unchecked_append({ class_name_of(step), visitor.node(step).edge_kind });+ path.steps.unchecked_append({ class_name_of(step) });}paths.append(move(path));}@@ -1165,8 +1093,6 @@ class CensusVisitor final : public Cell::Visitor {public:size_t cell_edges { 0 };- virtual void visit_possible_values(ReadonlyBytes) override { }-private:virtual void visit_impl(Cell&) override { ++cell_edges; }virtual void visit_impl(ReadonlySpan<NanBoxedValue> values) override@@ -1480,15 +1406,6 @@ NO_SANITIZE_ADDRESS void Heap::gather_conservative_roots(ConservativeScanOrigin}}- {- ScopedPhaseTimer timer { g_recording_phase_timings, g_phase_timings.conservative_vector_scan_us };- for (auto& vector : m_conservative_vectors) {- for (auto possible_value : vector.possible_values()) {- add_possible_value(possible_pointers, possible_value, HeapRoot { .type = HeapRoot::Type::ConservativeVector }, bounds);- }- }- }-{ScopedPhaseTimer timer { g_recording_phase_timings, g_phase_timings.conservative_cell_lookup_us };for_each_cell_among_possible_pointers(m_live_heap_blocks, possible_pointers, [&](Cell* cell, HashMap<FlatPtr, HeapRoot>& candidates, FlatPtr possible_pointer) {@@ -1508,7 +1425,6 @@ public:explicit MarkingVisitor(ReadonlySpan<Heap* const> domain, HashMap<Cell*, HeapRoot> const& roots): m_domain(domain){- m_possible_pointer_bounds = PossiblePointerBounds::current();for (auto* root : roots.keys()) {visit(root);}@@ -1557,24 +1473,6 @@ public:}}- virtual void visit_possible_values(ReadonlyBytes bytes) override- {- PossiblePointers possible_pointers;-- add_possible_captured_values(possible_pointers, bytes, m_possible_pointer_bounds);-- for (auto* heap : m_domain) {- for_each_cell_among_possible_pointers(heap->m_live_heap_blocks, possible_pointers, [&](Cell* cell, auto&, FlatPtr) {- if (cell->is_marked())- return;- if (cell->state() != Cell::State::Live)- return;- cell->set_marked(true);- m_work_queue.append(*cell);- });- }- }-virtual void visit_ephemeron(Cell& key, NanBoxedValue const& value) override{if (!value.is_cell())@@ -1622,7 +1520,6 @@ private:ReadonlySpan<Heap* const> m_domain;Vector<Ref<Cell>> m_work_queue;Vector<Ephemeron> m_pending_ephemerons;- PossiblePointerBounds m_possible_pointer_bounds;};void Heap::mark_live_cells(HashMap<Cell*, HeapRoot>& roots)diff --git a/Libraries/LibGC/Heap.h b/Libraries/LibGC/Heap.hindex cc1803f1f8b..d8f22da8a68 100644--- a/Libraries/LibGC/Heap.h+++ b/Libraries/LibGC/Heap.h@@ -21,7 +21,6 @@#include <LibCore/Forward.h>#include <LibGC/Cell.h>#include <LibGC/CellAllocator.h>-#include <LibGC/ConservativeVector.h>#include <LibGC/CrossHeapMember.h>#include <LibGC/Forward.h>#include <LibGC/FunctionTable.h>@@ -88,20 +87,13 @@ public:NEVER_INLINE void collect_garbage(CollectionType = CollectionType::CollectGarbage, bool print_report = false);NEVER_INLINE AK::JsonObject dump_graph();- // How a cell on a retaining path reaches the next one: through a field it visits, or through a word a conservative- // scan of its contents (the captures of an AK::Function, for example) took for a pointer, whole or as either 32-bit half.- enum class RetainingEdgeKind : u8 {- Precise,- ConservativeWord,- ConservativeHalf,- };+ // A cell on a retaining path, which reaches the next one through a field it visits.struct RetainingPathStep {StringView class_name;- RetainingEdgeKind edge_kind { RetainingEdgeKind::Precise };};struct RetainingPath {HeapRoot root;- // The first step is the root cell, whose edge kind is unused, and the last is the target.+ // The first step is the root cell, and the last is the target.Vector<RetainingPathStep> steps;};// The shortest path from a root to each reachable cell that is_target accepts, for at most max_paths of them.@@ -131,8 +123,6 @@ public:void did_create_root_hash_table(Badge<RootHashTableBase>, RootHashTableBase&);void did_destroy_root_hash_table(Badge<RootHashTableBase>, RootHashTableBase&);- void did_create_conservative_vector(Badge<ConservativeVectorBase>, ConservativeVectorBase&);- void did_destroy_conservative_vector(Badge<ConservativeVectorBase>, ConservativeVectorBase&);void did_create_cross_heap_member(Badge<CrossHeapMemberBase>, CrossHeapMemberBase&);void did_destroy_cross_heap_member(Badge<CrossHeapMemberBase>, CrossHeapMemberBase&);@@ -183,8 +173,6 @@ private:friend class CellAllocator;friend class HeapBlock;friend class MarkingVisitor;- friend class GraphConstructorVisitor;- friend class RetainingPathVisitor;friend class DeferGC;void defer_gc();@@ -343,7 +331,6 @@ private:RootVectorBase::List m_root_vectors;RootHashMapBase::List m_root_hash_maps;RootHashTableBase::List m_root_hash_tables;- ConservativeVectorBase::List m_conservative_vectors;HashTable<CrossHeapMemberBase*> m_incoming_cross_heap_members;HeapGroup* m_group { nullptr };bool m_incremental_sweep_enabled { true };@@ -440,18 +427,6 @@ inline void Heap::did_destroy_root_hash_table(Badge<RootHashTableBase>, RootHashm_root_hash_tables.remove(hash_table);}-inline void Heap::did_create_conservative_vector(Badge<ConservativeVectorBase>, ConservativeVectorBase& vector)-{- VERIFY(!m_conservative_vectors.contains(vector));- m_conservative_vectors.append(vector);-}--inline void Heap::did_destroy_conservative_vector(Badge<ConservativeVectorBase>, ConservativeVectorBase& vector)-{- VERIFY(m_conservative_vectors.contains(vector));- m_conservative_vectors.remove(vector);-}-inline void Heap::did_create_cross_heap_member(Badge<CrossHeapMemberBase>, CrossHeapMemberBase& member){VERIFY(!m_incoming_cross_heap_members.contains(&member));diff --git a/Libraries/LibGC/HeapRoot.h b/Libraries/LibGC/HeapRoot.hindex 68d5f5f05c8..5acd4f82e47 100644--- a/Libraries/LibGC/HeapRoot.h+++ b/Libraries/LibGC/HeapRoot.h@@ -14,9 +14,7 @@ namespace GC {struct GC_API HeapRoot {enum class Type {- ConservativeVector,CrossHeapMember,- AKFunctionCapturedPointer,RegisterPointer,Root,RootHashMap,diff --git a/Libraries/LibGC/Rootable.cpp b/Libraries/LibGC/Rootable.cppindex 30196135c8d..c163e8c981c 100644--- a/Libraries/LibGC/Rootable.cpp+++ b/Libraries/LibGC/Rootable.cpp@@ -8,12 +8,6 @@namespace GC::Detail {-void RootGatheringVisitor::visit_possible_values(ReadonlyBytes)-{- // NB: Roots are gathered precisely.- VERIFY_NOT_REACHED();-}-void RootGatheringVisitor::visit_impl(Cell& cell){m_roots.set(&cell, HeapRoot { .type = m_root_type });diff --git a/Libraries/LibGC/Rootable.h b/Libraries/LibGC/Rootable.hindex 882d3fe00d2..e557ddb7b11 100644--- a/Libraries/LibGC/Rootable.h+++ b/Libraries/LibGC/Rootable.h@@ -68,8 +68,6 @@ public:{}- virtual void visit_possible_values(ReadonlyBytes) override;-private:virtual void visit_impl(Cell&) override;virtual void visit_impl(ReadonlySpan<NanBoxedValue>) override;diff --git a/Libraries/LibJS/Rust/src/gc/capi.rs b/Libraries/LibJS/Rust/src/gc/capi.rsindex 323fbff6fe1..99d0f1d4884 100644--- a/Libraries/LibJS/Rust/src/gc/capi.rs+++ b/Libraries/LibJS/Rust/src/gc/capi.rs@@ -142,7 +142,6 @@ unsafe extern "C" {pub fn gc_visitor_visit_cells(visitor: *mut GCVisitor, cells: *const *mut c_void, count: usize);pub fn gc_visitor_visit_values(visitor: *mut GCVisitor, values: *const u64, count: usize);pub fn gc_visitor_visit_ephemeron(visitor: *mut GCVisitor, key: *mut c_void, value: *const u64);- pub fn gc_visitor_visit_possible_values(visitor: *mut GCVisitor, data: *const u8, size: usize);pub fn gc_primitive_storage_allocate(size: usize,diff --git a/Libraries/LibWasm/Engine/src/runtime/heap.rs b/Libraries/LibWasm/Engine/src/runtime/heap.rsindex 9261be6baa9..76a13cd91ab 100644--- a/Libraries/LibWasm/Engine/src/runtime/heap.rs+++ b/Libraries/LibWasm/Engine/src/runtime/heap.rs@@ -88,7 +88,6 @@ pub struct GcInterface {pub gc_root_create: unsafe extern "C" fn(cell: *mut c_void) -> *mut c_void,pub gc_root_destroy: unsafe extern "C" fn(root: *mut c_void),pub gc_visitor_visit_cell: unsafe extern "C" fn(visitor: *mut c_void, cell: *mut c_void),- pub gc_visitor_visit_possible_values: unsafe extern "C" fn(visitor: *mut c_void, data: *const u8, size: usize),pub gc_primitive_storage_reserve: unsafe extern "C" fn(size: usize,capacity: usize,diff --git a/Libraries/LibWasm/Runtime.cpp b/Libraries/LibWasm/Runtime.cppindex 71958a2fd33..90bdb8a01cb 100644--- a/Libraries/LibWasm/Runtime.cpp+++ b/Libraries/LibWasm/Runtime.cpp@@ -168,7 +168,6 @@ static FFI::GcInterface gc_interface(GC::Heap& heap).gc_root_create = function_cast<decltype(Interface::gc_root_create)>(gc_root_create),.gc_root_destroy = function_cast<decltype(Interface::gc_root_destroy)>(gc_root_destroy),.gc_visitor_visit_cell = function_cast<decltype(Interface::gc_visitor_visit_cell)>(gc_visitor_visit_cell),- .gc_visitor_visit_possible_values = function_cast<decltype(Interface::gc_visitor_visit_possible_values)>(gc_visitor_visit_possible_values),.gc_primitive_storage_reserve = function_cast<decltype(Interface::gc_primitive_storage_reserve)>(gc_primitive_storage_reserve),.gc_primitive_storage_resize = function_cast<decltype(Interface::gc_primitive_storage_resize)>(gc_primitive_storage_resize),.gc_primitive_storage_free = gc_primitive_storage_free,diff --git a/Libraries/LibWeb/Bindings/Rust/src/web_assembly/mod.rs b/Libraries/LibWeb/Bindings/Rust/src/web_assembly/mod.rsindex b9178a5f257..38a2d658bee 100644--- a/Libraries/LibWeb/Bindings/Rust/src/web_assembly/mod.rs+++ b/Libraries/LibWeb/Bindings/Rust/src/web_assembly/mod.rs@@ -80,7 +80,6 @@ unsafe extern "C" {fn gc_root_create(cell: *mut c_void) -> *mut c_void;fn gc_root_destroy(root: *mut c_void);pub(crate) fn gc_visitor_visit_cell(visitor: *mut c_void, cell: *mut c_void);- fn gc_visitor_visit_possible_values(visitor: *mut c_void, data: *const u8, size: usize);fn gc_primitive_storage_reserve(size: usize,capacity: usize,@@ -112,7 +111,6 @@ fn gc_interface(heap: *mut c_void) -> GcInterface {gc_root_create,gc_root_destroy,gc_visitor_visit_cell,- gc_visitor_visit_possible_values,gc_primitive_storage_reserve,gc_primitive_storage_resize,gc_primitive_storage_free,diff --git a/Meta/ClangPlugins/LibJSGCPluginAction.cpp b/Meta/ClangPlugins/LibJSGCPluginAction.cppindex 81523377557..171d98c8c83 100644--- a/Meta/ClangPlugins/LibJSGCPluginAction.cpp+++ b/Meta/ClangPlugins/LibJSGCPluginAction.cpp@@ -144,7 +144,6 @@ static ContainsGCPtrResult record_contains_gc_ptr(clang::CXXRecordDecl const* re"GC::RootHashTableBase","GC::Heap","GC::MarkedVector",- "GC::ConservativeVector","GC::RootHashMap","GC::RootHashMapBase",};@@ -1107,7 +1106,6 @@ static bool is_type_that_does_not_store_gc_pointers_by_value(std::string const&"AK::RefPtr","AK::Span","AK::WeakPtr",- "GC::ConservativeVector","GC::RawPtr","GC::RawRef","GC::Root",@@ -1472,7 +1470,6 @@ static bool is_container_with_heap_storage(std::string const& template_name)static bool is_container_scanned_by_gc(std::string const& template_name){static std::unordered_set<std::string> const template_names {- "GC::ConservativeVector","GC::RootHashMap","GC::RootHashTable","GC::RootVector",@@ -1618,7 +1615,7 @@ void LibJSGCVisitor::validate_type_on_stack(clang::QualType type, clang::SourceLreturn;auto& diag_engine = m_context.getDiagnostics();- auto diag_id = diag_engine.getCustomDiagID(clang::DiagnosticsEngine::Error, "%0 keeps GC pointers in heap memory that is not scanned for roots; use GC::RootVector, GC::RootHashMap, GC::RootHashTable or a GC::Conservative container instead");+ auto diag_id = diag_engine.getCustomDiagID(clang::DiagnosticsEngine::Error, "%0 keeps GC pointers in heap memory that is not scanned for roots; use GC::RootVector, GC::RootHashMap or GC::RootHashTable instead");diag_engine.Report(location, diag_id) << *container;}diff --git a/Services/WebContent/ConnectionFromClient.cpp b/Services/WebContent/ConnectionFromClient.cppindex 5a2364f41a5..dc3998d5f02 100644--- a/Services/WebContent/ConnectionFromClient.cpp+++ b/Services/WebContent/ConnectionFromClient.cpp@@ -1105,21 +1105,7 @@ static void report_leaked_documents()builder.append(GC::Heap::describe_root(path.root));for (size_t i = 0; i < path.steps.size(); ++i) {auto const& step = path.steps[i];- if (i == 0) {- builder.append(": "sv);- } else {- switch (step.edge_kind) {- case GC::Heap::RetainingEdgeKind::Precise:- builder.append(" -> "sv);- break;- case GC::Heap::RetainingEdgeKind::ConservativeWord:- builder.append(" ~word~> "sv);- break;- case GC::Heap::RetainingEdgeKind::ConservativeHalf:- builder.append(" ~half~> "sv);- break;- }- }+ builder.append(i == 0 ? ": "sv : " -> "sv);builder.append(step.class_name);}auto signature = builder.to_string_without_validation();diff --git a/Tests/ClangPlugins/LibJSGCTests/gc_pointer_container_on_stack.cpp b/Tests/ClangPlugins/LibJSGCTests/gc_pointer_container_on_stack.cppindex 41617ba3322..d95103bb0d2 100644--- a/Tests/ClangPlugins/LibJSGCTests/gc_pointer_container_on_stack.cpp+++ b/Tests/ClangPlugins/LibJSGCTests/gc_pointer_container_on_stack.cpp@@ -12,7 +12,6 @@#include <AK/Optional.h>#include <AK/Vector.h>#include <LibGC/Cell.h>-#include <LibGC/ConservativeVector.h>#include <LibGC/NanBoxedValue.h>#include <LibGC/Ptr.h>#include <LibGC/Root.h>@@ -87,8 +86,6 @@ void unrooted_locals()Vector<GC::Ref<GC::Cell>> groups[2];// expected-error@+1 {{'Vector<GC::Ref<GC::Cell>>' keeps GC pointers in heap memory that is not scanned for roots}}GC::RootHashMap<GC::Ref<GC::Cell>, Vector<GC::Ref<GC::Cell>>> root_map_of_vectors;- // expected-error@+1 {{'Vector<GC::Ref<GC::Cell>>' keeps GC pointers in heap memory that is not scanned for roots}}- GC::ConservativeVector<State> conservative_states;// expected-error@+1 {{keeps GC pointers in heap memory that is not scanned for roots}}auto deduced = make_cells();// expected-error@+1 {{keeps GC pointers in heap memory that is not scanned for roots}}@@ -171,7 +168,6 @@ void rooted_or_not_holding_gc_pointers(State& state)GC::RootVector<GC::Ref<GC::Cell>> root_vector;GC::RootVector<GC::Ref<GC::Cell>> root_groups[2];Vector<GC::Root<GC::Cell>> roots;- GC::ConservativeVector<Entry> conservative_entries;GC::RootVector<TracedState> traced_states;GC::RootHashMap<int, TracedState> traced_state_map;GC::RootHashMap<int, GC::Ref<GC::Cell>> root_map;diff --git a/Tests/LibGC/TestCompressedPointer.cpp b/Tests/LibGC/TestCompressedPointer.cppindex 446a34cc18b..cd133e14481 100644--- a/Tests/LibGC/TestCompressedPointer.cpp+++ b/Tests/LibGC/TestCompressedPointer.cpp@@ -8,7 +8,6 @@#include <LibGC/Cell.h>#include <LibGC/CellAllocator.h>#include <LibGC/CompressedPointer.h>-#include <LibGC/ConservativeVector.h>#include <LibGC/Heap.h>#include <LibGC/Testing.h>#include <LibGC/Weak.h>@@ -115,28 +114,4 @@ TEST_CASE(conservative_scanner_ignores_compressed_pointer_into_a_cell)EXPECT(word != 0);}-static NEVER_INLINE void allocate_cell_into_vector(GC::Weak<TestCell>& weak_cell, GC::ConservativeVector<u64>& words)-{- auto cell = test_heap().allocate<TestCell>();- weak_cell = cell.ptr();- words.append(static_cast<u64>(GC::compress(cell.ptr())) << 32);-}--TEST_CASE(conservative_vector_keeps_compressed_pointer_alive)-{- auto& heap = test_heap();- GC::Weak<TestCell> weak_cell;- GC::ConservativeVector<u64> words;- allocate_cell_into_vector(weak_cell, words);-- GC::scrub_stack_for_testing();- heap.collect_garbage();- EXPECT(weak_cell);-- words.clear();- GC::scrub_stack_for_testing();- heap.collect_garbage();- EXPECT(!weak_cell);-}-}diff --git a/Tests/LibGC/TestGCContainers.cpp b/Tests/LibGC/TestGCContainers.cppindex d5d73560734..42224072169 100644--- a/Tests/LibGC/TestGCContainers.cpp+++ b/Tests/LibGC/TestGCContainers.cpp@@ -7,7 +7,6 @@#include <AK/NeverDestroyed.h>#include <LibGC/Cell.h>#include <LibGC/CellAllocator.h>-#include <LibGC/ConservativeVector.h>#include <LibGC/Heap.h>#include <LibGC/HeapHashTable.h>#include <LibGC/HeapVector.h>@@ -32,40 +31,6 @@ class TestCell : public GC::Cell {GC_DEFINE_ALLOCATOR(TestCell);-// Probe the public container type, including aliases and incomplete pointees, rather than its implementation trait.-template<typename T>-concept ConservativeVectorAccepts = requires { typename GC::ConservativeVector<T>; };--class ForwardDeclaredCell;-using AliasedCellPtr = GC::Ptr<ForwardDeclaredCell>;-using AliasedCellRef = GC::Ref<ForwardDeclaredCell>;-struct ConservativeRecord {- GC::Ref<TestCell> cell;- FlatPtr payload;-};--static_assert(ConservativeVectorAccepts<FlatPtr>);-static_assert(ConservativeVectorAccepts<TestCell*>);-static_assert(ConservativeVectorAccepts<ConservativeRecord>);-static_assert(!ConservativeVectorAccepts<GC::Ptr<TestCell>>);-static_assert(!ConservativeVectorAccepts<GC::Ref<TestCell>>);-static_assert(!ConservativeVectorAccepts<GC::Ptr<TestCell const>>);-static_assert(!ConservativeVectorAccepts<GC::Ref<TestCell const>>);-static_assert(!ConservativeVectorAccepts<AliasedCellPtr>);-static_assert(!ConservativeVectorAccepts<AliasedCellRef>);-static_assert(!ConservativeVectorAccepts<AliasedCellPtr const>);-static_assert(!ConservativeVectorAccepts<AliasedCellRef volatile>);-static_assert(!ConservativeVectorAccepts<AliasedCellPtr volatile>);-static_assert(!ConservativeVectorAccepts<AliasedCellRef const>);-static_assert(!ConservativeVectorAccepts<AliasedCellPtr const volatile>);-static_assert(!ConservativeVectorAccepts<AliasedCellRef const volatile>);-static_assert(!ConservativeVectorAccepts<AliasedCellPtr&>);-static_assert(!ConservativeVectorAccepts<AliasedCellRef&>);-static_assert(!ConservativeVectorAccepts<AliasedCellPtr const&>);-static_assert(!ConservativeVectorAccepts<AliasedCellRef const&>);-static_assert(!ConservativeVectorAccepts<AliasedCellPtr&&>);-static_assert(!ConservativeVectorAccepts<AliasedCellRef&&>);-class FinalizerObservingCell : public GC::Cell {GC_CELL(FinalizerObservingCell, GC::Cell);GC_DECLARE_ALLOCATOR(FinalizerObservingCell);@@ -100,22 +65,11 @@ TEST_SETUPclass TestVisitor : public GC::Cell::Visitor {virtual void visit_impl(GC::Cell& cell) override { visited_cells.set(&cell); }virtual void visit_impl(ReadonlySpan<GC::NanBoxedValue>) override { }- virtual void visit_possible_values(ReadonlyBytes) override { }public:HashTable<GC::Cell*> visited_cells;};-static bool possible_values_contain(GC::ConservativeVectorBase const& container, GC::Cell* cell)-{- auto target = bit_cast<FlatPtr>(cell);- for (auto value : container.possible_values()) {- if (value == target)- return true;- }- return false;-}-TEST_CASE(root_vector_reports_roots){auto& heap = test_heap();@@ -357,29 +311,6 @@ TEST_CASE(root_vector_of_traced_values_keeps_their_cells_alive)EXPECT(weak_cell);}-TEST_CASE(conservative_vector_adopts_moved_vector)-{- auto& heap = test_heap();- Vector<FlatPtr> vector;-- auto cell = heap.allocate<TestCell>();- vector.append(bit_cast<FlatPtr>(cell.ptr()));- GC::ConservativeVector<FlatPtr> conservative_vector { move(vector) };-- EXPECT(possible_values_contain(conservative_vector, cell.ptr()));-}--TEST_CASE(conservative_vector_reports_possible_values)-{- auto& heap = test_heap();- GC::ConservativeVector<ConservativeRecord> vector;-- auto cell = heap.allocate<TestCell>();- vector.append({ cell, 0x1234 });-- EXPECT(possible_values_contain(vector, cell.ptr()));-}-TEST_CASE(heap_vector_visit_edges_reports_cells){auto& heap = test_heap();diff --git a/Tests/LibGC/TestGCVisitor.cpp b/Tests/LibGC/TestGCVisitor.cppindex 10de44ab8bb..5eadc54fef3 100644--- a/Tests/LibGC/TestGCVisitor.cpp+++ b/Tests/LibGC/TestGCVisitor.cpp@@ -43,7 +43,6 @@ TEST_SETUPclass TestVisitor : public GC::Cell::Visitor {virtual void visit_impl(GC::Cell& cell) override { visited_cells.set(&cell); }virtual void visit_impl(ReadonlySpan<GC::NanBoxedValue> span) override { last_nan_span_size = span.size(); }- virtual void visit_possible_values(ReadonlyBytes) override { }public:HashTable<GC::Cell*> visited_cells;diff --git a/Tests/LibGC/TestMember.cpp b/Tests/LibGC/TestMember.cppindex cb7df807cbc..b386481c90e 100644--- a/Tests/LibGC/TestMember.cpp+++ b/Tests/LibGC/TestMember.cpp@@ -181,7 +181,6 @@ TEST_CASE(members_hash_like_pointers)class TestVisitor : public GC::Cell::Visitor {virtual void visit_impl(GC::Cell& cell) override { visited_cells.append(&cell); }virtual void visit_impl(ReadonlySpan<GC::NanBoxedValue>) override { }- virtual void visit_possible_values(ReadonlyBytes) override { }public:Vector<GC::Cell*> visited_cells;@@ -251,39 +250,6 @@ static NEVER_INLINE GC::Root<GC::Function<size_t()>> make_function_capturing_a_m}));}-// Scans the captures of an AK::Function for cell pointers, as a timer does for its callback.-class CallbackScanningCell final : public GC::Cell {- GC_CELL(CallbackScanningCell, GC::Cell);- GC_DECLARE_ALLOCATOR(CallbackScanningCell);--public:- explicit CallbackScanningCell(AK::Function<size_t()> callback)- : m_callback(move(callback))- {- }-- size_t call() const { return m_callback(); }--private:- virtual void visit_edges(Visitor& visitor) override- {- Base::visit_edges(visitor);- visitor.visit_possible_values(m_callback.raw_capture_range());- }-- AK::Function<size_t()> m_callback;-};--GC_DEFINE_ALLOCATOR(CallbackScanningCell);--// Keeps nothing on the stack that points at the cell the callback captures, other than the root of the scanning cell.-template<typename MakeCallable>-static NEVER_INLINE GC::Root<CallbackScanningCell> make_callback_capturing_a_member(bool& finalized, MakeCallable make_callable)-{- GC::Member<FinalizationTrackingCell> member = test_heap().allocate<FinalizationTrackingCell>(finalized);- return GC::make_root(test_heap().allocate<CallbackScanningCell>(make_callable(member)));-}-static NEVER_INLINE void clobber_the_stack(){u8 volatile scratch[16 * KiB];@@ -305,45 +271,6 @@ TEST_CASE(function_capturing_a_member_keeps_its_cell_alive)EXPECT_NE(function->function()(), 0u);}-TEST_CASE(callback_whose_only_capture_is_a_member_keeps_its_cell_alive)-{- // NB: Static, since the cell outlives the test once nothing holds it anymore.- static bool finalized;- finalized = false;- auto cell = make_callback_capturing_a_member(finalized, [](GC::Member<FinalizationTrackingCell> member) {- auto callable = [member] { return reinterpret_cast<size_t>(member.ptr()); };- static_assert(sizeof(callable) == sizeof(u32));- return callable;- });- clobber_the_stack();-- test_heap().collect_garbage(GC::Heap::CollectionType::CollectGarbage);-- EXPECT(!finalized);- EXPECT_NE(cell->call(), 0u);-}--TEST_CASE(callback_whose_captures_end_in_a_member_keeps_its_cell_alive)-{- // NB: Static, since the cell outlives the test once nothing holds it anymore.- static bool finalized;- finalized = false;- auto cell = make_callback_capturing_a_member(finalized, [](GC::Member<FinalizationTrackingCell> member) {- auto callable = [first = static_cast<u32>(1), second = static_cast<u32>(2), member] {- return reinterpret_cast<size_t>(member.ptr()) + first + second;- };- // NB: The member is past the last whole word of the captures.- static_assert(sizeof(callable) == 3 * sizeof(u32));- return callable;- });- clobber_the_stack();-- test_heap().collect_garbage(GC::Heap::CollectionType::CollectGarbage);-- EXPECT(!finalized);- EXPECT_NE(cell->call(), 0u);-}-// Walks a list of cells through compressed pointers, decoding them against the base copy or against the base exported// from LibGC. The opaque call per cell keeps the compiler from hoisting the base out of the loop, as an ordinary DOM// walk with calls in its body would.