summaryrefslogtreecommitdiffstats
path: root/js/src/gc/WeakMap-inl.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
commit8dd16259287f58f9273002717ec4d27e97127719 (patch)
tree3863e62a53829a84037444beab3abd4ed9dfc7d0 /js/src/gc/WeakMap-inl.h
parentReleasing progress-linux version 126.0.1-1~progress7.99u1. (diff)
downloadfirefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz
firefox-8dd16259287f58f9273002717ec4d27e97127719.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/gc/WeakMap-inl.h')
-rw-r--r--js/src/gc/WeakMap-inl.h36
1 files changed, 28 insertions, 8 deletions
diff --git a/js/src/gc/WeakMap-inl.h b/js/src/gc/WeakMap-inl.h
index d7b5feb5a6..b1e52aacc8 100644
--- a/js/src/gc/WeakMap-inl.h
+++ b/js/src/gc/WeakMap-inl.h
@@ -22,6 +22,7 @@
#include "js/TraceKind.h"
#include "vm/JSContext.h"
+#include "gc/Marking-inl.h"
#include "gc/StableCellHasher-inl.h"
namespace js {
@@ -184,23 +185,24 @@ bool WeakMap<K, V>::markEntry(GCMarker* marker, gc::CellColor mapColor, K& key,
}
if (populateWeakKeysTable) {
+ MOZ_ASSERT(trc->weakMapAction() == JS::WeakMapTraceAction::Expand);
+
// Note that delegateColor >= keyColor because marking a key marks its
// delegate, so we only need to check whether keyColor < mapColor to tell
// this.
-
if (keyColor < mapColor) {
- MOZ_ASSERT(trc->weakMapAction() == JS::WeakMapTraceAction::Expand);
- // The final color of the key is not yet known. Record this weakmap and
- // the lookup key in the list of weak keys. If the key has a delegate,
- // then the lookup key is the delegate (because marking the key will end
- // up marking the delegate and thereby mark the entry.)
+ // The final color of the key is not yet known. Add an edge to the
+ // relevant ephemerons table to ensure that the value will be marked if
+ // the key is marked. If the key has a delegate, also add an edge to
+ // ensure the key is marked if the delegate is marked.
+
gc::TenuredCell* tenuredValue = nullptr;
if (cellValue && cellValue->isTenured()) {
tenuredValue = &cellValue->asTenured();
}
- if (!this->addImplicitEdges(AsMarkColor(mapColor), keyCell, delegate,
- tenuredValue)) {
+ if (!this->addEphemeronEdgesForEntry(AsMarkColor(mapColor), keyCell,
+ delegate, tenuredValue)) {
marker->abortLinearWeakMarking();
}
}
@@ -392,6 +394,24 @@ bool WeakMap<K, V>::checkMarking() const {
}
#endif
+#ifdef JSGC_HASH_TABLE_CHECKS
+template <class K, class V>
+void WeakMap<K, V>::checkAfterMovingGC() const {
+ for (Range r = all(); !r.empty(); r.popFront()) {
+ gc::Cell* key = gc::ToMarkable(r.front().key());
+ gc::Cell* value = gc::ToMarkable(r.front().value());
+ CheckGCThingAfterMovingGC(key);
+ if (!allowKeysInOtherZones()) {
+ Zone* keyZone = key->zoneFromAnyThread();
+ MOZ_RELEASE_ASSERT(keyZone == zone() || keyZone->isAtomsZone());
+ }
+ CheckGCThingAfterMovingGC(value, zone());
+ auto ptr = lookupUnbarriered(r.front().key());
+ MOZ_RELEASE_ASSERT(ptr.found() && &*ptr == &r.front());
+ }
+}
+#endif // JSGC_HASH_TABLE_CHECKS
+
inline HashNumber GetHash(JS::Symbol* sym) { return sym->hash(); }
inline bool HashMatch(JS::Symbol* key, JS::Symbol* lookup) {