Bug 1473135: Stop using ReentrantMonitor for string bundle mutexes. r=gandalf
authorKris Maglione <maglione.k@gmail.com>
Fri, 20 Jul 2018 17:20:00 -0700
changeset 427922 9ba70b8ff0f755d5575333a71267805e0ece02f6
parent 427921 2eaa478b89791ff48402c18a9bab985b13cc4f36
child 427923 232216b44fce618ff638e4f50a8790011fab47e5
push id34320
push userrgurzau@mozilla.com
push dateTue, 24 Jul 2018 09:50:07 +0000
treeherdermozilla-central@1e5fa52a612e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgandalf
bugs1473135
milestone63.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 1473135: Stop using ReentrantMonitor for string bundle mutexes. r=gandalf MozReview-Commit-ID: HUfb47Eei7P
intl/strres/nsStringBundle.cpp
intl/strres/nsStringBundle.h
--- a/intl/strres/nsStringBundle.cpp
+++ b/intl/strres/nsStringBundle.cpp
@@ -115,25 +115,25 @@ namespace {
  */
 class StringBundleProxy : public nsIStringBundle
 {
   NS_DECL_THREADSAFE_ISUPPORTS
 
   NS_DECLARE_STATIC_IID_ACCESSOR(STRINGBUNDLEPROXY_IID)
 
   explicit StringBundleProxy(already_AddRefed<nsIStringBundle> aTarget)
-    : mReentrantMonitor("StringBundleProxy::mReentrantMonitor")
+    : mMutex("StringBundleProxy::mMutex")
     , mTarget(aTarget)
   {}
 
   NS_FORWARD_NSISTRINGBUNDLE(Target()->);
 
   void Retarget(nsIStringBundle* aTarget)
   {
-    ReentrantMonitorAutoEnter automon(mReentrantMonitor);
+    MutexAutoLock automon(mMutex);
     mTarget = aTarget;
   }
 
   size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override
   {
     return aMallocSizeOf(this);
   }
 
@@ -141,25 +141,25 @@ class StringBundleProxy : public nsIStri
   {
     return mRefCnt == 1 ? SizeOfIncludingThis(aMallocSizeOf) : 0;
   }
 
 protected:
   virtual ~StringBundleProxy() = default;
 
 private:
-  ReentrantMonitor mReentrantMonitor;
+  Mutex mMutex;
   nsCOMPtr<nsIStringBundle> mTarget;
 
   // Atomically reads mTarget and returns a strong reference to it. This
   // allows for safe multi-threaded use when the proxy may be retargetted by
   // the main thread during access.
   nsCOMPtr<nsIStringBundle> Target()
   {
-    ReentrantMonitorAutoEnter automon(mReentrantMonitor);
+    MutexAutoLock automon(mMutex);
     return mTarget;
   }
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(StringBundleProxy, STRINGBUNDLEPROXY_IID)
 
 NS_IMPL_ISUPPORTS(StringBundleProxy, nsIStringBundle, StringBundleProxy)
 
@@ -299,17 +299,17 @@ MakeBundleRefPtr(Args... args)
 
 NS_IMPL_ISUPPORTS(nsStringBundleBase, nsIStringBundle, nsIMemoryReporter)
 
 NS_IMPL_ISUPPORTS_INHERITED0(nsStringBundle, nsStringBundleBase)
 NS_IMPL_ISUPPORTS_INHERITED(SharedStringBundle, nsStringBundleBase, SharedStringBundle)
 
 nsStringBundleBase::nsStringBundleBase(const char* aURLSpec) :
   mPropertiesURL(aURLSpec),
-  mReentrantMonitor("nsStringBundle.mReentrantMonitor"),
+  mMutex("nsStringBundle.mMutex"),
   mAttemptedLoad(false),
   mLoaded(false)
 {
 }
 
 nsStringBundleBase::~nsStringBundleBase()
 {
   UnregisterWeakMemoryReporter(this);
@@ -590,17 +590,17 @@ nsStringBundleBase::GetStringFromAUTF8Na
   return GetStringFromName(PromiseFlatCString(aName).get(), aResult);
 }
 
 NS_IMETHODIMP
 nsStringBundleBase::GetStringFromName(const char* aName, nsAString& aResult)
 {
   NS_ENSURE_ARG_POINTER(aName);
 
-  ReentrantMonitorAutoEnter automon(mReentrantMonitor);
+  MutexAutoLock autolock(mMutex);
 
   return GetStringImpl(nsDependentCString(aName), aResult);
 }
 
 nsresult
 nsStringBundle::GetStringImpl(const nsACString& aName, nsAString& aResult)
 {
   MOZ_TRY(LoadProperties());
--- a/intl/strres/nsStringBundle.h
+++ b/intl/strres/nsStringBundle.h
@@ -1,17 +1,17 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsStringBundle_h__
 #define nsStringBundle_h__
 
-#include "mozilla/ReentrantMonitor.h"
+#include "mozilla/Mutex.h"
 #include "nsIStringBundle.h"
 #include "nsIMemoryReporter.h"
 #include "nsCOMPtr.h"
 #include "nsString.h"
 #include "nsCOMArray.h"
 
 class nsIPersistentProperties;
 
@@ -50,20 +50,20 @@ protected:
     virtual ~nsStringBundleBase();
 
     virtual nsresult GetStringImpl(const nsACString& aName, nsAString& aResult) = 0;
 
     virtual nsresult GetSimpleEnumerationImpl(nsISimpleEnumerator** elements) = 0;
 
     void RegisterMemoryReporter();
 
-    nsCString              mPropertiesURL;
-    mozilla::ReentrantMonitor    mReentrantMonitor;
-    bool                         mAttemptedLoad;
-    bool                         mLoaded;
+    nsCString mPropertiesURL;
+    mozilla::Mutex mMutex;
+    bool mAttemptedLoad;
+    bool mLoaded;
 
     size_t SizeOfIncludingThisIfUnshared(mozilla::MallocSizeOf aMallocSizeOf) const override;
 
 public:
     static nsresult FormatString(const char16_t *formatStr,
                                  const char16_t **aParams, uint32_t aLength,
                                  nsAString& aResult);
 };