Bug 1402582 - Make shell's EnvironmentPreparer grab cx from TLS. r=bhackett, a=NPOTB
authorSteve Fink <sfink@mozilla.com>
Tue, 10 Oct 2017 16:16:21 -0700
changeset 432498 d1ca9be4e5210cec58daaad6deb5003d299274d9
parent 432495 95e2671a811d131c93a862bf6266394d60a8e5d3
child 432499 025fd4ef0173ab04e2782efb518fbc3c542b9f3a
push id7969
push userryanvm@gmail.com
push dateFri, 13 Oct 2017 22:47:45 +0000
treeherdermozilla-beta@d8aed408f78a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett, NPOTB
bugs1402582
milestone57.0
Bug 1402582 - Make shell's EnvironmentPreparer grab cx from TLS. r=bhackett, a=NPOTB
js/src/shell/js.cpp
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -240,19 +240,17 @@ OffThreadState::waitUntilDone(JSContext*
     return holdToken;
 }
 
 struct ShellCompartmentPrivate {
     JS::Heap<JSObject*> grayRoot;
 };
 
 struct MOZ_STACK_CLASS EnvironmentPreparer : public js::ScriptEnvironmentPreparer {
-    JSContext* cx;
     explicit EnvironmentPreparer(JSContext* cx)
-      : cx(cx)
     {
         js::SetScriptEnvironmentPreparer(cx, this);
     }
     void invoke(JS::HandleObject scope, Closure& closure) override;
 };
 
 // Shell state set once at startup.
 static bool enableCodeCoverage = false;
@@ -556,16 +554,17 @@ SkipUTF8BOM(FILE* file)
         ungetc(ch2, file);
     if (ch1 != EOF)
         ungetc(ch1, file);
 }
 
 void
 EnvironmentPreparer::invoke(HandleObject scope, Closure& closure)
 {
+    JSContext* cx = TlsContext.get();
     MOZ_ASSERT(!JS_IsExceptionPending(cx));
 
     AutoCompartment ac(cx, scope);
     AutoReportException are(cx);
     if (!closure(cx))
         return;
 }