Bug 1165486 - Rename hasPollutedGlobalScope to hasNonSyntacticScope. (r=luke)

This commit is contained in:
Shu-yu Guo 2015-06-17 21:26:57 -07:00
Родитель 6ecb6bd195
Коммит bf0309af90
18 изменённых файлов: 67 добавлений и 66 удалений

Просмотреть файл

@ -507,7 +507,7 @@ js::ExecuteInGlobalAndReturnScope(JSContext* cx, HandleObject global, HandleScri
CHECK_REQUEST(cx);
assertSameCompartment(cx, global);
MOZ_ASSERT(global->is<GlobalObject>());
MOZ_RELEASE_ASSERT(scriptArg->hasPollutedGlobalScope());
MOZ_RELEASE_ASSERT(scriptArg->hasNonSyntacticScope());
RootedScript script(cx, scriptArg);
if (script->compartment() != cx->compartment()) {

Просмотреть файл

@ -1587,9 +1587,9 @@ BytecodeEmitter::tryConvertFreeName(ParseNode* pn)
if (insideNonGlobalEval)
return false;
// Skip trying to use GNAME ops if we know our script has a polluted
// global scope, since they'll just get treated as NAME ops anyway.
if (script->hasPollutedGlobalScope())
// Skip trying to use GNAME ops if we know our script has a non-syntactic
// scope, since they'll just get treated as NAME ops anyway.
if (script->hasNonSyntacticScope())
return false;
// Deoptimized names also aren't necessarily globals.

Просмотреть файл

@ -704,13 +704,14 @@ InitFromBailout(JSContext* cx, HandleScript caller, jsbytecode* callerPC,
scopeChain = fun->environment();
}
} else {
// For global scripts without a polluted global scope the scope
// For global scripts without a non-syntactic scope the scope
// chain is the script's global (Ion does not compile scripts
// with a polluted global scope). Also note that it's invalid to
// resume into the prologue in this case because the prologue
// expects the scope chain in R1 for eval and global scripts.
// with a non-syntactic global scope). Also note that it's
// invalid to resume into the prologue in this case because
// the prologue expects the scope chain in R1 for eval and
// global scripts.
MOZ_ASSERT(!script->isForEval());
MOZ_ASSERT(!script->hasPollutedGlobalScope());
MOZ_ASSERT(!script->hasNonSyntacticScope());
scopeChain = &(script->global());
}
}

Просмотреть файл

@ -2063,7 +2063,7 @@ BaselineCompiler::emit_JSOP_IN()
bool
BaselineCompiler::emit_JSOP_GETGNAME()
{
if (script->hasPollutedGlobalScope())
if (script->hasNonSyntacticScope())
return emit_JSOP_GETNAME();
RootedPropertyName name(cx, script->getName(pc));
@ -2098,7 +2098,7 @@ BaselineCompiler::emit_JSOP_GETGNAME()
bool
BaselineCompiler::emit_JSOP_BINDGNAME()
{
if (!script->hasPollutedGlobalScope()) {
if (!script->hasNonSyntacticScope()) {
frame.push(ObjectValue(script->global()));
return true;
}
@ -2921,7 +2921,7 @@ BaselineCompiler::emit_JSOP_IMPLICITTHIS()
bool
BaselineCompiler::emit_JSOP_GIMPLICITTHIS()
{
if (!script->hasPollutedGlobalScope()) {
if (!script->hasNonSyntacticScope()) {
frame.push(UndefinedValue());
return true;
}

Просмотреть файл

@ -6133,7 +6133,7 @@ DoGetNameFallback(JSContext* cx, BaselineFrame* frame, ICGetName_Fallback* stub_
attached = true;
}
if (!attached && IsGlobalOp(JSOp(*pc)) && !script->hasPollutedGlobalScope()) {
if (!attached && IsGlobalOp(JSOp(*pc)) && !script->hasNonSyntacticScope()) {
if (!TryAttachGlobalNameAccessorStub(cx, script, pc, stub, scopeChain.as<GlobalObject>(),
name, &attached, &isTemporarilyUnoptimizable))
{
@ -6163,7 +6163,7 @@ DoGetNameFallback(JSContext* cx, BaselineFrame* frame, ICGetName_Fallback* stub_
if (attached)
return true;
if (IsGlobalOp(JSOp(*pc)) && !script->hasPollutedGlobalScope()) {
if (IsGlobalOp(JSOp(*pc)) && !script->hasNonSyntacticScope()) {
Handle<GlobalObject*> global = scopeChain.as<GlobalObject>();
if (!TryAttachGlobalNameValueStub(cx, script, pc, stub, global, name, &attached))
return false;

Просмотреть файл

@ -170,7 +170,7 @@ BytecodeAnalysis::init(TempAllocator& alloc, GSNCache& gsn)
case JSOP_GETGNAME:
case JSOP_SETGNAME:
case JSOP_STRICTSETGNAME:
if (script_->hasPollutedGlobalScope())
if (script_->hasNonSyntacticScope())
usesScopeChain_ = true;
break;

Просмотреть файл

@ -2173,12 +2173,12 @@ CheckScript(JSContext* cx, JSScript* script, bool osr)
return false;
}
if (script->hasPollutedGlobalScope() && !script->functionNonDelazifying()) {
// Support functions with a polluted global scope but not other
if (script->hasNonSyntacticScope() && !script->functionNonDelazifying()) {
// Support functions with a non-syntactic global scope but not other
// scripts. For global scripts, IonBuilder currently uses the global
// object as scope chain, this is not valid when the script has a
// polluted global scope.
TrackAndSpewIonAbort(cx, script, "has polluted global scope");
// non-syntactic global scope.
TrackAndSpewIonAbort(cx, script, "has non-syntactic global scope");
return false;
}

Просмотреть файл

@ -618,7 +618,7 @@ IonBuilder::analyzeNewLoopTypes(MBasicBlock* entry, jsbytecode* start, jsbytecod
type = MIRType_Undefined;
break;
case JSOP_GIMPLICITTHIS:
if (!script()->hasPollutedGlobalScope())
if (!script()->hasNonSyntacticScope())
type = MIRType_Undefined;
break;
case JSOP_NULL:
@ -1182,10 +1182,10 @@ IonBuilder::initScopeChain(MDefinition* callee)
return false;
}
} else {
// For global scripts without a polluted global scope, the scope chain
// is the global object.
// For global scripts without a non-syntactic global scope, the scope
// chain is the global object.
MOZ_ASSERT(!script()->isForEval());
MOZ_ASSERT(!script()->hasPollutedGlobalScope());
MOZ_ASSERT(!script()->hasNonSyntacticScope());
scope = constant(ObjectValue(script()->global()));
}
@ -1800,7 +1800,7 @@ IonBuilder::inspectOpcode(JSOp op)
case JSOP_GETGNAME:
{
PropertyName* name = info().getAtom(pc)->asPropertyName();
if (!script()->hasPollutedGlobalScope())
if (!script()->hasNonSyntacticScope())
return jsop_getgname(name);
return jsop_getname(name);
}
@ -1809,7 +1809,7 @@ IonBuilder::inspectOpcode(JSOp op)
case JSOP_STRICTSETGNAME:
{
PropertyName* name = info().getAtom(pc)->asPropertyName();
if (script()->hasPollutedGlobalScope())
if (script()->hasNonSyntacticScope())
return jsop_setprop(name);
JSObject* obj = &script()->global();
return setStaticName(obj, name);
@ -1828,7 +1828,7 @@ IonBuilder::inspectOpcode(JSOp op)
}
case JSOP_BINDGNAME:
if (!script()->hasPollutedGlobalScope())
if (!script()->hasNonSyntacticScope())
return pushConstant(ObjectValue(script()->global()));
// Fall through to JSOP_BINDNAME
case JSOP_BINDNAME:
@ -1975,7 +1975,7 @@ IonBuilder::inspectOpcode(JSOp op)
return jsop_debugger();
case JSOP_GIMPLICITTHIS:
if (!script()->hasPollutedGlobalScope())
if (!script()->hasNonSyntacticScope())
return pushConstant(UndefinedValue());
// Just fall through to the unsupported bytecode case.
@ -7613,7 +7613,7 @@ bool
IonBuilder::jsop_getname(PropertyName* name)
{
MDefinition* object;
if (IsGlobalOp(JSOp(*pc)) && !script()->hasPollutedGlobalScope()) {
if (IsGlobalOp(JSOp(*pc)) && !script()->hasNonSyntacticScope()) {
MInstruction* global = constant(ObjectValue(script()->global()));
object = global;
} else {

Просмотреть файл

@ -2553,7 +2553,7 @@ InlineFrameIterator::computeScopeChain(Value scopeChainValue, MaybeReadFallback&
// Ion does not handle non-function scripts that have anything other than
// the global on their scope chain.
MOZ_ASSERT(!script()->isForEval());
MOZ_ASSERT(!script()->hasPollutedGlobalScope());
MOZ_ASSERT(!script()->hasNonSyntacticScope());
return &script()->global();
}

Просмотреть файл

@ -4180,7 +4180,7 @@ ExecuteScript(JSContext* cx, HandleObject obj, HandleScript scriptArg, jsval* rv
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj, scriptArg);
if (!script->hasPollutedGlobalScope() && !obj->is<GlobalObject>()) {
if (!script->hasNonSyntacticScope() && !obj->is<GlobalObject>()) {
script = CloneScript(cx, nullptr, nullptr, script, HasPollutedGlobalScope);
if (!script)
return false;

Просмотреть файл

@ -2101,11 +2101,11 @@ js::CloneFunctionObjectUseSameScript(JSCompartment* compartment, HandleFunction
return true;
// We need to clone the script if we're interpreted and not already marked
// as having a polluted scope. If we're lazy, go ahead and clone the
// script; see the big comment at the end of CloneScript for the explanation
// of what's going on there.
// as having a non-syntactic scope. If we're lazy, go ahead and clone the
// script; see the big comment at the end of CopyScriptInternal for the
// explanation of what's going on there.
return !fun->isInterpreted() ||
(fun->hasScript() && fun->nonLazyScript()->hasPollutedGlobalScope());
(fun->hasScript() && fun->nonLazyScript()->hasNonSyntacticScope());
}
JSFunction*

Просмотреть файл

@ -422,10 +422,10 @@ class JSObject : public js::gc::Cell
* slot of the object. For other scope objects, the chain goes directly to
* the global.
*
* In code which is not marked hasPollutedGlobalScope, scope chains can
* In code which is not marked hasNonSyntacticScope, scope chains can
* contain only syntactic scope objects (see IsSyntacticScope) with a global
* object at the root as the scope of the outermost non-function script. In
* hasPollutedGlobalScope code, the scope of the outermost non-function
* hasNonSyntacticScope code, the scope of the outermost non-function
* script might not be a global object, and can have a mix of other objects
* above it before the global object is reached.
*/

Просмотреть файл

@ -600,7 +600,7 @@ js::XDRScript(XDRState<mode>* xdr, HandleObject enclosingScope, HandleScript enc
HasSingleton,
TreatAsRunOnce,
HasLazyScript,
HasPollutedGlobalScope,
HasNonSyntacticScope,
};
uint32_t length, lineno, column, nslots, staticLevel;
@ -732,8 +732,8 @@ js::XDRScript(XDRState<mode>* xdr, HandleObject enclosingScope, HandleScript enc
scriptBits |= (1 << TreatAsRunOnce);
if (script->isRelazifiable())
scriptBits |= (1 << HasLazyScript);
if (script->hasPollutedGlobalScope())
scriptBits |= (1 << HasPollutedGlobalScope);
if (script->hasNonSyntacticScope())
scriptBits |= (1 << HasNonSyntacticScope);
}
if (!xdr->codeUint32(&prologueLength))
@ -849,8 +849,8 @@ js::XDRScript(XDRState<mode>* 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 << HasNonSyntacticScope))
script->hasNonSyntacticScope_ = true;
if (scriptBits & (1 << IsLegacyGenerator)) {
MOZ_ASSERT(!(scriptBits & (1 << IsStarGenerator)));
@ -2429,7 +2429,7 @@ JSScript::Create(ExclusiveContext* cx, HandleObject enclosingScope, bool savedCa
script->savedCallerFun_ = savedCallerFun;
script->initCompartment(cx);
script->hasPollutedGlobalScope_ = options.hasPollutedGlobalScope;
script->hasNonSyntacticScope_ = options.hasPollutedGlobalScope;
script->selfHosted_ = options.selfHostingMode;
script->noScriptRval_ = options.noScriptRval;
script->treatAsRunOnce_ = options.isRunOnce;
@ -3207,21 +3207,21 @@ js::CloneScript(JSContext* cx, HandleObject enclosingScope, HandleFunction fun,
/*
* Function delazification assumes that their script does not have a
* polluted global scope. We ensure that as follows:
* non-syntactic global scope. We ensure that as follows:
*
* 1) Initial parsing only creates lazy functions if
* !hasPollutedGlobalScope.
* !hasNonSyntacticScope.
* 2) Cloning a lazy function into a non-global scope will always require
* that its script be cloned. See comments in
* CloneFunctionObjectUseSameScript.
* 3) Cloning a script never sets a lazyScript on the clone, so the function
* cannot be relazified.
*
* If you decide that lazy functions should be supported with a polluted
* global scope, make sure delazification can deal.
* If you decide that lazy functions should be supported with a
* non-syntactic global scope, make sure delazification can deal.
*/
MOZ_ASSERT_IF(dst->hasPollutedGlobalScope(), !dst->maybeLazyScript());
MOZ_ASSERT_IF(dst->hasPollutedGlobalScope(), !dst->isRelazifiable());
MOZ_ASSERT_IF(dst->hasNonSyntacticScope(), !dst->maybeLazyScript());
MOZ_ASSERT_IF(dst->hasNonSyntacticScope(), !dst->isRelazifiable());
return dst;
}

Просмотреть файл

@ -936,7 +936,7 @@ class JSScript : public js::gc::TenuredCell
// 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;
bool hasNonSyntacticScope_:1;
// see Parser::selfHostingMode.
bool selfHosted_:1;
@ -1176,8 +1176,8 @@ class JSScript : public js::gc::TenuredCell
bool explicitUseStrict() const { return explicitUseStrict_; }
bool hasPollutedGlobalScope() const {
return hasPollutedGlobalScope_;
bool hasNonSyntacticScope() const {
return hasNonSyntacticScope_;
}
bool selfHosted() const { return selfHosted_; }

Просмотреть файл

@ -304,9 +304,9 @@ SetNameOperation(JSContext* cx, JSScript* script, jsbytecode* pc, HandleObject s
*pc == JSOP_STRICTSETNAME ||
*pc == JSOP_SETGNAME ||
*pc == JSOP_STRICTSETGNAME);
MOZ_ASSERT_IF(*pc == JSOP_SETGNAME && !script->hasPollutedGlobalScope(),
MOZ_ASSERT_IF(*pc == JSOP_SETGNAME && !script->hasNonSyntacticScope(),
scope == cx->global());
MOZ_ASSERT_IF(*pc == JSOP_STRICTSETGNAME && !script->hasPollutedGlobalScope(),
MOZ_ASSERT_IF(*pc == JSOP_STRICTSETGNAME && !script->hasNonSyntacticScope(),
scope == cx->global());
bool strict = *pc == JSOP_STRICTSETNAME || *pc == JSOP_STRICTSETGNAME;

Просмотреть файл

@ -274,7 +274,7 @@ GetNameOperation(JSContext* cx, InterpreterFrame* fp, jsbytecode* pc, MutableHan
* the actual behavior even if the id could be found on the scope chain
* before the global object.
*/
if (IsGlobalOp(JSOp(*pc)) && !fp->script()->hasPollutedGlobalScope())
if (IsGlobalOp(JSOp(*pc)) && !fp->script()->hasNonSyntacticScope())
obj = &obj->global();
Shape* shape = nullptr;
@ -868,7 +868,7 @@ js::ExecuteKernel(JSContext* cx, HandleScript script, JSObject& scopeChainArg, c
while (IsSyntacticScope(terminatingScope))
terminatingScope = terminatingScope->enclosingScope();
MOZ_ASSERT(terminatingScope->is<GlobalObject>() ||
script->hasPollutedGlobalScope());
script->hasNonSyntacticScope());
#endif
if (script->treatAsRunOnce()) {
@ -904,8 +904,8 @@ js::Execute(JSContext* cx, HandleScript script, JSObject& scopeChainArg, Value*
RootedObject scopeChain(cx, &scopeChainArg);
MOZ_ASSERT(scopeChain == GetInnerObject(scopeChain));
MOZ_RELEASE_ASSERT(scopeChain->is<GlobalObject>() || script->hasPollutedGlobalScope(),
"Only scripts with polluted scopes can be executed with "
MOZ_RELEASE_ASSERT(scopeChain->is<GlobalObject>() || script->hasNonSyntacticScope(),
"Only scripts with non-syntactic scopes can be executed with "
"interesting scopechains");
/* Ensure the scope chain is all same-compartment and terminates in a global. */
@ -2320,7 +2320,7 @@ CASE(JSOP_BINDGNAME)
CASE(JSOP_BINDNAME)
{
JSOp op = JSOp(*REGS.pc);
if (op == JSOP_BINDNAME || script->hasPollutedGlobalScope()) {
if (op == JSOP_BINDNAME || script->hasNonSyntacticScope()) {
ReservedRooted<JSObject*> scopeChain(&rootObject0, REGS.fp()->scopeChain());
ReservedRooted<PropertyName*> name(&rootName0, script->getName(REGS.pc));
@ -3062,7 +3062,7 @@ CASE(JSOP_IMPLICITTHIS)
CASE(JSOP_GIMPLICITTHIS)
{
JSOp op = JSOp(*REGS.pc);
if (op == JSOP_IMPLICITTHIS || script->hasPollutedGlobalScope()) {
if (op == JSOP_IMPLICITTHIS || script->hasNonSyntacticScope()) {
ReservedRooted<PropertyName*> name(&rootName0, script->getName(REGS.pc));
ReservedRooted<JSObject*> scopeObj(&rootObject0, REGS.fp()->scopeChain());
ReservedRooted<JSObject*> scope(&rootObject1);

Просмотреть файл

@ -1570,9 +1570,9 @@
macro(JSOP_RETRVAL, 153,"retrval", NULL, 1, 0, 0, JOF_BYTE) \
\
/*
* Looks up name on global scope and pushes its value onto the stack, unless
* the script has a polluted global, in which case it acts just like
* JSOP_NAME.
* Looks up name on global scope and pushes its value onto the stack,
* unless the script has a non-syntactic global scope, in which case it
* acts just like JSOP_NAME.
*
* Free variable references that must either be found on the global or a
* ReferenceError.
@ -1586,7 +1586,7 @@
* Pops the top two values on the stack as 'val' and 'scope', sets property
* of 'scope' as 'val' and pushes 'val' back on the stack.
*
* 'scope' should be the global scope unless the script has a polluted
* 'scope' should be the global scope unless the script has a non-syntactic
* global scope, in which case acts like JSOP_SETNAME.
* Category: Variables and Scopes
* Type: Free Variables
@ -1600,7 +1600,7 @@
* of 'scope' as 'val' and pushes 'val' back on the stack. Throws a
* TypeError if the set fails, per strict mode semantics.
*
* 'scope' should be the global scope unless the script has a polluted
* 'scope' should be the global scope unless the script has a non-syntactic
* global scope, in which case acts like JSOP_STRICTSETNAME.
* Category: Variables and Scopes
* Type: Free Variables
@ -1871,7 +1871,7 @@
macro(JSOP_UNUSED213, 213, "unused213", NULL, 1, 0, 0, JOF_BYTE) \
/*
* Pushes the global scope onto the stack if the script doesn't have a
* polluted global scope. Otherwise will act like JSOP_BINDNAME.
* non-syntactic global scope. Otherwise will act like JSOP_BINDNAME.
*
* 'nameIndex' is only used when acting like JSOP_BINDNAME.
* Category: Variables and Scopes

Просмотреть файл

@ -2521,7 +2521,7 @@ RemoveReferencedNames(JSContext* cx, HandleScript script, PropertyNameSet& remai
case JSOP_GETGNAME:
case JSOP_SETGNAME:
case JSOP_STRICTSETGNAME:
if (script->hasPollutedGlobalScope())
if (script->hasNonSyntacticScope())
name = script->getName(pc);
else
name = nullptr;