Bug 1410132 - Skip mutex ordering checks when JS engine is not initialized r=sfink
authorJon Coppeard <jcoppeard@mozilla.com>
Tue, 07 Nov 2017 17:37:25 +0000
changeset 443978 69aedd61b682f6086a6a47b5616bbc9e1bbf1487
parent 443977 adcb5a4c7591c970b7ac75071f4c5ce1ecbabcd4
child 443979 cdabc4808a0fc6bc99475a7011b07d0f2df22727
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1410132
milestone58.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 1410132 - Skip mutex ordering checks when JS engine is not initialized r=sfink
js/src/threading/Mutex.cpp
--- a/js/src/threading/Mutex.cpp
+++ b/js/src/threading/Mutex.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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/. */
 
 #include "threading/Mutex.h"
 
+#include "js/Initialization.h"
 #include "js/Utility.h"
 
 using namespace js;
 
 #ifdef DEBUG
 
 MOZ_THREAD_LOCAL(js::Mutex::MutexVector*) js::Mutex::HeldMutexStack;
 
@@ -39,16 +40,21 @@ js::Mutex::heldMutexStack()
     HeldMutexStack.set(stack);
   }
   return *stack;
 }
 
 void
 js::Mutex::lock()
 {
+  if (!JS_IsInitialized()) {
+    MutexImpl::lock();
+    return;
+  }
+
   auto& stack = heldMutexStack();
   if (!stack.empty()) {
     const Mutex& prev = *stack.back();
     if (id_.order <= prev.id_.order) {
       fprintf(stderr,
               "Attempt to acquire mutex %s with order %d while holding %s with order %d\n",
               id_.name, id_.order, prev.id_.name, prev.id_.order);
       MOZ_CRASH("Mutex ordering violation");
@@ -60,16 +66,21 @@ js::Mutex::lock()
   AutoEnterOOMUnsafeRegion oomUnsafe;
   if (!stack.append(this))
     oomUnsafe.crash("js::Mutex::lock");
 }
 
 void
 js::Mutex::unlock()
 {
+  if (!JS_IsInitialized()) {
+    MutexImpl::unlock();
+    return;
+  }
+
   auto& stack = heldMutexStack();
   MOZ_ASSERT(stack.back() == this);
   MutexImpl::unlock();
   stack.popBack();
 }
 
 bool
 js::Mutex::ownedByCurrentThread() const