From e54e391f05657915dff9d6a206c726e3f7b6c222 Mon Sep 17 00:00:00 2001 From: Terrence Cole Date: Wed, 2 Mar 2016 10:43:34 -0800 Subject: [PATCH] Bug 956899 - Convert exclusive access lock from PRLock to Mutex; r=jandem --HG-- extra : rebase_source : b13f0ea577d947e5192d16181ac14051490de741 --- js/src/jscntxt.h | 4 ++-- js/src/vm/Runtime.cpp | 7 ------- js/src/vm/Runtime.h | 2 +- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/js/src/jscntxt.h b/js/src/jscntxt.h index dd645a04ec6d..4040c0006278 100644 --- a/js/src/jscntxt.h +++ b/js/src/jscntxt.h @@ -762,7 +762,7 @@ class MOZ_RAII AutoLockForExclusiveAccess runtime = rt; if (runtime->numExclusiveThreads) { runtime->assertCanLock(ExclusiveAccessLock); - PR_Lock(runtime->exclusiveAccessLock); + runtime->exclusiveAccessLock.lock(); #ifdef DEBUG runtime->exclusiveAccessOwner = PR_GetCurrentThread(); #endif @@ -789,7 +789,7 @@ class MOZ_RAII AutoLockForExclusiveAccess MOZ_ASSERT(runtime->exclusiveAccessOwner == PR_GetCurrentThread()); runtime->exclusiveAccessOwner = nullptr; #endif - PR_Unlock(runtime->exclusiveAccessLock); + runtime->exclusiveAccessLock.unlock(); } else { MOZ_ASSERT(runtime->mainThreadHasExclusiveAccess); #ifdef DEBUG diff --git a/js/src/vm/Runtime.cpp b/js/src/vm/Runtime.cpp index 20f78e345f7d..7e490fd366bc 100644 --- a/js/src/vm/Runtime.cpp +++ b/js/src/vm/Runtime.cpp @@ -151,7 +151,6 @@ JSRuntime::JSRuntime(JSRuntime* parentRuntime) handlingSegFault(false), handlingJitInterrupt_(false), interruptCallback(nullptr), - exclusiveAccessLock(nullptr), #ifdef DEBUG exclusiveAccessOwner(nullptr), mainThreadHasExclusiveAccess(false), @@ -287,10 +286,6 @@ JSRuntime::init(uint32_t maxbytes, uint32_t maxNurseryBytes) ownerThreadNative_ = (size_t)pthread_self(); #endif - exclusiveAccessLock = PR_NewLock(); - if (!exclusiveAccessLock) - return false; - if (!mainThread.init()) return false; @@ -428,8 +423,6 @@ JSRuntime::~JSRuntime() finishSelfHosting(); MOZ_ASSERT(!exclusiveAccessOwner); - if (exclusiveAccessLock) - PR_DestroyLock(exclusiveAccessLock); // Avoid bogus asserts during teardown. MOZ_ASSERT(!numExclusiveThreads); diff --git a/js/src/vm/Runtime.h b/js/src/vm/Runtime.h index 40c96269362a..ad57de1f5ec7 100644 --- a/js/src/vm/Runtime.h +++ b/js/src/vm/Runtime.h @@ -919,7 +919,7 @@ struct JSRuntime : public JS::shadow::Runtime, * 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;