Bug 1130811 - Handle pushing assignment and compound assignment nodes by kind when recycling. r=shu

--HG--
extra : rebase_source : b3490367763e6164ea01550fc1f4f9e80795b652
This commit is contained in:
Jeff Walden 2015-02-10 01:00:01 -08:00
parent fbfd429f10
commit 41c67924b6

View File

@ -202,6 +202,17 @@ PushUnaryNodeNullableChild(ParseNode *node, NodeStack *stack)
static PushResult
PushBinaryNodeChildren(ParseNode *node, NodeStack *stack)
{
MOZ_ASSERT(node->isArity(PN_BINARY));
stack->push(node->pn_left);
stack->push(node->pn_right);
return PushResult::Recyclable;
}
static PushResult
PushBinaryNodeNullableChildren(ParseNode *node, NodeStack *stack)
{
MOZ_ASSERT(node->isArity(PN_BINARY) || node->isArity(PN_BINARY_OBJ));
@ -279,6 +290,21 @@ PushNodeChildren(ParseNode *pn, NodeStack *stack)
case PNK_EXPORT:
return PushUnaryNodeChild(pn, stack);
// Assignment nodes are binary with two non-null children.
case PNK_ASSIGN:
case PNK_ADDASSIGN:
case PNK_SUBASSIGN:
case PNK_BITORASSIGN:
case PNK_BITXORASSIGN:
case PNK_BITANDASSIGN:
case PNK_LSHASSIGN:
case PNK_RSHASSIGN:
case PNK_URSHASSIGN:
case PNK_MULASSIGN:
case PNK_DIVASSIGN:
case PNK_MODASSIGN:
return PushBinaryNodeChildren(pn, stack);
// List nodes with all non-null children.
case PNK_OR:
case PNK_AND:
@ -357,21 +383,6 @@ PushNodeChildren(ParseNode *pn, NodeStack *stack)
case PNK_FOROF:
case PNK_FORHEAD:
case PNK_ARGSBODY:
/* Assignment operators (= += -= etc.). */
/* ParseNode::isAssignment assumes all these are consecutive. */
case PNK_ASSIGN:
case PNK_ADDASSIGN:
case PNK_SUBASSIGN:
case PNK_BITORASSIGN:
case PNK_BITXORASSIGN:
case PNK_BITANDASSIGN:
case PNK_LSHASSIGN:
case PNK_RSHASSIGN:
case PNK_URSHASSIGN:
case PNK_MULASSIGN:
case PNK_DIVASSIGN:
case PNK_MODASSIGN:
break; // for now
case PNK_LIMIT: // invalid sentinel value
@ -394,7 +405,7 @@ PushNodeChildren(ParseNode *pn, NodeStack *stack)
case PN_BINARY:
case PN_BINARY_OBJ:
return PushBinaryNodeChildren(pn, stack);
return PushBinaryNodeNullableChildren(pn, stack);
case PN_UNARY:
return PushUnaryNodeNullableChild(pn, stack);