1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-10 18:10:56 +09:00

LibJS: Visit WeakMap's values as long as their keys were not collected

While the WeakMap only holds a weak reference to its keys, their
accompanying values should be kept alive as long as they're accessible.
This commit is contained in:
Idan Horowitz 2021-09-11 19:19:40 +03:00 committed by Andreas Kling
parent 073a1dec16
commit b92871f7ef
Notes: sideshowbarker 2024-07-19 01:59:31 +09:00
2 changed files with 8 additions and 0 deletions

View file

@ -29,4 +29,11 @@ void WeakMap::remove_swept_cells(Badge<Heap>, Span<Cell*> cells)
m_values.remove(cell);
}
void WeakMap::visit_edges(Visitor& visitor)
{
Base::visit_edges(visitor);
for (auto& entry : m_values)
visitor.visit(entry.value);
}
}