Bug 1340537 - Don't trace parse task things if they cannot be GCed, r=jonco.
authorBrian Hackett <bhackett1024@gmail.com>
Tue, 21 Feb 2017 06:46:22 -0700
changeset 373096 1dd59724f67f32bd626fe6b68a5c7d1eaeaa274f
parent 373095 bb77e8d293e031b08825e588fe4cea11ff094a2e
child 373097 d0a0da23ac051c8d906affcae71d89b597980af3
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs1340537
milestone54.0a1
Bug 1340537 - Don't trace parse task things if they cannot be GCed, r=jonco.
js/src/vm/HelperThreads.cpp
--- a/js/src/vm/HelperThreads.cpp
+++ b/js/src/vm/HelperThreads.cpp
@@ -23,16 +23,18 @@
 #include "vm/TraceLogging.h"
 #include "vm/Xdr.h"
 
 #include "jscntxtinlines.h"
 #include "jscompartmentinlines.h"
 #include "jsobjinlines.h"
 #include "jsscriptinlines.h"
 
+#include "vm/NativeObject-inl.h"
+
 using namespace js;
 
 using mozilla::ArrayLength;
 using mozilla::DebugOnly;
 using mozilla::Unused;
 using mozilla::TimeDuration;
 
 namespace js {
@@ -347,16 +349,21 @@ ParseTask::~ParseTask()
         js_delete(errors[i]);
 }
 
 void
 ParseTask::trace(JSTracer* trc)
 {
     if (parseGlobal->runtimeFromAnyThread() != trc->runtime())
         return;
+    Zone* zone = MaybeForwarded(parseGlobal)->zoneFromAnyThread();
+    if (zone->usedByHelperThread()) {
+        MOZ_ASSERT(!zone->isCollecting());
+        return;
+    }
 
     TraceManuallyBarrieredEdge(trc, &parseGlobal, "ParseTask::parseGlobal");
     if (script)
         TraceManuallyBarrieredEdge(trc, &script, "ParseTask::script");
     if (sourceObject)
         TraceManuallyBarrieredEdge(trc, &sourceObject, "ParseTask::sourceObject");
 }
 
@@ -1224,17 +1231,17 @@ HelperThread::handleGCParallelWorkload(A
     gcParallelTask()->runFromHelperThread(locked);
     currentTask.reset();
     HelperThreadState().notifyAll(GlobalHelperThreadState::CONSUMER, locked);
 }
 
 static void
 LeaveParseTaskZone(JSRuntime* rt, ParseTask* task)
 {
-    // Mark the zone as no longer in use by an JSContext, and available
+    // 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());
 }
 
 ParseTask*
 GlobalHelperThreadState::removeFinishedParseTask(ParseTaskKind kind, void* token)
 {
     // The token is a ParseTask* which should be in the finished list.