Bug 1144743 part 1. Add a hasPollutedGlobalScope flag to scripts. r=luke

This commit is contained in:
Boris Zbarsky 2015-03-20 00:34:07 -04:00
parent 3c7aa89ef5
commit ccaabb9de0
3 changed files with 16 additions and 2 deletions

View File

@ -576,7 +576,8 @@ js::XDRScript(XDRState<mode> *xdr, HandleObject enclosingScope, HandleScript enc
IsCompileAndGo, IsCompileAndGo,
HasSingleton, HasSingleton,
TreatAsRunOnce, TreatAsRunOnce,
HasLazyScript HasLazyScript,
HasPollutedGlobalScope,
}; };
uint32_t length, lineno, column, nslots, staticLevel; uint32_t length, lineno, column, nslots, staticLevel;
@ -694,6 +695,8 @@ js::XDRScript(XDRState<mode> *xdr, HandleObject enclosingScope, HandleScript enc
scriptBits |= (1 << TreatAsRunOnce); scriptBits |= (1 << TreatAsRunOnce);
if (script->isRelazifiable()) if (script->isRelazifiable())
scriptBits |= (1 << HasLazyScript); scriptBits |= (1 << HasLazyScript);
if (script->hasPollutedGlobalScope())
scriptBits |= (1 << HasPollutedGlobalScope);
} }
if (!xdr->codeUint32(&prologLength)) if (!xdr->codeUint32(&prologLength))
@ -811,6 +814,8 @@ js::XDRScript(XDRState<mode> *xdr, HandleObject enclosingScope, HandleScript enc
script->hasSingletons_ = true; script->hasSingletons_ = true;
if (scriptBits & (1 << TreatAsRunOnce)) if (scriptBits & (1 << TreatAsRunOnce))
script->treatAsRunOnce_ = true; script->treatAsRunOnce_ = true;
if (scriptBits & (1 << HasPollutedGlobalScope))
script->hasPollutedGlobalScope_ = true;
if (scriptBits & (1 << IsLegacyGenerator)) { if (scriptBits & (1 << IsLegacyGenerator)) {
MOZ_ASSERT(!(scriptBits & (1 << IsStarGenerator))); MOZ_ASSERT(!(scriptBits & (1 << IsStarGenerator)));

View File

@ -918,6 +918,11 @@ class JSScript : public js::gc::TenuredCell
// See Parser::compileAndGo. // See Parser::compileAndGo.
bool compileAndGo_:1; 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. // see Parser::selfHostingMode.
bool selfHosted_:1; bool selfHosted_:1;
@ -1143,6 +1148,10 @@ class JSScript : public js::gc::TenuredCell
return compileAndGo_; return compileAndGo_;
} }
bool hasPollutedGlobalScope() const {
return hasPollutedGlobalScope_;
}
bool selfHosted() const { return selfHosted_; } bool selfHosted() const { return selfHosted_; }
bool bindingsAccessedDynamically() const { return bindingsAccessedDynamically_; } bool bindingsAccessedDynamically() const { return bindingsAccessedDynamically_; }
bool funHasExtensibleScope() const { bool funHasExtensibleScope() const {

View File

@ -29,7 +29,7 @@ namespace js {
* *
* https://developer.mozilla.org/en-US/docs/SpiderMonkey/Internals/Bytecode * 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 = static const uint32_t XDR_BYTECODE_VERSION =
uint32_t(0xb973c0de - XDR_BYTECODE_VERSION_SUBTRAHEND); uint32_t(0xb973c0de - XDR_BYTECODE_VERSION_SUBTRAHEND);