Bug 1130811 - Handle pushing unary nodes with a non-null kid, kindwise, when recycling. r=shu
authorJeff Walden <jwalden@mit.edu>
Tue, 10 Feb 2015 01:00:01 -0800
changeset 256049 823e4436a2ff5f613fe8e5f0de5eb12073322988
parent 256048 0a9bc8928f541376321012d9317e4528f7f7dd2b
child 256050 cb48b124f67b49ed2941e46fe23f0195a6ea05a4
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)
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 pushing unary nodes with a non-null kid, kindwise, when recycling. r=shu
js/src/frontend/ParseNode.cpp
--- a/js/src/frontend/ParseNode.cpp
+++ b/js/src/frontend/ParseNode.cpp
@@ -179,17 +179,28 @@ PushTernaryNodeChildren(ParseNode *node,
     return PushResult::Recyclable;
 }
 
 static PushResult
 PushUnaryNodeChild(ParseNode *node, NodeStack *stack)
 {
     MOZ_ASSERT(node->isArity(PN_UNARY));
 
-    stack->pushUnlessNull(node->pn_kid);
+    stack->push(node->pn_kid);
+
+    return PushResult::Recyclable;
+}
+
+static PushResult
+PushUnaryNodeNullableChild(ParseNode *node, NodeStack *stack)
+{
+    MOZ_ASSERT(node->isArity(PN_UNARY));
+
+    if (node->pn_kid)
+        stack->push(node->pn_kid);
 
     return PushResult::Recyclable;
 }
 
 static PushResult
 PushBinaryNodeChildren(ParseNode *node, NodeStack *stack)
 {
     MOZ_ASSERT(node->isArity(PN_BINARY) || node->isArity(PN_BINARY_OBJ));
@@ -243,88 +254,88 @@ PushNodeChildren(ParseNode *pn, NodeStac
       case PNK_CONTINUE:
       case PNK_DEBUGGER:
       case PNK_EXPORT_BATCH_SPEC:
         MOZ_ASSERT(pn->isArity(PN_NULLARY));
         MOZ_ASSERT(!pn->isUsed(), "handle non-trivial cases separately");
         MOZ_ASSERT(!pn->isDefn(), "handle non-trivial cases separately");
         return PushResult::Recyclable;
 
-      case PNK_SEMI:
-      case PNK_COMMA:
-      case PNK_CONDITIONAL:
-      case PNK_COLON:
-      case PNK_SHORTHAND:
+      // Nodes with a single non-null child.
+      case PNK_TYPEOF:
+      case PNK_VOID:
+      case PNK_NOT:
+      case PNK_BITNOT:
+      case PNK_THROW:
+      case PNK_DELETE:
       case PNK_POS:
       case PNK_NEG:
       case PNK_PREINCREMENT:
       case PNK_POSTINCREMENT:
       case PNK_PREDECREMENT:
       case PNK_POSTDECREMENT:
+      case PNK_COMPUTED_NAME:
+      case PNK_ARRAYPUSH:
+      case PNK_SPREAD:
+      case PNK_MUTATEPROTO:
+      case PNK_EXPORT:
+        return PushUnaryNodeChild(pn, stack);
+
+      case PNK_SEMI:
+      case PNK_COMMA:
+      case PNK_CONDITIONAL:
+      case PNK_COLON:
+      case PNK_SHORTHAND:
       case PNK_DOT:
       case PNK_ELEM:
       case PNK_ARRAY:
       case PNK_STATEMENTLIST:
       case PNK_LABEL:
       case PNK_OBJECT:
       case PNK_CALL:
       case PNK_NAME:
-      case PNK_COMPUTED_NAME:
       case PNK_TEMPLATE_STRING_LIST:
       case PNK_TAGGED_TEMPLATE:
       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_DELETE:
       case PNK_TRY:
       case PNK_CATCH:
       case PNK_CATCHLIST:
-      case PNK_THROW:
       case PNK_YIELD:
       case PNK_YIELD_STAR:
       case PNK_GENEXP:
       case PNK_ARRAYCOMP:
-      case PNK_ARRAYPUSH:
       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:
       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:
-      case PNK_SPREAD:
-      case PNK_MUTATEPROTO:
-
-        /* Unary operators. */
-      case PNK_TYPEOF:
-      case PNK_VOID:
-      case PNK_NOT:
-      case PNK_BITNOT:
 
         /*
          * Binary operators.
          * These must be in the same order as TOK_OR and friends in TokenStream.h.
          */
       case PNK_OR:
       case PNK_AND:
       case PNK_BITOR:
@@ -384,17 +395,17 @@ PushNodeChildren(ParseNode *pn, NodeStac
       case PN_TERNARY:
         return PushTernaryNodeChildren(pn, stack);
 
       case PN_BINARY:
       case PN_BINARY_OBJ:
         return PushBinaryNodeChildren(pn, stack);
 
       case PN_UNARY:
-        return PushUnaryNodeChild(pn, stack);
+        return PushUnaryNodeNullableChild(pn, stack);
 
       case PN_NULLARY:
         return CanRecycleNullaryNode(pn, stack);
 
       default:
         MOZ_CRASH("huh?");
         return PushResult::CleanUpLater;
     }