diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2021-06-09 20:10:47 +0300 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-06-09 21:52:25 +0100 |
commit | a00d154522eeed0b2976827be5dd91500e5a45cf (patch) | |
tree | 08f3fdc376dda75c9a83a4a082e8b31f769472c5 /Userland/Libraries/LibJS/Runtime/WeakSet.cpp | |
parent | fb63aeae4d7c2b18833837cc54509f6627792af9 (diff) | |
download | serenity-a00d154522eeed0b2976827be5dd91500e5a45cf.zip |
LibJS: Notify WeakSets when heap cells are sweeped
This is an implementation of the following optional optimization:
https://tc39.es/ecma262/#sec-weakref-execution
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/WeakSet.cpp')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/WeakSet.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/WeakSet.cpp b/Userland/Libraries/LibJS/Runtime/WeakSet.cpp index 50bf41c0ba..ff64c0858d 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakSet.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakSet.cpp @@ -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); } } |