Bug 1290240 - Switch GCHelperState::thread to js::Thread::Id instead of PRThread*; r=terrence
☠☠ backed out by 76bb0a40db1b ☠ ☠
authorNick Fitzgerald <fitzgen@gmail.com>
Mon, 01 Aug 2016 09:45:31 -0700
changeset 351153 072392a96295f553b6d50783d37c81a99014f5c7
parent 351152 e834808ca14bcd8cdd0edb3e56a2a1f91e80c6d9
child 351154 14c1777276fe2a52b52551f258f340db67dc3ec5
push id1324
push usermtabara@mozilla.com
push dateMon, 16 Jan 2017 13:07:44 +0000
treeherdermozilla-release@a01c49833940 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence
bugs1290240
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 1290240 - Switch GCHelperState::thread to js::Thread::Id instead of PRThread*; r=terrence
js/src/jsgc.cpp
js/src/jsgc.h
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -3312,18 +3312,18 @@ GCHelperState::waitForBackgroundThread(j
 
 void
 GCHelperState::work()
 {
     MOZ_ASSERT(CanUseExtraThreads());
 
     AutoLockGC lock(rt);
 
-    MOZ_ASSERT(!thread);
-    thread = PR_GetCurrentThread();
+    MOZ_ASSERT(thread.isNothing());
+    thread = mozilla::Some(ThisThread::GetId());
 
     TraceLoggerThread* logger = TraceLoggerForCurrentThread();
 
     switch (state(lock)) {
 
       case IDLE:
         MOZ_CRASH("GC helper triggered on idle state");
         break;
@@ -3333,17 +3333,17 @@ GCHelperState::work()
         doSweep(lock);
         MOZ_ASSERT(state(lock) == SWEEPING);
         break;
       }
 
     }
 
     setState(IDLE, lock);
-    thread = nullptr;
+    thread.reset();
 
     done.notify_all();
 }
 
 void
 GCRuntime::queueZonesForBackgroundSweep(ZoneList& zones)
 {
     AutoLockHelperThreadState helperLock;
@@ -3414,17 +3414,17 @@ GCHelperState::doSweep(AutoLockGC& lock)
             rt->gc.sweepBackgroundThings(zones, freeLifoAlloc, BackgroundThread);
         }
     } while (!rt->gc.backgroundSweepZones.isEmpty());
 }
 
 bool
 GCHelperState::onBackgroundThread()
 {
-    return PR_GetCurrentThread() == thread;
+    return thread.isSome() && *thread == ThisThread::GetId();
 }
 
 bool
 GCRuntime::shouldReleaseObservedTypes()
 {
     bool releaseTypes = false;
 
 #ifdef JS_GC_ZEAL
--- a/js/src/jsgc.h
+++ b/js/src/jsgc.h
@@ -15,16 +15,17 @@
 #include "mozilla/TypeTraits.h"
 
 #include "jslock.h"
 
 #include "js/GCAPI.h"
 #include "js/SliceBudget.h"
 #include "js/Vector.h"
 #include "threading/ConditionVariable.h"
+#include "threading/Thread.h"
 #include "vm/NativeObject.h"
 
 namespace js {
 
 class AutoLockHelperThreadState;
 unsigned GetCPUCount();
 
 enum ThreadType
@@ -857,18 +858,18 @@ class GCHelperState
     // Condvar for notifying the main thread when work has finished. This is
     // associated with the runtime's GC lock --- the worker thread state
     // condvars can't be used here due to lock ordering issues.
     js::ConditionVariable done;
 
     // Activity for the helper to do, protected by the GC lock.
     State state_;
 
-    // Thread which work is being performed on, or null.
-    PRThread* thread;
+    // Thread which work is being performed on, if any.
+    mozilla::Maybe<Thread::Id> thread;
 
     void startBackgroundThread(State newState, const AutoLockGC& lock,
                                const AutoLockHelperThreadState& helperLock);
     void waitForBackgroundThread(js::AutoLockGC& lock);
 
     State state(const AutoLockGC&);
     void setState(State state, const AutoLockGC&);
 
@@ -882,18 +883,17 @@ class GCHelperState
     }
 
     void doSweep(AutoLockGC& lock);
 
   public:
     explicit GCHelperState(JSRuntime* rt)
       : rt(rt),
         done(),
-        state_(IDLE),
-        thread(nullptr)
+        state_(IDLE)
     { }
 
     void finish();
 
     void work();
 
     void maybeStartBackgroundSweep(const AutoLockGC& lock,
                                    const AutoLockHelperThreadState& helperLock);