Bug 894701 - Disable the watchdog thread on b2g. r=mrbkap,sr=sicking
☠☠ backed out by 35cb56244e74 ☠ ☠
authorBobby Holley <bobbyholley@gmail.com>
Tue, 23 Jul 2013 17:02:50 -0700
changeset 119801 13a54f1eac4f0932f2d5231c33ea7d8c686e56f7
parent 119800 962a3f271748acf665292729f443f96b7667d412
child 119802 2d2d9c09d35806cbc9fded87e1ab5f980d69c61b
push id999
push userbobbyholley@gmail.com
push dateWed, 24 Jul 2013 00:03:12 +0000
reviewersmrbkap, sicking
bugs894701
milestone18.1
Bug 894701 - Disable the watchdog thread on b2g. r=mrbkap,sr=sicking
js/xpconnect/src/XPCJSRuntime.cpp
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -1009,21 +1009,23 @@ XPCJSRuntime::FinalizeCallback(JSFreeOp 
 }
 
 class AutoLockWatchdog {
     XPCJSRuntime* const mRuntime;
 
   public:
     AutoLockWatchdog(XPCJSRuntime* aRuntime)
       : mRuntime(aRuntime) {
-        PR_Lock(mRuntime->mWatchdogLock);
+        if (mRuntime->mWatchdogLock)
+            PR_Lock(mRuntime->mWatchdogLock);
     }
 
     ~AutoLockWatchdog() {
-        PR_Unlock(mRuntime->mWatchdogLock);
+        if (mRuntime->mWatchdogLock)
+            PR_Unlock(mRuntime->mWatchdogLock);
     }
 };
 
 //static
 void
 XPCJSRuntime::WatchdogMain(void *arg)
 {
     PR_SetCurrentThreadName("JS Watchdog");
@@ -1057,17 +1059,18 @@ XPCJSRuntime::ActivityCallback(void *arg
     XPCJSRuntime* self = static_cast<XPCJSRuntime*>(arg);
 
     AutoLockWatchdog lock(self);
     
     if (active) {
         self->mLastActiveTime = -1;
         if (self->mWatchdogHibernating) {
             self->mWatchdogHibernating = false;
-            PR_NotifyCondVar(self->mWatchdogWakeup);
+            if (self->mWatchdogWakeup)
+                PR_NotifyCondVar(self->mWatchdogWakeup);
         }
     } else {
         self->mLastActiveTime = PR_Now();
     }
 }
 
 size_t
 XPCJSRuntime::SizeOfIncludingThis(nsMallocSizeOfFun mallocSizeOf)
@@ -2495,32 +2498,35 @@ XPCJSRuntime::XPCJSRuntime(nsXPConnect* 
     mCompartmentSet.init();
 
     // Install a JavaScript 'debugger' keyword handler in debug builds only
 #ifdef DEBUG
     if (!JS_GetGlobalDebugHooks(mJSRuntime)->debuggerHandler)
         xpc_InstallJSDebuggerKeywordHandler(mJSRuntime);
 #endif
 
+// We disable the watchdog for b2g on b2g18.
+#ifndef MOZ_WIDGET_GONK
     mWatchdogLock = PR_NewLock();
     if (!mWatchdogLock)
         NS_RUNTIMEABORT("PR_NewLock failed.");
     mWatchdogWakeup = PR_NewCondVar(mWatchdogLock);
     if (!mWatchdogWakeup)
         NS_RUNTIMEABORT("PR_NewCondVar failed.");
 
     {
         AutoLockWatchdog lock(this);
 
         mWatchdogThread = PR_CreateThread(PR_USER_THREAD, WatchdogMain, this,
                                           PR_PRIORITY_NORMAL, PR_LOCAL_THREAD,
                                           PR_UNJOINABLE_THREAD, 0);
         if (!mWatchdogThread)
             NS_RUNTIMEABORT("PR_CreateThread failed!");
     }
+#endif
 }
 
 // static
 XPCJSRuntime*
 XPCJSRuntime::newXPCJSRuntime(nsXPConnect* aXPConnect)
 {
     NS_PRECONDITION(aXPConnect,"bad param");
 
@@ -2532,18 +2538,17 @@ XPCJSRuntime::newXPCJSRuntime(nsXPConnec
         self->GetWrappedJSClassMap()            &&
         self->GetIID2NativeInterfaceMap()       &&
         self->GetClassInfo2NativeSetMap()       &&
         self->GetNativeSetMap()                 &&
         self->GetThisTranslatorMap()            &&
         self->GetNativeScriptableSharedMap()    &&
         self->GetDyingWrappedNativeProtoMap()   &&
         self->GetMapLock()                      &&
-        self->GetCompartmentSet().initialized() &&
-        self->mWatchdogThread) {
+        self->GetCompartmentSet().initialized()) {
         return self;
     }
 
     NS_RUNTIMEABORT("new XPCJSRuntime failed to initialize.");
 
     delete self;
     return nullptr;
 }