Bug 926681 - Make JSRuntime::currentThreadOwnsOperationCallbackLock() work the the same in non-threadsafe builds r=bhackett
authorJon Coppeard <jcoppeard@mozilla.com>
Thu, 17 Oct 2013 09:41:27 +0100
changeset 165879 440098bca4eb491e263f9236a131538191c720ba
parent 165878 f3f9a19a57b95c54f37aa675cf571c1d838f77b0
child 165880 883941b3f9278f59e3b50629434dd7244c51a62a
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett
bugs926681
milestone27.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 926681 - Make JSRuntime::currentThreadOwnsOperationCallbackLock() work the the same in non-threadsafe builds r=bhackett
js/src/vm/Runtime.cpp
js/src/vm/Runtime.h
--- a/js/src/vm/Runtime.cpp
+++ b/js/src/vm/Runtime.cpp
@@ -113,16 +113,18 @@ JSRuntime::JSRuntime(JSUseHelperThreads 
     ),
     mainThread(this),
     interrupt(0),
     handlingSignal(false),
     operationCallback(nullptr),
 #ifdef JS_THREADSAFE
     operationCallbackLock(nullptr),
     operationCallbackOwner(nullptr),
+#else
+    operationCallbackLockTaken(false),
 #endif
 #ifdef JS_WORKER_THREADS
     workerThreadState(nullptr),
     exclusiveAccessLock(nullptr),
     exclusiveAccessOwner(nullptr),
     mainThreadHasExclusiveAccess(false),
     exclusiveThreadsPaused(false),
     numExclusiveThreads(0),
--- a/js/src/vm/Runtime.h
+++ b/js/src/vm/Runtime.h
@@ -714,57 +714,60 @@ struct JSRuntime : public JS::shadow::Ru
 #endif
 
     /* Set when handling a signal for a thread associated with this runtime. */
     bool handlingSignal;
 
     /* Branch callback */
     JSOperationCallback operationCallback;
 
-#ifdef JS_THREADSAFE
   private:
     /*
      * Lock taken when triggering the operation callback from another thread.
      * Protects all data that is touched in this process.
      */
+#ifdef JS_THREADSAFE
     PRLock *operationCallbackLock;
     PRThread *operationCallbackOwner;
+#else
+    bool operationCallbackLockTaken;
+#endif // JS_THREADSAFE
   public:
-#endif // JS_THREADSAFE
 
     class AutoLockForOperationCallback {
-#ifdef JS_THREADSAFE
         JSRuntime *rt;
       public:
         AutoLockForOperationCallback(JSRuntime *rt MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : rt(rt) {
             MOZ_GUARD_OBJECT_NOTIFIER_INIT;
             JS_ASSERT(!rt->currentThreadOwnsOperationCallbackLock());
+#ifdef JS_THREADSAFE
             PR_Lock(rt->operationCallbackLock);
             rt->operationCallbackOwner = PR_GetCurrentThread();
+#else
+            rt->operationCallbackLockTaken = true;
+#endif // JS_THREADSAFE
         }
         ~AutoLockForOperationCallback() {
-            JS_ASSERT(rt->operationCallbackOwner == PR_GetCurrentThread());
+            JS_ASSERT(rt->currentThreadOwnsOperationCallbackLock());
+#ifdef JS_THREADSAFE
             rt->operationCallbackOwner = nullptr;
             PR_Unlock(rt->operationCallbackLock);
+#else
+            rt->operationCallbackLockTaken = false;
+#endif // JS_THREADSAFE
         }
-#else // JS_THREADSAFE
-      public:
-        AutoLockForOperationCallback(JSRuntime *rt MOZ_GUARD_OBJECT_NOTIFIER_PARAM) {
-            MOZ_GUARD_OBJECT_NOTIFIER_INIT;
-        }
-#endif // JS_THREADSAFE
 
         MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
     };
 
     bool currentThreadOwnsOperationCallbackLock() {
 #if defined(JS_THREADSAFE)
         return operationCallbackOwner == PR_GetCurrentThread();
 #else
-        return true;
+        return operationCallbackLockTaken;
 #endif
     }
 
 #if defined(JS_THREADSAFE) && defined(JS_ION)
 # define JS_WORKER_THREADS
 
     js::WorkerThreadState *workerThreadState;