Bug 1341283 - Avoid conflicts between GC zeal behavior and cooperative multithreading context switches, r=jonco.
authorBrian Hackett <bhackett1024@gmail.com>
Wed, 22 Feb 2017 05:22:47 -0700
changeset 344291 3c365d2e82021bff402507092a42b2b4c00ed297
parent 344290 c6a89afa0c6b9c26cdba08a5d8e4115bc699d8d7
child 344292 246d39385cd3ac5273bb9d6b184a0005c3791079
push id31406
push userkwierso@gmail.com
push dateWed, 22 Feb 2017 23:01:18 +0000
treeherdermozilla-central@32dcdde1fc64 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs1341283
milestone54.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 1341283 - Avoid conflicts between GC zeal behavior and cooperative multithreading context switches, r=jonco.
js/src/gc/Verifier.cpp
js/src/shell/js.cpp
--- a/js/src/gc/Verifier.cpp
+++ b/js/src/gc/Verifier.cpp
@@ -174,18 +174,23 @@ NextNode(VerifyNode* node)
 }
 
 void
 gc::GCRuntime::startVerifyPreBarriers()
 {
     if (verifyPreData || isIncrementalGCInProgress())
         return;
 
-    if (IsIncrementalGCUnsafe(rt) != AbortReason::None || TlsContext.get()->keepAtoms || rt->hasHelperThreadZones())
+    if (IsIncrementalGCUnsafe(rt) != AbortReason::None ||
+        TlsContext.get()->keepAtoms ||
+        rt->hasHelperThreadZones() ||
+        rt->cooperatingContexts().length() != 1)
+    {
         return;
+    }
 
     number++;
 
     VerifyPreTracer* trc = js_new<VerifyPreTracer>(rt);
     if (!trc)
         return;
 
     AutoPrepareForTracing prep(TlsContext.get(), WithAtoms);
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -3595,16 +3595,21 @@ EvalInThread(JSContext* cx, unsigned arg
         // Disallowing cooperative multithreading in worker runtimes allows
         // yield state to be process wide, and some other simplifications.
         // When we have a better idea of how cooperative multithreading will be
         // used in the browser this restriction might be relaxed.
         JS_ReportErrorASCII(cx, "Cooperative multithreading in worker runtimes is not supported");
         return false;
     }
 
+    if (cooperative && !cx->runtime()->gc.canChangeActiveContext(cx)) {
+        JS_ReportErrorASCII(cx, "Cooperating multithreading context switches are not currently allowed");
+        return false;
+    }
+
     if (!args[0].toString()->ensureLinear(cx))
         return false;
 
     if (!workerThreadsLock) {
         workerThreadsLock = js_new<Mutex>(mutexid::ShellWorkerThreads);
         if (!workerThreadsLock) {
             ReportOutOfMemory(cx);
             return false;