Bug 1356103 - Part 2: Add functions to assert the Servo font metrics mutex is locked. r=bholley
☠☠ backed out by 8f8cb62a8749 ☠ ☠
authorCameron McCormack <cam@mcc.id.au>
Sun, 30 Apr 2017 13:15:42 +0800
changeset 356463 559f06e32df3a9412095f1000770ac915dfc3777
parent 356462 784865d234cdb3822745cdddc0e0422d94a17c04
child 356464 1c7831db6b0750720a5bc617cf56804525fd18f2
push id31767
push usercbook@mozilla.com
push dateFri, 05 May 2017 13:15:58 +0000
treeherdermozilla-central@8872ad4d52b6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1356103
milestone55.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 1356103 - Part 2: Add functions to assert the Servo font metrics mutex is locked. r=bholley MozReview-Commit-ID: QtydYSYvxW
layout/style/ServoBindings.cpp
layout/style/ServoUtils.h
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -1816,16 +1816,29 @@ InitializeServo()
 
 void
 ShutdownServo()
 {
   delete sServoFontMetricsLock;
   Servo_Shutdown();
 }
 
+namespace mozilla {
+
+void
+AssertIsMainThreadOrServoFontMetricsLocked()
+{
+  if (!NS_IsMainThread()) {
+    MOZ_ASSERT(sServoFontMetricsLock);
+    sServoFontMetricsLock->AssertCurrentThreadOwns();
+  }
+}
+
+} // namespace mozilla
+
 GeckoFontMetrics
 Gecko_GetFontMetrics(RawGeckoPresContextBorrowed aPresContext,
                      bool aIsVertical,
                      const nsStyleFont* aFont,
                      nscoord aFontSize,
                      bool aUseUserFontSet)
 {
   // This function is still unsafe due to frobbing DOM and network
--- a/layout/style/ServoUtils.h
+++ b/layout/style/ServoUtils.h
@@ -6,16 +6,23 @@
 
 /* some utilities for stylo */
 
 #ifndef mozilla_ServoUtils_h
 #define mozilla_ServoUtils_h
 
 #include "mozilla/TypeTraits.h"
 
+namespace mozilla {
+
+// Defined in ServoBindings.cpp.
+void AssertIsMainThreadOrServoFontMetricsLocked();
+
+} // namespace mozilla
+
 #ifdef MOZ_STYLO
 # define MOZ_DECL_STYLO_CHECK_METHODS \
   bool IsGecko() const { return !IsServo(); } \
   bool IsServo() const { return mType == StyleBackendType::Servo; }
 #else
 # define MOZ_DECL_STYLO_CHECK_METHODS \
   bool IsGecko() const { return true; } \
   bool IsServo() const { return false; }