Bug 1165486 - Use JS::CompileForNonSyntacticScope in Gecko where we used to set polluted global scope. (r=bz, rs=bholley)
☠☠ backed out by 62c1baace9f4 ☠ ☠
authorShu-yu Guo <shu@rfrn.org>
Mon, 15 Jun 2015 21:32:30 -0700
changeset 279813 8031242fe5e5aa19b4270693de9bed6a0080e26f
parent 279812 0cfeee56564bca5da7000e92633780b64e64f6e7
child 279814 9ec0a501209a1f0d32b5ef61d1cf2d1f15f6b2e1
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, bholley
bugs1165486
milestone41.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 1165486 - Use JS::CompileForNonSyntacticScope in Gecko where we used to set polluted global scope. (r=bz, rs=bholley)
dom/base/nsFrameMessageManager.cpp
js/xpconnect/loader/mozJSSubScriptLoader.cpp
--- a/dom/base/nsFrameMessageManager.cpp
+++ b/dom/base/nsFrameMessageManager.cpp
@@ -1783,18 +1783,17 @@ nsMessageManagerScriptExecutor::TryCache
     JS::Rooted<JSScript*> script(cx);
 
     if (aRunInGlobalScope) {
       if (!JS::Compile(cx, options, srcBuf, &script)) {
         return;
       }
     } else {
       // We're going to run these against some non-global scope.
-      options.setHasPollutedScope(true);
-      if (!JS::Compile(cx, options, srcBuf, &script)) {
+      if (!JS::CompileForNonSyntacticScope(cx, options, srcBuf, &script)) {
         return;
       }
     }
 
     aScriptp.set(script);
 
     nsAutoCString scheme;
     uri->GetScheme(scheme);
--- a/js/xpconnect/loader/mozJSSubScriptLoader.cpp
+++ b/js/xpconnect/loader/mozJSSubScriptLoader.cpp
@@ -141,35 +141,39 @@ PrepareScript(nsIURI* uri,
         JS::SourceBufferHolder srcBuf(scriptBuf, scriptLength,
                                       JS::SourceBufferHolder::GiveOwnership);
 
         if (NS_FAILED(rv)) {
             return ReportError(cx, LOAD_ERROR_BADCHARSET, uri);
         }
 
         if (!reuseGlobal) {
-            options.setHasPollutedScope(!JS_IsGlobalObject(targetObj));
-            JS::Compile(cx, options, srcBuf, script);
+            if (JS_IsGlobalObject(targetObj))
+                JS::Compile(cx, options, srcBuf, script);
+            else
+                JS::CompileForNonSyntacticScope(cx, options, srcBuf, script);
         } else {
             AutoObjectVector scopeChain(cx);
             if (!JS_IsGlobalObject(targetObj) &&
                 !scopeChain.append(targetObj)) {
                 return NS_ERROR_OUT_OF_MEMORY;
             }
             // XXXbz do we really not care if the compile fails???
             JS::CompileFunction(cx, scopeChain, options, nullptr, 0, nullptr,
                                 srcBuf, function);
         }
     } else {
         // We only use lazy source when no special encoding is specified because
         // the lazy source loader doesn't know the encoding.
         if (!reuseGlobal) {
-            options.setSourceIsLazy(true)
-                   .setHasPollutedScope(!JS_IsGlobalObject(targetObj));
-            JS::Compile(cx, options, buf, len, script);
+            options.setSourceIsLazy(true);
+            if (JS_IsGlobalObject(targetObj))
+                JS::Compile(cx, options, buf, len, script);
+            else
+                JS::CompileForNonSyntacticScope(cx, options, buf, len, script);
         } else {
             AutoObjectVector scopeChain(cx);
             if (!JS_IsGlobalObject(targetObj) &&
                 !scopeChain.append(targetObj)) {
                 return NS_ERROR_OUT_OF_MEMORY;
             }
             // XXXbz do we really not care if the compile fails???
             JS::CompileFunction(cx, scopeChain, options, nullptr, 0, nullptr,