Truly independent web browser
LibGC: Scan both halves of each word for compressed cell pointers
Andreas Kling0217c0a0f43f
diff --git a/Libraries/LibGC/CompressedPointer.h b/Libraries/LibGC/CompressedPointer.hnew file mode 100644index 00000000000..7600fbedb1f--- /dev/null+++ b/Libraries/LibGC/CompressedPointer.h@@ -0,0 +1,54 @@+/*+ * Copyright (c) 2026-present, the Ladybird developers.+ *+ * SPDX-License-Identifier: BSD-2-Clause+ */++#pragma once++#include <AK/Assertions.h>+#include <AK/Platform.h>+#include <AK/Types.h>+#include <LibGC/HeapRegion.h>++namespace GC {++// A compressed cell pointer is the cell's offset into the heap region in units of the 8-byte cell alignment. A u32 then+// covers the whole region, so decoding never leaves it whatever the 32 bits are. Null compresses to 0.+static constexpr u32 COMPRESSED_POINTER_SHIFT = 3;+static_assert((static_cast<u64>(1) << (32 + COMPRESSED_POINTER_SHIFT)) == HEAP_REGION_SIZE);++// Every compressed pointer below this decodes into the low guard, so it is never a cell.+static constexpr u32 MIN_COMPRESSED_CELL_POINTER = HEAP_REGION_LOW_GUARD_SIZE >> COMPRESSED_POINTER_SHIFT;++ALWAYS_INLINE u32 compress(void const* cell)+{+ if (!cell)+ return 0;+ auto offset = reinterpret_cast<FlatPtr>(cell) - js_heap_region_base;+ ASSERT(offset < HEAP_REGION_SIZE);+ ASSERT(offset % (1 << COMPRESSED_POINTER_SHIFT) == 0);+ return static_cast<u32>(offset >> COMPRESSED_POINTER_SHIFT);+}++// Decodes a compressed pointer that is not null.+//+// Makes the compressed pointer live up to this point, and the decoded address from this point on. The conservative+// stack scan recognizes a cell by its address or by its compressed pointer in either half of a word, but not by its+// unshifted offset, which the compiler could otherwise keep instead while either is held across an allocation.+ALWAYS_INLINE FlatPtr decompress_nonnull(u32 compressed, FlatPtr heap_region_base = js_heap_region_base)+{+ auto address = heap_region_base + (static_cast<FlatPtr>(compressed) << COMPRESSED_POINTER_SHIFT);+ // NB: The assembly is empty. It only has the compiler put the compressed pointer and the address in registers here.+ asm("" : "+r"(address) : "r"(compressed));+ return address;+}++ALWAYS_INLINE FlatPtr decompress(u32 compressed)+{+ if (!compressed)+ return 0;+ return decompress_nonnull(compressed);+}++}diff --git a/Libraries/LibGC/Heap.cpp b/Libraries/LibGC/Heap.cppindex 4756839644b..ac2f6316eeb 100644--- a/Libraries/LibGC/Heap.cpp+++ b/Libraries/LibGC/Heap.cpp@@ -29,6 +29,7 @@#include <LibCore/Timer.h>#include <LibGC/BlockAllocator.h>#include <LibGC/CellAllocator.h>+#include <LibGC/CompressedPointer.h>#include <LibGC/Heap.h>#include <LibGC/HeapAccess.h>#include <LibGC/HeapBlock.h>@@ -440,34 +441,79 @@ void Heap::update_gc_bytes_threshold(size_t live_cell_bytes, size_t live_externam_gc_bytes_threshold = max(next_gc_bytes_threshold.value(), GC_MIN_BYTES_THRESHOLD);}-static void add_possible_value(HashMap<FlatPtr, HeapRoot>& possible_pointers, FlatPtr data, HeapRoot origin, FlatPtr heap_region_start, FlatPtr heap_region_end)+// The part of the heap region that can hold cells, read once per scan.+struct PossiblePointerBounds {+ static PossiblePointerBounds current()+ {+ return { BlockAllocator::heap_region_start(), BlockAllocator::heap_region_committed_end() };+ }++ FlatPtr heap_region_start { 0 };+ FlatPtr cells_end { 0 };+};++struct PossiblePointers {+ // Addresses taken from whole words, as a raw pointer or as a NaN-boxed cell value. They may point into a cell.+ HashMap<FlatPtr, HeapRoot> pointers;+ // Addresses decoded from either 32-bit half of a word, as a compressed cell pointer. Compressed pointers only ever+ // point at the start of a cell, so these do too.+ HashMap<FlatPtr, HeapRoot> compressed_pointers;+};++static ALWAYS_INLINE void add_possible_compressed_pointer(PossiblePointers& possible_pointers, u32 compressed, HeapRoot const& origin, PossiblePointerBounds const& bounds)+{+ // OPTIMIZATION: Most halves are small integers, either half of a pointer, or either half of a NaN-boxed value. Those+ // decode into the low guard or above everything committed, so two compares reject them before any+ // hashing.+ if (compressed < MIN_COMPRESSED_CELL_POINTER)+ return;+ auto possible_pointer = decompress_nonnull(compressed, bounds.heap_region_start);+ if (possible_pointer >= bounds.cells_end)+ return;+ possible_pointers.compressed_pointers.set(possible_pointer, origin);+}++static void add_possible_value(PossiblePointers& possible_pointers, FlatPtr data, HeapRoot origin, PossiblePointerBounds const& bounds){+ // A compiler may keep only a compressed cell pointer alive across a collection, in a register or in a spill slot that+ // shares a word with other data, so either half of a word may be one.+ add_possible_compressed_pointer(possible_pointers, static_cast<u32>(data), origin, bounds);+ add_possible_compressed_pointer(possible_pointers, static_cast<u32>(data >> 32), origin, bounds);+// Because NanBoxedValue stores heap offsets in the payload, decode// pointer-backed values relative to the heap region before checking the// resulting address.FlatPtr possible_pointer;if ((data & SHIFTED_IS_CELL_PATTERN) == SHIFTED_IS_CELL_PATTERN)- possible_pointer = heap_region_start + (data & HEAP_REGION_OFFSET_MASK);+ possible_pointer = bounds.heap_region_start + (data & HEAP_REGION_OFFSET_MASK);elsepossible_pointer = data;- if (possible_pointer < heap_region_start || possible_pointer >= heap_region_end)+ if (possible_pointer < bounds.heap_region_start || possible_pointer >= bounds.cells_end)return;- possible_pointers.set(possible_pointer, move(origin));+ possible_pointers.pointers.set(possible_pointer, move(origin));}template<typename Callback>-static void for_each_cell_among_possible_pointers(HashTable<HeapBlock*> const& all_live_heap_blocks, HashMap<FlatPtr, HeapRoot>& possible_pointers, Callback callback)+static void for_each_cell_among_possible_pointers(HashTable<HeapBlock*> const& all_live_heap_blocks, PossiblePointers& possible_pointers, Callback callback){- for (auto possible_pointer : possible_pointers.keys()) {- if (!possible_pointer)- continue;- auto* possible_heap_block = HeapBlock::from_cell(reinterpret_cast<Cell const*>(possible_pointer));- if (!all_live_heap_blocks.contains(possible_heap_block))- continue;- if (auto* cell = possible_heap_block->cell_from_possible_pointer(possible_pointer)) {- callback(cell, possible_pointer);+ auto visit = [&](HashMap<FlatPtr, HeapRoot>& candidates, bool must_be_cell_start) {+ for (auto possible_pointer : candidates.keys()) {+ if (!possible_pointer)+ continue;+ auto* possible_heap_block = HeapBlock::from_cell(reinterpret_cast<Cell const*>(possible_pointer));+ if (!all_live_heap_blocks.contains(possible_heap_block))+ continue;+ auto* cell = possible_heap_block->cell_from_possible_pointer(possible_pointer);+ if (!cell)+ continue;+ if (must_be_cell_start && reinterpret_cast<FlatPtr>(cell) != possible_pointer)+ continue;+ callback(cell, candidates, possible_pointer);}- }+ };+ // NB: The whole-word candidates go last, so a cell that both find is attributed to the whole word.+ visit(possible_pointers.compressed_pointers, true);+ visit(possible_pointers.pointers, false);}class GraphConstructorVisitor final : public Cell::Visitor {@@ -475,8 +521,7 @@ public:explicit GraphConstructorVisitor(Heap& heap, HashMap<Cell*, HeapRoot> const& roots): m_heap(heap){- m_heap_region_start = BlockAllocator::heap_region_start();- m_heap_region_end = BlockAllocator::heap_region_end();+ m_possible_pointer_bounds = PossiblePointerBounds::current();m_work_queue.ensure_capacity(roots.size());for (auto& [root, root_origin] : roots) {@@ -507,13 +552,13 @@ public:virtual void visit_possible_values(ReadonlyBytes bytes) override{- HashMap<FlatPtr, HeapRoot> possible_pointers;+ PossiblePointers possible_pointers;auto* raw_pointer_sized_values = reinterpret_cast<FlatPtr const*>(bytes.data());for (size_t i = 0; i < (bytes.size() / sizeof(FlatPtr)); ++i)- add_possible_value(possible_pointers, raw_pointer_sized_values[i], HeapRoot { .type = HeapRoot::Type::HeapFunctionCapturedPointer }, m_heap_region_start, m_heap_region_end);+ add_possible_value(possible_pointers, raw_pointer_sized_values[i], HeapRoot { .type = HeapRoot::Type::HeapFunctionCapturedPointer }, m_possible_pointer_bounds);- for_each_cell_among_possible_pointers(m_heap.m_live_heap_blocks, possible_pointers, [&](Cell* cell, FlatPtr) {+ 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;@@ -615,8 +660,7 @@ private:HashMap<FlatPtr, GraphNode> m_graph;Heap& m_heap;- FlatPtr m_heap_region_start;- FlatPtr m_heap_region_end;+ PossiblePointerBounds m_possible_pointer_bounds;};NO_SANITIZE_ADDRESS AK::JsonObject Heap::dump_graph()@@ -1080,7 +1124,7 @@ void Heap::gather_roots(ConservativeScanOrigin const& origin, HashMap<Cell*, Hea}#ifdef HAS_ADDRESS_SANITIZER-NO_SANITIZE_ADDRESS void Heap::gather_asan_fake_stack_roots(HashMap<FlatPtr, HeapRoot>& possible_pointers, FlatPtr addr, FlatPtr heap_region_start, FlatPtr heap_region_end, FlatPtr stack_reference, FlatPtr stack_top)+NO_SANITIZE_ADDRESS static void gather_asan_fake_stack_roots(PossiblePointers& possible_pointers, FlatPtr addr, PossiblePointerBounds const& bounds, FlatPtr stack_reference, FlatPtr stack_top){void* begin = nullptr;void* end = nullptr;@@ -1099,11 +1143,11 @@ NO_SANITIZE_ADDRESS void Heap::gather_asan_fake_stack_roots(HashMap<FlatPtr, Heavoid const* real_address = *real_stack_addr;if (real_address == nullptr)continue;- add_possible_value(possible_pointers, reinterpret_cast<FlatPtr>(real_address), HeapRoot { .type = HeapRoot::Type::StackPointer }, heap_region_start, heap_region_end);+ add_possible_value(possible_pointers, reinterpret_cast<FlatPtr>(real_address), HeapRoot { .type = HeapRoot::Type::StackPointer }, bounds);}}#else-void Heap::gather_asan_fake_stack_roots(HashMap<FlatPtr, HeapRoot>&, FlatPtr, FlatPtr, FlatPtr, FlatPtr, FlatPtr)+static void gather_asan_fake_stack_roots(PossiblePointers&, FlatPtr, PossiblePointerBounds const&, FlatPtr, FlatPtr){}#endif@@ -1112,10 +1156,8 @@ NO_SANITIZE_ADDRESS void Heap::gather_conservative_roots(ConservativeScanOrigin{dbgln_if(HEAP_DEBUG, "gather_conservative_roots:");- HashMap<FlatPtr, HeapRoot> possible_pointers;-- auto heap_region_start = BlockAllocator::heap_region_start();- auto heap_region_end = BlockAllocator::heap_region_end();+ PossiblePointers possible_pointers;+ auto bounds = PossiblePointerBounds::current();// The scan covers the entry point's frame and its callers; the collection's own frames below the floor are left out.FlatPtr own_frame;@@ -1132,8 +1174,8 @@ NO_SANITIZE_ADDRESS void Heap::gather_conservative_roots(ConservativeScanOrigin{ScopedPhaseTimer timer { g_recording_phase_timings, g_phase_timings.conservative_register_scan_us };for (auto register_value : origin.callee_saved_registers) {- add_possible_value(possible_pointers, register_value, HeapRoot { .type = HeapRoot::Type::RegisterPointer }, heap_region_start, heap_region_end);- gather_asan_fake_stack_roots(possible_pointers, register_value, heap_region_start, heap_region_end, stack_reference, stack_top);+ add_possible_value(possible_pointers, register_value, HeapRoot { .type = HeapRoot::Type::RegisterPointer }, bounds);+ gather_asan_fake_stack_roots(possible_pointers, register_value, bounds, stack_reference, stack_top);}}@@ -1236,8 +1278,8 @@ NO_SANITIZE_ADDRESS void Heap::gather_conservative_roots(ConservativeScanOrigincontinue;}auto data = *reinterpret_cast<FlatPtr*>(stack_address);- add_possible_value(possible_pointers, data, HeapRoot { .type = HeapRoot::Type::StackPointer, .stack_frame_index = frame_index_for_stack_address(stack_address) }, heap_region_start, heap_region_end);- gather_asan_fake_stack_roots(possible_pointers, data, heap_region_start, heap_region_end, stack_reference, stack_top);+ add_possible_value(possible_pointers, data, HeapRoot { .type = HeapRoot::Type::StackPointer, .stack_frame_index = frame_index_for_stack_address(stack_address) }, bounds);+ gather_asan_fake_stack_roots(possible_pointers, data, bounds, stack_reference, stack_top);}}@@ -1245,36 +1287,36 @@ NO_SANITIZE_ADDRESS void Heap::gather_conservative_roots(ConservativeScanOriginScopedPhaseTimer 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 }, heap_region_start, heap_region_end);+ add_possible_value(possible_pointers, possible_value, HeapRoot { .type = HeapRoot::Type::ConservativeVector }, bounds);}}for (auto& provider : m_conservative_range_providers) {provider.for_each_conservative_range([&](ReadonlySpan<FlatPtr> range) {for (auto possible_value : range)- add_possible_value(possible_pointers, possible_value, HeapRoot { .type = HeapRoot::Type::ConservativeVector }, heap_region_start, heap_region_end);+ add_possible_value(possible_pointers, possible_value, HeapRoot { .type = HeapRoot::Type::ConservativeVector }, bounds);});}}for (auto& hash_map : m_conservative_hash_maps) {hash_map.for_each_possible_value([&](FlatPtr possible_value) {- add_possible_value(possible_pointers, possible_value, HeapRoot { .type = HeapRoot::Type::ConservativeHashMap }, heap_region_start, heap_region_end);+ add_possible_value(possible_pointers, possible_value, HeapRoot { .type = HeapRoot::Type::ConservativeHashMap }, bounds);});}for (auto& hash_table : m_conservative_hash_tables) {hash_table.for_each_possible_value([&](FlatPtr possible_value) {- add_possible_value(possible_pointers, possible_value, HeapRoot { .type = HeapRoot::Type::ConservativeHashTable }, heap_region_start, heap_region_end);+ add_possible_value(possible_pointers, possible_value, HeapRoot { .type = HeapRoot::Type::ConservativeHashTable }, 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, FlatPtr possible_pointer) {+ for_each_cell_among_possible_pointers(m_live_heap_blocks, possible_pointers, [&](Cell* cell, HashMap<FlatPtr, HeapRoot>& candidates, FlatPtr possible_pointer) {if (cell->state() == Cell::State::Live) {dbgln_if(HEAP_DEBUG, " ?-> {}", (void const*)cell);- roots.set(cell, *possible_pointers.get(possible_pointer));+ roots.set(cell, *candidates.get(possible_pointer));} else {dbgln_if(HEAP_DEBUG, " #-> {}", (void const*)cell);}@@ -1288,8 +1330,7 @@ public:explicit MarkingVisitor(ReadonlySpan<Heap* const> domain, HashMap<Cell*, HeapRoot> const& roots): m_domain(domain){- m_heap_region_start = BlockAllocator::heap_region_start();- m_heap_region_end = BlockAllocator::heap_region_end();+ m_possible_pointer_bounds = PossiblePointerBounds::current();for (auto* root : roots.keys()) {visit(root);}@@ -1340,14 +1381,14 @@ public:virtual void visit_possible_values(ReadonlyBytes bytes) override{- HashMap<FlatPtr, HeapRoot> possible_pointers;+ PossiblePointers possible_pointers;auto* raw_pointer_sized_values = reinterpret_cast<FlatPtr const*>(bytes.data());for (size_t i = 0; i < (bytes.size() / sizeof(FlatPtr)); ++i)- add_possible_value(possible_pointers, raw_pointer_sized_values[i], HeapRoot { .type = HeapRoot::Type::HeapFunctionCapturedPointer }, m_heap_region_start, m_heap_region_end);+ add_possible_value(possible_pointers, raw_pointer_sized_values[i], HeapRoot { .type = HeapRoot::Type::HeapFunctionCapturedPointer }, m_possible_pointer_bounds);for (auto* heap : m_domain) {- for_each_cell_among_possible_pointers(heap->m_live_heap_blocks, possible_pointers, [&](Cell* cell, FlatPtr) {+ 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)@@ -1403,8 +1444,7 @@ private:ReadonlySpan<Heap* const> m_domain;Vector<Ref<Cell>> m_work_queue;Vector<Ephemeron> m_pending_ephemerons;- FlatPtr m_heap_region_start;- FlatPtr m_heap_region_end;+ 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 54804ef3bd2..fcc3bc4f376 100644--- a/Libraries/LibGC/Heap.h+++ b/Libraries/LibGC/Heap.h@@ -251,7 +251,6 @@ private:void clear_weak_pointers_to_dead_cells(bool report);void run_post_mark_phases(bool report);void gather_conservative_roots(ConservativeScanOrigin const&, HashMap<Cell*, HeapRoot>&, Vector<StackFrameInfo>* out_stack_frames = nullptr);- void gather_asan_fake_stack_roots(HashMap<FlatPtr, HeapRoot>&, FlatPtr, FlatPtr heap_region_start, FlatPtr heap_region_end, FlatPtr stack_reference, FlatPtr stack_top);void mark_live_cells(HashMap<Cell*, HeapRoot>& roots);void finalize_unmarked_cells();void sweep_dead_cells(bool print_report, Core::ElapsedTimer const&);diff --git a/Tests/LibGC/CMakeLists.txt b/Tests/LibGC/CMakeLists.txtindex 9348c3d0c2a..4122e550bfa 100644--- a/Tests/LibGC/CMakeLists.txt+++ b/Tests/LibGC/CMakeLists.txt@@ -2,6 +2,7 @@ ladybird_test_suite(LibGC)set(TEST_SOURCESTestBlockAllocator.cpp+ TestCompressedPointer.cppTestExternalEntityTable.cppTestGCContainers.cppTestGCEphemeron.cppdiff --git a/Tests/LibGC/TestCompressedPointer.cpp b/Tests/LibGC/TestCompressedPointer.cppnew file mode 100644index 00000000000..446a34cc18b--- /dev/null+++ b/Tests/LibGC/TestCompressedPointer.cpp@@ -0,0 +1,142 @@+/*+ * Copyright (c) 2026-present, the Ladybird developers.+ *+ * SPDX-License-Identifier: BSD-2-Clause+ */++#include <AK/NeverDestroyed.h>+#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>+#include <LibGC/WeakInlines.h>+#include <LibTest/TestCase.h>++namespace {++class TestCell final : public GC::Cell {+ GC_CELL(TestCell, GC::Cell);+ GC_DECLARE_ALLOCATOR(TestCell);++ u8 m_padding[32] {};+};++GC_DEFINE_ALLOCATOR(TestCell);++static GC::Heap& test_heap()+{+ static AK::NeverDestroyed<GC::Heap> heap([](auto&) { });+ return *heap;+}++TEST_SETUP+{+ GC::Heap::set_default_heap_for_testing(test_heap());+}++TEST_CASE(compressed_pointer_round_trips)+{+ auto cell = test_heap().allocate<TestCell>();+ auto compressed = GC::compress(cell.ptr());++ EXPECT(compressed >= GC::MIN_COMPRESSED_CELL_POINTER);+ EXPECT_EQ(GC::decompress(compressed), reinterpret_cast<FlatPtr>(cell.ptr()));+ EXPECT_EQ(GC::decompress_nonnull(compressed), reinterpret_cast<FlatPtr>(cell.ptr()));+}++TEST_CASE(null_compresses_to_zero)+{+ EXPECT_EQ(GC::compress(nullptr), 0u);+ EXPECT_EQ(GC::decompress(0), 0u);+}++TEST_CASE(every_compressed_pointer_decodes_inside_the_heap_region)+{+ auto start = js_heap_region_base;+ for (u32 compressed : { 1u, GC::MIN_COMPRESSED_CELL_POINTER, 0x8000'0000u, 0xffff'ffffu }) {+ auto address = GC::decompress_nonnull(compressed);+ EXPECT(address >= start);+ EXPECT(address + sizeof(FlatPtr) <= start + GC::HEAP_REGION_SIZE);+ }+}++using MakeWord = u64 (*)(u32 compressed);++// Allocates a cell that nothing refers to but the word made from its compressed pointer.+static NEVER_INLINE void allocate_cell_into_word(GC::Weak<TestCell>& weak_cell, u64 volatile& word, MakeWord make_word)+{+ auto cell = test_heap().allocate<TestCell>();+ weak_cell = cell.ptr();+ word = make_word(GC::compress(cell.ptr()));+}++// Keeps a cell alive through the given word only, then drops the word and collects again.+static void expect_word_keeps_cell_alive(MakeWord make_word)+{+ auto& heap = test_heap();+ GC::Weak<TestCell> weak_cell;+ u64 volatile word = 0;+ allocate_cell_into_word(weak_cell, word, make_word);++ GC::scrub_stack_for_testing();+ heap.collect_garbage();+ EXPECT(weak_cell);++ word = 0;+ GC::scrub_stack_for_testing();+ heap.collect_garbage(GC::Heap::CollectionType::CollectEverything);+ EXPECT(!weak_cell);+}++TEST_CASE(conservative_scanner_finds_compressed_pointer_in_low_half)+{+ expect_word_keeps_cell_alive([](u32 compressed) -> u64 { return 0xdead'beef'0000'0000ULL | compressed; });+}++TEST_CASE(conservative_scanner_finds_compressed_pointer_in_high_half)+{+ expect_word_keeps_cell_alive([](u32 compressed) -> u64 { return (static_cast<u64>(compressed) << 32) | 0x1234; });+}++TEST_CASE(conservative_scanner_ignores_compressed_pointer_into_a_cell)+{+ auto& heap = test_heap();+ GC::Weak<TestCell> weak_cell;+ u64 volatile word = 0;+ // One unit past the cell's start points into the cell, which no compressed pointer does.+ allocate_cell_into_word(weak_cell, word, [](u32 compressed) -> u64 { return compressed + 1; });++ GC::scrub_stack_for_testing();+ heap.collect_garbage();+ EXPECT(!weak_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);+}++}