summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-06-09 18:01:06 +0300
committerLinus Groh <mail@linusgroh.de>2021-06-09 17:05:53 +0100
commitad0e3c0e548070554f92367721303ac1dc16dbfc (patch)
tree2045524adcfeea9abb54e0c7090d0025d50ebab4 /Userland/Libraries/LibJS
parent6a0d1fa2598e4546ee121331a71241d519627979 (diff)
downloadserenity-ad0e3c0e548070554f92367721303ac1dc16dbfc.zip
LibJS: Mark heap cell values stored in Set instances
This makes sure they dont get garbage collected while stored in a Set.
Diffstat (limited to 'Userland/Libraries/LibJS')
-rw-r--r--Userland/Libraries/LibJS/Runtime/Set.cpp7
-rw-r--r--Userland/Libraries/LibJS/Runtime/Set.h2
2 files changed, 9 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Set.cpp b/Userland/Libraries/LibJS/Runtime/Set.cpp
index f0cc7be803..4cb42f215f 100644
--- a/Userland/Libraries/LibJS/Runtime/Set.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Set.cpp
@@ -34,4 +34,11 @@ Set* Set::typed_this(VM& vm, GlobalObject& global_object)
return static_cast<Set*>(this_object);
}
+void Set::visit_edges(Cell::Visitor& visitor)
+{
+ Object::visit_edges(visitor);
+ for (auto& value : m_values)
+ visitor.visit(value);
+}
+
}
diff --git a/Userland/Libraries/LibJS/Runtime/Set.h b/Userland/Libraries/LibJS/Runtime/Set.h
index 289d361c03..59ac8ace4c 100644
--- a/Userland/Libraries/LibJS/Runtime/Set.h
+++ b/Userland/Libraries/LibJS/Runtime/Set.h
@@ -47,6 +47,8 @@ public:
HashTable<Value, ValueTraits>& values() { return m_values; };
private:
+ virtual void visit_edges(Visitor& visitor) override;
+
HashTable<Value, ValueTraits> m_values; // FIXME: Replace with a HashTable that maintains a linked list of insertion order for correct iteration order
};