Bug 1147371: Rename allowContentSpread to allowContentIter

Issue #74
This commit is contained in:
janekptacijarabaci 2018-03-24 12:11:23 +01:00 • committed by Roy Tam
commit 10ee43a416
3 changed files with 22 additions and 12 deletions

View file

@ -6676,7 +6676,17 @@ BytecodeEmitter::emitForOf(ParseNode* forOfLoop, EmitterScope* headLexicalEmitte
if (!emit1(JSOP_DUP)) // ITER ITER if (!emit1(JSOP_DUP)) // ITER ITER
return false; return false;
if (!emitIteratorNext(forOfHead)) // ITER RESULT // Certain builtins (e.g. Array.from) are implemented in self-hosting
// as for-of loops.
bool allowSelfHostedIter = false;
if (emitterMode == BytecodeEmitter::SelfHosting &&
forHeadExpr->isKind(PNK_CALL) &&
forHeadExpr->pn_head->name() == cx->names().allowContentIter)
{
allowSelfHostedIter = true;
}
if (!emitIteratorNext(forOfHead, allowSelfHostedIter)) // ITER RESULT
return false; return false;
if (!emit1(JSOP_DUP)) // ITER RESULT RESULT if (!emit1(JSOP_DUP)) // ITER RESULT RESULT
return false; return false;
@ -8438,10 +8448,10 @@ BytecodeEmitter::emitSelfHostedForceInterpreter(ParseNode* pn)
} }
bool bool
BytecodeEmitter::emitSelfHostedAllowContentSpread(ParseNode* pn) BytecodeEmitter::emitSelfHostedAllowContentIter(ParseNode* pn)
{ {
if (pn->pn_count != 2) { if (pn->pn_count != 2) {
reportError(pn, JSMSG_MORE_ARGS_NEEDED, "allowContentSpread", "1", ""); reportError(pn, JSMSG_MORE_ARGS_NEEDED, "allowContentIter", "1", "");
return false; return false;
} }
@ -8467,7 +8477,7 @@ BytecodeEmitter::isRestParameter(ParseNode* pn, bool* result)
if (!pn->isKind(PNK_NAME)) { if (!pn->isKind(PNK_NAME)) {
if (emitterMode == BytecodeEmitter::SelfHosting && pn->isKind(PNK_CALL)) { if (emitterMode == BytecodeEmitter::SelfHosting && pn->isKind(PNK_CALL)) {
ParseNode* pn2 = pn->pn_head; ParseNode* pn2 = pn->pn_head;
if (pn2->getKind() == PNK_NAME && pn2->name() == cx->names().allowContentSpread) if (pn2->getKind() == PNK_NAME && pn2->name() == cx->names().allowContentIter)
return isRestParameter(pn2->pn_next, result); return isRestParameter(pn2->pn_next, result);
} }
*result = false; *result = false;
@ -8575,8 +8585,8 @@ BytecodeEmitter::emitCallOrNew(ParseNode* pn)
return emitSelfHostedResumeGenerator(pn); return emitSelfHostedResumeGenerator(pn);
if (pn2->name() == cx->names().forceInterpreter) if (pn2->name() == cx->names().forceInterpreter)
return emitSelfHostedForceInterpreter(pn); return emitSelfHostedForceInterpreter(pn);
if (pn2->name() == cx->names().allowContentSpread) if (pn2->name() == cx->names().allowContentIter)
return emitSelfHostedAllowContentSpread(pn); return emitSelfHostedAllowContentIter(pn);
// Fall through. // Fall through.
} }
if (!emitGetName(pn2, callop)) if (!emitGetName(pn2, callop))
@ -9231,7 +9241,7 @@ BytecodeEmitter::emitArray(ParseNode* pn, uint32_t count, JSOp op)
if (!updateSourceCoordNotes(pn2->pn_pos.begin)) if (!updateSourceCoordNotes(pn2->pn_pos.begin))
return false; return false;
bool allowSelfHostedSpread = false; bool allowSelfHostedIter = false;
if (pn2->isKind(PNK_ELISION)) { if (pn2->isKind(PNK_ELISION)) {
if (!emit1(JSOP_HOLE)) if (!emit1(JSOP_HOLE))
return false; return false;
@ -9242,9 +9252,9 @@ BytecodeEmitter::emitArray(ParseNode* pn, uint32_t count, JSOp op)
if (emitterMode == BytecodeEmitter::SelfHosting && if (emitterMode == BytecodeEmitter::SelfHosting &&
expr->isKind(PNK_CALL) && expr->isKind(PNK_CALL) &&
expr->pn_head->name() == cx->names().allowContentSpread) expr->pn_head->name() == cx->names().allowContentIter)
{ {
allowSelfHostedSpread = true; allowSelfHostedIter = true;
} }
} else { } else {
expr = pn2; expr = pn2;
@ -9259,7 +9269,7 @@ BytecodeEmitter::emitArray(ParseNode* pn, uint32_t count, JSOp op)
return false; return false;
if (!emit2(JSOP_PICK, 2)) // ITER ARRAY INDEX if (!emit2(JSOP_PICK, 2)) // ITER ARRAY INDEX
return false; return false;
if (!emitSpread(allowSelfHostedSpread)) // ARRAY INDEX if (!emitSpread(allowSelfHostedIter)) // ARRAY INDEX
return false; return false;
} else if (afterSpread) { } else if (afterSpread) {
if (!emit1(JSOP_INITELEM_INC)) if (!emit1(JSOP_INITELEM_INC))

View file

@ -732,7 +732,7 @@ struct MOZ_STACK_CLASS BytecodeEmitter
MOZ_MUST_USE bool emitSelfHostedCallFunction(ParseNode* pn); MOZ_MUST_USE bool emitSelfHostedCallFunction(ParseNode* pn);
MOZ_MUST_USE bool emitSelfHostedResumeGenerator(ParseNode* pn); MOZ_MUST_USE bool emitSelfHostedResumeGenerator(ParseNode* pn);
MOZ_MUST_USE bool emitSelfHostedForceInterpreter(ParseNode* pn); MOZ_MUST_USE bool emitSelfHostedForceInterpreter(ParseNode* pn);
MOZ_MUST_USE bool emitSelfHostedAllowContentSpread(ParseNode* pn); MOZ_MUST_USE bool emitSelfHostedAllowContentIter(ParseNode* pn);
MOZ_MUST_USE bool emitComprehensionFor(ParseNode* compFor); MOZ_MUST_USE bool emitComprehensionFor(ParseNode* compFor);
MOZ_MUST_USE bool emitComprehensionForIn(ParseNode* pn); MOZ_MUST_USE bool emitComprehensionForIn(ParseNode* pn);

View file

@ -13,7 +13,7 @@
#define FOR_EACH_COMMON_PROPERTYNAME(macro) \ #define FOR_EACH_COMMON_PROPERTYNAME(macro) \
macro(add, add, "add") \ macro(add, add, "add") \
macro(allowContentSpread, allowContentSpread, "allowContentSpread") \ macro(allowContentIter, allowContentIter, "allowContentIter") \
macro(anonymous, anonymous, "anonymous") \ macro(anonymous, anonymous, "anonymous") \
macro(Any, Any, "Any") \ macro(Any, Any, "Any") \
macro(apply, apply, "apply") \ macro(apply, apply, "apply") \