Bug 1130811 - Handle a few more kinds, by kind, when recycling. r=shu
authorJeff Walden <jwalden@mit.edu>
Tue, 10 Feb 2015 01:00:02 -0800
changeset 228942 28cbfff0dd9a52ccfcef907f64cbd82c5f59a17b
parent 228941 6d93b1ffb2ce1d4f8c2e93c91b1b86d1d62cdf58
child 228943 03eda399201b8c6ebc07066beff31c1f6573ff20
push id55559
push userjwalden@mit.edu
push dateFri, 13 Feb 2015 08:44:38 +0000
treeherdermozilla-inbound@8a411bde0705 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersshu
bugs1130811
milestone38.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1130811 - Handle a few more kinds, by kind, when recycling. r=shu
js/src/frontend/ParseNode.cpp
--- a/js/src/frontend/ParseNode.cpp
+++ b/js/src/frontend/ParseNode.cpp
@@ -163,17 +163,17 @@ PushListNodeChildren(ParseNode *node, No
     node->checkListConsistency();
 
     stack->pushList(node);
 
     return PushResult::Recyclable;
 }
 
 static PushResult
-PushTernaryNodeChildren(ParseNode *node, NodeStack *stack)
+PushTernaryNodeNullableChildren(ParseNode *node, NodeStack *stack)
 {
     MOZ_ASSERT(node->isArity(PN_TERNARY));
 
     stack->pushUnlessNull(node->pn_kid1);
     stack->pushUnlessNull(node->pn_kid2);
     stack->pushUnlessNull(node->pn_kid3);
 
     return PushResult::Recyclable;
@@ -314,16 +314,19 @@ PushNodeChildren(ParseNode *pn, NodeStac
       case PNK_DIVASSIGN:
       case PNK_MODASSIGN:
       // ...and a few others.
       case PNK_COLON:
       case PNK_CASE:
       case PNK_SHORTHAND:
       case PNK_DOWHILE:
       case PNK_WHILE:
+      case PNK_SWITCH:
+      case PNK_LETBLOCK:
+      case PNK_FOR:
         return PushBinaryNodeChildren(pn, stack);
 
       // Default nodes, for dumb reasons that we're not changing now (mostly
       // structural semi-consistency with PNK_CASE nodes), have a null left
       // node and a non-null right node.
       case PNK_DEFAULT: {
         MOZ_ASSERT(pn->isArity(PN_BINARY));
         MOZ_ASSERT(pn->pn_left == nullptr);
@@ -353,16 +356,36 @@ PushNodeChildren(ParseNode *pn, NodeStac
       case PNK_CONDITIONAL: {
         MOZ_ASSERT(pn->isArity(PN_TERNARY));
         stack->push(pn->pn_kid1);
         stack->push(pn->pn_kid2);
         stack->push(pn->pn_kid3);
         return PushResult::Recyclable;
       }
 
+      // For for-in and for-of, the first child is any declaration present in
+      // the for-loop (and null if not).  The second child is the expression or
+      // pattern assigned every loop, and the third child is the expression
+      // looped over.  For example, in |for (var p in obj)|, the first child is
+      // |var p|, the second child is |p| (a node distinct from the one in
+      // |var p|), and the third child is |obj|.
+      case PNK_FORIN:
+      case PNK_FOROF: {
+        MOZ_ASSERT(pn->isArity(PN_TERNARY));
+        if (pn->pn_kid1)
+            stack->push(pn->pn_kid1);
+        stack->push(pn->pn_kid2);
+        stack->push(pn->pn_kid3);
+        return PushResult::Recyclable;
+      }
+
+      // for (;;) nodes have one child per optional component of the loop head.
+      case PNK_FORHEAD:
+        return PushTernaryNodeNullableChildren(pn, stack);
+
       // if-statement nodes have condition and consequent children and a
       // possibly-null alternative.
       case PNK_IF: {
         MOZ_ASSERT(pn->isArity(PN_TERNARY));
         stack->push(pn->pn_kid1);
         stack->push(pn->pn_kid2);
         if (pn->pn_kid3)
             stack->push(pn->pn_kid3);
@@ -410,48 +433,44 @@ PushNodeChildren(ParseNode *pn, NodeStac
       case PNK_ARRAY:
       case PNK_OBJECT:
       case PNK_VAR:
       case PNK_CONST:
       case PNK_GLOBALCONST:
       case PNK_CATCHLIST:
         return PushListNodeChildren(pn, stack);
 
+      case PNK_LABEL:
+        return PushNameNodeChildren(pn, stack);
+
       case PNK_DOT:
       case PNK_ELEM:
       case PNK_STATEMENTLIST:
-      case PNK_LABEL:
       case PNK_CALL:
       case PNK_NAME:
       case PNK_TEMPLATE_STRING_LIST:
       case PNK_TAGGED_TEMPLATE:
       case PNK_CALLSITEOBJ:
       case PNK_FUNCTION:
-      case PNK_SWITCH:
-      case PNK_FOR:
       case PNK_WITH:
       case PNK_RETURN:
       case PNK_NEW:
       case PNK_CATCH:
       case PNK_GENEXP:
       case PNK_ARRAYCOMP:
       case PNK_LEXICALSCOPE:
       case PNK_LET:
-      case PNK_LETBLOCK:
       case PNK_LETEXPR:
       case PNK_IMPORT:
       case PNK_IMPORT_SPEC_LIST:
       case PNK_IMPORT_SPEC:
       case PNK_EXPORT_FROM:
       case PNK_EXPORT_SPEC_LIST:
       case PNK_EXPORT_SPEC:
       case PNK_SEQ:
-      case PNK_FORIN:
-      case PNK_FOROF:
-      case PNK_FORHEAD:
       case PNK_ARGSBODY:
         break; // for now
 
       case PNK_LIMIT: // invalid sentinel value
         MOZ_CRASH("invalid node kind");
     }
 
     // Fallthrough for not-yet-handled kinds.
@@ -461,17 +480,17 @@ PushNodeChildren(ParseNode *pn, NodeStac
 
       case PN_NAME:
         return PushNameNodeChildren(pn, stack);
 
       case PN_LIST:
         return PushListNodeChildren(pn, stack);
 
       case PN_TERNARY:
-        return PushTernaryNodeChildren(pn, stack);
+        return PushTernaryNodeNullableChildren(pn, stack);
 
       case PN_BINARY:
       case PN_BINARY_OBJ:
         return PushBinaryNodeNullableChildren(pn, stack);
 
       case PN_UNARY:
         return PushUnaryNodeNullableChild(pn, stack);