Bug 1183400 - Remove SyntacticContext completely. r=efaust
authorJeff Walden <jwalden@mit.edu>
Mon, 13 Jul 2015 13:09:55 -0700
changeset 257761 ef403529cdd715fdfe7bb3cdc2531c9a2e405102
parent 257760 7d13f9aefa3e41dc84ee0cb8ed505ec358f7f495
child 257762 5c3304cf2c039376dcecfe24188024c2b0de9073
push id29226
push userryanvm@gmail.com
push dateFri, 14 Aug 2015 13:01:14 +0000
treeherdermozilla-central@1b2402247429 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersefaust
bugs1183400
milestone43.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 1183400 - Remove SyntacticContext completely. r=efaust
js/src/frontend/FoldConstants.cpp
--- a/js/src/frontend/FoldConstants.cpp
+++ b/js/src/frontend/FoldConstants.cpp
@@ -525,33 +525,25 @@ Boolish(ParseNode* pn)
         return Unknown;
       }
 
       default:
         return Unknown;
     }
 }
 
-// Expressions that appear in a few specific places are treated specially
-// during constant folding. This enum tells where a parse node appears.
-enum class SyntacticContext : int {
-    // Any other syntactic context.
-    Other
-};
-
 static bool
-Fold(ExclusiveContext* cx, ParseNode** pnp, Parser<FullParseHandler>& parser, bool inGenexpLambda,
-     SyntacticContext sc);
+Fold(ExclusiveContext* cx, ParseNode** pnp, Parser<FullParseHandler>& parser, bool inGenexpLambda);
 
 static bool
 FoldCondition(ExclusiveContext* cx, ParseNode** nodePtr, Parser<FullParseHandler>& parser,
               bool inGenexpLambda)
 {
     // Conditions fold like any other expression...
-    if (!Fold(cx, nodePtr, parser, inGenexpLambda, SyntacticContext::Other))
+    if (!Fold(cx, nodePtr, parser, inGenexpLambda))
         return false;
 
     // ...but then they sometimes can be further folded to constants.
     ParseNode* node = *nodePtr;
     Truthiness t = Boolish(node);
     if (t != Unknown) {
         // We can turn function nodes into constant nodes here, but mutating
         // function nodes is tricky --- in particular, mutating a function node
@@ -575,17 +567,17 @@ FoldCondition(ExclusiveContext* cx, Pars
 static bool
 FoldTypeOfExpr(ExclusiveContext* cx, ParseNode* node, Parser<FullParseHandler>& parser,
                bool inGenexpLambda)
 {
     MOZ_ASSERT(node->isKind(PNK_TYPEOFEXPR));
     MOZ_ASSERT(node->isArity(PN_UNARY));
 
     ParseNode*& expr = node->pn_kid;
-    if (!Fold(cx, &expr, parser, inGenexpLambda, SyntacticContext::Other))
+    if (!Fold(cx, &expr, parser, inGenexpLambda))
         return false;
 
     // Constant-fold the entire |typeof| if given a constant with known type.
     RootedPropertyName result(cx);
     if (expr->isKind(PNK_STRING) || expr->isKind(PNK_TEMPLATE_STRING))
         result = cx->names().string;
     else if (expr->isKind(PNK_NUMBER))
         result = cx->names().number;
@@ -611,17 +603,17 @@ FoldTypeOfExpr(ExclusiveContext* cx, Par
 static bool
 FoldDeleteExpr(ExclusiveContext* cx, ParseNode* node, Parser<FullParseHandler>& parser,
                bool inGenexpLambda)
 {
     MOZ_ASSERT(node->isKind(PNK_DELETEEXPR));
     MOZ_ASSERT(node->isArity(PN_UNARY));
 
     ParseNode*& expr = node->pn_kid;
-    if (!Fold(cx, &expr, parser, inGenexpLambda, SyntacticContext::Other))
+    if (!Fold(cx, &expr, parser, inGenexpLambda))
         return false;
 
     // Expression deletion evaluates the expression, then evaluates to
     // true.  For trivial expressions, eliminate the expression evaluation.
     if (expr->isKind(PNK_TRUE) ||
         expr->isKind(PNK_FALSE) ||
         expr->isKind(PNK_STRING) ||
         expr->isKind(PNK_TEMPLATE_STRING) ||
@@ -642,17 +634,17 @@ static bool
 FoldDeleteElement(ExclusiveContext* cx, ParseNode* node, Parser<FullParseHandler>& parser,
                   bool inGenexpLambda)
 {
     MOZ_ASSERT(node->isKind(PNK_DELETEELEM) || node->isKind(PNK_DELETESUPERELEM));
     MOZ_ASSERT(node->isArity(PN_UNARY));
     MOZ_ASSERT(node->pn_kid->isKind(PNK_ELEM) || node->pn_kid->isKind(PNK_SUPERELEM));
 
     ParseNode*& expr = node->pn_kid;
-    if (!Fold(cx, &expr, parser, inGenexpLambda, SyntacticContext::Other))
+    if (!Fold(cx, &expr, parser, inGenexpLambda))
         return false;
 
     // If we're deleting an element, but constant-folding converted our
     // element reference into a dotted property access, we must *also*
     // morph the node's kind.
     //
     // In principle this also applies to |super["foo"] -> super.foo|,
     // but we don't constant-fold |super["foo"]| yet.
@@ -673,17 +665,17 @@ FoldDeleteProperty(ExclusiveContext* cx,
     MOZ_ASSERT(node->isArity(PN_UNARY));
     MOZ_ASSERT(node->pn_kid->isKind(PNK_DOT) || node->pn_kid->isKind(PNK_SUPERPROP));
 
     ParseNode*& expr = node->pn_kid;
 #ifdef DEBUG
     ParseNodeKind oldKind = expr->getKind();
 #endif
 
-    if (!Fold(cx, &expr, parser, inGenexpLambda, SyntacticContext::Other))
+    if (!Fold(cx, &expr, parser, inGenexpLambda))
         return false;
 
     MOZ_ASSERT(expr->isKind(oldKind),
                "kind should have remained invariant under folding");
 
     return true;
 }
 
@@ -726,17 +718,17 @@ static bool
 FoldUnaryArithmetic(ExclusiveContext* cx, ParseNode* node, Parser<FullParseHandler>& parser,
                     bool inGenexpLambda)
 {
     MOZ_ASSERT(node->isKind(PNK_BITNOT) || node->isKind(PNK_POS) || node->isKind(PNK_NEG),
                "need a different method for this node kind");
     MOZ_ASSERT(node->isArity(PN_UNARY));
 
     ParseNode*& expr = node->pn_kid;
-    if (!Fold(cx, &expr, parser, inGenexpLambda, SyntacticContext::Other))
+    if (!Fold(cx, &expr, parser, inGenexpLambda))
         return false;
 
     if (expr->isKind(PNK_NUMBER) || expr->isKind(PNK_TRUE) || expr->isKind(PNK_FALSE)) {
         double d = expr->isKind(PNK_NUMBER)
                    ? expr->pn_dval
                    : double(expr->isKind(PNK_TRUE));
 
         if (node->isKind(PNK_BITNOT))
@@ -764,38 +756,37 @@ FoldIncrementDecrement(ExclusiveContext*
                node->isKind(PNK_POSTINCREMENT) ||
                node->isKind(PNK_PREDECREMENT) ||
                node->isKind(PNK_POSTDECREMENT));
     MOZ_ASSERT(node->isArity(PN_UNARY));
 
     ParseNode*& target = node->pn_kid;
     MOZ_ASSERT(parser.isValidSimpleAssignmentTarget(target, Parser<FullParseHandler>::PermitAssignmentToFunctionCalls));
 
-    if (!Fold(cx, &target, parser, inGenexpLambda, SyntacticContext::Other))
+    if (!Fold(cx, &target, parser, inGenexpLambda))
         return false;
 
     MOZ_ASSERT(parser.isValidSimpleAssignmentTarget(target, Parser<FullParseHandler>::PermitAssignmentToFunctionCalls));
 
     return true;
 }
 
 static bool
 FoldAndOr(ExclusiveContext* cx, ParseNode** nodePtr, Parser<FullParseHandler>& parser,
-          bool inGenexpLambda, SyntacticContext sc)
+          bool inGenexpLambda)
 {
     ParseNode* node = *nodePtr;
 
     MOZ_ASSERT(node->isKind(PNK_AND) || node->isKind(PNK_OR));
     MOZ_ASSERT(node->isArity(PN_LIST));
 
     bool isOrNode = node->isKind(PNK_OR);
     ParseNode** elem = &node->pn_head;
     do {
-        // Pass |sc| through to propagate conditionality.
-        if (!Fold(cx, elem, parser, inGenexpLambda, sc))
+        if (!Fold(cx, elem, parser, inGenexpLambda))
             return false;
 
         Truthiness t = Boolish(*elem);
 
         // If we don't know the constant-folded node's truthiness, we can't
         // reduce this node with its surroundings.  Continue folding any
         // remaining nodes.
         if (t == Unknown) {
@@ -878,32 +869,32 @@ FoldConditional(ExclusiveContext* cx, Pa
         MOZ_ASSERT(node->isKind(PNK_CONDITIONAL));
         MOZ_ASSERT(node->isArity(PN_TERNARY));
 
         ParseNode*& expr = node->pn_kid1;
         if (!FoldCondition(cx, &expr, parser, inGenexpLambda))
             return false;
 
         ParseNode*& ifTruthy = node->pn_kid2;
-        if (!Fold(cx, &ifTruthy, parser, inGenexpLambda, SyntacticContext::Other))
+        if (!Fold(cx, &ifTruthy, parser, inGenexpLambda))
             return false;
 
         ParseNode*& ifFalsy = node->pn_kid3;
 
         // If our C?T:F node has F as another ?: node, *iteratively* constant-
         // fold F *after* folding C and T (and possibly eliminating C and one
         // of T/F entirely); otherwise fold F normally.  Making |nextNode| non-
         // null causes this loop to run again to fold F.
         //
         // Conceivably we could instead/also iteratively constant-fold T, if T
         // were more complex than F.  Such an optimization is unimplemented.
         if (ifFalsy->isKind(PNK_CONDITIONAL)) {
             nextNode = &ifFalsy;
         } else {
-            if (!Fold(cx, &ifFalsy, parser, inGenexpLambda, SyntacticContext::Other))
+            if (!Fold(cx, &ifFalsy, parser, inGenexpLambda))
                 return false;
         }
 
         // Try to constant-fold based on the condition expression.
         Truthiness t = Boolish(expr);
         if (t == Unknown)
             continue;
 
@@ -969,34 +960,31 @@ FoldIf(ExclusiveContext* cx, ParseNode**
         MOZ_ASSERT(node->isKind(PNK_IF));
         MOZ_ASSERT(node->isArity(PN_TERNARY));
 
         ParseNode*& expr = node->pn_kid1;
         if (!FoldCondition(cx, &expr, parser, inGenexpLambda))
             return false;
 
         ParseNode*& consequent = node->pn_kid2;
-        if (!Fold(cx, &consequent, parser, inGenexpLambda, SyntacticContext::Other))
+        if (!Fold(cx, &consequent, parser, inGenexpLambda))
             return false;
 
         ParseNode*& alternative = node->pn_kid3;
         if (alternative) {
             // If in |if (C) T; else F;| we have |F| as another |if|,
             // *iteratively* constant-fold |F| *after* folding |C| and |T| (and
             // possibly completely replacing the whole thing with |T| or |F|);
             // otherwise fold F normally.  Making |nextNode| non-null causes
             // this loop to run again to fold F.
             if (alternative->isKind(PNK_IF)) {
                 nextNode = &alternative;
             } else {
-                if (!Fold(cx, &alternative, parser, inGenexpLambda,
-                          SyntacticContext::Other))
-                {
+                if (!Fold(cx, &alternative, parser, inGenexpLambda))
                     return false;
-                }
             }
         }
 
         // Eliminate the consequent or alternative if the condition has
         // constant truthiness.  Don't eliminate if we have an |if (0)| in
         // trailing position in a generator expression, as this is a special
         // form we can't fold away.
         Truthiness t = Boolish(expr);
@@ -1078,21 +1066,18 @@ FoldFunction(ExclusiveContext* cx, Parse
 
     // Don't constant-fold inside "use asm" code, as this could create a parse
     // tree that doesn't type-check as asm.js.
     if (node->pn_funbox->useAsmOrInsideUseAsm())
         return true;
 
     // Note: pn_body is null for lazily-parsed functions.
     if (ParseNode*& functionBody = node->pn_body) {
-        if (!Fold(cx, &functionBody, parser, node->pn_funbox->inGenexpLambda,
-                  SyntacticContext::Other))
-        {
+        if (!Fold(cx, &functionBody, parser, node->pn_funbox->inGenexpLambda))
             return false;
-        }
     }
 
     return true;
 }
 
 static double
 ComputeBinary(ParseNodeKind kind, double left, double right)
 {
@@ -1147,17 +1132,17 @@ FoldBinaryArithmetic(ExclusiveContext* c
                node->isKind(PNK_DIV) ||
                node->isKind(PNK_MOD));
     MOZ_ASSERT(node->isArity(PN_LIST));
     MOZ_ASSERT(node->pn_count >= 2);
 
     // Fold each operand, ideally into a number.
     ParseNode** listp = &node->pn_head;
     for (; *listp; listp = &(*listp)->pn_next) {
-        if (!Fold(cx, listp, parser, inGenexpLambda, SyntacticContext::Other))
+        if (!Fold(cx, listp, parser, inGenexpLambda))
             return false;
 
         if (!FoldType(cx, *listp, PNK_NUMBER))
             return false;
     }
 
     // Repoint the list's tail pointer.
     node->pn_tail = listp;
@@ -1213,17 +1198,17 @@ FoldExponentiation(ExclusiveContext* cx,
 {
     MOZ_ASSERT(node->isKind(PNK_POW));
     MOZ_ASSERT(node->isArity(PN_LIST));
     MOZ_ASSERT(node->pn_count >= 2);
 
     // Fold each operand, ideally into a number.
     ParseNode** listp = &node->pn_head;
     for (; *listp; listp = &(*listp)->pn_next) {
-        if (!Fold(cx, listp, parser, inGenexpLambda, SyntacticContext::Other))
+        if (!Fold(cx, listp, parser, inGenexpLambda))
             return false;
 
         if (!FoldType(cx, *listp, PNK_NUMBER))
             return false;
     }
 
     // Repoint the list's tail pointer.
     node->pn_tail = listp;
@@ -1254,17 +1239,17 @@ FoldExponentiation(ExclusiveContext* cx,
 static bool
 FoldList(ExclusiveContext* cx, ParseNode* list, Parser<FullParseHandler>& parser,
          bool inGenexpLambda)
 {
     MOZ_ASSERT(list->isArity(PN_LIST));
 
     ParseNode** elem = &list->pn_head;
     for (; *elem; elem = &(*elem)->pn_next) {
-        if (!Fold(cx, elem, parser, inGenexpLambda, SyntacticContext::Other))
+        if (!Fold(cx, elem, parser, inGenexpLambda))
             return false;
     }
 
     // Repoint the list's tail pointer if the final element was replaced.
     list->pn_tail = elem;
 
     list->checkListConsistency();
 
@@ -1274,17 +1259,17 @@ FoldList(ExclusiveContext* cx, ParseNode
 static bool
 FoldReturn(ExclusiveContext* cx, ParseNode* node, Parser<FullParseHandler>& parser,
            bool inGenexpLambda)
 {
     MOZ_ASSERT(node->isKind(PNK_RETURN));
     MOZ_ASSERT(node->isArity(PN_BINARY));
 
     if (ParseNode*& expr = node->pn_left) {
-        if (!Fold(cx, &expr, parser, inGenexpLambda, SyntacticContext::Other))
+        if (!Fold(cx, &expr, parser, inGenexpLambda))
             return false;
     }
 
 #ifdef DEBUG
     if (ParseNode* generatorSpecific = node->pn_right) {
         MOZ_ASSERT(generatorSpecific->isKind(PNK_NAME));
         MOZ_ASSERT(generatorSpecific->pn_atom->equals(".genrval"));
         MOZ_ASSERT(generatorSpecific->isAssigned());
@@ -1297,92 +1282,92 @@ FoldReturn(ExclusiveContext* cx, ParseNo
 static bool
 FoldTry(ExclusiveContext* cx, ParseNode* node, Parser<FullParseHandler>& parser,
         bool inGenexpLambda)
 {
     MOZ_ASSERT(node->isKind(PNK_TRY));
     MOZ_ASSERT(node->isArity(PN_TERNARY));
 
     ParseNode*& statements = node->pn_kid1;
-    if (!Fold(cx, &statements, parser, inGenexpLambda, SyntacticContext::Other))
+    if (!Fold(cx, &statements, parser, inGenexpLambda))
         return false;
 
     if (ParseNode*& catchList = node->pn_kid2) {
-        if (!Fold(cx, &catchList, parser, inGenexpLambda, SyntacticContext::Other))
+        if (!Fold(cx, &catchList, parser, inGenexpLambda))
             return false;
     }
 
     if (ParseNode*& finally = node->pn_kid3) {
-        if (!Fold(cx, &finally, parser, inGenexpLambda, SyntacticContext::Other))
+        if (!Fold(cx, &finally, parser, inGenexpLambda))
             return false;
     }
 
     return true;
 }
 
 static bool
 FoldCatch(ExclusiveContext* cx, ParseNode* node, Parser<FullParseHandler>& parser,
           bool inGenexpLambda)
 {
     MOZ_ASSERT(node->isKind(PNK_CATCH));
     MOZ_ASSERT(node->isArity(PN_TERNARY));
 
     ParseNode*& declPattern = node->pn_kid1;
-    if (!Fold(cx, &declPattern, parser, inGenexpLambda, SyntacticContext::Other))
+    if (!Fold(cx, &declPattern, parser, inGenexpLambda))
         return false;
 
     if (ParseNode*& cond = node->pn_kid2) {
         if (!FoldCondition(cx, &cond, parser, inGenexpLambda))
             return false;
     }
 
     if (ParseNode*& statements = node->pn_kid3) {
-        if (!Fold(cx, &statements, parser, inGenexpLambda, SyntacticContext::Other))
+        if (!Fold(cx, &statements, parser, inGenexpLambda))
             return false;
     }
 
     return true;
 }
 
 static bool
 FoldClass(ExclusiveContext* cx, ParseNode* node, Parser<FullParseHandler>& parser,
           bool inGenexpLambda)
 {
     MOZ_ASSERT(node->isKind(PNK_CLASS));
     MOZ_ASSERT(node->isArity(PN_TERNARY));
 
     if (ParseNode*& classNames = node->pn_kid1) {
-        if (!Fold(cx, &classNames, parser, inGenexpLambda, SyntacticContext::Other))
+        if (!Fold(cx, &classNames, parser, inGenexpLambda))
             return false;
     }
 
     if (ParseNode*& heritage = node->pn_kid2) {
-        if (!Fold(cx, &heritage, parser, inGenexpLambda, SyntacticContext::Other))
+        if (!Fold(cx, &heritage, parser, inGenexpLambda))
             return false;
     }
 
     ParseNode*& body = node->pn_kid3;
-    return Fold(cx, &body, parser, inGenexpLambda, SyntacticContext::Other);
+    return Fold(cx, &body, parser, inGenexpLambda);
 }
 
 static bool
 FoldElement(ExclusiveContext* cx, ParseNode** nodePtr, Parser<FullParseHandler>& parser,
             bool inGenexpLambda)
 {
     ParseNode* node = *nodePtr;
 
     MOZ_ASSERT(node->isKind(PNK_ELEM));
     MOZ_ASSERT(node->isArity(PN_BINARY));
 
     ParseNode*& expr = node->pn_left;
-    if (!Fold(cx, &expr, parser, inGenexpLambda, SyntacticContext::Other))
+    if (!Fold(cx, &expr, parser, inGenexpLambda))
         return false;
 
     ParseNode*& key = node->pn_right;
-    if (!Fold(cx, &key, parser, inGenexpLambda, SyntacticContext::Other))
+    if (!Fold(cx, &key, parser, inGenexpLambda))
         return false;
 
     PropertyName* name = nullptr;
     if (key->isKind(PNK_STRING)) {
         JSAtom* atom = key->pn_atom;
         uint32_t index;
 
         if (atom->isIndex(&index)) {
@@ -1608,17 +1593,17 @@ FoldCall(ExclusiveContext* cx, ParseNode
     //   assertEq(obj.f``, "obj");
     //
     // See bug 537673 and bug 1182373.
     ParseNode** listp = &node->pn_head;
     if ((*listp)->isInParens())
         listp = &(*listp)->pn_next;
 
     for (; *listp; listp = &(*listp)->pn_next) {
-        if (!Fold(cx, listp, parser, inGenexpLambda, SyntacticContext::Other))
+        if (!Fold(cx, listp, parser, inGenexpLambda))
             return false;
     }
 
     // If the last node in the list was replaced, pn_tail points into the wrong node.
     node->pn_tail = listp;
 
     node->checkListConsistency();
     return true;
@@ -1627,48 +1612,48 @@ FoldCall(ExclusiveContext* cx, ParseNode
 static bool
 FoldForInOrOf(ExclusiveContext* cx, ParseNode* node, Parser<FullParseHandler>& parser,
               bool inGenexpLambda)
 {
     MOZ_ASSERT(node->isKind(PNK_FORIN) || node->isKind(PNK_FOROF));
     MOZ_ASSERT(node->isArity(PN_TERNARY));
 
     if (ParseNode*& decl = node->pn_kid1) {
-        if (!Fold(cx, &decl, parser, inGenexpLambda, SyntacticContext::Other))
+        if (!Fold(cx, &decl, parser, inGenexpLambda))
             return false;
     }
 
-    return Fold(cx, &node->pn_kid2, parser, inGenexpLambda, SyntacticContext::Other) &&
-           Fold(cx, &node->pn_kid3, parser, inGenexpLambda, SyntacticContext::Other);
+    return Fold(cx, &node->pn_kid2, parser, inGenexpLambda) &&
+           Fold(cx, &node->pn_kid3, parser, inGenexpLambda);
 }
 
 static bool
 FoldForHead(ExclusiveContext* cx, ParseNode* node, Parser<FullParseHandler>& parser,
             bool inGenexpLambda)
 {
     MOZ_ASSERT(node->isKind(PNK_FORHEAD));
     MOZ_ASSERT(node->isArity(PN_TERNARY));
 
     if (ParseNode*& init = node->pn_kid1) {
-        if (!Fold(cx, &init, parser, inGenexpLambda, SyntacticContext::Other))
+        if (!Fold(cx, &init, parser, inGenexpLambda))
             return false;
     }
 
     if (ParseNode*& test = node->pn_kid2) {
         if (!FoldCondition(cx, &test, parser, inGenexpLambda))
             return false;
 
         if (test->isKind(PNK_TRUE)) {
             parser.freeTree(test);
             test = nullptr;
         }
     }
 
     if (ParseNode*& update = node->pn_kid3) {
-        if (!Fold(cx, &update, parser, inGenexpLambda, SyntacticContext::Other))
+        if (!Fold(cx, &update, parser, inGenexpLambda))
             return false;
     }
 
     return true;
 }
 
 static bool
 FoldDottedProperty(ExclusiveContext* cx, ParseNode* node, Parser<FullParseHandler>& parser,
@@ -1680,17 +1665,17 @@ FoldDottedProperty(ExclusiveContext* cx,
     // Iterate through a long chain of dotted property accesses to find the
     // most-nested non-dotted property node, then fold that.
     ParseNode** nested = &node->pn_expr;
     while ((*nested)->isKind(PNK_DOT)) {
         MOZ_ASSERT((*nested)->isArity(PN_NAME));
         nested = &(*nested)->pn_expr;
     }
 
-    return Fold(cx, nested, parser, inGenexpLambda, SyntacticContext::Other);
+    return Fold(cx, nested, parser, inGenexpLambda);
 }
 
 static bool
 FoldName(ExclusiveContext* cx, ParseNode* node, Parser<FullParseHandler>& parser,
          bool inGenexpLambda)
 {
     MOZ_ASSERT(node->isKind(PNK_NAME));
     MOZ_ASSERT(node->isArity(PN_NAME));
@@ -1699,22 +1684,21 @@ FoldName(ExclusiveContext* cx, ParseNode
     // name analysis information and contain nothing foldable.
     if (node->isUsed())
         return true;
 
     // Other names might have a foldable expression in pn_expr.
     if (!node->pn_expr)
         return true;
 
-    return Fold(cx, &node->pn_expr, parser, inGenexpLambda, SyntacticContext::Other);
+    return Fold(cx, &node->pn_expr, parser, inGenexpLambda);
 }
 
 bool
-Fold(ExclusiveContext* cx, ParseNode** pnp, Parser<FullParseHandler>& parser, bool inGenexpLambda,
-     SyntacticContext sc)
+Fold(ExclusiveContext* cx, ParseNode** pnp, Parser<FullParseHandler>& parser, bool inGenexpLambda)
 {
     JS_CHECK_RECURSION(cx, return false);
 
     ParseNode* pn = *pnp;
 
     switch (pn->getKind()) {
       case PNK_NEWTARGET:
       case PNK_NOP:
@@ -1789,27 +1773,27 @@ Fold(ExclusiveContext* cx, ParseNode** p
       case PNK_MUTATEPROTO:
       case PNK_COMPUTED_NAME:
       case PNK_SPREAD:
       case PNK_SUPERELEM:
       case PNK_EXPORT:
       case PNK_EXPORT_DEFAULT:
       case PNK_VOID:
         MOZ_ASSERT(pn->isArity(PN_UNARY));
-        return Fold(cx, &pn->pn_kid, parser, inGenexpLambda, SyntacticContext::Other);
+        return Fold(cx, &pn->pn_kid, parser, inGenexpLambda);
 
       case PNK_SEMI:
         MOZ_ASSERT(pn->isArity(PN_UNARY));
         if (ParseNode*& expr = pn->pn_kid)
-            return Fold(cx, &expr, parser, inGenexpLambda, SyntacticContext::Other);
+            return Fold(cx, &expr, parser, inGenexpLambda);
         return true;
 
       case PNK_AND:
       case PNK_OR:
-        return FoldAndOr(cx, pnp, parser, inGenexpLambda, sc);
+        return FoldAndOr(cx, pnp, parser, inGenexpLambda);
 
       case PNK_FUNCTION:
         return FoldFunction(cx, pn, parser, inGenexpLambda);
 
       case PNK_SUB:
       case PNK_STAR:
       case PNK_LSH:
       case PNK_RSH:
@@ -1855,27 +1839,27 @@ Fold(ExclusiveContext* cx, ParseNode** p
       case PNK_IMPORT_SPEC_LIST:
       case PNK_GENEXP:
         return FoldList(cx, pn, parser, inGenexpLambda);
 
       case PNK_YIELD_STAR:
         MOZ_ASSERT(pn->isArity(PN_BINARY));
         MOZ_ASSERT(pn->pn_right->isKind(PNK_NAME));
         MOZ_ASSERT(!pn->pn_right->isAssigned());
-        return Fold(cx, &pn->pn_left, parser, inGenexpLambda, SyntacticContext::Other);
+        return Fold(cx, &pn->pn_left, parser, inGenexpLambda);
 
       case PNK_YIELD:
         MOZ_ASSERT(pn->isArity(PN_BINARY));
         MOZ_ASSERT((pn->pn_right->isKind(PNK_NAME) && !pn->pn_right->isAssigned()) ||
                    (pn->pn_right->isKind(PNK_ASSIGN) &&
                     pn->pn_right->pn_left->isKind(PNK_NAME) &&
                     pn->pn_right->pn_right->isKind(PNK_GENERATOR)));
         if (!pn->pn_left)
             return true;
-        return Fold(cx, &pn->pn_left, parser, inGenexpLambda, SyntacticContext::Other);
+        return Fold(cx, &pn->pn_left, parser, inGenexpLambda);
 
       case PNK_RETURN:
         return FoldReturn(cx, pn, parser, inGenexpLambda);
 
       case PNK_TRY:
         return FoldTry(cx, pn, parser, inGenexpLambda);
 
       case PNK_CATCH:
@@ -1914,67 +1898,67 @@ Fold(ExclusiveContext* cx, ParseNode** p
       case PNK_EXPORT_FROM:
       case PNK_SHORTHAND:
       case PNK_LETBLOCK:
       case PNK_FOR:
       case PNK_CLASSMETHOD:
       case PNK_IMPORT_SPEC:
       case PNK_EXPORT_SPEC:
         MOZ_ASSERT(pn->isArity(PN_BINARY));
-        return Fold(cx, &pn->pn_left, parser, inGenexpLambda, SyntacticContext::Other) &&
-               Fold(cx, &pn->pn_right, parser, inGenexpLambda, SyntacticContext::Other);
+        return Fold(cx, &pn->pn_left, parser, inGenexpLambda) &&
+               Fold(cx, &pn->pn_right, parser, inGenexpLambda);
 
       case PNK_CLASSNAMES:
         MOZ_ASSERT(pn->isArity(PN_BINARY));
         if (ParseNode*& outerBinding = pn->pn_left) {
-            if (!Fold(cx, &outerBinding, parser, inGenexpLambda, SyntacticContext::Other))
+            if (!Fold(cx, &outerBinding, parser, inGenexpLambda))
                 return false;
         }
-        return Fold(cx, &pn->pn_right, parser, inGenexpLambda, SyntacticContext::Other);
+        return Fold(cx, &pn->pn_right, parser, inGenexpLambda);
 
       case PNK_DOWHILE:
         MOZ_ASSERT(pn->isArity(PN_BINARY));
-        return Fold(cx, &pn->pn_left, parser, inGenexpLambda, SyntacticContext::Other) &&
+        return Fold(cx, &pn->pn_left, parser, inGenexpLambda) &&
                FoldCondition(cx, &pn->pn_right, parser, inGenexpLambda);
 
       case PNK_WHILE:
         MOZ_ASSERT(pn->isArity(PN_BINARY));
         return FoldCondition(cx, &pn->pn_left, parser, inGenexpLambda) &&
-               Fold(cx, &pn->pn_right, parser, inGenexpLambda, SyntacticContext::Other);
+               Fold(cx, &pn->pn_right, parser, inGenexpLambda);
 
       case PNK_DEFAULT:
         MOZ_ASSERT(pn->isArity(PN_BINARY));
         MOZ_ASSERT(!pn->pn_left);
         MOZ_ASSERT(pn->pn_right->isKind(PNK_STATEMENTLIST));
-        return Fold(cx, &pn->pn_right, parser, inGenexpLambda, SyntacticContext::Other);
+        return Fold(cx, &pn->pn_right, parser, inGenexpLambda);
 
       case PNK_WITH:
         MOZ_ASSERT(pn->isArity(PN_BINARY_OBJ));
-        return Fold(cx, &pn->pn_left, parser, inGenexpLambda, SyntacticContext::Other) &&
-               Fold(cx, &pn->pn_right, parser, inGenexpLambda, SyntacticContext::Other);
+        return Fold(cx, &pn->pn_left, parser, inGenexpLambda) &&
+               Fold(cx, &pn->pn_right, parser, inGenexpLambda);
 
       case PNK_FORIN:
       case PNK_FOROF:
         return FoldForInOrOf(cx, pn, parser, inGenexpLambda);
 
       case PNK_FORHEAD:
         return FoldForHead(cx, pn, parser, inGenexpLambda);
 
       case PNK_LABEL:
         MOZ_ASSERT(pn->isArity(PN_NAME));
-        return Fold(cx, &pn->pn_expr, parser, inGenexpLambda, SyntacticContext::Other);
+        return Fold(cx, &pn->pn_expr, parser, inGenexpLambda);
 
       case PNK_DOT:
         return FoldDottedProperty(cx, pn, parser, inGenexpLambda);
 
       case PNK_LEXICALSCOPE:
         MOZ_ASSERT(pn->isArity(PN_NAME));
         if (!pn->pn_expr)
             return true;
-        return Fold(cx, &pn->pn_expr, parser, inGenexpLambda, SyntacticContext::Other);
+        return Fold(cx, &pn->pn_expr, parser, inGenexpLambda);
 
       case PNK_NAME:
         return FoldName(cx, pn, parser, inGenexpLambda);
 
       case PNK_LIMIT: // invalid sentinel value
         MOZ_CRASH("invalid node kind");
     }
 
@@ -1985,10 +1969,10 @@ Fold(ExclusiveContext* cx, ParseNode** p
 bool
 frontend::FoldConstants(ExclusiveContext* cx, ParseNode** pnp, Parser<FullParseHandler>* parser)
 {
     // Don't constant-fold inside "use asm" code, as this could create a parse
     // tree that doesn't type-check as asm.js.
     if (parser->pc->useAsmOrInsideUseAsm())
         return true;
 
-    return Fold(cx, pnp, *parser, false, SyntacticContext::Other);
+    return Fold(cx, pnp, *parser, false);
 }