Bug 1447964 - Improve CurrentThreadCanAccessZone() check r=jandem
authorJon Coppeard <jcoppeard@mozilla.com>
Thu, 22 Mar 2018 18:24:32 +0000
changeset 409593 e6df204b3970f1516dfb97d81c4db59a673c9e86
parent 409592 54ae81245f469e9cc2972b6f727016187602d1d6
child 409594 bdf1b3096b346d457ddea59c1ff7ff2babaefc99
push id33693
push usernbeleuzu@mozilla.com
push dateFri, 23 Mar 2018 09:52:16 +0000
treeherdermozilla-central@9cb650de48f9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1447964
milestone61.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 1447964 - Improve CurrentThreadCanAccessZone() check r=jandem
js/src/vm/HelperThreads.cpp
js/src/vm/Runtime.cpp
--- a/js/src/vm/HelperThreads.cpp
+++ b/js/src/vm/HelperThreads.cpp
@@ -1492,17 +1492,17 @@ HelperThread::handleGCParallelWorkload(A
     HelperThreadState().notifyAll(GlobalHelperThreadState::CONSUMER, locked);
 }
 
 static void
 LeaveParseTaskZone(JSRuntime* rt, ParseTask* task)
 {
     // Mark the zone as no longer in use by a helper thread, and available
     // to be collected by the GC.
-    rt->clearUsedByHelperThread(task->parseGlobal->zone());
+    rt->clearUsedByHelperThread(task->parseGlobal->zoneFromAnyThread());
 }
 
 ParseTask*
 GlobalHelperThreadState::removeFinishedParseTask(ParseTaskKind kind, void* token)
 {
     // The token is a ParseTask* which should be in the finished list.
     // Find and remove its entry.
 
--- a/js/src/vm/Runtime.cpp
+++ b/js/src/vm/Runtime.cpp
@@ -909,21 +909,22 @@ bool
 js::CurrentThreadCanAccessRuntime(const JSRuntime* rt)
 {
     return rt->activeContext() == TlsContext.get();
 }
 
 bool
 js::CurrentThreadCanAccessZone(Zone* zone)
 {
-    if (CurrentThreadCanAccessRuntime(zone->runtime_))
-        return true;
+    // Helper thread zones can only be used by their owning thread.
+    if (zone->usedByHelperThread())
+        return zone->group()->ownedByCurrentThread();
 
-    // Only zones marked for use by a helper thread can be used off thread.
-    return zone->usedByHelperThread() && zone->group()->ownedByCurrentThread();
+    // Other zones can only be accessed by the runtime's active context.
+    return CurrentThreadCanAccessRuntime(zone->runtime_);
 }
 
 #ifdef DEBUG
 bool
 js::CurrentThreadIsPerformingGC()
 {
     return TlsContext.get()->performingGC;
 }