Bug 1290220 - Switch the simulators over to js::Thread instead of PRThread; r=terrence
authorNick Fitzgerald <fitzgen@gmail.com>
Mon, 01 Aug 2016 18:39:44 -0700
changeset 307684 3ec6476e6d896823d32f631e6f4ce8e7e26fbf44
parent 307683 3335ffe05307a27db7724bd7b43aa05ebd4c20f8
child 307685 9df647a3c10ad133c5051fe5e6a3d6f8259736f0
push id30516
push usercbook@mozilla.com
push dateTue, 02 Aug 2016 15:10:10 +0000
treeherdermozilla-central@f299890191b2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence
bugs1290220
milestone51.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);                                         \