зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1533003 - Compute JSScript::FunHasAnyAliasedFormal directly from BCE r=jandem
Compute this flag directly from BytecodeEmitter data structures instead of needing to access the partially initialized script while setting its own flags. Depends on D22313 Differential Revision: https://phabricator.services.mozilla.com/D22315 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
e0eaf32604
Коммит
327f2137b8
|
@ -349,6 +349,10 @@ struct MOZ_STACK_CLASS BytecodeEmitter {
|
|||
|
||||
Scope* outermostScope() const { return scopeList.vector[0]; }
|
||||
Scope* innermostScope() const;
|
||||
Scope* bodyScope() const {
|
||||
MOZ_ASSERT(bodyScopeIndex < scopeList.length());
|
||||
return scopeList.vector[bodyScopeIndex];
|
||||
}
|
||||
|
||||
MOZ_ALWAYS_INLINE
|
||||
MOZ_MUST_USE bool makeAtomIndex(JSAtom* atom, uint32_t* indexp) {
|
||||
|
|
|
@ -3452,6 +3452,17 @@ static void InitAtomMap(frontend::AtomIndexMap& indices, GCPtrAtom* atoms) {
|
|||
}
|
||||
}
|
||||
|
||||
static bool HasAnyAliasedFormal(frontend::BytecodeEmitter* bce) {
|
||||
PositionalFormalParameterIter fi(bce->bodyScope());
|
||||
for (; fi; fi++) {
|
||||
// Check if the formal parameter is closed over.
|
||||
if (fi.closedOver()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* static */
|
||||
void JSScript::initFromFunctionBox(HandleScript script,
|
||||
frontend::FunctionBox* funbox) {
|
||||
|
@ -3489,12 +3500,6 @@ void JSScript::initFromFunctionBox(HandleScript script,
|
|||
script->setFlag(ImmutableFlags::IsAsync, funbox->isAsync());
|
||||
script->setFlag(ImmutableFlags::HasRest, funbox->hasRest());
|
||||
|
||||
PositionalFormalParameterIter fi(script);
|
||||
while (fi && !fi.closedOver()) {
|
||||
fi++;
|
||||
}
|
||||
script->setFlag(ImmutableFlags::FunHasAnyAliasedFormal, !!fi);
|
||||
|
||||
script->setFlag(ImmutableFlags::HasInnerFunctions,
|
||||
funbox->hasInnerFunctions());
|
||||
|
||||
|
@ -3586,6 +3591,8 @@ bool JSScript::fullyInitFromEmitter(JSContext* cx, HandleScript script,
|
|||
script->bodyScopeIndex_ = bce->bodyScopeIndex;
|
||||
script->setFlag(ImmutableFlags::HasNonSyntacticScope,
|
||||
bce->outermostScope()->hasOnChain(ScopeKind::NonSyntactic));
|
||||
script->setFlag(ImmutableFlags::FunHasAnyAliasedFormal,
|
||||
HasAnyAliasedFormal(bce));
|
||||
|
||||
// There shouldn't be any fallible operation after initFromFunctionBox,
|
||||
// JSFunction::hasUncompletedScript relies on the fact that the existence
|
||||
|
|
|
@ -1577,15 +1577,18 @@ void BindingIter::init(WasmFunctionScope::Data& data) {
|
|||
data.trailingNames.start(), data.length);
|
||||
}
|
||||
|
||||
PositionalFormalParameterIter::PositionalFormalParameterIter(JSScript* script)
|
||||
: BindingIter(script) {
|
||||
PositionalFormalParameterIter::PositionalFormalParameterIter(Scope* scope)
|
||||
: BindingIter(scope) {
|
||||
// Reinit with flags = 0, i.e., iterate over all positional parameters.
|
||||
if (script->bodyScope()->is<FunctionScope>()) {
|
||||
init(script->bodyScope()->as<FunctionScope>().data(), /* flags = */ 0);
|
||||
if (scope->is<FunctionScope>()) {
|
||||
init(scope->as<FunctionScope>().data(), /* flags = */ 0);
|
||||
}
|
||||
settle();
|
||||
}
|
||||
|
||||
PositionalFormalParameterIter::PositionalFormalParameterIter(JSScript* script)
|
||||
: PositionalFormalParameterIter(script->bodyScope()) { }
|
||||
|
||||
void js::DumpBindings(JSContext* cx, Scope* scopeArg) {
|
||||
RootedScope scope(cx, scopeArg);
|
||||
for (Rooted<BindingIter> bi(cx, BindingIter(scope)); bi; bi++) {
|
||||
|
|
|
@ -1322,6 +1322,7 @@ class PositionalFormalParameterIter : public BindingIter {
|
|||
}
|
||||
|
||||
public:
|
||||
explicit PositionalFormalParameterIter(Scope* scope);
|
||||
explicit PositionalFormalParameterIter(JSScript* script);
|
||||
|
||||
void operator++(int) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче