mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 10:44:57 +00:00
LibJS: Make the GC marking phase cycle-proof
Don't visit cells that are already marked. This prevents the marking phase from looping forever when two cells refer to each other. Also do the marking directly from the CellVisitor, removing another unnecessary phase of the collector. :^)
This commit is contained in:
parent
70a3e738f5
commit
05c80cac20
5 changed files with 24 additions and 51 deletions
|
@ -48,12 +48,12 @@ void Object::put(String property_name, Value value)
|
|||
m_properties.set(property_name, move(value));
|
||||
}
|
||||
|
||||
void Object::visit_graph(Cell::Visitor& visitor)
|
||||
void Object::visit_children(Cell::Visitor& visitor)
|
||||
{
|
||||
Cell::visit_graph(visitor);
|
||||
Cell::visit_children(visitor);
|
||||
for (auto& it : m_properties) {
|
||||
if (it.value.is_object())
|
||||
it.value.as_object()->visit_graph(visitor);
|
||||
visitor.visit(it.value.as_object());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue