Bug 940321 - Eliminate ambient noScriptRval, and make it live exclusively on CompileOptions. r=jandem
authorBobby Holley <bobbyholley@gmail.com>
Thu, 31 Jul 2014 09:55:20 -0700
changeset 197061 3069d118d21d9b4c238c8dc202fa296809a619e7
parent 197060 f644ef79d9eeaab96efd61fd089e050305aa500c
child 197062 9cdb0d2dcf5d8a2fd66d4927d8b2cbd4b5562ba4
push id27230
push userryanvm@gmail.com
push dateThu, 31 Jul 2014 19:42:35 +0000
treeherdermozilla-central@1f216e2e339e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs940321
milestone34.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 940321 - Eliminate ambient noScriptRval, and make it live exclusively on CompileOptions. r=jandem
dom/workers/RuntimeService.cpp
dom/workers/ScriptLoader.cpp
dom/workers/WorkerPrivate.cpp
js/src/jsapi.cpp
js/src/jsapi.h
js/src/shell/js.cpp
--- a/dom/workers/RuntimeService.cpp
+++ b/dom/workers/RuntimeService.cpp
@@ -157,18 +157,17 @@ static_assert(MAX_WORKERS_PER_DOMAIN >= 
 #define PREF_DOM_FETCH_ENABLED         "dom.fetch.enabled"
 #define PREF_WORKERS_LATEST_JS_VERSION "dom.workers.latestJSVersion"
 
 namespace {
 
 const uint32_t kNoIndex = uint32_t(-1);
 
 const JS::ContextOptions kRequiredContextOptions =
-  JS::ContextOptions().setDontReportUncaught(true)
-                      .setNoScriptRval(true);
+  JS::ContextOptions().setDontReportUncaught(true);
 
 uint32_t gMaxWorkersPerDomain = MAX_WORKERS_PER_DOMAIN;
 
 // Does not hold an owning reference.
 RuntimeService* gRuntimeService = nullptr;
 
 // Only non-null during the call to Init.
 RuntimeService* gRuntimeServiceDuringInit = nullptr;
--- a/dom/workers/ScriptLoader.cpp
+++ b/dom/workers/ScriptLoader.cpp
@@ -740,17 +740,18 @@ ScriptExecutorRunnable::WorkerRun(JSCont
       scriptloader::ReportLoadError(aCx, loadInfo.mURL, loadInfo.mLoadResult,
                                     false);
       return true;
     }
 
     NS_ConvertUTF16toUTF8 filename(loadInfo.mURL);
 
     JS::CompileOptions options(aCx);
-    options.setFileAndLine(filename.get(), 1);
+    options.setFileAndLine(filename.get(), 1)
+           .setNoScriptRval(true);
 
     JS::SourceBufferHolder srcBuf(loadInfo.mScriptTextBuf,
                                   loadInfo.mScriptTextLength,
                                   JS::SourceBufferHolder::GiveOwnership);
     loadInfo.mScriptTextBuf = nullptr;
     loadInfo.mScriptTextLength = 0;
 
     if (!JS::Evaluate(aCx, global, options, srcBuf)) {
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -5425,17 +5425,18 @@ WorkerPrivate::RunExpiredTimeouts(JSCont
         retval = false;
         break;
       }
     }
     else {
       nsString expression = info->mTimeoutString;
 
       JS::CompileOptions options(aCx);
-      options.setFileAndLine(info->mFilename.get(), info->mLineNumber);
+      options.setFileAndLine(info->mFilename.get(), info->mLineNumber)
+             .setNoScriptRval(true);
 
       if ((expression.IsEmpty() ||
            !JS::Evaluate(aCx, global, options, expression.get(), expression.Length())) &&
           !JS_ReportPendingException(aCx)) {
         retval = false;
         break;
       }
     }
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -4426,17 +4426,16 @@ JS::OwningCompileOptions::setIntroducerF
 
 JS::CompileOptions::CompileOptions(JSContext *cx, JSVersion version)
     : ReadOnlyCompileOptions(), elementRoot(cx), elementAttributeNameRoot(cx),
       introductionScriptRoot(cx)
 {
     this->version = (version != JSVERSION_UNKNOWN) ? version : cx->findVersion();
 
     compileAndGo = false;
-    noScriptRval = cx->options().noScriptRval();
     strictOption = cx->runtime()->options().strictMode();
     extraWarningsOption = cx->compartment()->options().extraWarnings(cx);
     werrorOption = cx->runtime()->options().werror();
     asmJSOption = cx->runtime()->options().asmJS();
 }
 
 bool
 JS::Compile(JSContext *cx, HandleObject obj, const ReadOnlyCompileOptions &options,
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -1512,18 +1512,17 @@ RuntimeOptionsRef(JSRuntime *rt);
 JS_PUBLIC_API(RuntimeOptions &)
 RuntimeOptionsRef(JSContext *cx);
 
 class JS_PUBLIC_API(ContextOptions) {
   public:
     ContextOptions()
       : privateIsNSISupports_(false),
         dontReportUncaught_(false),
-        noDefaultCompartmentObject_(false),
-        noScriptRval_(false)
+        noDefaultCompartmentObject_(false)
     {
     }
 
     bool privateIsNSISupports() const { return privateIsNSISupports_; }
     ContextOptions &setPrivateIsNSISupports(bool flag) {
         privateIsNSISupports_ = flag;
         return *this;
     }
@@ -1547,31 +1546,20 @@ class JS_PUBLIC_API(ContextOptions) {
         noDefaultCompartmentObject_ = flag;
         return *this;
     }
     ContextOptions &toggleNoDefaultCompartmentObject() {
         noDefaultCompartmentObject_ = !noDefaultCompartmentObject_;
         return *this;
     }
 
-    bool noScriptRval() const { return noScriptRval_; }
-    ContextOptions &setNoScriptRval(bool flag) {
-        noScriptRval_ = flag;
-        return *this;
-    }
-    ContextOptions &toggleNoScriptRval() {
-        noScriptRval_ = !noScriptRval_;
-        return *this;
-    }
-
   private:
     bool privateIsNSISupports_ : 1;
     bool dontReportUncaught_ : 1;
     bool noDefaultCompartmentObject_ : 1;
-    bool noScriptRval_ : 1;
 };
 
 JS_PUBLIC_API(ContextOptions &)
 ContextOptionsRef(JSContext *cx);
 
 class JS_PUBLIC_API(AutoSaveContextOptions) {
   public:
     explicit AutoSaveContextOptions(JSContext *cx)
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -418,24 +418,22 @@ RunFile(JSContext *cx, Handle<JSObject*>
         }
     }
     ungetc(ch, file);
 
     int64_t t1 = PRMJ_Now();
     RootedScript script(cx);
 
     {
-        JS::AutoSaveContextOptions asco(cx);
-        JS::ContextOptionsRef(cx).setNoScriptRval(true);
-
         CompileOptions options(cx);
         options.setIntroductionType("js shell file")
                .setUTF8(true)
                .setFileAndLine(filename, 1)
-               .setCompileAndGo(true);
+               .setCompileAndGo(true)
+               .setNoScriptRval(true);
 
         gGotError = false;
         (void) JS::Compile(cx, obj, options, file, &script);
         JS_ASSERT_IF(!script, gGotError);
     }
 
     #ifdef DEBUG
         if (dumpEntrainedVariables)
@@ -1242,18 +1240,16 @@ Evaluate(JSContext *cx, unsigned argc, j
         AutoSaveFrameChain asfc(cx);
         if (saveFrameChain && !asfc.save())
             return false;
 
         JSAutoCompartment ac(cx, global);
         RootedScript script(cx);
 
         {
-            JS::AutoSaveContextOptions asco(cx);
-            JS::ContextOptionsRef(cx).setNoScriptRval(options.noScriptRval);
             if (saveBytecode) {
                 if (!JS::CompartmentOptionsRef(cx).getSingletonsAsTemplates()) {
                     JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr,
                                          JSSMSG_CACHE_SINGLETON_FAILED);
                     return false;
                 }
                 JS::CompartmentOptionsRef(cx).setCloneSingletons(true);
             }
@@ -1453,23 +1449,21 @@ Run(JSContext *cx, unsigned argc, jsval 
     const jschar *ucbuf = chars.twoByteRange().start().get();
     size_t buflen = str->length();
 
     JS::Anchor<JSString *> a_str(str);
 
     RootedScript script(cx);
     int64_t startClock = PRMJ_Now();
     {
-        JS::AutoSaveContextOptions asco(cx);
-        JS::ContextOptionsRef(cx).setNoScriptRval(true);
-
         JS::CompileOptions options(cx);
         options.setIntroductionType("js shell run")
                .setFileAndLine(filename.ptr(), 1)
-               .setCompileAndGo(true);
+               .setCompileAndGo(true)
+               .setNoScriptRval(true);
         if (!JS_CompileUCScript(cx, thisobj, ucbuf, buflen, options, &script))
             return false;
     }
 
     if (!JS_ExecuteScript(cx, thisobj, script))
         return false;
 
     int64_t endClock = PRMJ_Now();
@@ -2181,24 +2175,22 @@ DisassFile(JSContext *cx, unsigned argc,
     if (!str)
         return false;
     JSAutoByteString filename(cx, str);
     if (!filename)
         return false;
     RootedScript script(cx);
 
     {
-        JS::AutoSaveContextOptions asco(cx);
-        JS::ContextOptionsRef(cx).setNoScriptRval(true);
-
         CompileOptions options(cx);
         options.setIntroductionType("js shell disFile")
                .setUTF8(true)
                .setFileAndLine(filename.ptr(), 1)
-               .setCompileAndGo(true);
+               .setCompileAndGo(true)
+               .setNoScriptRval(true);
 
         if (!JS::Compile(cx, thisobj, options, filename.ptr(), &script))
             return false;
     }
 
     Sprinter sprinter(cx);
     if (!sprinter.init())
         return false;
@@ -3327,22 +3319,21 @@ Compile(JSContext *cx, unsigned argc, js
     JSFlatString *scriptContents = args[0].toString()->ensureFlat(cx);
     if (!scriptContents)
         return false;
 
     AutoStableStringChars stableChars(cx);
     if (!stableChars.initTwoByte(cx, scriptContents))
         return false;
 
-    JS::AutoSaveContextOptions asco(cx);
-    JS::ContextOptionsRef(cx).setNoScriptRval(true);
     JS::CompileOptions options(cx);
     options.setIntroductionType("js shell compile")
            .setFileAndLine("<string>", 1)
-           .setCompileAndGo(true);
+           .setCompileAndGo(true)
+           .setNoScriptRval(true);
     RootedScript script(cx);
     const jschar *chars = stableChars.twoByteRange().start().get();
     bool ok = JS_CompileUCScript(cx, global, chars,
                                  scriptContents->length(), options, &script);
     args.rval().setUndefined();
     return ok;
 }