mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:48:11 +00:00
LibJS: Add ConservativeVector<T>
This works very similarly to MarkedVector<T>, but instead of expecting T to be Value or a GC-allocated pointer type, T can be anything. Every pointer-sized value in the vector's storage will be checked during conservative root scanning. In other words, this allows you to put something like this in a ConservativeVector<Foo> and it will be protected from GC: struct Foo { i64 number; Value some_value; GCPtr<Object> some_object; };
This commit is contained in:
parent
cbecd096c2
commit
4bbb0a5c35
8 changed files with 126 additions and 1 deletions
|
@ -369,6 +369,12 @@ __attribute__((no_sanitize("address"))) void Heap::gather_conservative_roots(Has
|
|||
}
|
||||
}
|
||||
|
||||
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 }, min_block_address, max_block_address);
|
||||
}
|
||||
}
|
||||
|
||||
HashTable<HeapBlock*> all_live_heap_blocks;
|
||||
for_each_block([&](auto& block) {
|
||||
all_live_heap_blocks.set(&block);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue