Bug 677079 - Part u: Provide TriggerOperationCallbacksForActiveContexts in jsfriendapi.h; r=bhackett
authorMs2ger <ms2ger@gmail.com>
Sun, 15 Jan 2012 09:13:10 +0100
changeset 85698 d848942fc440ea80308708045d32846e5c8bd3e3
parent 85697 c8ba49dafe5e2fad9822ec590cdb3a486113410b
child 85699 b2bffccbc28b7274a58d30024ee4d903eb5bcf3e
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)
reviewersbhackett
bugs677079
milestone12.0a1
Bug 677079 - Part u: Provide TriggerOperationCallbacksForActiveContexts in jsfriendapi.h; r=bhackett
js/src/jscntxt.h
js/src/jsfriendapi.cpp
js/src/jsfriendapi.h
js/xpconnect/src/XPCJSRuntime.cpp
--- a/js/src/jscntxt.h
+++ b/js/src/jscntxt.h
@@ -1964,17 +1964,17 @@ js_InvokeOperationCallback(JSContext *cx
 
 extern JSBool
 js_HandleExecutionInterrupt(JSContext *cx);
 
 namespace js {
 
 /* These must be called with GC lock taken. */
 
-JS_FRIEND_API(void)
+void
 TriggerOperationCallback(JSContext *cx);
 
 void
 TriggerAllOperationCallbacks(JSRuntime *rt);
 
 } /* namespace js */
 
 /*
--- a/js/src/jsfriendapi.cpp
+++ b/js/src/jsfriendapi.cpp
@@ -581,9 +581,18 @@ SetActivityCallback(JSRuntime *rt, Activ
 }
 
 JS_FRIEND_API(bool)
 IsContextRunningJS(JSContext *cx)
 {
     return !cx->stack.empty();
 }
 
+JS_FRIEND_API(void)
+TriggerOperationCallbacksForActiveContexts(JSRuntime *rt)
+{
+    JSContext* cx = NULL;
+    while ((cx = js_NextActiveContext(rt, cx))) {
+        TriggerOperationCallback(cx);
+    }
+}
+
 } // namespace js
--- a/js/src/jsfriendapi.h
+++ b/js/src/jsfriendapi.h
@@ -533,16 +533,20 @@ extern JS_FRIEND_API(bool)
 CanCallContextDebugHandler(JSContext *cx);
 
 extern JS_FRIEND_API(JSTrapStatus)
 CallContextDebugHandler(JSContext *cx, JSScript *script, jsbytecode *bc, Value *rval);
 
 extern JS_FRIEND_API(bool)
 IsContextRunningJS(JSContext *cx);
 
+/* Must be called with GC lock taken. */
+extern JS_FRIEND_API(void)
+TriggerOperationCallbacksForActiveContexts(JSRuntime *rt);
+
 } /* namespace js */
 
 /*
  * If protoKey is not JSProto_Null, then clasp is ignored. If protoKey is
  * JSProto_Null, clasp must non-null.
  */
 extern JS_FRIEND_API(JSBool)
 js_GetClassPrototype(JSContext *cx, JSObject *scope, JSProtoKey protoKey,
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -59,21 +59,16 @@
 
 #include "jsfriendapi.h"
 #include "js/MemoryMetrics.h"
 
 #ifdef MOZ_CRASHREPORTER
 #include "nsExceptionHandler.h"
 #endif
 
-#include "jscntxt.h"
-#if 0
-js_NextActiveContext, js::TriggerOperationCallback
-#endif
-
 using namespace mozilla;
 using namespace mozilla::xpconnect::memory;
 
 /***************************************************************************/
 
 const char* XPCJSRuntime::mStrings[] = {
     "constructor",          // IDX_CONSTRUCTOR
     "toString",             // IDX_TO_STRING
@@ -952,20 +947,17 @@ XPCJSRuntime::WatchdogMain(void *arg)
             sleepInterval = PR_INTERVAL_NO_TIMEOUT;
             self->mWatchdogHibernating = true;
         }
 #ifdef DEBUG
         PRStatus status =
 #endif
             PR_WaitCondVar(self->mWatchdogWakeup, sleepInterval);
         JS_ASSERT(status == PR_SUCCESS);
-        JSContext* cx = nsnull;
-        while ((cx = js_NextActiveContext(self->mJSRuntime, cx))) {
-            js::TriggerOperationCallback(cx);
-        }
+        js::TriggerOperationCallbacksForActiveContexts(self->mJSRuntime);
     }
 
     /* Wake up the main thread waiting for the watchdog to terminate. */
     PR_NotifyCondVar(self->mWatchdogWakeup);
 }
 
 //static
 void