mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:07:34 +00:00
LibJS: Notify WeakSets when heap cells are sweeped
This is an implementation of the following optional optimization: https://tc39.es/ecma262/#sec-weakref-execution
This commit is contained in:
parent
fb63aeae4d
commit
a00d154522
7 changed files with 62 additions and 3 deletions
|
@ -16,10 +16,18 @@ WeakSet* WeakSet::create(GlobalObject& global_object)
|
|||
WeakSet::WeakSet(Object& prototype)
|
||||
: Object(prototype)
|
||||
{
|
||||
heap().did_create_weak_set({}, *this);
|
||||
}
|
||||
|
||||
WeakSet::~WeakSet()
|
||||
{
|
||||
heap().did_destroy_weak_set({}, *this);
|
||||
}
|
||||
|
||||
void WeakSet::remove_sweeped_cells(Badge<Heap>, Vector<Cell*>& cells)
|
||||
{
|
||||
for (auto* cell : cells)
|
||||
m_values.remove(cell);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue