Bug 899759 - Prevent JS_NondeterministicGetWeakMapKeys from GCing while iterating over a weakmap (r=sfink)
authorBill McCloskey <wmccloskey@mozilla.com>
Wed, 31 Jul 2013 11:45:37 -0700
changeset 140817 eb36948223ccb81b59c0a21adaaca99abbfad93b
parent 140816 b2f43bbdf3420afe4570df3f2a7f76912de518d5
child 140818 50f69b500c020dc5397fbcd4ef8eca26d7d01c38
push id25041
push userkwierso@gmail.com
push dateThu, 01 Aug 2013 00:32:15 +0000
treeherdermozilla-central@05d3797276d3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs899759
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 899759 - Prevent JS_NondeterministicGetWeakMapKeys from GCing while iterating over a weakmap (r=sfink)
js/src/jsweakmap.cpp
--- a/js/src/jsweakmap.cpp
+++ b/js/src/jsweakmap.cpp
@@ -336,16 +336,18 @@ JS_NondeterministicGetWeakMapKeys(JSCont
         *ret = NULL;
         return true;
     }
     RootedObject arr(cx, NewDenseEmptyArray(cx));
     if (!arr)
         return false;
     ObjectValueMap *map = obj->as<WeakMapObject>().getMap();
     if (map) {
+        // Prevent GC from mutating the weakmap while iterating.
+        AutoSuppressGC suppress(cx);
         for (ObjectValueMap::Base::Range r = map->all(); !r.empty(); r.popFront()) {
             RootedObject key(cx, r.front().key);
             if (!JS_WrapObject(cx, key.address()))
                 return false;
             if (!js_NewbornArrayPush(cx, arr, ObjectValue(*key)))
                 return false;
         }
     }