1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 07:27:45 +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:
Idan Horowitz 2021-06-09 20:10:47 +03:00 committed by Linus Groh
parent fb63aeae4d
commit a00d154522
7 changed files with 62 additions and 3 deletions

View file

@ -21,11 +21,13 @@ public:
explicit WeakSet(Object& prototype);
virtual ~WeakSet() override;
HashTable<Object*> const& values() const { return m_values; };
HashTable<Object*>& values() { return m_values; };
HashTable<Cell*> const& values() const { return m_values; };
HashTable<Cell*>& values() { return m_values; };
void remove_sweeped_cells(Badge<Heap>, Vector<Cell*>&);
private:
HashTable<Object*> m_values;
HashTable<Cell*> m_values; // This stores Cell pointers instead of Object pointers to aide with sweeping
};
}