Bug 677079 - Part n: Expose JSOPTION_UNROOTED_GLOBAL in jsfriendapi.h; r=gal
authorMs2ger <ms2ger@gmail.com>
Sun, 15 Jan 2012 09:13:09 +0100
changeset 85691 fe8240db58344f6a24b961ef1d0b7c0bb4dc5975
parent 85690 41ea9acca64152f6513ca1c30afea9dd366aa015
child 85692 33d5a1f2af518d6f1503c6583bcd38d5f96f76de
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgal
bugs677079
milestone12.0a1
Bug 677079 - Part n: Expose JSOPTION_UNROOTED_GLOBAL in jsfriendapi.h; r=gal
js/src/jsfriendapi.cpp
js/src/jsfriendapi.h
js/xpconnect/src/XPCJSRuntime.cpp
--- a/js/src/jsfriendapi.cpp
+++ b/js/src/jsfriendapi.cpp
@@ -536,9 +536,15 @@ GetContextOutstandingRequests(const JSCo
 #endif
 
 JS_FRIEND_API(JSCompartment *)
 GetContextCompartment(const JSContext *cx)
 {
     return cx->compartment;
 }
 
+JS_FRIEND_API(bool)
+HasUnrootedGlobal(const JSContext *cx)
+{
+    return cx->hasRunOption(JSOPTION_UNROOTED_GLOBAL);
+}
+
 } // namespace js
--- a/js/src/jsfriendapi.h
+++ b/js/src/jsfriendapi.h
@@ -456,16 +456,19 @@ GetContextThread(const JSContext *cx);
 
 JS_FRIEND_API(unsigned)
 GetContextOutstandingRequests(const JSContext *cx);
 #endif
 
 JS_FRIEND_API(JSCompartment *)
 GetContextCompartment(const JSContext *cx);
 
+JS_FRIEND_API(bool)
+HasUnrootedGlobal(const JSContext *cx);
+
 class JS_FRIEND_API(AutoLockGC)
 {
   public:
     explicit AutoLockGC(JSRuntime *rt = NULL
                         MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
       : runtime(rt)
     {
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -61,21 +61,16 @@
 #include "js/MemoryMetrics.h"
 
 #ifdef MOZ_CRASHREPORTER
 #include "nsExceptionHandler.h"
 #endif
 
 #include "jscntxt.h"
 #if 0
-        JS_ASSERT(acx->hasRunOption(JSOPTION_UNROOTED_GLOBAL));
-            while ((acx = JS_ContextIterator(cx->runtime, &iter))) {
-                if (!acx->hasRunOption(JSOPTION_UNROOTED_GLOBAL))
-                    JS_ToggleOptions(acx, JSOPTION_UNROOTED_GLOBAL);
-
 JS_LOCK_GC, JS_UNLOCK_GC
 
 js_NextActiveContext, js::TriggerOperationCallback
         mWatchdogWakeup = JS_NEW_CONDVAR(mJSRuntime->gcLock);
         mJSRuntime->setActivityCallback(ActivityCallback, this);
 #endif
 
 using namespace mozilla;
@@ -446,17 +441,17 @@ TraceCompartment(xpc::PtrAndPrincipalHas
         priv->domExpandoMap->EnumerateEntries(TraceDOMExpandos, aClosure);
     return PL_DHASH_NEXT;
 }
 
 void XPCJSRuntime::TraceXPConnectRoots(JSTracer *trc)
 {
     JSContext *iter = nsnull;
     while (JSContext *acx = JS_ContextIterator(GetJSRuntime(), &iter)) {
-        JS_ASSERT(acx->hasRunOption(JSOPTION_UNROOTED_GLOBAL));
+        JS_ASSERT(js::HasUnrootedGlobal(acx));
         if (JSObject *global = JS_GetGlobalObject(acx))
             JS_CALL_OBJECT_TRACER(trc, global, "XPC global object");
     }
 
     XPCAutoLock lock(mMapLock);
 
     XPCWrappedNativeScope::TraceJS(trc, this);
 
@@ -679,17 +674,17 @@ JSBool XPCJSRuntime::GCCallback(JSContex
             if (!NS_IsMainThread()) {
                 return false;
             }
 
             // We seem to sometime lose the unrooted global flag. Restore it
             // here. FIXME: bug 584495.
             JSContext *iter = nsnull;
             while (JSContext *acx = JS_ContextIterator(JS_GetRuntime(cx), &iter)) {
-                if (!acx->hasRunOption(JSOPTION_UNROOTED_GLOBAL))
+                if (!js::HasUnrootedGlobal(acx))
                     JS_ToggleOptions(acx, JSOPTION_UNROOTED_GLOBAL);
             }
             break;
         }
         case JSGC_MARK_END:
         {
             NS_ASSERTION(!self->mDoingFinalization, "bad state");