Bug 1144743 part 1. Add a hasPollutedGlobalScope flag to scripts. r=luke
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 20 Mar 2015 00:34:07 -0400
changeset 263528 df51f5c349f09ba2e1769b0297cd75e097bdc5b2
parent 263527 74aab037e628b4f5d772cd9ad13731fdfc7dff02
child 263529 d67adea5f54e30fb5e8d96a5f1e40e6cd1c29f1a
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1144743
milestone39.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 1144743 part 1. Add a hasPollutedGlobalScope flag to scripts. r=luke
js/src/jsscript.cpp
js/src/jsscript.h
js/src/vm/Xdr.h
--- a/js/src/jsscript.cpp
+++ b/js/src/jsscript.cpp
@@ -571,17 +571,18 @@ js::XDRScript(XDRState<mode> *xdr, Handl
         IsLegacyGenerator,
         IsStarGenerator,
         OwnSource,
         ExplicitUseStrict,
         SelfHosted,
         IsCompileAndGo,
         HasSingleton,
         TreatAsRunOnce,
-        HasLazyScript
+        HasLazyScript,
+        HasPollutedGlobalScope,
     };
 
     uint32_t length, lineno, column, nslots, staticLevel;
     uint32_t natoms, nsrcnotes, i;
     uint32_t nconsts, nobjects, nregexps, ntrynotes, nblockscopes, nyieldoffsets;
     uint32_t prologLength, version;
     uint32_t funLength = 0;
     uint32_t nTypeSets = 0;
@@ -689,16 +690,18 @@ js::XDRScript(XDRState<mode> *xdr, Handl
         if (script->compileAndGo())
             scriptBits |= (1 << IsCompileAndGo);
         if (script->hasSingletons())
             scriptBits |= (1 << HasSingleton);
         if (script->treatAsRunOnce())
             scriptBits |= (1 << TreatAsRunOnce);
         if (script->isRelazifiable())
             scriptBits |= (1 << HasLazyScript);
+        if (script->hasPollutedGlobalScope())
+            scriptBits |= (1 << HasPollutedGlobalScope);
     }
 
     if (!xdr->codeUint32(&prologLength))
         return false;
     if (!xdr->codeUint32(&version))
         return false;
 
     // To fuse allocations, we need lengths of all embedded arrays early.
@@ -806,16 +809,18 @@ js::XDRScript(XDRState<mode> *xdr, Handl
         if (scriptBits & (1 << IsGeneratorExp))
             script->isGeneratorExp_ = true;
         if (scriptBits & (1 << IsCompileAndGo))
             script->compileAndGo_ = true;
         if (scriptBits & (1 << HasSingleton))
             script->hasSingletons_ = true;
         if (scriptBits & (1 << TreatAsRunOnce))
             script->treatAsRunOnce_ = true;
+        if (scriptBits & (1 << HasPollutedGlobalScope))
+            script->hasPollutedGlobalScope_ = true;
 
         if (scriptBits & (1 << IsLegacyGenerator)) {
             MOZ_ASSERT(!(scriptBits & (1 << IsStarGenerator)));
             script->setGeneratorKind(LegacyGenerator);
         } else if (scriptBits & (1 << IsStarGenerator))
             script->setGeneratorKind(StarGenerator);
     }
 
--- a/js/src/jsscript.h
+++ b/js/src/jsscript.h
@@ -913,16 +913,21 @@ class JSScript : public js::gc::TenuredC
     bool strict_:1;
 
     // Code has "use strict"; explicitly.
     bool explicitUseStrict_:1;
 
     // See Parser::compileAndGo.
     bool compileAndGo_:1;
 
+    // True if the script has a non-syntactic scope on its dynamic scope chain.
+    // That is, there are objects about which we know nothing between the
+    // outermost syntactic scope and the global.
+    bool hasPollutedGlobalScope_:1;
+
     // see Parser::selfHostingMode.
     bool selfHosted_:1;
 
     // See FunctionContextFlags.
     bool bindingsAccessedDynamically_:1;
     bool funHasExtensibleScope_:1;
     bool funNeedsDeclEnvObject_:1;
 
@@ -1138,16 +1143,20 @@ class JSScript : public js::gc::TenuredC
     }
 
     bool explicitUseStrict() const { return explicitUseStrict_; }
 
     bool compileAndGo() const {
         return compileAndGo_;
     }
 
+    bool hasPollutedGlobalScope() const {
+        return hasPollutedGlobalScope_;
+    }
+
     bool selfHosted() const { return selfHosted_; }
     bool bindingsAccessedDynamically() const { return bindingsAccessedDynamically_; }
     bool funHasExtensibleScope() const {
         return funHasExtensibleScope_;
     }
     bool funNeedsDeclEnvObject() const {
         return funNeedsDeclEnvObject_;
     }
--- a/js/src/vm/Xdr.h
+++ b/js/src/vm/Xdr.h
@@ -24,17 +24,17 @@ namespace js {
  * versions.  If deserialization fails, the data should be invalidated if
  * possible.
  *
  * When you change this, run make_opcode_doc.py and copy the new output into
  * this wiki page:
  *
  *  https://developer.mozilla.org/en-US/docs/SpiderMonkey/Internals/Bytecode
  */
-static const uint32_t XDR_BYTECODE_VERSION_SUBTRAHEND = 259;
+static const uint32_t XDR_BYTECODE_VERSION_SUBTRAHEND = 260;
 static const uint32_t XDR_BYTECODE_VERSION =
     uint32_t(0xb973c0de - XDR_BYTECODE_VERSION_SUBTRAHEND);
 
 static_assert(JSErr_Limit == 388,
               "GREETINGS, POTENTIAL SUBTRAHEND INCREMENTER! If you added or "
               "removed MSG_DEFs from js.msg, you should increment "
               "XDR_BYTECODE_VERSION_SUBTRAHEND and update this assertion's "
               "expected JSErr_Limit value.");