diff --git a/js/src/jscntxt.h b/js/src/jscntxt.h index d0b654bacab..141ee25690e 100644 --- a/js/src/jscntxt.h +++ b/js/src/jscntxt.h @@ -1710,16 +1710,21 @@ class AutoGCRooter { void operator=(AutoGCRooter &ida); }; -class AutoSaveWeakRoots : private AutoGCRooter +class AutoSaveRestoreWeakRoots : private AutoGCRooter { public: - explicit AutoSaveWeakRoots(JSContext *cx - JS_GUARD_OBJECT_NOTIFIER_PARAM) + explicit AutoSaveRestoreWeakRoots(JSContext *cx + JS_GUARD_OBJECT_NOTIFIER_PARAM) : AutoGCRooter(cx, WEAKROOTS), savedRoots(cx->weakRoots) { JS_GUARD_OBJECT_NOTIFIER_INIT; } + ~AutoSaveRestoreWeakRoots() + { + context->weakRoots = savedRoots; + } + friend void AutoGCRooter::trace(JSTracer *trc); private: diff --git a/js/src/jscntxtinlines.h b/js/src/jscntxtinlines.h index ff633e08c5b..1b92509e884 100644 --- a/js/src/jscntxtinlines.h +++ b/js/src/jscntxtinlines.h @@ -78,7 +78,7 @@ AutoGCRooter::trace(JSTracer *trc) return; case WEAKROOTS: - static_cast(this)->savedRoots.mark(trc); + static_cast(this)->savedRoots.mark(trc); return; case PARSER: diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index f0ae73e35eb..98c6e5af80e 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -1408,7 +1408,7 @@ LastDitchGC(JSContext *cx) JS_ASSERT(!JS_ON_TRACE(cx)); /* The last ditch GC preserves weak roots and all atoms. */ - AutoSaveWeakRoots save(cx); + AutoSaveRestoreWeakRoots save(cx); AutoKeepAtoms keep(cx->runtime); /*