Bug 1130811 - Handle a few more kinds, by kind, when recycling. r=efaust
authorJeff Walden <jwalden@mit.edu>
Tue, 10 Feb 2015 01:00:02 -0800
changeset 256872 a382317116055ef03ca9f288b6da836a441a1144
parent 256871 5c7e45daf893d5a7de008ef0195c2c208794f7a6
child 256873 d4a230d1ff773288cd4796060e80d4f04a2e3e8c
push id4610
push userjlund@mozilla.com
push dateMon, 30 Mar 2015 18:32:55 +0000
treeherdermozilla-beta@4df54044d9ef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersefaust
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=efaust
js/src/frontend/ParseNode.cpp
--- a/js/src/frontend/ParseNode.cpp
+++ b/js/src/frontend/ParseNode.cpp
@@ -309,26 +309,38 @@ PushNodeChildren(ParseNode *pn, NodeStac
       case PNK_BITANDASSIGN:
       case PNK_LSHASSIGN:
       case PNK_RSHASSIGN:
       case PNK_URSHASSIGN:
       case PNK_MULASSIGN:
       case PNK_DIVASSIGN:
       case PNK_MODASSIGN:
       // ...and a few others.
+      case PNK_ELEM:
       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);
 
+      // PNK_WITH is PN_BINARY_OBJ -- that is, PN_BINARY with (irrelevant for
+      // this method's purposes) the addition of the StaticWithObject as
+      // pn_binary_obj.  Both left (expression) and right (statement) are
+      // non-null.
+      case PNK_WITH: {
+        MOZ_ASSERT(pn->isArity(PN_BINARY_OBJ));
+        stack->push(pn->pn_left);
+        stack->push(pn->pn_right);
+        return PushResult::Recyclable;
+      }
+
       // 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);
         stack->push(pn->pn_right);
         return PushResult::Recyclable;
@@ -347,16 +359,30 @@ PushNodeChildren(ParseNode *pn, NodeStac
                     pn->pn_right->pn_left->isKind(PNK_NAME) &&
                     pn->pn_right->pn_right->isKind(PNK_GENERATOR)));
         if (pn->pn_left)
             stack->push(pn->pn_left);
         stack->push(pn->pn_right);
         return PushResult::Recyclable;
       }
 
+      // A return node's left half is what you'd expect: the return expression,
+      // if any.  The right half is non-null only for returns inside generator
+      // functions, with the structure described in the assertions.
+      case PNK_RETURN:
+        MOZ_ASSERT(pn->isArity(PN_BINARY));
+#ifdef DEBUG
+        if (pn->pn_right) {
+            MOZ_ASSERT(pn->pn_right->isKind(PNK_NAME));
+            MOZ_ASSERT(pn->pn_right->pn_atom->equals(".genrval"));
+            MOZ_ASSERT(pn->pn_right->isAssigned());
+        }
+#endif
+        return PushBinaryNodeNullableChildren(pn, stack);
+
       // Ternary nodes with all children non-null.
       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;
       }
@@ -400,16 +426,29 @@ PushNodeChildren(ParseNode *pn, NodeStac
         stack->push(pn->pn_kid1);
         if (pn->pn_kid2)
             stack->push(pn->pn_kid2);
         if (pn->pn_kid3)
             stack->push(pn->pn_kid3);
         return PushResult::Recyclable;
       }
 
+      // A catch node has first kid as catch-variable pattern, the second kid
+      // as catch condition (which, if non-null, records the |<cond>| in
+      // SpiderMonkey's |catch (e if <cond>)| extension), and third kid as the
+      // statements in the catch block.
+      case PNK_CATCH: {
+        MOZ_ASSERT(pn->isArity(PN_TERNARY));
+        stack->push(pn->pn_kid1);
+        if (pn->pn_kid2)
+            stack->push(pn->pn_kid2);
+        stack->push(pn->pn_kid3);
+        return PushResult::Recyclable;
+      }
+
       // List nodes with all non-null children.
       case PNK_OR:
       case PNK_AND:
       case PNK_BITOR:
       case PNK_BITXOR:
       case PNK_BITAND:
       case PNK_STRICTEQ:
       case PNK_EQ:
@@ -425,43 +464,39 @@ PushNodeChildren(ParseNode *pn, NodeStac
       case PNK_RSH:
       case PNK_URSH:
       case PNK_ADD:
       case PNK_SUB:
       case PNK_STAR:
       case PNK_DIV:
       case PNK_MOD:
       case PNK_COMMA:
+      case PNK_NEW:
+      case PNK_CALL:
+      case PNK_GENEXP:
       case PNK_ARRAY:
       case PNK_OBJECT:
       case PNK_VAR:
       case PNK_CONST:
       case PNK_GLOBALCONST:
       case PNK_CATCHLIST:
       case PNK_SEQ:
       case PNK_ARGSBODY:
         return PushListNodeChildren(pn, stack);
 
       case PNK_LABEL:
+      case PNK_DOT:
         return PushNameNodeChildren(pn, stack);
 
-      case PNK_DOT:
-      case PNK_ELEM:
       case PNK_STATEMENTLIST:
-      case PNK_CALL:
       case PNK_NAME:
       case PNK_TEMPLATE_STRING_LIST:
       case PNK_TAGGED_TEMPLATE:
       case PNK_CALLSITEOBJ:
       case PNK_FUNCTION:
-      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_LETEXPR:
       case PNK_IMPORT:
       case PNK_IMPORT_SPEC_LIST:
       case PNK_IMPORT_SPEC:
       case PNK_EXPORT_FROM: