From ccaabb9de0b5827a4da5aa136c49ce1f0fc98eb6 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 20 Mar 2015 00:34:07 -0400 Subject: [PATCH] Bug 1144743 part 1. Add a hasPollutedGlobalScope flag to scripts. r=luke --- js/src/jsscript.cpp | 7 ++++++- js/src/jsscript.h | 9 +++++++++ js/src/vm/Xdr.h | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/js/src/jsscript.cpp b/js/src/jsscript.cpp index 85f93d7ff489..c5ef0123011a 100644 --- a/js/src/jsscript.cpp +++ b/js/src/jsscript.cpp @@ -576,7 +576,8 @@ js::XDRScript(XDRState *xdr, HandleObject enclosingScope, HandleScript enc IsCompileAndGo, HasSingleton, TreatAsRunOnce, - HasLazyScript + HasLazyScript, + HasPollutedGlobalScope, }; uint32_t length, lineno, column, nslots, staticLevel; @@ -694,6 +695,8 @@ js::XDRScript(XDRState *xdr, HandleObject enclosingScope, HandleScript enc scriptBits |= (1 << TreatAsRunOnce); if (script->isRelazifiable()) scriptBits |= (1 << HasLazyScript); + if (script->hasPollutedGlobalScope()) + scriptBits |= (1 << HasPollutedGlobalScope); } if (!xdr->codeUint32(&prologLength)) @@ -811,6 +814,8 @@ js::XDRScript(XDRState *xdr, HandleObject enclosingScope, HandleScript enc 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))); diff --git a/js/src/jsscript.h b/js/src/jsscript.h index 019b9a286588..26f31831bc4d 100644 --- a/js/src/jsscript.h +++ b/js/src/jsscript.h @@ -918,6 +918,11 @@ class JSScript : public js::gc::TenuredCell // 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; @@ -1143,6 +1148,10 @@ class JSScript : public js::gc::TenuredCell return compileAndGo_; } + bool hasPollutedGlobalScope() const { + return hasPollutedGlobalScope_; + } + bool selfHosted() const { return selfHosted_; } bool bindingsAccessedDynamically() const { return bindingsAccessedDynamically_; } bool funHasExtensibleScope() const { diff --git a/js/src/vm/Xdr.h b/js/src/vm/Xdr.h index 5aa1f60409a7..2db29922f77a 100644 --- a/js/src/vm/Xdr.h +++ b/js/src/vm/Xdr.h @@ -29,7 +29,7 @@ namespace js { * * 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);