Bug 1130811 - Handle various miscellaneous nodes by kind when recycling. r=shu
authorJeff Walden <jwalden@mit.edu>
Tue, 10 Feb 2015 01:00:02 -0800
changeset 228939 d6c56cf464f524ca43301e099152d32dfca93faa
parent 228938 af3054673b35978d957e15575ef7935a024cd52b
child 228940 7fd630ae8bbf0cb8c66e844730815beefbcdc258
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)
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 various miscellaneous nodes by kind when recycling. r=shu
--- a/js/src/frontend/ParseNode.cpp
+++ b/js/src/frontend/ParseNode.cpp
@@ -211,19 +211,23 @@ PushBinaryNodeChildren(ParseNode *node, 
     return PushResult::Recyclable;
 static PushResult
 PushBinaryNodeNullableChildren(ParseNode *node, NodeStack *stack)
     MOZ_ASSERT(node->isArity(PN_BINARY) || node->isArity(PN_BINARY_OBJ));
-    // This is *probably* PNK_SHORTHAND, but that's not yet clear.
-    if (node->pn_left != node->pn_right)
+    if (node->pn_left != node->pn_right) {
+        // XXX Is it ever the case that left == right any more?  I think this
+        //     used to be PNK_SHORTHAND, but its two children are now different
+        //     nodes that are structurally equivalent, so PNK_SHORTHAND doesn't
+        //     require this.
+    }
     return PushResult::Recyclable;
 static PushResult
 CanRecycleNullaryNode(ParseNode *node, NodeStack *stack)
@@ -285,31 +289,51 @@ PushNodeChildren(ParseNode *pn, NodeStac
       case PNK_COMPUTED_NAME:
       case PNK_ARRAYPUSH:
       case PNK_SPREAD:
       case PNK_MUTATEPROTO:
       case PNK_EXPORT:
         return PushUnaryNodeChild(pn, stack);
-      // Assignment nodes are binary with two non-null children.
+      // Nodes with a single nullable child.
+      case PNK_SEMI:
+        return PushUnaryNodeNullableChild(pn, stack);
+      // Binary nodes with two non-null children.
+      // All assignment and compound assignment nodes qualify.
       case PNK_ASSIGN:
       case PNK_ADDASSIGN:
       case PNK_SUBASSIGN:
       case PNK_BITORASSIGN:
       case PNK_LSHASSIGN:
       case PNK_RSHASSIGN:
       case PNK_URSHASSIGN:
       case PNK_MULASSIGN:
       case PNK_DIVASSIGN:
       case PNK_MODASSIGN:
+      // ...and a few others.
+      case PNK_COLON:
+      case PNK_CASE:
+      case PNK_SHORTHAND:
         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);
+        stack->push(pn->pn_right);
+        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:
@@ -327,42 +351,37 @@ PushNodeChildren(ParseNode *pn, NodeStac
       case PNK_ADD:
       case PNK_SUB:
       case PNK_STAR:
       case PNK_DIV:
       case PNK_MOD:
       case PNK_COMMA:
       case PNK_ARRAY:
       case PNK_OBJECT:
+      case PNK_VAR:
+      case PNK_CONST:
+      case PNK_GLOBALCONST:
         return PushListNodeChildren(pn, stack);
-      case PNK_SEMI:
       case PNK_CONDITIONAL:
-      case PNK_COLON:
-      case PNK_SHORTHAND:
       case PNK_DOT:
       case PNK_ELEM:
       case PNK_LABEL:
       case PNK_CALL:
       case PNK_NAME:
       case PNK_CALLSITEOBJ:
       case PNK_FUNCTION:
       case PNK_IF:
       case PNK_SWITCH:
-      case PNK_CASE:
-      case PNK_DEFAULT:
       case PNK_WHILE:
       case PNK_DOWHILE:
       case PNK_FOR:
-      case PNK_VAR:
-      case PNK_CONST:
-      case PNK_GLOBALCONST:
       case PNK_WITH:
       case PNK_RETURN:
       case PNK_NEW:
       case PNK_TRY:
       case PNK_CATCH:
       case PNK_CATCHLIST:
       case PNK_YIELD:
       case PNK_YIELD_STAR: