Bug 977340 - Use an AutoJSContext when clearing modules. r=gabor
authorBobby Holley <bobbyholley@gmail.com>
Tue, 04 Mar 2014 10:05:08 -0800
changeset 171757 681a088dd2b8ee51196d32b108f463993dc2eeae
parent 171756 b5ce697407293473c17b9e5fcea3b380a36ce2e1
child 171758 3c8c8d1b869b9f481b8d69563a999806e556b522
push id40557
push userbobbyholley@gmail.com
push dateTue, 04 Mar 2014 18:05:18 +0000
treeherdermozilla-inbound@de377011ed9d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgabor
bugs977340
milestone30.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 977340 - Use an AutoJSContext when clearing modules. r=gabor
js/xpconnect/loader/mozJSComponentLoader.h
--- a/js/xpconnect/loader/mozJSComponentLoader.h
+++ b/js/xpconnect/loader/mozJSComponentLoader.h
@@ -9,16 +9,17 @@
 
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/ModuleLoader.h"
 #include "nsISupports.h"
 #include "nsIObserver.h"
 #include "nsIURI.h"
 #include "xpcIJSModuleLoader.h"
 #include "nsClassHashtable.h"
+#include "nsCxPusher.h"
 #include "nsDataHashtable.h"
 #include "jsapi.h"
 
 #include "xpcIJSGetFactory.h"
 
 class nsIFile;
 class nsIJSRuntimeService;
 class nsIPrincipal;
@@ -110,24 +111,23 @@ class mozJSComponentLoader : public mozi
         ~ModuleEntry() {
             Clear();
         }
 
         void Clear() {
             getfactoryobj = nullptr;
 
             if (obj) {
-                JSAutoRequest ar(sSelf->mContext);
-
-                JSAutoCompartment ac(sSelf->mContext, obj);
+                mozilla::AutoJSContext cx;
+                JSAutoCompartment ac(cx, obj);
 
-                JS_SetAllNonReservedSlotsToUndefined(sSelf->mContext, obj);
-                JS_RemoveObjectRoot(sSelf->mContext, &obj);
+                JS_SetAllNonReservedSlotsToUndefined(cx, obj);
+                JS_RemoveObjectRoot(cx, &obj);
                 if (thisObjectKey)
-                    JS_RemoveScriptRoot(sSelf->mContext, &thisObjectKey);
+                    JS_RemoveScriptRoot(cx, &thisObjectKey);
             }
 
             if (location)
                 NS_Free(location);
 
             obj = nullptr;
             thisObjectKey = nullptr;
             location = nullptr;