Bug 1164774 - Remove unused code handling binary-arity PNK_ADD nodes in constant-folding. r=shu

This commit is contained in:
Jeff Walden 2015-02-18 13:12:54 -08:00
parent c70350c2f6
commit 86347c8e66

View File

@ -886,8 +886,9 @@ Fold(ExclusiveContext* cx, ParseNode** pnp,
}
break;
case PNK_ADD:
if (pn->isArity(PN_LIST)) {
case PNK_ADD: {
MOZ_ASSERT(pn->isArity(PN_LIST));
bool folded = false;
pn2 = pn1->pn_next;
@ -977,41 +978,10 @@ Fold(ExclusiveContext* cx, ParseNode** pnp,
pn->pn_tail = &pn1->pn_next;
}
}
break;
}
/* Handle a binary string concatenation. */
MOZ_ASSERT(pn->isArity(PN_BINARY));
if (pn1->isKind(PNK_STRING) || pn2->isKind(PNK_STRING)) {
if (!FoldType(cx, !pn1->isKind(PNK_STRING) ? pn1 : pn2, PNK_STRING))
return false;
if (!pn1->isKind(PNK_STRING) || !pn2->isKind(PNK_STRING))
return true;
RootedString left(cx, pn1->pn_atom);
RootedString right(cx, pn2->pn_atom);
RootedString str(cx, ConcatStrings<CanGC>(cx, left, right));
if (!str)
return false;
pn->pn_atom = AtomizeString(cx, str);
if (!pn->pn_atom)
return false;
pn->setKind(PNK_STRING);
pn->setOp(JSOP_STRING);
pn->setArity(PN_NULLARY);
handler.freeTree(pn1);
handler.freeTree(pn2);
break;
}
/* Can't concatenate string literals, let's try numbers. */
if (!FoldType(cx, pn1, PNK_NUMBER) || !FoldType(cx, pn2, PNK_NUMBER))
return false;
if (pn1->isKind(PNK_NUMBER) && pn2->isKind(PNK_NUMBER)) {
if (!FoldBinaryNumeric(cx, pn->getOp(), pn1, pn2, pn))
return false;
}
break;
case PNK_SUB:
case PNK_STAR:
case PNK_LSH: