Bug 1185106 - Part 10.2: Support async arrow function in Reflect.parse. r=efaust,till
authorTooru Fujisawa <arai_a@mac.com>
Sun, 28 Aug 2016 23:58:30 +0900
changeset 320244 3e7d781a99640e24397d87c6d31bc8de45f60a8e
parent 320243 3a03d945279843d6eaa80ff56af174e0b45abf7d
child 320245 b33af49c646c8709c004bd09191298f1153d593d
push id20754
push usercbook@mozilla.com
push dateMon, 31 Oct 2016 15:58:35 +0000
treeherderfx-team@b1b66b1780c2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersefaust, till
bugs1185106
milestone52.0a1
Bug 1185106 - Part 10.2: Support async arrow function in Reflect.parse. r=efaust,till MozReview-Commit-ID: LYJym1TTrQa
js/src/builtin/ReflectParse.cpp
--- a/js/src/builtin/ReflectParse.cpp
+++ b/js/src/builtin/ReflectParse.cpp
@@ -1804,16 +1804,17 @@ class ASTSerializer
     bool literal(ParseNode* pn, MutableHandleValue dst);
 
     bool pattern(ParseNode* pn, MutableHandleValue dst);
     bool arrayPattern(ParseNode* pn, MutableHandleValue dst);
     bool objectPattern(ParseNode* pn, MutableHandleValue dst);
 
     bool function(ParseNode* pn, ASTType type, MutableHandleValue dst);
     bool functionArgsAndBody(ParseNode* pn, NodeVector& args, NodeVector& defaults,
+                             bool isAsync, bool isExpression,
                              MutableHandleValue body, MutableHandleValue rest);
     bool functionBody(ParseNode* pn, TokenPos* pos, MutableHandleValue dst);
 
     bool comprehensionBlock(ParseNode* pn, MutableHandleValue dst);
     bool comprehensionIf(ParseNode* pn, MutableHandleValue dst);
     bool comprehension(ParseNode* pn, MutableHandleValue dst);
     bool generatorExpression(ParseNode* pn, MutableHandleValue dst);
 
@@ -3421,23 +3422,24 @@ ASTSerializer::function(ParseNode* pn, A
     NodeVector args(cx);
     NodeVector defaults(cx);
 
     RootedValue body(cx), rest(cx);
     if (func->hasRest())
         rest.setUndefined();
     else
         rest.setNull();
-    return functionArgsAndBody(pn->pn_body, args, defaults, &body, &rest) &&
+    return functionArgsAndBody(pn->pn_body, args, defaults, isAsync, isExpression, &body, &rest) &&
            builder.function(type, &pn->pn_pos, id, args, defaults, body,
                             rest, generatorStyle, isAsync, isExpression, dst);
 }
 
 bool
 ASTSerializer::functionArgsAndBody(ParseNode* pn, NodeVector& args, NodeVector& defaults,
+                                   bool isAsync, bool isExpression,
                                    MutableHandleValue body, MutableHandleValue rest)
 {
     ParseNode* pnargs;
     ParseNode* pnbody;
 
     /* Extract the args and body separately. */
     if (pn->isKind(PNK_PARAMSBODY)) {
         pnargs = pn;
@@ -3461,16 +3463,24 @@ ASTSerializer::functionArgsAndBody(Parse
         ParseNode* pnstart = pnbody->pn_head;
 
         // Skip over initial yield in generator.
         if (pnstart && pnstart->isKind(PNK_YIELD)) {
             MOZ_ASSERT(pnstart->getOp() == JSOP_INITIALYIELD);
             pnstart = pnstart->pn_next;
         }
 
+        // Async arrow with expression body is converted into STATEMENTLIST
+        // to insert initial yield.
+        if (isAsync && isExpression) {
+            MOZ_ASSERT(pnstart->getKind() == PNK_RETURN);
+            return functionArgs(pn, pnargs, args, defaults, rest) &&
+                   expression(pnstart->pn_kid, body);
+        }
+
         return functionArgs(pn, pnargs, args, defaults, rest) &&
                functionBody(pnstart, &pnbody->pn_pos, body);
       }
 
       default:
         LOCAL_NOT_REACHED("unexpected function contents");
     }
 }