Bug 1165486 - Use JS::CompileForNonSyntacticScope in Gecko where we used to set polluted global scope. (r=bz, rs=bholley)
☠☠ backed out by b4e617011c42 ☠ ☠
authorShu-yu Guo <shu@rfrn.org>
Wed, 17 Jun 2015 21:26:57 -0700
changeset 280271 4143cca42cc7e7bf55b3cd1b376dbff26e3d51f2
parent 280270 5abb37cb04950f15ef98d37b41ae7a60ff6d6a10
child 280272 97352c48fb985506afcb9550bd507f88c17f96c7
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
@@ -1780,18 +1780,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,