Bug 1518391 - Part 4: Use pn_u.function.syntaxKind instead of pn_op for FunctionNode. r=jorendorff
authorTooru Fujisawa <arai_a@mac.com>
Tue, 05 Feb 2019 14:59:11 +0000
changeset 517651 a8aa16000d0100e2f736b2970ce3dc1f7da9f515
parent 517650 c753ec107783d59196300ab4fe49c3204d0b519f
child 517652 1999a751e5dbb4526c1e4a2a0942b9a09f3bd984
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1518391
milestone67.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 1518391 - Part 4: Use pn_u.function.syntaxKind instead of pn_op for FunctionNode. r=jorendorff Differential Revision: https://phabricator.services.mozilla.com/D18329
js/src/frontend/BytecodeEmitter.cpp
js/src/frontend/FullParseHandler.h
js/src/frontend/ParseNode.h
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -5632,17 +5632,18 @@ MOZ_NEVER_INLINE bool BytecodeEmitter::e
   }
 
   // Make the function object a literal in the outer script's pool.
   unsigned index = objectList.add(funNode->funbox());
 
   // Non-hoisted functions simply emit their respective op.
   if (!funNode->functionIsHoisted()) {
     // JSOP_LAMBDA_ARROW is always preceded by a new.target
-    MOZ_ASSERT(fun->isArrow() == (funNode->getOp() == JSOP_LAMBDA_ARROW));
+    MOZ_ASSERT(fun->isArrow() ==
+               (funNode->syntaxKind() == FunctionSyntaxKind::Arrow));
     if (funbox->isAsync()) {
       MOZ_ASSERT(!needsProto);
       return emitAsyncWrapper(index, funbox->needsHomeObject(), fun->isArrow(),
                               fun->isGenerator());
     }
 
     if (fun->isArrow()) {
       if (sc->allowNewTarget()) {
@@ -5652,23 +5653,27 @@ MOZ_NEVER_INLINE bool BytecodeEmitter::e
       } else {
         if (!emit1(JSOP_NULL)) {
           return false;
         }
       }
     }
 
     if (needsProto) {
-      MOZ_ASSERT(funNode->getOp() == JSOP_LAMBDA);
+      MOZ_ASSERT(funNode->syntaxKind() ==
+                 FunctionSyntaxKind::DerivedClassConstructor);
       return emitIndex32(JSOP_FUNWITHPROTO, index);
     }
 
     // This is a FunctionExpression, ArrowFunctionExpression, or class
     // constructor. Emit the single instruction (without location info).
-    return emitIndex32(funNode->getOp(), index);
+    JSOp op = funNode->syntaxKind() == FunctionSyntaxKind::Arrow
+                  ? JSOP_LAMBDA_ARROW
+                  : JSOP_LAMBDA;
+    return emitIndex32(op, index);
   }
 
   MOZ_ASSERT(!needsProto);
 
   bool topLevelFunction;
   if (sc->isFunctionBox() || (sc->isEvalContext() && sc->strict())) {
     // No nested functions inside other functions are top-level.
     topLevelFunction = false;
@@ -5687,17 +5692,17 @@ MOZ_NEVER_INLINE bool BytecodeEmitter::e
       // during ModuleInstantiate(), before the script is run.
 
       RootedModuleObject module(cx, sc->asModuleContext()->module());
       if (!module->noteFunctionDeclaration(cx, name, fun)) {
         return false;
       }
     } else {
       MOZ_ASSERT(sc->isGlobalContext() || sc->isEvalContext());
-      MOZ_ASSERT(funNode->getOp() == JSOP_NOP);
+      MOZ_ASSERT(funNode->syntaxKind() == FunctionSyntaxKind::Statement);
       MOZ_ASSERT(inPrologue());
       if (funbox->isAsync()) {
         if (!emitAsyncWrapper(index, fun->isMethod(), fun->isArrow(),
                               fun->isGenerator())) {
           return false;
         }
       } else {
         if (!emitIndex32(JSOP_LAMBDA, index)) {
--- a/js/src/frontend/FullParseHandler.h
+++ b/js/src/frontend/FullParseHandler.h
@@ -771,17 +771,17 @@ class FullParseHandler {
     if (IsAnonymousFunctionDefinition(pn)) {
       pn->setDirectRHSAnonFunction(true);
     }
   }
 
  public:
   FunctionNodeType newFunction(FunctionSyntaxKind syntaxKind,
                                const TokenPos& pos) {
-    return new_<FunctionNode>(syntaxKind, JSOP_NOP, pos);
+    return new_<FunctionNode>(syntaxKind, pos);
   }
 
   BinaryNodeType newObjectMethodOrPropertyDefinition(Node key, Node value,
                                                      AccessorType atype) {
     MOZ_ASSERT(isUsableAsObjectPropertyName(key));
 
     return newBinary(ParseNodeKind::Colon, key, value,
                      AccessorTypeToJSOp(atype));
--- a/js/src/frontend/ParseNode.h
+++ b/js/src/frontend/ParseNode.h
@@ -1494,30 +1494,18 @@ inline bool ParseNode::isForLoopDeclarat
     return true;
   }
 
   return false;
 }
 
 class FunctionNode : public ParseNode {
  public:
-  FunctionNode(FunctionSyntaxKind syntaxKind, JSOp op, const TokenPos& pos)
-      : ParseNode(ParseNodeKind::Function, op, pos) {
-    MOZ_ASSERT(op == JSOP_NOP || op == JSOP_LAMBDA_ARROW || op == JSOP_LAMBDA);
-    MOZ_ASSERT_IF(op == JSOP_NOP, syntaxKind == FunctionSyntaxKind::Statement);
-    MOZ_ASSERT_IF(op == JSOP_LAMBDA_ARROW,
-                  syntaxKind == FunctionSyntaxKind::Arrow);
-    MOZ_ASSERT_IF(
-        op == JSOP_LAMBDA,
-        syntaxKind == FunctionSyntaxKind::Statement ||
-            syntaxKind == FunctionSyntaxKind::Construction ||
-            syntaxKind == FunctionSyntaxKind::DerivedClassConstructor ||
-            syntaxKind == FunctionSyntaxKind::Method ||
-            syntaxKind == FunctionSyntaxKind::Getter ||
-            syntaxKind == FunctionSyntaxKind::Setter);
+  FunctionNode(FunctionSyntaxKind syntaxKind, const TokenPos& pos)
+      : ParseNode(ParseNodeKind::Function, JSOP_NOP, pos) {
     MOZ_ASSERT(!pn_u.function.body);
     MOZ_ASSERT(!pn_u.function.funbox);
     MOZ_ASSERT(is<FunctionNode>());
     pn_u.function.syntaxKind = syntaxKind;
   }
 
   static bool test(const ParseNode& node) {
     bool match = node.isKind(ParseNodeKind::Function);
@@ -1550,18 +1538,17 @@ class FunctionNode : public ParseNode {
 
   void setFunbox(FunctionBox* funbox) { pn_u.function.funbox = funbox; }
 
   void setBody(ListNode* body) { pn_u.function.body = body; }
 
   FunctionSyntaxKind syntaxKind() const { return pn_u.function.syntaxKind; }
 
   bool functionIsHoisted() const {
-    MOZ_ASSERT(isOp(JSOP_LAMBDA) || isOp(JSOP_LAMBDA_ARROW) || isOp(JSOP_NOP));
-    return isOp(JSOP_NOP);
+    return syntaxKind() == FunctionSyntaxKind::Statement;
   }
 };
 
 class ModuleNode : public ParseNode {
  public:
   explicit ModuleNode(const TokenPos& pos)
       : ParseNode(ParseNodeKind::Module, JSOP_NOP, pos) {
     MOZ_ASSERT(!pn_u.module.body);