summaryrefslogtreecommitdiffstats
path: root/js/src/gc/Zone.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/gc/Zone.cpp')
-rw-r--r--js/src/gc/Zone.cpp88
1 files changed, 39 insertions, 49 deletions
diff --git a/js/src/gc/Zone.cpp b/js/src/gc/Zone.cpp
index 6437f6f4c3..13324d7e43 100644
--- a/js/src/gc/Zone.cpp
+++ b/js/src/gc/Zone.cpp
@@ -27,6 +27,7 @@
#include "gc/GC-inl.h"
#include "gc/Marking-inl.h"
#include "gc/Nursery-inl.h"
+#include "gc/StableCellHasher-inl.h"
#include "gc/WeakMap-inl.h"
#include "vm/JSScript-inl.h"
#include "vm/Realm-inl.h"
@@ -367,17 +368,12 @@ void Zone::checkAllCrossCompartmentWrappersAfterMovingGC() {
}
void Zone::checkStringWrappersAfterMovingGC() {
- for (StringWrapperMap::Enum e(crossZoneStringWrappers()); !e.empty();
- e.popFront()) {
- // Assert that the postbarriers have worked and that nothing is left in the
- // wrapper map that points into the nursery, and that the hash table entries
- // are discoverable.
- auto key = e.front().key();
- CheckGCThingAfterMovingGC(key.get());
-
- auto ptr = crossZoneStringWrappers().lookup(key);
- MOZ_RELEASE_ASSERT(ptr.found() && &*ptr == &e.front());
- }
+ CheckTableAfterMovingGC(crossZoneStringWrappers(), [this](const auto& entry) {
+ JSString* key = entry.key().get();
+ CheckGCThingAfterMovingGC(key); // Keys may be in a different zone.
+ CheckGCThingAfterMovingGC(entry.value().unbarrieredGet(), this);
+ return key;
+ });
}
#endif
@@ -546,25 +542,24 @@ void JS::Zone::traceWeakJitScripts(JSTracer* trc) {
void JS::Zone::beforeClearDelegateInternal(JSObject* wrapper,
JSObject* delegate) {
+ // 'delegate' is no longer the delegate of 'wrapper'.
MOZ_ASSERT(js::gc::detail::GetDelegate(wrapper) == delegate);
MOZ_ASSERT(needsIncrementalBarrier());
MOZ_ASSERT(!RuntimeFromMainThreadIsHeapMajorCollecting(this));
- runtimeFromMainThread()->gc.marker().severWeakDelegate(wrapper, delegate);
-}
-void JS::Zone::afterAddDelegateInternal(JSObject* wrapper) {
- MOZ_ASSERT(!RuntimeFromMainThreadIsHeapMajorCollecting(this));
- JSObject* delegate = js::gc::detail::GetDelegate(wrapper);
- if (delegate) {
- runtimeFromMainThread()->gc.marker().restoreWeakDelegate(wrapper, delegate);
+ // If |wrapper| might be a key in a weak map, trigger a barrier to account for
+ // the removal of the automatically added edge from delegate to wrapper.
+ if (HasUniqueId(wrapper)) {
+ PreWriteBarrier(wrapper);
}
}
#ifdef JSGC_HASH_TABLE_CHECKS
void JS::Zone::checkUniqueIdTableAfterMovingGC() {
- for (auto r = uniqueIds().all(); !r.empty(); r.popFront()) {
- js::gc::CheckGCThingAfterMovingGC(r.front().key());
- }
+ CheckTableAfterMovingGC(uniqueIds(), [this](const auto& entry) {
+ js::gc::CheckGCThingAfterMovingGC(entry.key(), this);
+ return entry.key();
+ });
}
#endif
@@ -862,47 +857,42 @@ void Zone::fixupScriptMapsAfterMovingGC(JSTracer* trc) {
#ifdef JSGC_HASH_TABLE_CHECKS
void Zone::checkScriptMapsAfterMovingGC() {
+ // |debugScriptMap| is checked automatically because it is s a WeakMap.
+
if (scriptCountsMap) {
- for (auto r = scriptCountsMap->all(); !r.empty(); r.popFront()) {
- BaseScript* script = r.front().key();
- MOZ_ASSERT(script->zone() == this);
- CheckGCThingAfterMovingGC(script);
- auto ptr = scriptCountsMap->lookup(script);
- MOZ_RELEASE_ASSERT(ptr.found() && &*ptr == &r.front());
- }
+ CheckTableAfterMovingGC(*scriptCountsMap, [this](const auto& entry) {
+ BaseScript* script = entry.key();
+ CheckGCThingAfterMovingGC(script, this);
+ return script;
+ });
}
if (scriptLCovMap) {
- for (auto r = scriptLCovMap->all(); !r.empty(); r.popFront()) {
- BaseScript* script = r.front().key();
- MOZ_ASSERT(script->zone() == this);
- CheckGCThingAfterMovingGC(script);
- auto ptr = scriptLCovMap->lookup(script);
- MOZ_RELEASE_ASSERT(ptr.found() && &*ptr == &r.front());
- }
+ CheckTableAfterMovingGC(*scriptLCovMap, [this](const auto& entry) {
+ BaseScript* script = entry.key();
+ CheckGCThingAfterMovingGC(script, this);
+ return script;
+ });
}
# ifdef MOZ_VTUNE
if (scriptVTuneIdMap) {
- for (auto r = scriptVTuneIdMap->all(); !r.empty(); r.popFront()) {
- BaseScript* script = r.front().key();
- MOZ_ASSERT(script->zone() == this);
- CheckGCThingAfterMovingGC(script);
- auto ptr = scriptVTuneIdMap->lookup(script);
- MOZ_RELEASE_ASSERT(ptr.found() && &*ptr == &r.front());
- }
+ CheckTableAfterMovingGC(*scriptVTuneIdMap, [this](const auto& entry) {
+ BaseScript* script = entry.key();
+ CheckGCThingAfterMovingGC(script, this);
+ return script;
+ });
}
# endif // MOZ_VTUNE
# ifdef JS_CACHEIR_SPEW
if (scriptFinalWarmUpCountMap) {
- for (auto r = scriptFinalWarmUpCountMap->all(); !r.empty(); r.popFront()) {
- BaseScript* script = r.front().key();
- MOZ_ASSERT(script->zone() == this);
- CheckGCThingAfterMovingGC(script);
- auto ptr = scriptFinalWarmUpCountMap->lookup(script);
- MOZ_RELEASE_ASSERT(ptr.found() && &*ptr == &r.front());
- }
+ CheckTableAfterMovingGC(*scriptFinalWarmUpCountMap,
+ [this](const auto& entry) {
+ BaseScript* script = entry.key();
+ CheckGCThingAfterMovingGC(script, this);
+ return script;
+ });
}
# endif // JS_CACHEIR_SPEW
}