LibJS: Do not allocate in Set's constructor

We are currently allocating in Set's constructor to create the set's
underlying Map. This can cause GC to occur before the member is actually
initialized, thus we will crash in Set::visit_edges trying to visit a
member that does not exist.

Instead, create the Map in Set::initialize, where we can allocate. Also
change Map to be stored as a normal JS heap-allocated object, rather
than as a stack variable.
This commit is contained in:
Timothy Flynn 2022-11-30 09:18:27 -05:00 committed by Tim Flynn
commit c0952e3670
Notes: sideshowbarker 2024-07-17 03:49:40 +09:00
3 changed files with 16 additions and 14 deletions

View file

@ -19,9 +19,6 @@ namespace JS {
class Map : public Object {
JS_OBJECT(Map, Object);
// NOTE: This awkwardness is due to Set using a Map internally.
friend class Set;
public:
static Map* create(Realm&);