Bug 956899 - Convert exclusive access lock from PRLock to Mutex; r=jandem
authorTerrence Cole <terrence@mozilla.com>
Wed, 02 Mar 2016 10:43:34 -0800
changeset 288567 85b84b87c6a7f56571a1872f8bb76591031df306
parent 288566 583f746e9e55311a6f586e1b5bc67ff059ec55fe
child 288568 59abf823d078ac9042baed6bd750de94413a9f43
push id73459
push usertcole@mozilla.com
push dateMon, 14 Mar 2016 17:26:14 +0000
treeherdermozilla-inbound@161e40cc86c1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs956899
milestone48.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 956899 - Convert exclusive access lock from PRLock to Mutex; r=jandem
js/src/jscntxt.h
js/src/vm/Runtime.cpp
js/src/vm/Runtime.h
--- a/js/src/jscntxt.h
+++ b/js/src/jscntxt.h
@@ -757,17 +757,17 @@ bool intrinsic_IsSuspendedStarGenerator(
 class MOZ_RAII AutoLockForExclusiveAccess
 {
     JSRuntime* runtime;
 
     void init(JSRuntime* rt) {
         runtime = rt;
         if (runtime->numExclusiveThreads) {
             runtime->assertCanLock(ExclusiveAccessLock);
-            PR_Lock(runtime->exclusiveAccessLock);
+            runtime->exclusiveAccessLock.lock();
 #ifdef DEBUG
             runtime->exclusiveAccessOwner = PR_GetCurrentThread();
 #endif
         } else {
             MOZ_ASSERT(!runtime->mainThreadHasExclusiveAccess);
 #ifdef DEBUG
             runtime->mainThreadHasExclusiveAccess = true;
 #endif
@@ -784,17 +784,17 @@ class MOZ_RAII AutoLockForExclusiveAcces
         init(rt);
     }
     ~AutoLockForExclusiveAccess() {
         if (runtime->numExclusiveThreads) {
 #ifdef DEBUG
             MOZ_ASSERT(runtime->exclusiveAccessOwner == PR_GetCurrentThread());
             runtime->exclusiveAccessOwner = nullptr;
 #endif
-            PR_Unlock(runtime->exclusiveAccessLock);
+            runtime->exclusiveAccessLock.unlock();
         } else {
             MOZ_ASSERT(runtime->mainThreadHasExclusiveAccess);
 #ifdef DEBUG
             runtime->mainThreadHasExclusiveAccess = false;
 #endif
         }
     }
 
--- a/js/src/vm/Runtime.cpp
+++ b/js/src/vm/Runtime.cpp
@@ -146,17 +146,16 @@ JSRuntime::JSRuntime(JSRuntime* parentRu
 #ifdef DEBUG
     updateChildRuntimeCount(parentRuntime),
 #endif
     interrupt_(false),
     telemetryCallback(nullptr),
     handlingSegFault(false),
     handlingJitInterrupt_(false),
     interruptCallback(nullptr),
-    exclusiveAccessLock(nullptr),
 #ifdef DEBUG
     exclusiveAccessOwner(nullptr),
     mainThreadHasExclusiveAccess(false),
 #endif
     numExclusiveThreads(0),
     numCompartments(0),
     localeCallbacks(nullptr),
     defaultLocale(nullptr),
@@ -282,20 +281,16 @@ JSRuntime::init(uint32_t maxbytes, uint3
         return false;
     static_assert(sizeof(HANDLE) <= sizeof(ownerThreadNative_), "need bigger field");
     ownerThreadNative_ = (size_t)self;
 #else
     static_assert(sizeof(pthread_t) <= sizeof(ownerThreadNative_), "need bigger field");
     ownerThreadNative_ = (size_t)pthread_self();
 #endif
 
-    exclusiveAccessLock = PR_NewLock();
-    if (!exclusiveAccessLock)
-        return false;
-
     if (!mainThread.init())
         return false;
 
     if (!regexpStack.init())
         return false;
 
     if (CanUseExtraThreads() && !EnsureHelperThreadsInitialized())
         return false;
@@ -423,18 +418,16 @@ JSRuntime::~JSRuntime()
 
     /*
      * Clear the self-hosted global and delete self-hosted classes *after*
      * GC, as finalizers for objects check for clasp->finalize during GC.
      */
     finishSelfHosting();
 
     MOZ_ASSERT(!exclusiveAccessOwner);
-    if (exclusiveAccessLock)
-        PR_DestroyLock(exclusiveAccessLock);
 
     // Avoid bogus asserts during teardown.
     MOZ_ASSERT(!numExclusiveThreads);
 #ifdef DEBUG
     mainThreadHasExclusiveAccess = true;
 #endif
 
     /*
--- a/js/src/vm/Runtime.h
+++ b/js/src/vm/Runtime.h
@@ -914,17 +914,17 @@ struct JSRuntime : public JS::shadow::Ru
     /*
      * Lock taken when using per-runtime or per-zone data that could otherwise
      * be accessed simultaneously by both the main thread and another thread
      * with an ExclusiveContext.
      *
      * Locking this only occurs if there is actually a thread other than the
      * main thread with an ExclusiveContext which could access such data.
      */
-    PRLock* exclusiveAccessLock;
+    js::Mutex exclusiveAccessLock;
 #ifdef DEBUG
     PRThread* exclusiveAccessOwner;
     bool mainThreadHasExclusiveAccess;
 #endif
 
     /* Number of non-main threads with an ExclusiveContext. */
     size_t numExclusiveThreads;