Bug 1130811 - Add a few extra arity assertions to ContainsHoistedDeclaration for documentation of various kinds' arities. r=adding-assertions-only
authorJeff Walden <jwalden@mit.edu>
Tue, 10 Feb 2015 00:33:26 -0800
changeset 255653 b560b5afe0c48dfc380e4b5d55067bc9ed106df4
parent 255652 5a850bc4ea8fe8cee9fb030373239c80f112095f
child 255654 3b00f60dbd69e3a82c699765967341f6ebb68349
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)
reviewersadding-assertions-only
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 - Add a few extra arity assertions to ContainsHoistedDeclaration for documentation of various kinds' arities. r=adding-assertions-only
js/src/frontend/FoldConstants.cpp
--- a/js/src/frontend/FoldConstants.cpp
+++ b/js/src/frontend/FoldConstants.cpp
@@ -71,43 +71,51 @@ ContainsHoistedDeclaration(ExclusiveCont
         return true;
 
       // Non-global lexical declarations are block-scoped (ergo not hoistable).
       // (Global lexical declarations, in addition to being irrelevant here as
       // ContainsHoistedDeclaration is only used on the arms of an |if|
       // statement, are handled by PNK_GLOBALCONST and PNK_VAR.)
       case PNK_LET:
       case PNK_CONST:
+        MOZ_ASSERT(node->isArity(PN_LIST));
         *result = false;
         return true;
 
       // ContainsHoistedDeclaration is only called on nested nodes, so any
       // instance of this can't be function statements at body level.  In
       // SpiderMonkey, a binding induced by a function statement is added when
       // the function statement is evaluated.  Thus any declaration introduced
       // by a function statement, as observed by this function, isn't a hoisted
       // declaration.
       case PNK_FUNCTION:
+        MOZ_ASSERT(node->isArity(PN_CODE));
         *result = false;
         return true;
 
       // Statements with no sub-components at all.
       case PNK_NOP: // induced by function f() {} function f() {}
       case PNK_DEBUGGER:
+        MOZ_ASSERT(node->isArity(PN_NULLARY));
         *result = false;
         return true;
 
       // Statements containing only an expression have no declarations.
       case PNK_SEMI:
+      case PNK_THROW:
+        MOZ_ASSERT(node->isArity(PN_UNARY));
+        *result = false;
+        return true;
+
       case PNK_RETURN:
-      case PNK_THROW:
       // These two aren't statements in the spec, but we sometimes insert them
       // in statement lists anyway.
       case PNK_YIELD_STAR:
       case PNK_YIELD:
+        MOZ_ASSERT(node->isArity(PN_BINARY));
         *result = false;
         return true;
 
       // Other statements with no sub-statement components.
       case PNK_BREAK:
       case PNK_CONTINUE:
       case PNK_IMPORT:
       case PNK_IMPORT_SPEC_LIST:
@@ -293,16 +301,17 @@ ContainsHoistedDeclaration(ExclusiveCont
       case PNK_LETBLOCK: {
         MOZ_ASSERT(node->isArity(PN_BINARY));
         MOZ_ASSERT(node->pn_left->isKind(PNK_LET));
         MOZ_ASSERT(node->pn_right->isKind(PNK_LEXICALSCOPE));
         return ContainsHoistedDeclaration(cx, node->pn_right, result);
       }
 
       case PNK_LEXICALSCOPE: {
+        MOZ_ASSERT(node->isArity(PN_NAME));
         ParseNode *expr = node->pn_expr;
 
         if (expr->isKind(PNK_FOR))
             return ContainsHoistedDeclaration(cx, expr, result);
 
         MOZ_ASSERT(expr->isKind(PNK_STATEMENTLIST));
         return ListContainsHoistedDeclaration(cx, &node->pn_expr->as<ListNode>(), result);
       }