Bug 1290220 - Switch the simulators over to js::Thread instead of PRThread; r=terrence
☠☠ backed out by a86df78500c3 ☠ ☠
authorNick Fitzgerald <fitzgen@gmail.com>
Mon, 01 Aug 2016 09:45:31 -0700
changeset 307561 e834808ca14bcd8cdd0edb3e56a2a1f91e80c6d9
parent 307560 41096329fbed09dd0b344483f896068cc8c802eb
child 307562 072392a96295f553b6d50783d37c81a99014f5c7
push id80126
push usernfitzgerald@mozilla.com
push dateMon, 01 Aug 2016 16:46:09 +0000
treeherdermozilla-inbound@effd2a452de9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence
bugs1290220
milestone50.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 1290220 - Switch the simulators over to js::Thread instead of PRThread; r=terrence
js/src/jit/arm/Simulator-arm.cpp
js/src/jit/arm/Simulator-arm.h
js/src/jit/mips32/Simulator-mips32.cpp
js/src/jit/mips32/Simulator-mips32.h
js/src/jit/mips64/Simulator-mips64.cpp
js/src/jit/mips64/Simulator-mips64.h
--- a/js/src/jit/arm/Simulator-arm.cpp
+++ b/js/src/jit/arm/Simulator-arm.cpp
@@ -363,26 +363,26 @@ class AutoLockSimulatorCache : public Lo
 {
     using Base = LockGuard<Mutex>;
 
   public:
     explicit AutoLockSimulatorCache(Simulator* sim)
       : Base(sim->cacheLock_)
       , sim_(sim)
     {
-        MOZ_ASSERT(!sim_->cacheLockHolder_);
+        MOZ_ASSERT(sim_->cacheLockHolder_.isNothing());
 #ifdef DEBUG
-        sim_->cacheLockHolder_ = PR_GetCurrentThread();
+        sim_->cacheLockHolder_ = mozilla::Some(ThisThread::GetId());
 #endif
     }
 
     ~AutoLockSimulatorCache() {
-        MOZ_ASSERT(sim_->cacheLockHolder_);
+        MOZ_ASSERT(sim_->cacheLockHolder_.isSome());
 #ifdef DEBUG
-        sim_->cacheLockHolder_ = nullptr;
+        sim_->cacheLockHolder_.reset();
 #endif
     }
 
   private:
     Simulator* const sim_;
 };
 
 bool Simulator::ICacheCheckingEnabled = false;
@@ -1123,19 +1123,16 @@ Simulator::Simulator()
 
     // The lr and pc are initialized to a known bad value that will cause an
     // access violation if the simulator ever tries to execute it.
     registers_[pc] = bad_lr;
     registers_[lr] = bad_lr;
 
     lastDebuggerInput_ = nullptr;
 
-#ifdef DEBUG
-    cacheLockHolder_ = nullptr;
-#endif
     redirection_ = nullptr;
     exclusiveMonitorHeld_ = false;
     exclusiveMonitor_ = 0;
 }
 
 bool
 Simulator::init()
 {
--- a/js/src/jit/arm/Simulator-arm.h
+++ b/js/src/jit/arm/Simulator-arm.h
@@ -32,16 +32,17 @@
 #ifdef JS_SIMULATOR_ARM
 
 #include "jslock.h"
 
 #include "jit/arm/Architecture-arm.h"
 #include "jit/arm/disasm/Disasm-arm.h"
 #include "jit/IonTypes.h"
 #include "threading/Mutex.h"
+#include "threading/Thread.h"
 
 namespace js {
 namespace jit {
 
 class Simulator;
 class Redirection;
 class CachePage;
 class AutoLockSimulator;
@@ -430,38 +431,38 @@ class Simulator
     typedef HashMap<void*, CachePage*, ICacheHasher, SystemAllocPolicy> ICacheMap;
 
   private:
     // This lock creates a critical section around 'redirection_' and
     // 'icache_', which are referenced both by the execution engine
     // and by the off-thread compiler (see Redirection::Get in the cpp file).
     Mutex cacheLock_;
 #ifdef DEBUG
-    PRThread* cacheLockHolder_;
+    mozilla::Maybe<Thread::Id> cacheLockHolder_;
 #endif
 
     Redirection* redirection_;
     ICacheMap icache_;
 
   public:
     ICacheMap& icache() {
         // Technically we need the lock to access the innards of the
         // icache, not to take its address, but the latter condition
         // serves as a useful complement to the former.
-        MOZ_ASSERT(cacheLockHolder_);
+        MOZ_ASSERT(cacheLockHolder_.isSome());
         return icache_;
     }
 
     Redirection* redirection() const {
-        MOZ_ASSERT(cacheLockHolder_);
+        MOZ_ASSERT(cacheLockHolder_.isSome());
         return redirection_;
     }
 
     void setRedirection(js::jit::Redirection* redirection) {
-        MOZ_ASSERT(cacheLockHolder_);
+        MOZ_ASSERT(cacheLockHolder_.isSome());
         redirection_ = redirection;
     }
 
   private:
     // Exclusive access monitor
     void exclusiveMonitorSet(uint64_t value);
     uint64_t exclusiveMonitorGetAndClear(bool* held);
     void exclusiveMonitorClear();
--- a/js/src/jit/mips32/Simulator-mips32.cpp
+++ b/js/src/jit/mips32/Simulator-mips32.cpp
@@ -491,26 +491,26 @@ class AutoLockSimulatorCache : public Lo
 {
     using Base = LockGuard<Mutex>;
 
   public:
     explicit AutoLockSimulatorCache(Simulator* sim)
       : Base(sim->cacheLock_)
       , sim_(sim)
     {
-        MOZ_ASSERT(!sim_->cacheLockHolder_);
+        MOZ_ASSERT(sim_->cacheLockHolder_.isNothing());
 #ifdef DEBUG
-        sim_->cacheLockHolder_ = PR_GetCurrentThread();
+        sim_->cacheLockHolder_ = mozilla::Some(ThisThread::GetId());
 #endif
     }
 
     ~AutoLockSimulatorCache() {
-        MOZ_ASSERT(sim_->cacheLockHolder_);
+        MOZ_ASSERT(sim_->cacheLockHolder_.isSome());
 #ifdef DEBUG
-        sim_->cacheLockHolder_ = nullptr;
+        sim_->cacheLockHolder_.reset();
 #endif
     }
 
   private:
     Simulator* const sim_;
 };
 
 bool Simulator::ICacheCheckingEnabled = false;
@@ -1272,19 +1272,16 @@ Simulator::Simulator()
     registers_[pc] = bad_ra;
     registers_[ra] = bad_ra;
 
     for (int i = 0; i < kNumExceptions; i++)
         exceptions[i] = 0;
 
     lastDebuggerInput_ = nullptr;
 
-#ifdef DEBUG
-    cacheLockHolder_ = nullptr;
-#endif
     redirection_ = nullptr;
 }
 
 bool
 Simulator::init()
 {
     if (!icache_.init())
         return false;
--- a/js/src/jit/mips32/Simulator-mips32.h
+++ b/js/src/jit/mips32/Simulator-mips32.h
@@ -30,16 +30,17 @@
 #define jit_mips32_Simulator_mips32_h
 
 #ifdef JS_SIMULATOR_MIPS32
 
 #include "jslock.h"
 
 #include "jit/IonTypes.h"
 #include "threading/Mutex.h"
+#include "threading/Thread.h"
 
 namespace js {
 namespace jit {
 
 class Simulator;
 class Redirection;
 class CachePage;
 class AutoLockSimulator;
@@ -378,38 +379,38 @@ class Simulator {
     typedef HashMap<void*, CachePage*, ICacheHasher, SystemAllocPolicy> ICacheMap;
 
   private:
     // This lock creates a critical section around 'redirection_' and
     // 'icache_', which are referenced both by the execution engine
     // and by the off-thread compiler (see Redirection::Get in the cpp file).
     Mutex cacheLock_;
 #ifdef DEBUG
-    PRThread* cacheLockHolder_;
+    mozilla::Maybe<Thread::Id> cacheLockHolder_;
 #endif
 
     Redirection* redirection_;
     ICacheMap icache_;
 
   public:
     ICacheMap& icache() {
         // Technically we need the lock to access the innards of the
         // icache, not to take its address, but the latter condition
         // serves as a useful complement to the former.
-        MOZ_ASSERT(cacheLockHolder_);
+        MOZ_ASSERT(cacheLockHolder_.isSome());
         return icache_;
     }
 
     Redirection* redirection() const {
-        MOZ_ASSERT(cacheLockHolder_);
+        MOZ_ASSERT(cacheLockHolder_.isSome());
         return redirection_;
     }
 
     void setRedirection(js::jit::Redirection* redirection) {
-        MOZ_ASSERT(cacheLockHolder_);
+        MOZ_ASSERT(cacheLockHolder_.isSome());
         redirection_ = redirection;
     }
 };
 
 #define JS_CHECK_SIMULATOR_RECURSION_WITH_EXTRA(cx, extra, onerror)             \
     JS_BEGIN_MACRO                                                              \
         if (cx->mainThread().simulator()->overRecursedWithExtra(extra)) {       \
             js::ReportOverRecursed(cx);                                         \
--- a/js/src/jit/mips64/Simulator-mips64.cpp
+++ b/js/src/jit/mips64/Simulator-mips64.cpp
@@ -529,26 +529,26 @@ class AutoLockSimulatorCache : public Lo
 {
     using Base = LockGuard<Mutex>;
 
   public:
     explicit AutoLockSimulatorCache(Simulator* sim)
       : Base(sim->cacheLock_)
       , sim_(sim)
     {
-        MOZ_ASSERT(!sim_->cacheLockHolder_);
+        MOZ_ASSERT(sim_->cacheLockHolder_.isNothing());
 #ifdef DEBUG
-        sim_->cacheLockHolder_ = PR_GetCurrentThread();
+        sim_->cacheLockHolder_ = mozilla::Some(ThisThread::GetId());
 #endif
     }
 
     ~AutoLockSimulatorCache() {
-        MOZ_ASSERT(sim_->cacheLockHolder_);
+        MOZ_ASSERT(sim_->cacheLockHolder_.isSome());
 #ifdef DEBUG
-        sim_->cacheLockHolder_ = nullptr;
+        sim_->cacheLockHolder_.reset();
 #endif
     }
 
   private:
     Simulator* const sim_;
 };
 
 bool Simulator::ICacheCheckingEnabled = false;
@@ -1286,19 +1286,16 @@ Simulator::Simulator()
     registers_[pc] = bad_ra;
     registers_[ra] = bad_ra;
 
     for (int i = 0; i < kNumExceptions; i++)
         exceptions[i] = 0;
 
     lastDebuggerInput_ = nullptr;
 
-#ifdef DEBUG
-    cacheLockHolder_ = nullptr;
-#endif
     redirection_ = nullptr;
 }
 
 bool
 Simulator::init()
 {
     if (!icache_.init())
         return false;
--- a/js/src/jit/mips64/Simulator-mips64.h
+++ b/js/src/jit/mips64/Simulator-mips64.h
@@ -31,16 +31,17 @@
 #define jit_mips64_Simulator_mips64_h
 
 #ifdef JS_SIMULATOR_MIPS64
 
 #include "jslock.h"
 
 #include "jit/IonTypes.h"
 #include "threading/Mutex.h"
+#include "threading/Thread.h"
 
 namespace js {
 namespace jit {
 
 class Simulator;
 class Redirection;
 class CachePage;
 class AutoLockSimulator;
@@ -394,38 +395,38 @@ class Simulator {
     typedef HashMap<void*, CachePage*, ICacheHasher, SystemAllocPolicy> ICacheMap;
 
   private:
     // This lock creates a critical section around 'redirection_' and
     // 'icache_', which are referenced both by the execution engine
     // and by the off-thread compiler (see Redirection::Get in the cpp file).
     Mutex cacheLock_;
 #ifdef DEBUG
-    PRThread* cacheLockHolder_;
+    mozilla::Maybe<Thread::Id> cacheLockHolder_;
 #endif
 
     Redirection* redirection_;
     ICacheMap icache_;
 
   public:
     ICacheMap& icache() {
         // Technically we need the lock to access the innards of the
         // icache, not to take its address, but the latter condition
         // serves as a useful complement to the former.
-        MOZ_ASSERT(cacheLockHolder_);
+        MOZ_ASSERT(cacheLockHolder_.isSome());
         return icache_;
     }
 
     Redirection* redirection() const {
-        MOZ_ASSERT(cacheLockHolder_);
+        MOZ_ASSERT(cacheLockHolder_.isSome());
         return redirection_;
     }
 
     void setRedirection(js::jit::Redirection* redirection) {
-        MOZ_ASSERT(cacheLockHolder_);
+        MOZ_ASSERT(cacheLockHolder_.isSome());
         redirection_ = redirection;
     }
 };
 
 #define JS_CHECK_SIMULATOR_RECURSION_WITH_EXTRA(cx, extra, onerror)             \
     JS_BEGIN_MACRO                                                              \
         if (cx->mainThread().simulator()->overRecursedWithExtra(extra)) {       \
             js::ReportOverRecursed(cx);                                         \