Bug 1137336 - Explicitly disallow WeakMapTracer.callback from GCing, r=terrence

--HG--
extra : rebase_source : 49c1862cdb21a3089f91a3234276ae394e3928e1
This commit is contained in:
Steve Fink 2015-03-02 10:25:16 -08:00
Родитель fe060f5fe7
Коммит ae44364491
2 изменённых файлов: 7 добавлений и 1 удалений

Просмотреть файл

@ -480,6 +480,8 @@ struct WeakMapTracer;
* weak map that was live at the time of the last garbage collection.
*
* m will be nullptr if the weak map is not contained in a JS Object.
*
* The callback should not GC (and will assert in a debug build if it does so.)
*/
typedef void
(* WeakMapTraceCallback)(WeakMapTracer *trc, JSObject *m, JS::GCCellPtr key, JS::GCCellPtr value);

Просмотреть файл

@ -14,6 +14,7 @@
#include "jsobj.h"
#include "jswrapper.h"
#include "js/GCAPI.h"
#include "vm/GlobalObject.h"
#include "vm/WeakMapObject.h"
@ -132,8 +133,11 @@ WeakMapBase::traceAllMappings(WeakMapTracer *tracer)
{
JSRuntime *rt = tracer->runtime;
for (CompartmentsIter c(rt, SkipAtoms); !c.done(); c.next()) {
for (WeakMapBase *m = c->gcWeakMapList; m; m = m->next)
for (WeakMapBase *m = c->gcWeakMapList; m; m = m->next) {
// The WeakMapTracer callback is not allowed to GC.
JS::AutoSuppressGCAnalysis nogc;
m->traceMappings(tracer);
}
}
}