Bug 1301496 - Simplify runtime check when tracing helper threads r=terrence a=decoder
authorJon Coppeard <jcoppeard@mozilla.com>
Thu, 22 Sep 2016 13:02:40 +0100
changeset 314906 41b22909f10a0a8b4657da8170d10aeaec2b4af8
parent 314905 ef2896b755b744de344b24208e55adcac586b534
child 314907 20395f99a3d654cd873e01216c4438e248a0598b
push id82002
push userjcoppeard@mozilla.com
push dateThu, 22 Sep 2016 12:06:35 +0000
treeherdermozilla-inbound@41b22909f10a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence, decoder
bugs1301496
milestone52.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 1301496 - Simplify runtime check when tracing helper threads r=terrence a=decoder
js/src/jit-test/tests/gc/bug-1301496.js
js/src/jit/CompileWrappers.cpp
js/src/jit/CompileWrappers.h
js/src/jit/IonBuilder.cpp
js/src/jscntxt.h
js/src/vm/HelperThreads.cpp
js/src/vm/HelperThreads.h
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/gc/bug-1301496.js
@@ -0,0 +1,7 @@
+if (helperThreadCount() == 0)
+    quit();
+startgc(1, 'shrinking');
+offThreadCompileScript("");
+// Adapted from randomly chosen test: js/src/jit-test/tests/parser/bug-1263355-13.js
+gczeal(9);
+newGlobal();
--- a/js/src/jit/CompileWrappers.cpp
+++ b/js/src/jit/CompileWrappers.cpp
@@ -183,16 +183,22 @@ CompileRuntime::gcNursery()
 
 void
 CompileRuntime::setMinorGCShouldCancelIonCompilations()
 {
     MOZ_ASSERT(onMainThread());
     runtime()->gc.storeBuffer.setShouldCancelIonCompilations();
 }
 
+bool
+CompileRuntime::runtimeMatches(JSRuntime* rt)
+{
+    return rt == runtime();
+}
+
 Zone*
 CompileZone::zone()
 {
     return reinterpret_cast<Zone*>(this);
 }
 
 /* static */ CompileZone*
 CompileZone::get(Zone* zone)
--- a/js/src/jit/CompileWrappers.h
+++ b/js/src/jit/CompileWrappers.h
@@ -81,16 +81,18 @@ class CompileRuntime
     bool isInsideNursery(gc::Cell* cell);
 #endif
 
     // DOM callbacks must be threadsafe (and will hopefully be removed soon).
     const DOMCallbacks* DOMcallbacks();
 
     const Nursery& gcNursery();
     void setMinorGCShouldCancelIonCompilations();
+
+    bool runtimeMatches(JSRuntime* rt);
 };
 
 class CompileZone
 {
     Zone* zone();
 
   public:
     static CompileZone* get(Zone* zone);
--- a/js/src/jit/IonBuilder.cpp
+++ b/js/src/jit/IonBuilder.cpp
@@ -14617,15 +14617,15 @@ IonBuilder::convertToBoolean(MDefinition
     current->add(result);
 
     return result;
 }
 
 void
 IonBuilder::trace(JSTracer* trc)
 {
-    if (script_->zoneFromAnyThread()->runtimeFromAnyThread() != trc->runtime())
+    if (!compartment->runtime()->runtimeMatches(trc->runtime()))
         return;
 
     TraceManuallyBarrieredEdge(trc, &script_, "IonBuiler::script_");
     if (actionableAbortScript_)
         TraceManuallyBarrieredEdge(trc, &actionableAbortScript_, "IonBuiler::actionableAbortScript_");
 }
--- a/js/src/jscntxt.h
+++ b/js/src/jscntxt.h
@@ -157,16 +157,20 @@ class ExclusiveContext : public ContextF
         MOZ_ASSERT(isJSContext());
         return isJSContext();
     }
 
     const JS::ContextOptions& options() const {
         return options_;
     }
 
+    bool runtimeMatches(JSRuntime* rt) const {
+        return runtime_ == rt;
+    }
+
   protected:
     js::gc::ArenaLists* arenas_;
 
   public:
     inline js::gc::ArenaLists* arenas() const { return arenas_; }
 
     template <typename T>
     bool isInsideCurrentZone(T thing) const {
--- a/js/src/vm/HelperThreads.cpp
+++ b/js/src/vm/HelperThreads.cpp
@@ -340,17 +340,17 @@ ParseTask::~ParseTask()
 
     for (size_t i = 0; i < errors.length(); i++)
         js_delete(errors[i]);
 }
 
 void
 ParseTask::trace(JSTracer* trc)
 {
-    if (exclusiveContextGlobal->zoneFromAnyThread()->runtimeFromAnyThread() != trc->runtime())
+    if (!cx->runtimeMatches(trc->runtime()))
         return;
 
     TraceManuallyBarrieredEdge(trc, &exclusiveContextGlobal, "ParseTask::exclusiveContextGlobal");
     if (script)
         TraceManuallyBarrieredEdge(trc, &script, "ParseTask::script");
     if (sourceObject)
         TraceManuallyBarrieredEdge(trc, &sourceObject, "ParseTask::sourceObject");
 }
--- a/js/src/vm/HelperThreads.h
+++ b/js/src/vm/HelperThreads.h
@@ -563,17 +563,17 @@ struct ParseTask
               JS::OffThreadCompileCallback callback, void* callbackData);
     bool init(JSContext* cx, const ReadOnlyCompileOptions& options);
 
     void activate(JSRuntime* rt);
     virtual void parse() = 0;
     bool finish(JSContext* cx);
 
     bool runtimeMatches(JSRuntime* rt) {
-        return exclusiveContextGlobal->runtimeFromAnyThread() == rt;
+        return cx->runtimeMatches(rt);
     }
 
     virtual ~ParseTask();
 
     void trace(JSTracer* trc);
 };
 
 struct ScriptParseTask : public ParseTask