summaryrefslogtreecommitdiffstats
path: root/js/src/gc/WeakMap.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
commita90a5cba08fdf6c0ceb95101c275108a152a3aed (patch)
tree532507288f3defd7f4dcf1af49698bcb76034855 /js/src/gc/WeakMap.cpp
parentAdding debian version 126.0.1-1. (diff)
downloadfirefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.tar.xz
firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/gc/WeakMap.cpp')
-rw-r--r--js/src/gc/WeakMap.cpp59
1 files changed, 22 insertions, 37 deletions
diff --git a/js/src/gc/WeakMap.cpp b/js/src/gc/WeakMap.cpp
index 749ea52937..61d6b14e6d 100644
--- a/js/src/gc/WeakMap.cpp
+++ b/js/src/gc/WeakMap.cpp
@@ -72,42 +72,27 @@ bool WeakMapBase::markMap(MarkColor markColor) {
}
}
-bool WeakMapBase::addImplicitEdges(MarkColor mapColor, Cell* key,
- Cell* delegate, TenuredCell* value) {
- if (delegate) {
- return addEphemeronTableEntries(mapColor, delegate, key, value);
+bool WeakMapBase::addEphemeronEdgesForEntry(MarkColor mapColor, Cell* key,
+ Cell* delegate,
+ TenuredCell* value) {
+ if (delegate && !addEphemeronEdge(mapColor, delegate, key)) {
+ return false;
}
- if (value) {
- return addEphemeronTableEntries(mapColor, key, value, nullptr);
+ if (value && !addEphemeronEdge(mapColor, key, value)) {
+ return false;
}
return true;
}
-bool WeakMapBase::addEphemeronTableEntries(MarkColor mapColor, gc::Cell* key,
- gc::Cell* value1,
- gc::Cell* maybeValue2) {
- // Add implicit edges from |key| to |value1| and |maybeValue2| if supplied.
- //
- // Note the key and values do not necessarily correspond to the weak map
- // entry's key and value at this point.
-
- auto& edgeTable = key->zone()->gcEphemeronEdges(key);
- auto* ptr = edgeTable.getOrAdd(key);
- if (!ptr) {
- return false;
- }
-
- if (!ptr->value.emplaceBack(mapColor, value1)) {
- return false;
- }
-
- if (maybeValue2 && !ptr->value.emplaceBack(mapColor, maybeValue2)) {
- return false;
- }
+bool WeakMapBase::addEphemeronEdge(MarkColor color, gc::Cell* src,
+ gc::Cell* dst) {
+ // Add an implicit edge from |src| to |dst|.
- return true;
+ auto& edgeTable = src->zone()->gcEphemeronEdges(src);
+ auto* ptr = edgeTable.getOrAdd(src);
+ return ptr && ptr->value.emplaceBack(color, dst);
}
#if defined(JS_GC_ZEAL) || defined(DEBUG)
@@ -126,6 +111,15 @@ bool WeakMapBase::checkMarkingForZone(JS::Zone* zone) {
}
#endif
+#ifdef JSGC_HASH_TABLE_CHECKS
+/* static */
+void WeakMapBase::checkWeakMapsAfterMovingGC(JS::Zone* zone) {
+ for (WeakMapBase* map : zone->gcWeakMapList()) {
+ map->checkAfterMovingGC();
+ }
+}
+#endif
+
bool WeakMapBase::markZoneIteratively(JS::Zone* zone, GCMarker* marker) {
bool markedAny = false;
for (WeakMapBase* m : zone->gcWeakMapList()) {
@@ -228,12 +222,3 @@ void ObjectWeakMap::trace(JSTracer* trc) { map.trace(trc); }
size_t ObjectWeakMap::sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) {
return map.shallowSizeOfExcludingThis(mallocSizeOf);
}
-
-#ifdef JSGC_HASH_TABLE_CHECKS
-void ObjectWeakMap::checkAfterMovingGC() {
- for (ObjectValueWeakMap::Range r = map.all(); !r.empty(); r.popFront()) {
- CheckGCThingAfterMovingGC(r.front().key().get());
- CheckGCThingAfterMovingGC(&r.front().value().toObject());
- }
-}
-#endif // JSGC_HASH_TABLE_CHECKS