зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1306701 - Part 0.1: Remove dead code in BytecodeEmitter::emitDeclarationList. r=Waldo, shu
This commit is contained in:
Родитель
4e4bd01aae
Коммит
0437a1cfc0
|
@ -4940,55 +4940,20 @@ BytecodeEmitter::emitDeclarationList(ParseNode* declList)
|
||||||
return false;
|
return false;
|
||||||
next = decl->pn_next;
|
next = decl->pn_next;
|
||||||
|
|
||||||
if (decl->isKind(PNK_ARRAY) || decl->isKind(PNK_OBJECT)) {
|
if (decl->isKind(PNK_ASSIGN)) {
|
||||||
// Destructuring BindingPattern in a deprecated comprehension:
|
|
||||||
// a = [x*y for (let [x, y] of pts)];
|
|
||||||
//
|
|
||||||
// (When emitting code for a plain LexicalDeclaration, like
|
|
||||||
// `let [x, y] = pt;`, decl will be a PNK_ASSIGN node, not a
|
|
||||||
// PNK_ARRAY node. `let [x, y];` without an initializer is a
|
|
||||||
// SyntaxError.)
|
|
||||||
|
|
||||||
MOZ_ASSERT(declList->pn_count == 1);
|
|
||||||
|
|
||||||
auto emitInitializeToUndefined = [](BytecodeEmitter* bce, ParseNode *pn) {
|
|
||||||
MOZ_ASSERT(bce->lookupName(pn->name()).hasKnownSlot());
|
|
||||||
MOZ_ASSERT(bce->lookupName(pn->name()).isLexical());
|
|
||||||
auto emitUndefined = [](BytecodeEmitter* bce, const NameLocation&, bool) {
|
|
||||||
return bce->emit1(JSOP_UNDEFINED);
|
|
||||||
};
|
|
||||||
if (!bce->emitInitializeName(pn, emitUndefined))
|
|
||||||
return false;
|
|
||||||
// Pop the RHS.
|
|
||||||
return bce->emit1(JSOP_POP);
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!emitDestructuringDeclsWithEmitter(decl, emitInitializeToUndefined))
|
|
||||||
return false;
|
|
||||||
} else if (decl->isKind(PNK_ASSIGN)) {
|
|
||||||
/*
|
|
||||||
* A destructuring initialiser assignment preceded by var will
|
|
||||||
* never occur to the left of 'in' in a for-in loop. As with 'for
|
|
||||||
* (var x = i in o)...', this will cause the entire 'var [a, b] =
|
|
||||||
* i' to be hoisted out of the loop.
|
|
||||||
*/
|
|
||||||
MOZ_ASSERT(decl->isOp(JSOP_NOP));
|
MOZ_ASSERT(decl->isOp(JSOP_NOP));
|
||||||
|
|
||||||
if (decl->pn_left->isKind(PNK_NAME)) {
|
ParseNode* pattern = decl->pn_left;
|
||||||
if (!emitSingleDeclaration(declList, decl->pn_left, decl->pn_right))
|
MOZ_ASSERT(pattern->isKind(PNK_ARRAY) || pattern->isKind(PNK_OBJECT));
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
ParseNode* initializer = decl->pn_left;
|
|
||||||
|
|
||||||
if (!emitTree(decl->pn_right))
|
if (!emitTree(decl->pn_right))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!emitDestructuringOpsHelper(initializer, DestructuringDeclaration))
|
if (!emitDestructuringOpsHelper(pattern, DestructuringDeclaration))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!emit1(JSOP_POP))
|
if (!emit1(JSOP_POP))
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (!emitSingleDeclaration(declList, decl, decl->expr()))
|
if (!emitSingleDeclaration(declList, decl, decl->expr()))
|
||||||
return false;
|
return false;
|
||||||
|
@ -6082,9 +6047,7 @@ BytecodeEmitter::emitInitializeForInOrOfTarget(ParseNode* forHead)
|
||||||
}
|
}
|
||||||
|
|
||||||
MOZ_ASSERT(!target->isKind(PNK_ASSIGN),
|
MOZ_ASSERT(!target->isKind(PNK_ASSIGN),
|
||||||
"for-in/of loop declarations can't have initializers; or if "
|
"for-in/of loop destructuring declarations can't have initializers");
|
||||||
"they do, those initializers are ignored -- see "
|
|
||||||
"Parser::declarationPattern");
|
|
||||||
|
|
||||||
MOZ_ASSERT(target->isKind(PNK_ARRAY) || target->isKind(PNK_OBJECT));
|
MOZ_ASSERT(target->isKind(PNK_ARRAY) || target->isKind(PNK_OBJECT));
|
||||||
return emitDestructuringOps(target, DestructuringDeclaration);
|
return emitDestructuringOps(target, DestructuringDeclaration);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче