LCOV - code coverage report
Current view: top level - src/ast - ast.h (source / functions) Hit Total Coverage
Test: app.info Lines: 355 360 98.6 %
Date: 2019-02-19 Functions: 77 81 95.1 %

          Line data    Source code
       1             : // Copyright 2012 the V8 project authors. All rights reserved.
       2             : // Use of this source code is governed by a BSD-style license that can be
       3             : // found in the LICENSE file.
       4             : 
       5             : #ifndef V8_AST_AST_H_
       6             : #define V8_AST_AST_H_
       7             : 
       8             : #include <memory>
       9             : 
      10             : #include "src/ast/ast-value-factory.h"
      11             : #include "src/ast/modules.h"
      12             : #include "src/ast/variables.h"
      13             : #include "src/bailout-reason.h"
      14             : #include "src/globals.h"
      15             : #include "src/heap/factory.h"
      16             : #include "src/isolate.h"
      17             : #include "src/label.h"
      18             : #include "src/objects/literal-objects.h"
      19             : #include "src/objects/smi.h"
      20             : #include "src/parsing/token.h"
      21             : #include "src/runtime/runtime.h"
      22             : 
      23             : namespace v8 {
      24             : namespace internal {
      25             : 
      26             : // The abstract syntax tree is an intermediate, light-weight
      27             : // representation of the parsed JavaScript code suitable for
      28             : // compilation to native code.
      29             : 
      30             : // Nodes are allocated in a separate zone, which allows faster
      31             : // allocation and constant-time deallocation of the entire syntax
      32             : // tree.
      33             : 
      34             : 
      35             : // ----------------------------------------------------------------------------
      36             : // Nodes of the abstract syntax tree. Only concrete classes are
      37             : // enumerated here.
      38             : 
      39             : #define DECLARATION_NODE_LIST(V) \
      40             :   V(VariableDeclaration)         \
      41             :   V(FunctionDeclaration)
      42             : 
      43             : #define ITERATION_NODE_LIST(V) \
      44             :   V(DoWhileStatement)          \
      45             :   V(WhileStatement)            \
      46             :   V(ForStatement)              \
      47             :   V(ForInStatement)            \
      48             :   V(ForOfStatement)
      49             : 
      50             : #define BREAKABLE_NODE_LIST(V) \
      51             :   V(Block)                     \
      52             :   V(SwitchStatement)
      53             : 
      54             : #define STATEMENT_NODE_LIST(V)    \
      55             :   ITERATION_NODE_LIST(V)          \
      56             :   BREAKABLE_NODE_LIST(V)          \
      57             :   V(ExpressionStatement)          \
      58             :   V(EmptyStatement)               \
      59             :   V(SloppyBlockFunctionStatement) \
      60             :   V(IfStatement)                  \
      61             :   V(ContinueStatement)            \
      62             :   V(BreakStatement)               \
      63             :   V(ReturnStatement)              \
      64             :   V(WithStatement)                \
      65             :   V(TryCatchStatement)            \
      66             :   V(TryFinallyStatement)          \
      67             :   V(DebuggerStatement)            \
      68             :   V(InitializeClassMembersStatement)
      69             : 
      70             : #define LITERAL_NODE_LIST(V) \
      71             :   V(RegExpLiteral)           \
      72             :   V(ObjectLiteral)           \
      73             :   V(ArrayLiteral)
      74             : 
      75             : #define EXPRESSION_NODE_LIST(V) \
      76             :   LITERAL_NODE_LIST(V)          \
      77             :   V(Assignment)                 \
      78             :   V(Await)                      \
      79             :   V(BinaryOperation)            \
      80             :   V(NaryOperation)              \
      81             :   V(Call)                       \
      82             :   V(CallNew)                    \
      83             :   V(CallRuntime)                \
      84             :   V(ClassLiteral)               \
      85             :   V(CompareOperation)           \
      86             :   V(CompoundAssignment)         \
      87             :   V(Conditional)                \
      88             :   V(CountOperation)             \
      89             :   V(DoExpression)               \
      90             :   V(EmptyParentheses)           \
      91             :   V(FunctionLiteral)            \
      92             :   V(GetTemplateObject)          \
      93             :   V(ImportCallExpression)       \
      94             :   V(Literal)                    \
      95             :   V(NativeFunctionLiteral)      \
      96             :   V(Property)                   \
      97             :   V(ResolvedProperty)           \
      98             :   V(Spread)                     \
      99             :   V(StoreInArrayLiteral)        \
     100             :   V(SuperCallReference)         \
     101             :   V(SuperPropertyReference)     \
     102             :   V(TemplateLiteral)            \
     103             :   V(ThisExpression)             \
     104             :   V(Throw)                      \
     105             :   V(UnaryOperation)             \
     106             :   V(VariableProxy)              \
     107             :   V(Yield)                      \
     108             :   V(YieldStar)
     109             : 
     110             : #define FAILURE_NODE_LIST(V) V(FailureExpression)
     111             : 
     112             : #define AST_NODE_LIST(V)                        \
     113             :   DECLARATION_NODE_LIST(V)                      \
     114             :   STATEMENT_NODE_LIST(V)                        \
     115             :   EXPRESSION_NODE_LIST(V)
     116             : 
     117             : // Forward declarations
     118             : class AstNode;
     119             : class AstNodeFactory;
     120             : class Declaration;
     121             : class BreakableStatement;
     122             : class Expression;
     123             : class IterationStatement;
     124             : class MaterializedLiteral;
     125             : class NestedVariableDeclaration;
     126             : class ProducedPreparseData;
     127             : class Statement;
     128             : 
     129             : #define DEF_FORWARD_DECLARATION(type) class type;
     130             : AST_NODE_LIST(DEF_FORWARD_DECLARATION)
     131             : FAILURE_NODE_LIST(DEF_FORWARD_DECLARATION)
     132             : #undef DEF_FORWARD_DECLARATION
     133             : 
     134             : class AstNode: public ZoneObject {
     135             :  public:
     136             : #define DECLARE_TYPE_ENUM(type) k##type,
     137             :   enum NodeType : uint8_t {
     138             :     AST_NODE_LIST(DECLARE_TYPE_ENUM) /* , */
     139             :     FAILURE_NODE_LIST(DECLARE_TYPE_ENUM)
     140             :   };
     141             : #undef DECLARE_TYPE_ENUM
     142             : 
     143   221341674 :   void* operator new(size_t size, Zone* zone) { return zone->New(size); }
     144             : 
     145   690157668 :   NodeType node_type() const { return NodeTypeField::decode(bit_field_); }
     146          86 :   int position() const { return position_; }
     147             : 
     148             : #ifdef DEBUG
     149             :   void Print();
     150             :   void Print(Isolate* isolate);
     151             : #endif  // DEBUG
     152             : 
     153             :   // Type testing & conversion functions overridden by concrete subclasses.
     154             : #define DECLARE_NODE_FUNCTIONS(type) \
     155             :   V8_INLINE bool Is##type() const;   \
     156             :   V8_INLINE type* As##type();        \
     157             :   V8_INLINE const type* As##type() const;
     158             :   AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
     159             :   FAILURE_NODE_LIST(DECLARE_NODE_FUNCTIONS)
     160             : #undef DECLARE_NODE_FUNCTIONS
     161             : 
     162             :   IterationStatement* AsIterationStatement();
     163             :   MaterializedLiteral* AsMaterializedLiteral();
     164             : 
     165             :  private:
     166             :   // Hidden to prevent accidental usage. It would have to load the
     167             :   // current zone from the TLS.
     168             :   void* operator new(size_t size);
     169             : 
     170             :   int position_;
     171             :   class NodeTypeField : public BitField<NodeType, 0, 6> {};
     172             : 
     173             :  protected:
     174             :   uint32_t bit_field_;
     175             :   static const uint8_t kNextBitFieldIndex = NodeTypeField::kNext;
     176             : 
     177             :   AstNode(int position, NodeType type)
     178   235514091 :       : position_(position), bit_field_(NodeTypeField::encode(type)) {}
     179             : };
     180             : 
     181             : 
     182             : class Statement : public AstNode {
     183             :  protected:
     184             :   Statement(int position, NodeType type) : AstNode(position, type) {}
     185             : 
     186             :   static const uint8_t kNextBitFieldIndex = AstNode::kNextBitFieldIndex;
     187             : };
     188             : 
     189             : 
     190             : class Expression : public AstNode {
     191             :  public:
     192             :   enum Context {
     193             :     // Not assigned a context yet, or else will not be visited during
     194             :     // code generation.
     195             :     kUninitialized,
     196             :     // Evaluated for its side effects.
     197             :     kEffect,
     198             :     // Evaluated for its value (and side effects).
     199             :     kValue,
     200             :     // Evaluated for control flow (and side effects).
     201             :     kTest
     202             :   };
     203             : 
     204             :   // True iff the expression is a valid reference expression.
     205             :   bool IsValidReferenceExpression() const;
     206             : 
     207             :   // Helpers for ToBoolean conversion.
     208             :   bool ToBooleanIsTrue() const;
     209             :   bool ToBooleanIsFalse() const;
     210             : 
     211             :   // Symbols that cannot be parsed as array indices are considered property
     212             :   // names.  We do not treat symbols that can be array indexes as property
     213             :   // names because [] for string objects is handled only by keyed ICs.
     214             :   bool IsPropertyName() const;
     215             : 
     216             :   // True iff the expression is a class or function expression without
     217             :   // a syntactic name.
     218             :   bool IsAnonymousFunctionDefinition() const;
     219             : 
     220             :   // True iff the expression is a concise method definition.
     221             :   bool IsConciseMethodDefinition() const;
     222             : 
     223             :   // True iff the expression is an accessor function definition.
     224             :   bool IsAccessorFunctionDefinition() const;
     225             : 
     226             :   // True iff the expression is a literal represented as a smi.
     227             :   bool IsSmiLiteral() const;
     228             : 
     229             :   // True iff the expression is a literal represented as a number.
     230             :   bool IsNumberLiteral() const;
     231             : 
     232             :   // True iff the expression is a string literal.
     233             :   bool IsStringLiteral() const;
     234             : 
     235             :   // True iff the expression is the null literal.
     236             :   bool IsNullLiteral() const;
     237             : 
     238             :   // True iff the expression is the hole literal.
     239             :   bool IsTheHoleLiteral() const;
     240             : 
     241             :   // True if we can prove that the expression is the undefined literal. Note
     242             :   // that this also checks for loads of the global "undefined" variable.
     243             :   bool IsUndefinedLiteral() const;
     244             : 
     245             :   bool IsCompileTimeValue();
     246             : 
     247             :   bool IsPattern() {
     248             :     STATIC_ASSERT(kObjectLiteral + 1 == kArrayLiteral);
     249       95181 :     return IsInRange(node_type(), kObjectLiteral, kArrayLiteral);
     250             :   }
     251             : 
     252             :   bool is_parenthesized() const {
     253             :     return IsParenthesizedField::decode(bit_field_);
     254             :   }
     255             : 
     256             :   void mark_parenthesized() {
     257     2596127 :     bit_field_ = IsParenthesizedField::update(bit_field_, true);
     258             :   }
     259             : 
     260             :   void clear_parenthesized() {
     261      683900 :     bit_field_ = IsParenthesizedField::update(bit_field_, false);
     262             :   }
     263             : 
     264             :  private:
     265             :   class IsParenthesizedField
     266             :       : public BitField<bool, AstNode::kNextBitFieldIndex, 1> {};
     267             : 
     268             :  protected:
     269             :   Expression(int pos, NodeType type) : AstNode(pos, type) {
     270             :     DCHECK(!is_parenthesized());
     271             :   }
     272             : 
     273             :   static const uint8_t kNextBitFieldIndex = IsParenthesizedField::kNext;
     274             : };
     275             : 
     276             : class FailureExpression : public Expression {
     277             :  private:
     278             :   friend class AstNodeFactory;
     279             :   FailureExpression() : Expression(kNoSourcePosition, kFailureExpression) {}
     280             : };
     281             : 
     282             : // V8's notion of BreakableStatement does not correspond to the notion of
     283             : // BreakableStatement in ECMAScript. In V8, the idea is that a
     284             : // BreakableStatement is a statement that can be the target of a break
     285             : // statement.  The BreakableStatement AST node carries a list of labels, any of
     286             : // which can be used as an argument to the break statement in order to target
     287             : // it.
     288             : //
     289             : // Since we don't want to attach a list of labels to all kinds of statements, we
     290             : // only declare switchs, loops, and blocks as BreakableStatements.  This means
     291             : // that we implement breaks targeting other statement forms as breaks targeting
     292             : // a substatement thereof. For instance, in "foo: if (b) { f(); break foo; }" we
     293             : // pretend that foo is the label of the inner block. That's okay because one
     294             : // can't observe the difference.
     295             : //
     296             : // This optimization makes it harder to detect invalid continue labels, see the
     297             : // need for own_labels in IterationStatement.
     298             : //
     299             : class BreakableStatement : public Statement {
     300             :  public:
     301             :   enum BreakableType {
     302             :     TARGET_FOR_ANONYMOUS,
     303             :     TARGET_FOR_NAMED_ONLY
     304             :   };
     305             : 
     306             :   // A list of all labels declared on the path up to the previous
     307             :   // BreakableStatement (if any).
     308             :   //
     309             :   // Example: "l1: for (;;) l2: l3: { l4: if (b) l5: { s } }"
     310             :   // labels() of the ForStatement will be l1.
     311             :   // labels() of the Block { l4: ... } will be l2, l3.
     312             :   // labels() of the Block { s } will be l4, l5.
     313             :   ZonePtrList<const AstRawString>* labels() const;
     314             : 
     315             :   // Testers.
     316             :   bool is_target_for_anonymous() const {
     317             :     return BreakableTypeField::decode(bit_field_) == TARGET_FOR_ANONYMOUS;
     318             :   }
     319             : 
     320             :  private:
     321             :   class BreakableTypeField
     322             :       : public BitField<BreakableType, Statement::kNextBitFieldIndex, 1> {};
     323             : 
     324             :  protected:
     325             :   BreakableStatement(BreakableType breakable_type, int position, NodeType type)
     326             :       : Statement(position, type) {
     327    10698438 :     bit_field_ |= BreakableTypeField::encode(breakable_type);
     328             :   }
     329             : 
     330             :   static const uint8_t kNextBitFieldIndex = BreakableTypeField::kNext;
     331             : };
     332             : 
     333             : class Block : public BreakableStatement {
     334             :  public:
     335             :   ZonePtrList<Statement>* statements() { return &statements_; }
     336             :   bool ignore_completion_value() const {
     337             :     return IgnoreCompletionField::decode(bit_field_);
     338             :   }
     339             : 
     340             :   inline ZonePtrList<const AstRawString>* labels() const;
     341             : 
     342       87671 :   Scope* scope() const { return scope_; }
     343     1266531 :   void set_scope(Scope* scope) { scope_ = scope; }
     344             : 
     345             :   void InitializeStatements(const ScopedPtrList<Statement>& statements,
     346             :                             Zone* zone) {
     347             :     DCHECK_EQ(0, statements_.length());
     348    10083267 :     statements.CopyTo(&statements_, zone);
     349             :   }
     350             : 
     351             :  private:
     352             :   friend class AstNodeFactory;
     353             : 
     354             :   ZonePtrList<Statement> statements_;
     355             :   Scope* scope_;
     356             : 
     357             :   class IgnoreCompletionField
     358             :       : public BitField<bool, BreakableStatement::kNextBitFieldIndex, 1> {};
     359             :   class IsLabeledField
     360             :       : public BitField<bool, IgnoreCompletionField::kNext, 1> {};
     361             : 
     362             :  protected:
     363    10698438 :   Block(Zone* zone, ZonePtrList<const AstRawString>* labels, int capacity,
     364             :         bool ignore_completion_value)
     365             :       : BreakableStatement(TARGET_FOR_NAMED_ONLY, kNoSourcePosition, kBlock),
     366             :         statements_(capacity, zone),
     367    10698438 :         scope_(nullptr) {
     368             :     bit_field_ |= IgnoreCompletionField::encode(ignore_completion_value) |
     369    21396916 :                   IsLabeledField::encode(labels != nullptr);
     370    10698458 :   }
     371             : 
     372             :   Block(ZonePtrList<const AstRawString>* labels, bool ignore_completion_value)
     373    10103213 :       : Block(nullptr, labels, 0, ignore_completion_value) {}
     374             : };
     375             : 
     376             : class LabeledBlock final : public Block {
     377             :  private:
     378             :   friend class AstNodeFactory;
     379             :   friend class Block;
     380             : 
     381             :   LabeledBlock(Zone* zone, ZonePtrList<const AstRawString>* labels,
     382             :                int capacity, bool ignore_completion_value)
     383             :       : Block(zone, labels, capacity, ignore_completion_value),
     384        6635 :         labels_(labels) {
     385             :     DCHECK_NOT_NULL(labels);
     386             :     DCHECK_GT(labels->length(), 0);
     387             :   }
     388             : 
     389             :   LabeledBlock(ZonePtrList<const AstRawString>* labels,
     390             :                bool ignore_completion_value)
     391             :       : LabeledBlock(nullptr, labels, 0, ignore_completion_value) {}
     392             : 
     393             :   ZonePtrList<const AstRawString>* labels_;
     394             : };
     395             : 
     396             : inline ZonePtrList<const AstRawString>* Block::labels() const {
     397      152681 :   if (IsLabeledField::decode(bit_field_)) {
     398        7037 :     return static_cast<const LabeledBlock*>(this)->labels_;
     399             :   }
     400             :   return nullptr;
     401             : }
     402             : 
     403             : class DoExpression final : public Expression {
     404             :  public:
     405             :   Block* block() { return block_; }
     406             :   VariableProxy* result() { return result_; }
     407             : 
     408             :  private:
     409             :   friend class AstNodeFactory;
     410             : 
     411             :   DoExpression(Block* block, VariableProxy* result, int pos)
     412             :       : Expression(pos, kDoExpression), block_(block), result_(result) {
     413             :     DCHECK_NOT_NULL(block_);
     414             :     DCHECK_NOT_NULL(result_);
     415             :   }
     416             : 
     417             :   Block* block_;
     418             :   VariableProxy* result_;
     419             : };
     420             : 
     421             : 
     422             : class Declaration : public AstNode {
     423             :  public:
     424             :   typedef base::ThreadedList<Declaration> List;
     425             : 
     426     3906354 :   Variable* var() const { return var_; }
     427    15827917 :   void set_var(Variable* var) { var_ = var; }
     428             : 
     429             :  protected:
     430    15827721 :   Declaration(int pos, NodeType type) : AstNode(pos, type), next_(nullptr) {}
     431             : 
     432             :  private:
     433             :   Variable* var_;
     434             :   // Declarations list threaded through the declarations.
     435             :   Declaration** next() { return &next_; }
     436             :   Declaration* next_;
     437             :   friend List;
     438             :   friend base::ThreadedListTraits<Declaration>;
     439             : };
     440             : 
     441             : class VariableDeclaration : public Declaration {
     442             :  public:
     443             :   inline NestedVariableDeclaration* AsNested();
     444             : 
     445             :  private:
     446             :   friend class AstNodeFactory;
     447             : 
     448             :   class IsNestedField
     449             :       : public BitField<bool, Declaration::kNextBitFieldIndex, 1> {};
     450             : 
     451             :  protected:
     452             :   explicit VariableDeclaration(int pos, bool is_nested = false)
     453             :       : Declaration(pos, kVariableDeclaration) {
     454      960779 :     bit_field_ = IsNestedField::update(bit_field_, is_nested);
     455             :   }
     456             : 
     457             :   static const uint8_t kNextBitFieldIndex = IsNestedField::kNext;
     458             : };
     459             : 
     460             : // For var declarations that appear in a block scope.
     461             : // Only distinguished from VariableDeclaration during Scope analysis,
     462             : // so it doesn't get its own NodeType.
     463             : class NestedVariableDeclaration final : public VariableDeclaration {
     464             :  public:
     465             :   Scope* scope() const { return scope_; }
     466             : 
     467             :  private:
     468             :   friend class AstNodeFactory;
     469             : 
     470             :   NestedVariableDeclaration(Scope* scope, int pos)
     471      960779 :       : VariableDeclaration(pos, true), scope_(scope) {}
     472             : 
     473             :   // Nested scope from which the declaration originated.
     474             :   Scope* scope_;
     475             : };
     476             : 
     477             : inline NestedVariableDeclaration* VariableDeclaration::AsNested() {
     478    12886337 :   return IsNestedField::decode(bit_field_)
     479             :              ? static_cast<NestedVariableDeclaration*>(this)
     480    12886337 :              : nullptr;
     481             : }
     482             : 
     483             : class FunctionDeclaration final : public Declaration {
     484             :  public:
     485             :   FunctionLiteral* fun() const { return fun_; }
     486             : 
     487             :  private:
     488             :   friend class AstNodeFactory;
     489             : 
     490             :   FunctionDeclaration(FunctionLiteral* fun, int pos)
     491      979032 :       : Declaration(pos, kFunctionDeclaration), fun_(fun) {}
     492             : 
     493             :   FunctionLiteral* fun_;
     494             : };
     495             : 
     496             : 
     497             : class IterationStatement : public BreakableStatement {
     498             :  public:
     499             :   Statement* body() const { return body_; }
     500       60176 :   void set_body(Statement* s) { body_ = s; }
     501             : 
     502             :   ZonePtrList<const AstRawString>* labels() const { return labels_; }
     503             : 
     504             :   // A list of all labels that the iteration statement is directly prefixed
     505             :   // with, i.e.  all the labels that a continue statement in the body can use to
     506             :   // continue this iteration statement. This is always a subset of {labels}.
     507             :   //
     508             :   // Example: "l1: { l2: if (b) l3: l4: for (;;) s }"
     509             :   // labels() of the Block will be l1.
     510             :   // labels() of the ForStatement will be l2, l3, l4.
     511             :   // own_labels() of the ForStatement will be l3, l4.
     512             :   ZonePtrList<const AstRawString>* own_labels() const { return own_labels_; }
     513             : 
     514             :  protected:
     515             :   IterationStatement(ZonePtrList<const AstRawString>* labels,
     516             :                      ZonePtrList<const AstRawString>* own_labels, int pos,
     517             :                      NodeType type)
     518             :       : BreakableStatement(TARGET_FOR_ANONYMOUS, pos, type),
     519             :         labels_(labels),
     520             :         own_labels_(own_labels),
     521      509318 :         body_(nullptr) {}
     522      484494 :   void Initialize(Statement* body) { body_ = body; }
     523             : 
     524             :   static const uint8_t kNextBitFieldIndex =
     525             :       BreakableStatement::kNextBitFieldIndex;
     526             : 
     527             :  private:
     528             :   ZonePtrList<const AstRawString>* labels_;
     529             :   ZonePtrList<const AstRawString>* own_labels_;
     530             :   Statement* body_;
     531             : };
     532             : 
     533             : 
     534             : class DoWhileStatement final : public IterationStatement {
     535             :  public:
     536             :   void Initialize(Expression* cond, Statement* body) {
     537             :     IterationStatement::Initialize(body);
     538        4065 :     cond_ = cond;
     539             :   }
     540             : 
     541             :   Expression* cond() const { return cond_; }
     542             : 
     543             :  private:
     544             :   friend class AstNodeFactory;
     545             : 
     546             :   DoWhileStatement(ZonePtrList<const AstRawString>* labels,
     547             :                    ZonePtrList<const AstRawString>* own_labels, int pos)
     548             :       : IterationStatement(labels, own_labels, pos, kDoWhileStatement),
     549        4065 :         cond_(nullptr) {}
     550             : 
     551             :   Expression* cond_;
     552             : };
     553             : 
     554             : 
     555             : class WhileStatement final : public IterationStatement {
     556             :  public:
     557             :   void Initialize(Expression* cond, Statement* body) {
     558             :     IterationStatement::Initialize(body);
     559       17084 :     cond_ = cond;
     560             :   }
     561             : 
     562             :   Expression* cond() const { return cond_; }
     563             : 
     564             :  private:
     565             :   friend class AstNodeFactory;
     566             : 
     567             :   WhileStatement(ZonePtrList<const AstRawString>* labels,
     568             :                  ZonePtrList<const AstRawString>* own_labels, int pos)
     569             :       : IterationStatement(labels, own_labels, pos, kWhileStatement),
     570       17084 :         cond_(nullptr) {}
     571             : 
     572             :   Expression* cond_;
     573             : };
     574             : 
     575             : 
     576             : class ForStatement final : public IterationStatement {
     577             :  public:
     578             :   void Initialize(Statement* init, Expression* cond, Statement* next,
     579             :                   Statement* body) {
     580             :     IterationStatement::Initialize(body);
     581      297708 :     init_ = init;
     582      297708 :     cond_ = cond;
     583      297708 :     next_ = next;
     584             :   }
     585             : 
     586             :   Statement* init() const { return init_; }
     587             :   Expression* cond() const { return cond_; }
     588             :   Statement* next() const { return next_; }
     589             : 
     590             :  private:
     591             :   friend class AstNodeFactory;
     592             : 
     593             :   ForStatement(ZonePtrList<const AstRawString>* labels,
     594             :                ZonePtrList<const AstRawString>* own_labels, int pos)
     595             :       : IterationStatement(labels, own_labels, pos, kForStatement),
     596             :         init_(nullptr),
     597             :         cond_(nullptr),
     598      304407 :         next_(nullptr) {}
     599             : 
     600             :   Statement* init_;
     601             :   Expression* cond_;
     602             :   Statement* next_;
     603             : };
     604             : 
     605             : // Shared class for for-in and for-of statements.
     606             : class ForEachStatement : public IterationStatement {
     607             :  public:
     608             :   enum VisitMode {
     609             :     ENUMERATE,   // for (each in subject) body;
     610             :     ITERATE      // for (each of subject) body;
     611             :   };
     612             : 
     613             :   using IterationStatement::Initialize;
     614             : 
     615             :   static const char* VisitModeString(VisitMode mode) {
     616        6585 :     return mode == ITERATE ? "for-of" : "for-in";
     617             :   }
     618             : 
     619             :   void Initialize(Expression* each, Expression* subject, Statement* body) {
     620             :     IterationStatement::Initialize(body);
     621      165637 :     each_ = each;
     622      165637 :     subject_ = subject;
     623             :   }
     624             : 
     625             :   Expression* each() const { return each_; }
     626             :   Expression* subject() const { return subject_; }
     627             : 
     628             :  protected:
     629             :   friend class AstNodeFactory;
     630             : 
     631             :   ForEachStatement(ZonePtrList<const AstRawString>* labels,
     632             :                    ZonePtrList<const AstRawString>* own_labels, int pos,
     633             :                    NodeType type)
     634             :       : IterationStatement(labels, own_labels, pos, type),
     635             :         each_(nullptr),
     636      183762 :         subject_(nullptr) {}
     637             : 
     638             :   Expression* each_;
     639             :   Expression* subject_;
     640             : };
     641             : 
     642             : class ForInStatement final : public ForEachStatement {
     643             :  private:
     644             :   friend class AstNodeFactory;
     645             : 
     646             :   ForInStatement(ZonePtrList<const AstRawString>* labels,
     647             :                  ZonePtrList<const AstRawString>* own_labels, int pos)
     648             :       : ForEachStatement(labels, own_labels, pos, kForInStatement) {}
     649             : };
     650             : 
     651             : enum class IteratorType { kNormal, kAsync };
     652             : class ForOfStatement final : public ForEachStatement {
     653             :  public:
     654             :   IteratorType type() const { return type_; }
     655             : 
     656             :  private:
     657             :   friend class AstNodeFactory;
     658             : 
     659             :   ForOfStatement(ZonePtrList<const AstRawString>* labels,
     660             :                  ZonePtrList<const AstRawString>* own_labels, int pos,
     661             :                  IteratorType type)
     662             :       : ForEachStatement(labels, own_labels, pos, kForOfStatement),
     663      136261 :         type_(type) {}
     664             : 
     665             :   IteratorType type_;
     666             : };
     667             : 
     668             : class ExpressionStatement final : public Statement {
     669             :  public:
     670     1024434 :   void set_expression(Expression* e) { expression_ = e; }
     671     1313461 :   Expression* expression() const { return expression_; }
     672             : 
     673             :  private:
     674             :   friend class AstNodeFactory;
     675             : 
     676             :   ExpressionStatement(Expression* expression, int pos)
     677    17778859 :       : Statement(pos, kExpressionStatement), expression_(expression) {}
     678             : 
     679             :   Expression* expression_;
     680             : };
     681             : 
     682             : 
     683             : class JumpStatement : public Statement {
     684             :  protected:
     685             :   JumpStatement(int pos, NodeType type) : Statement(pos, type) {}
     686             : };
     687             : 
     688             : 
     689             : class ContinueStatement final : public JumpStatement {
     690             :  public:
     691             :   IterationStatement* target() const { return target_; }
     692             : 
     693             :  private:
     694             :   friend class AstNodeFactory;
     695             : 
     696             :   ContinueStatement(IterationStatement* target, int pos)
     697       12803 :       : JumpStatement(pos, kContinueStatement), target_(target) {}
     698             : 
     699             :   IterationStatement* target_;
     700             : };
     701             : 
     702             : 
     703             : class BreakStatement final : public JumpStatement {
     704             :  public:
     705             :   BreakableStatement* target() const { return target_; }
     706             : 
     707             :  private:
     708             :   friend class AstNodeFactory;
     709             : 
     710             :   BreakStatement(BreakableStatement* target, int pos)
     711       73111 :       : JumpStatement(pos, kBreakStatement), target_(target) {}
     712             : 
     713             :   BreakableStatement* target_;
     714             : };
     715             : 
     716             : 
     717             : class ReturnStatement final : public JumpStatement {
     718             :  public:
     719             :   enum Type { kNormal, kAsyncReturn };
     720             :   Expression* expression() const { return expression_; }
     721             : 
     722             :   Type type() const { return TypeField::decode(bit_field_); }
     723     2053395 :   bool is_async_return() const { return type() == kAsyncReturn; }
     724             : 
     725             :   int end_position() const { return end_position_; }
     726             : 
     727             :  private:
     728             :   friend class AstNodeFactory;
     729             : 
     730             :   ReturnStatement(Expression* expression, Type type, int pos, int end_position)
     731             :       : JumpStatement(pos, kReturnStatement),
     732             :         expression_(expression),
     733     2598559 :         end_position_(end_position) {
     734       72626 :     bit_field_ |= TypeField::encode(type);
     735             :   }
     736             : 
     737             :   Expression* expression_;
     738             :   int end_position_;
     739             : 
     740             :   class TypeField
     741             :       : public BitField<Type, JumpStatement::kNextBitFieldIndex, 1> {};
     742             : };
     743             : 
     744             : 
     745             : class WithStatement final : public Statement {
     746             :  public:
     747             :   Scope* scope() { return scope_; }
     748             :   Expression* expression() const { return expression_; }
     749             :   Statement* statement() const { return statement_; }
     750        3486 :   void set_statement(Statement* s) { statement_ = s; }
     751             : 
     752             :  private:
     753             :   friend class AstNodeFactory;
     754             : 
     755             :   WithStatement(Scope* scope, Expression* expression, Statement* statement,
     756             :                 int pos)
     757             :       : Statement(pos, kWithStatement),
     758             :         scope_(scope),
     759             :         expression_(expression),
     760       38423 :         statement_(statement) {}
     761             : 
     762             :   Scope* scope_;
     763             :   Expression* expression_;
     764             :   Statement* statement_;
     765             : };
     766             : 
     767             : class CaseClause final : public ZoneObject {
     768             :  public:
     769             :   bool is_default() const { return label_ == nullptr; }
     770             :   Expression* label() const {
     771             :     DCHECK(!is_default());
     772             :     return label_;
     773             :   }
     774             :   ZonePtrList<Statement>* statements() { return &statements_; }
     775             : 
     776             :  private:
     777             :   friend class AstNodeFactory;
     778             : 
     779             :   CaseClause(Zone* zone, Expression* label,
     780             :              const ScopedPtrList<Statement>& statements);
     781             : 
     782             :   Expression* label_;
     783             :   ZonePtrList<Statement> statements_;
     784             : };
     785             : 
     786             : 
     787             : class SwitchStatement final : public BreakableStatement {
     788             :  public:
     789             :   ZonePtrList<const AstRawString>* labels() const { return labels_; }
     790             : 
     791             :   Expression* tag() const { return tag_; }
     792         922 :   void set_tag(Expression* t) { tag_ = t; }
     793             : 
     794             :   ZonePtrList<CaseClause>* cases() { return &cases_; }
     795             : 
     796             :  private:
     797             :   friend class AstNodeFactory;
     798             : 
     799             :   SwitchStatement(Zone* zone, ZonePtrList<const AstRawString>* labels,
     800             :                   Expression* tag, int pos)
     801             :       : BreakableStatement(TARGET_FOR_ANONYMOUS, pos, kSwitchStatement),
     802             :         labels_(labels),
     803             :         tag_(tag),
     804       14302 :         cases_(4, zone) {}
     805             : 
     806             :   ZonePtrList<const AstRawString>* labels_;
     807             :   Expression* tag_;
     808             :   ZonePtrList<CaseClause> cases_;
     809             : };
     810             : 
     811             : 
     812             : // If-statements always have non-null references to their then- and
     813             : // else-parts. When parsing if-statements with no explicit else-part,
     814             : // the parser implicitly creates an empty statement. Use the
     815             : // HasThenStatement() and HasElseStatement() functions to check if a
     816             : // given if-statement has a then- or an else-part containing code.
     817             : class IfStatement final : public Statement {
     818             :  public:
     819             :   bool HasThenStatement() const { return !then_statement_->IsEmptyStatement(); }
     820             :   bool HasElseStatement() const { return !else_statement_->IsEmptyStatement(); }
     821             : 
     822             :   Expression* condition() const { return condition_; }
     823             :   Statement* then_statement() const { return then_statement_; }
     824             :   Statement* else_statement() const { return else_statement_; }
     825             : 
     826        2604 :   void set_then_statement(Statement* s) { then_statement_ = s; }
     827        2603 :   void set_else_statement(Statement* s) { else_statement_ = s; }
     828             : 
     829             :  private:
     830             :   friend class AstNodeFactory;
     831             : 
     832             :   IfStatement(Expression* condition, Statement* then_statement,
     833             :               Statement* else_statement, int pos)
     834             :       : Statement(pos, kIfStatement),
     835             :         condition_(condition),
     836             :         then_statement_(then_statement),
     837      655101 :         else_statement_(else_statement) {}
     838             : 
     839             :   Expression* condition_;
     840             :   Statement* then_statement_;
     841             :   Statement* else_statement_;
     842             : };
     843             : 
     844             : 
     845             : class TryStatement : public Statement {
     846             :  public:
     847             :   Block* try_block() const { return try_block_; }
     848        4263 :   void set_try_block(Block* b) { try_block_ = b; }
     849             : 
     850             :  protected:
     851             :   TryStatement(Block* try_block, int pos, NodeType type)
     852      187341 :       : Statement(pos, type), try_block_(try_block) {}
     853             : 
     854             :  private:
     855             :   Block* try_block_;
     856             : };
     857             : 
     858             : 
     859             : class TryCatchStatement final : public TryStatement {
     860             :  public:
     861             :   Scope* scope() { return scope_; }
     862             :   Block* catch_block() const { return catch_block_; }
     863        3965 :   void set_catch_block(Block* b) { catch_block_ = b; }
     864             : 
     865             :   // Prediction of whether exceptions thrown into the handler for this try block
     866             :   // will be caught.
     867             :   //
     868             :   // BytecodeGenerator tracks the state of catch prediction, which can change
     869             :   // with each TryCatchStatement encountered. The tracked catch prediction is
     870             :   // later compiled into the code's handler table. The runtime uses this
     871             :   // information to implement a feature that notifies the debugger when an
     872             :   // uncaught exception is thrown, _before_ the exception propagates to the top.
     873             :   //
     874             :   // If this try/catch statement is meant to rethrow (HandlerTable::UNCAUGHT),
     875             :   // the catch prediction value is set to the same value as the surrounding
     876             :   // catch prediction.
     877             :   //
     878             :   // Since it's generally undecidable whether an exception will be caught, our
     879             :   // prediction is only an approximation.
     880             :   // ---------------------------------------------------------------------------
     881             :   inline HandlerTable::CatchPrediction GetCatchPrediction(
     882             :       HandlerTable::CatchPrediction outer_catch_prediction) const {
     883       68904 :     if (catch_prediction_ == HandlerTable::UNCAUGHT) {
     884             :       return outer_catch_prediction;
     885             :     }
     886             :     return catch_prediction_;
     887             :   }
     888             : 
     889             :   // Indicates whether or not code should be generated to clear the pending
     890             :   // exception. The pending exception is cleared for cases where the exception
     891             :   // is not guaranteed to be rethrown, indicated by the value
     892             :   // HandlerTable::UNCAUGHT. If both the current and surrounding catch handler's
     893             :   // are predicted uncaught, the exception is not cleared.
     894             :   //
     895             :   // If this handler is not going to simply rethrow the exception, this method
     896             :   // indicates that the isolate's pending exception message should be cleared
     897             :   // before executing the catch_block.
     898             :   // In the normal use case, this flag is always on because the message object
     899             :   // is not needed anymore when entering the catch block and should not be
     900             :   // kept alive.
     901             :   // The use case where the flag is off is when the catch block is guaranteed
     902             :   // to rethrow the caught exception (using %ReThrow), which reuses the
     903             :   // pending message instead of generating a new one.
     904             :   // (When the catch block doesn't rethrow but is guaranteed to perform an
     905             :   // ordinary throw, not clearing the old message is safe but not very
     906             :   // useful.)
     907             :   inline bool ShouldClearPendingException(
     908             :       HandlerTable::CatchPrediction outer_catch_prediction) const {
     909       68912 :     return catch_prediction_ != HandlerTable::UNCAUGHT ||
     910             :            outer_catch_prediction != HandlerTable::UNCAUGHT;
     911             :   }
     912             : 
     913             :  private:
     914             :   friend class AstNodeFactory;
     915             : 
     916             :   TryCatchStatement(Block* try_block, Scope* scope, Block* catch_block,
     917             :                     HandlerTable::CatchPrediction catch_prediction, int pos)
     918             :       : TryStatement(try_block, pos, kTryCatchStatement),
     919             :         scope_(scope),
     920             :         catch_block_(catch_block),
     921      157493 :         catch_prediction_(catch_prediction) {}
     922             : 
     923             :   Scope* scope_;
     924             :   Block* catch_block_;
     925             :   HandlerTable::CatchPrediction catch_prediction_;
     926             : };
     927             : 
     928             : 
     929             : class TryFinallyStatement final : public TryStatement {
     930             :  public:
     931             :   Block* finally_block() const { return finally_block_; }
     932         102 :   void set_finally_block(Block* b) { finally_block_ = b; }
     933             : 
     934             :  private:
     935             :   friend class AstNodeFactory;
     936             : 
     937             :   TryFinallyStatement(Block* try_block, Block* finally_block, int pos)
     938             :       : TryStatement(try_block, pos, kTryFinallyStatement),
     939       29848 :         finally_block_(finally_block) {}
     940             : 
     941             :   Block* finally_block_;
     942             : };
     943             : 
     944             : 
     945             : class DebuggerStatement final : public Statement {
     946             :  private:
     947             :   friend class AstNodeFactory;
     948             : 
     949             :   explicit DebuggerStatement(int pos) : Statement(pos, kDebuggerStatement) {}
     950             : };
     951             : 
     952             : 
     953             : class EmptyStatement final : public Statement {
     954             :  private:
     955             :   friend class AstNodeFactory;
     956             :   EmptyStatement() : Statement(kNoSourcePosition, kEmptyStatement) {}
     957             : };
     958             : 
     959             : 
     960             : // Delegates to another statement, which may be overwritten.
     961             : // This was introduced to implement ES2015 Annex B3.3 for conditionally making
     962             : // sloppy-mode block-scoped functions have a var binding, which is changed
     963             : // from one statement to another during parsing.
     964             : class SloppyBlockFunctionStatement final : public Statement {
     965             :  public:
     966             :   Statement* statement() const { return statement_; }
     967        9233 :   void set_statement(Statement* statement) { statement_ = statement; }
     968       11311 :   Scope* scope() const { return var_->scope(); }
     969             :   Variable* var() const { return var_; }
     970             :   Token::Value init() const { return TokenField::decode(bit_field_); }
     971       11503 :   const AstRawString* name() const { return var_->raw_name(); }
     972             :   SloppyBlockFunctionStatement** next() { return &next_; }
     973             : 
     974             :  private:
     975             :   friend class AstNodeFactory;
     976             : 
     977             :   class TokenField
     978             :       : public BitField<Token::Value, Statement::kNextBitFieldIndex, 8> {};
     979             : 
     980             :   SloppyBlockFunctionStatement(int pos, Variable* var, Token::Value init,
     981             :                                Statement* statement)
     982             :       : Statement(pos, kSloppyBlockFunctionStatement),
     983             :         var_(var),
     984             :         statement_(statement),
     985       11610 :         next_(nullptr) {
     986       11610 :     bit_field_ = TokenField::update(bit_field_, init);
     987             :   }
     988             : 
     989             :   Variable* var_;
     990             :   Statement* statement_;
     991             :   SloppyBlockFunctionStatement* next_;
     992             : };
     993             : 
     994             : 
     995             : class Literal final : public Expression {
     996             :  public:
     997             :   enum Type {
     998             :     kSmi,
     999             :     kHeapNumber,
    1000             :     kBigInt,
    1001             :     kString,
    1002             :     kSymbol,
    1003             :     kBoolean,
    1004             :     kUndefined,
    1005             :     kNull,
    1006             :     kTheHole,
    1007             :   };
    1008             : 
    1009             :   Type type() const { return TypeField::decode(bit_field_); }
    1010             : 
    1011             :   // Returns true if literal represents a property name (i.e. cannot be parsed
    1012             :   // as array indices).
    1013             :   bool IsPropertyName() const;
    1014             : 
    1015             :   // Returns true if literal represents an array index.
    1016             :   // Note, that in general the following statement is not true:
    1017             :   //   key->IsPropertyName() != key->AsArrayIndex(...)
    1018             :   // but for non-computed LiteralProperty properties the following is true:
    1019             :   //   property->key()->IsPropertyName() != property->key()->AsArrayIndex(...)
    1020             :   bool AsArrayIndex(uint32_t* index) const;
    1021             : 
    1022       19000 :   const AstRawString* AsRawPropertyName() {
    1023             :     DCHECK(IsPropertyName());
    1024       19000 :     return string_;
    1025             :   }
    1026             : 
    1027             :   Smi AsSmiLiteral() const {
    1028             :     DCHECK_EQ(kSmi, type());
    1029             :     return Smi::FromInt(smi_);
    1030             :   }
    1031             : 
    1032             :   // Returns true if literal represents a Number.
    1033     3620500 :   bool IsNumber() const { return type() == kHeapNumber || type() == kSmi; }
    1034     3333820 :   double AsNumber() const {
    1035             :     DCHECK(IsNumber());
    1036     3333820 :     switch (type()) {
    1037             :       case kSmi:
    1038     2956810 :         return smi_;
    1039             :       case kHeapNumber:
    1040      377010 :         return number_;
    1041             :       default:
    1042           0 :         UNREACHABLE();
    1043             :     }
    1044             :   }
    1045             : 
    1046             :   AstBigInt AsBigInt() const {
    1047             :     DCHECK_EQ(type(), kBigInt);
    1048             :     return bigint_;
    1049             :   }
    1050             : 
    1051     8638086 :   bool IsString() const { return type() == kString; }
    1052             :   const AstRawString* AsRawString() {
    1053             :     DCHECK_EQ(type(), kString);
    1054             :     return string_;
    1055             :   }
    1056             : 
    1057             :   AstSymbol AsSymbol() {
    1058             :     DCHECK_EQ(type(), kSymbol);
    1059             :     return symbol_;
    1060             :   }
    1061             : 
    1062             :   V8_EXPORT_PRIVATE bool ToBooleanIsTrue() const;
    1063       33630 :   bool ToBooleanIsFalse() const { return !ToBooleanIsTrue(); }
    1064             : 
    1065             :   bool ToUint32(uint32_t* value) const;
    1066             : 
    1067             :   // Returns an appropriate Object representing this Literal, allocating
    1068             :   // a heap object if needed.
    1069             :   Handle<Object> BuildValue(Isolate* isolate) const;
    1070             : 
    1071             :   // Support for using Literal as a HashMap key. NOTE: Currently, this works
    1072             :   // only for string and number literals!
    1073             :   uint32_t Hash();
    1074             :   static bool Match(void* literal1, void* literal2);
    1075             : 
    1076             :  private:
    1077             :   friend class AstNodeFactory;
    1078             : 
    1079             :   class TypeField : public BitField<Type, Expression::kNextBitFieldIndex, 4> {};
    1080             : 
    1081    22548317 :   Literal(int smi, int position) : Expression(position, kLiteral), smi_(smi) {
    1082             :     bit_field_ = TypeField::update(bit_field_, kSmi);
    1083             :   }
    1084             : 
    1085             :   Literal(double number, int position)
    1086      791057 :       : Expression(position, kLiteral), number_(number) {
    1087      791057 :     bit_field_ = TypeField::update(bit_field_, kHeapNumber);
    1088             :   }
    1089             : 
    1090             :   Literal(AstBigInt bigint, int position)
    1091       12265 :       : Expression(position, kLiteral), bigint_(bigint) {
    1092       12265 :     bit_field_ = TypeField::update(bit_field_, kBigInt);
    1093             :   }
    1094             : 
    1095             :   Literal(const AstRawString* string, int position)
    1096    12006952 :       : Expression(position, kLiteral), string_(string) {
    1097    12006952 :     bit_field_ = TypeField::update(bit_field_, kString);
    1098             :   }
    1099             : 
    1100             :   Literal(AstSymbol symbol, int position)
    1101        2758 :       : Expression(position, kLiteral), symbol_(symbol) {
    1102        2758 :     bit_field_ = TypeField::update(bit_field_, kSymbol);
    1103             :   }
    1104             : 
    1105             :   Literal(bool boolean, int position)
    1106      453981 :       : Expression(position, kLiteral), boolean_(boolean) {
    1107      453981 :     bit_field_ = TypeField::update(bit_field_, kBoolean);
    1108             :   }
    1109             : 
    1110             :   Literal(Type type, int position) : Expression(position, kLiteral) {
    1111             :     DCHECK(type == kNull || type == kUndefined || type == kTheHole);
    1112     1616745 :     bit_field_ = TypeField::update(bit_field_, type);
    1113             :   }
    1114             : 
    1115             :   union {
    1116             :     const AstRawString* string_;
    1117             :     int smi_;
    1118             :     double number_;
    1119             :     AstSymbol symbol_;
    1120             :     AstBigInt bigint_;
    1121             :     bool boolean_;
    1122             :   };
    1123             : };
    1124             : 
    1125             : // Base class for literals that need space in the type feedback vector.
    1126             : class MaterializedLiteral : public Expression {
    1127             :  public:
    1128             :   // A Materializedliteral is simple if the values consist of only
    1129             :   // constants and simple object and array literals.
    1130             :   bool IsSimple() const;
    1131             : 
    1132             :  protected:
    1133             :   MaterializedLiteral(int pos, NodeType type) : Expression(pos, type) {}
    1134             : 
    1135             :   friend class CompileTimeValue;
    1136             :   friend class ArrayLiteral;
    1137             :   friend class ObjectLiteral;
    1138             : 
    1139             :   // Populate the depth field and any flags the literal has, returns the depth.
    1140             :   int InitDepthAndFlags();
    1141             : 
    1142             :   bool NeedsInitialAllocationSite();
    1143             : 
    1144             :   // Populate the constant properties/elements fixed array.
    1145             :   void BuildConstants(Isolate* isolate);
    1146             : 
    1147             :   // If the expression is a literal, return the literal value;
    1148             :   // if the expression is a materialized literal and is_simple
    1149             :   // then return an Array or Object Boilerplate Description
    1150             :   // Otherwise, return undefined literal as the placeholder
    1151             :   // in the object literal boilerplate.
    1152             :   Handle<Object> GetBoilerplateValue(Expression* expression, Isolate* isolate);
    1153             : };
    1154             : 
    1155             : // Node for capturing a regexp literal.
    1156             : class RegExpLiteral final : public MaterializedLiteral {
    1157             :  public:
    1158         257 :   Handle<String> pattern() const { return pattern_->string(); }
    1159             :   const AstRawString* raw_pattern() const { return pattern_; }
    1160             :   int flags() const { return flags_; }
    1161             : 
    1162             :  private:
    1163             :   friend class AstNodeFactory;
    1164             : 
    1165             :   RegExpLiteral(const AstRawString* pattern, int flags, int pos)
    1166             :       : MaterializedLiteral(pos, kRegExpLiteral),
    1167             :         flags_(flags),
    1168       48592 :         pattern_(pattern) {}
    1169             : 
    1170             :   int const flags_;
    1171             :   const AstRawString* const pattern_;
    1172             : };
    1173             : 
    1174             : // Base class for Array and Object literals, providing common code for handling
    1175             : // nested subliterals.
    1176             : class AggregateLiteral : public MaterializedLiteral {
    1177             :  public:
    1178             :   enum Flags {
    1179             :     kNoFlags = 0,
    1180             :     kIsShallow = 1,
    1181             :     kDisableMementos = 1 << 1,
    1182             :     kNeedsInitialAllocationSite = 1 << 2,
    1183             :   };
    1184             : 
    1185      649748 :   bool is_initialized() const { return 0 < depth_; }
    1186             :   int depth() const {
    1187             :     DCHECK(is_initialized());
    1188     1204562 :     return depth_;
    1189             :   }
    1190             : 
    1191             :   bool is_shallow() const { return depth() == 1; }
    1192             :   bool needs_initial_allocation_site() const {
    1193             :     return NeedsInitialAllocationSiteField::decode(bit_field_);
    1194             :   }
    1195             : 
    1196      553893 :   int ComputeFlags(bool disable_mementos = false) const {
    1197             :     int flags = kNoFlags;
    1198      553893 :     if (is_shallow()) flags |= kIsShallow;
    1199      199569 :     if (disable_mementos) flags |= kDisableMementos;
    1200      553893 :     if (needs_initial_allocation_site()) flags |= kNeedsInitialAllocationSite;
    1201             :     return flags;
    1202             :   }
    1203             : 
    1204             :   // An AggregateLiteral is simple if the values consist of only
    1205             :   // constants and simple object and array literals.
    1206             :   bool is_simple() const { return IsSimpleField::decode(bit_field_); }
    1207             : 
    1208             :  private:
    1209             :   int depth_ : 31;
    1210             :   class NeedsInitialAllocationSiteField
    1211             :       : public BitField<bool, MaterializedLiteral::kNextBitFieldIndex, 1> {};
    1212             :   class IsSimpleField
    1213             :       : public BitField<bool, NeedsInitialAllocationSiteField::kNext, 1> {};
    1214             : 
    1215             :  protected:
    1216             :   friend class AstNodeFactory;
    1217             :   AggregateLiteral(int pos, NodeType type)
    1218     1321224 :       : MaterializedLiteral(pos, type), depth_(0) {
    1219             :     bit_field_ |= NeedsInitialAllocationSiteField::encode(false) |
    1220             :                   IsSimpleField::encode(false);
    1221             :   }
    1222             : 
    1223             :   void set_is_simple(bool is_simple) {
    1224     1254562 :     bit_field_ = IsSimpleField::update(bit_field_, is_simple);
    1225             :   }
    1226             : 
    1227             :   void set_depth(int depth) {
    1228             :     DCHECK(!is_initialized());
    1229      627281 :     depth_ = depth;
    1230             :   }
    1231             : 
    1232             :   void set_needs_initial_allocation_site(bool required) {
    1233      627281 :     bit_field_ = NeedsInitialAllocationSiteField::update(bit_field_, required);
    1234             :   }
    1235             : 
    1236             :   static const uint8_t kNextBitFieldIndex = IsSimpleField::kNext;
    1237             : };
    1238             : 
    1239             : // Common supertype for ObjectLiteralProperty and ClassLiteralProperty
    1240             : class LiteralProperty : public ZoneObject {
    1241             :  public:
    1242         264 :   Expression* key() const { return key_and_is_computed_name_.GetPointer(); }
    1243             :   Expression* value() const { return value_; }
    1244             : 
    1245             :   bool is_computed_name() const {
    1246             :     return key_and_is_computed_name_.GetPayload();
    1247             :   }
    1248             :   bool NeedsSetFunctionName() const;
    1249             : 
    1250             :  protected:
    1251             :   LiteralProperty(Expression* key, Expression* value, bool is_computed_name)
    1252     3472548 :       : key_and_is_computed_name_(key, is_computed_name), value_(value) {}
    1253             : 
    1254             :   PointerWithPayload<Expression, bool, 1> key_and_is_computed_name_;
    1255             :   Expression* value_;
    1256             : };
    1257             : 
    1258             : // Property is used for passing information
    1259             : // about an object literal's properties from the parser
    1260             : // to the code generator.
    1261             : class ObjectLiteralProperty final : public LiteralProperty {
    1262             :  public:
    1263             :   enum Kind : uint8_t {
    1264             :     CONSTANT,              // Property with constant value (compile time).
    1265             :     COMPUTED,              // Property with computed value (execution time).
    1266             :     MATERIALIZED_LITERAL,  // Property value is a materialized literal.
    1267             :     GETTER,
    1268             :     SETTER,     // Property is an accessor function.
    1269             :     PROTOTYPE,  // Property is __proto__.
    1270             :     SPREAD
    1271             :   };
    1272             : 
    1273             :   Kind kind() const { return kind_; }
    1274             : 
    1275             :   bool IsCompileTimeValue() const;
    1276             : 
    1277             :   void set_emit_store(bool emit_store);
    1278             :   bool emit_store() const;
    1279             : 
    1280             :   bool IsNullPrototype() const {
    1281       11255 :     return IsPrototype() && value()->IsNullLiteral();
    1282             :   }
    1283    15008887 :   bool IsPrototype() const { return kind() == PROTOTYPE; }
    1284             : 
    1285             :  private:
    1286             :   friend class AstNodeFactory;
    1287             : 
    1288             :   ObjectLiteralProperty(Expression* key, Expression* value, Kind kind,
    1289             :                         bool is_computed_name);
    1290             :   ObjectLiteralProperty(AstValueFactory* ast_value_factory, Expression* key,
    1291             :                         Expression* value, bool is_computed_name);
    1292             : 
    1293             :   Kind kind_;
    1294             :   bool emit_store_;
    1295             : };
    1296             : 
    1297             : 
    1298             : // An object literal has a boilerplate object that is used
    1299             : // for minimizing the work when constructing it at runtime.
    1300             : class ObjectLiteral final : public AggregateLiteral {
    1301             :  public:
    1302             :   typedef ObjectLiteralProperty Property;
    1303             : 
    1304             :   Handle<ObjectBoilerplateDescription> boilerplate_description() const {
    1305             :     DCHECK(!boilerplate_description_.is_null());
    1306             :     return boilerplate_description_;
    1307             :   }
    1308      366550 :   int properties_count() const { return boilerplate_properties_; }
    1309         222 :   const ZonePtrList<Property>* properties() const { return &properties_; }
    1310             :   bool has_elements() const { return HasElementsField::decode(bit_field_); }
    1311             :   bool has_rest_property() const {
    1312             :     return HasRestPropertyField::decode(bit_field_);
    1313             :   }
    1314             :   bool fast_elements() const { return FastElementsField::decode(bit_field_); }
    1315             :   bool has_null_prototype() const {
    1316             :     return HasNullPrototypeField::decode(bit_field_);
    1317             :   }
    1318             : 
    1319      451754 :   bool is_empty() const {
    1320             :     DCHECK(is_initialized());
    1321      481831 :     return !has_elements() && properties_count() == 0 &&
    1322       30077 :            properties()->length() == 0;
    1323             :   }
    1324             : 
    1325      227166 :   bool IsEmptyObjectLiteral() const {
    1326      254784 :     return is_empty() && !has_null_prototype();
    1327             :   }
    1328             : 
    1329             :   // Populate the depth field and flags, returns the depth.
    1330             :   int InitDepthAndFlags();
    1331             : 
    1332             :   // Get the boilerplate description, populating it if necessary.
    1333             :   Handle<ObjectBoilerplateDescription> GetOrBuildBoilerplateDescription(
    1334             :       Isolate* isolate) {
    1335      185338 :     if (boilerplate_description_.is_null()) {
    1336      170504 :       BuildBoilerplateDescription(isolate);
    1337             :     }
    1338             :     return boilerplate_description();
    1339             :   }
    1340             : 
    1341             :   // Populate the boilerplate description.
    1342             :   void BuildBoilerplateDescription(Isolate* isolate);
    1343             : 
    1344             :   // Mark all computed expressions that are bound to a key that
    1345             :   // is shadowed by a later occurrence of the same key. For the
    1346             :   // marked expressions, no store code is emitted.
    1347             :   void CalculateEmitStore(Zone* zone);
    1348             : 
    1349             :   // Determines whether the {CreateShallowObjectLiteratal} builtin can be used.
    1350             :   bool IsFastCloningSupported() const;
    1351             : 
    1352             :   // Assemble bitfield of flags for the CreateObjectLiteral helper.
    1353      199569 :   int ComputeFlags(bool disable_mementos = false) const {
    1354             :     int flags = AggregateLiteral::ComputeFlags(disable_mementos);
    1355      199569 :     if (fast_elements()) flags |= kFastElements;
    1356      199569 :     if (has_null_prototype()) flags |= kHasNullPrototype;
    1357      199569 :     return flags;
    1358             :   }
    1359             : 
    1360      202073 :   int EncodeLiteralType() {
    1361             :     int flags = kNoFlags;
    1362      202073 :     if (fast_elements()) flags |= kFastElements;
    1363      202073 :     if (has_null_prototype()) flags |= kHasNullPrototype;
    1364             :     return flags;
    1365             :   }
    1366             : 
    1367             :   enum Flags {
    1368             :     kFastElements = 1 << 3,
    1369             :     kHasNullPrototype = 1 << 4,
    1370             :   };
    1371             :   STATIC_ASSERT(
    1372             :       static_cast<int>(AggregateLiteral::kNeedsInitialAllocationSite) <
    1373             :       static_cast<int>(kFastElements));
    1374             : 
    1375             :   struct Accessors: public ZoneObject {
    1376        4993 :     Accessors() : getter(nullptr), setter(nullptr) {}
    1377             :     ObjectLiteralProperty* getter;
    1378             :     ObjectLiteralProperty* setter;
    1379             :   };
    1380             : 
    1381             :  private:
    1382             :   friend class AstNodeFactory;
    1383             : 
    1384      587027 :   ObjectLiteral(Zone* zone, const ScopedPtrList<Property>& properties,
    1385             :                 uint32_t boilerplate_properties, int pos,
    1386             :                 bool has_rest_property)
    1387             :       : AggregateLiteral(pos, kObjectLiteral),
    1388             :         boilerplate_properties_(boilerplate_properties),
    1389     1174054 :         properties_(0, nullptr) {
    1390             :     bit_field_ |= HasElementsField::encode(false) |
    1391             :                   HasRestPropertyField::encode(has_rest_property) |
    1392             :                   FastElementsField::encode(false) |
    1393      587003 :                   HasNullPrototypeField::encode(false);
    1394      587003 :     properties.CopyTo(&properties_, zone);
    1395      587051 :   }
    1396             : 
    1397             :   void InitFlagsForPendingNullPrototype(int i);
    1398             : 
    1399             :   void set_has_elements(bool has_elements) {
    1400      244784 :     bit_field_ = HasElementsField::update(bit_field_, has_elements);
    1401             :   }
    1402             :   void set_fast_elements(bool fast_elements) {
    1403      244784 :     bit_field_ = FastElementsField::update(bit_field_, fast_elements);
    1404             :   }
    1405             :   void set_has_null_protoype(bool has_null_prototype) {
    1406        5680 :     bit_field_ = HasNullPrototypeField::update(bit_field_, has_null_prototype);
    1407             :   }
    1408             : 
    1409             :   uint32_t boilerplate_properties_;
    1410             :   Handle<ObjectBoilerplateDescription> boilerplate_description_;
    1411             :   ZoneList<Property*> properties_;
    1412             : 
    1413             :   class HasElementsField
    1414             :       : public BitField<bool, AggregateLiteral::kNextBitFieldIndex, 1> {};
    1415             :   class HasRestPropertyField
    1416             :       : public BitField<bool, HasElementsField::kNext, 1> {};
    1417             :   class FastElementsField
    1418             :       : public BitField<bool, HasRestPropertyField::kNext, 1> {};
    1419             :   class HasNullPrototypeField
    1420             :       : public BitField<bool, FastElementsField::kNext, 1> {};
    1421             : };
    1422             : 
    1423             : 
    1424             : // A map from property names to getter/setter pairs allocated in the zone.
    1425             : class AccessorTable
    1426             :     : public base::TemplateHashMap<Literal, ObjectLiteral::Accessors,
    1427             :                                    bool (*)(void*, void*),
    1428             :                                    ZoneAllocationPolicy> {
    1429             :  public:
    1430             :   explicit AccessorTable(Zone* zone)
    1431             :       : base::TemplateHashMap<Literal, ObjectLiteral::Accessors,
    1432             :                               bool (*)(void*, void*), ZoneAllocationPolicy>(
    1433             :             Literal::Match, ZoneAllocationPolicy(zone)),
    1434      199498 :         zone_(zone) {}
    1435             : 
    1436        5704 :   Iterator lookup(Literal* literal) {
    1437       11408 :     Iterator it = find(literal, true, ZoneAllocationPolicy(zone_));
    1438        5705 :     if (it->second == nullptr) {
    1439        9986 :       it->second = new (zone_) ObjectLiteral::Accessors();
    1440             :     }
    1441        5705 :     return it;
    1442             :   }
    1443             : 
    1444             :  private:
    1445             :   Zone* zone_;
    1446             : };
    1447             : 
    1448             : 
    1449             : // An array literal has a literals object that is used
    1450             : // for minimizing the work when constructing it at runtime.
    1451             : class ArrayLiteral final : public AggregateLiteral {
    1452             :  public:
    1453             :   Handle<ArrayBoilerplateDescription> boilerplate_description() const {
    1454             :     return boilerplate_description_;
    1455             :   }
    1456             : 
    1457             :   const ZonePtrList<Expression>* values() const { return &values_; }
    1458             : 
    1459             :   int first_spread_index() const { return first_spread_index_; }
    1460             : 
    1461             :   // Populate the depth field and flags, returns the depth.
    1462             :   int InitDepthAndFlags();
    1463             : 
    1464             :   // Get the boilerplate description, populating it if necessary.
    1465             :   Handle<ArrayBoilerplateDescription> GetOrBuildBoilerplateDescription(
    1466             :       Isolate* isolate) {
    1467      140770 :     if (boilerplate_description_.is_null()) {
    1468      136496 :       BuildBoilerplateDescription(isolate);
    1469             :     }
    1470             :     return boilerplate_description();
    1471             :   }
    1472             : 
    1473             :   // Populate the boilerplate description.
    1474             :   void BuildBoilerplateDescription(Isolate* isolate);
    1475             : 
    1476             :   // Determines whether the {CreateShallowArrayLiteral} builtin can be used.
    1477             :   bool IsFastCloningSupported() const;
    1478             : 
    1479             :   // Assemble bitfield of flags for the CreateArrayLiteral helper.
    1480             :   int ComputeFlags(bool disable_mementos = false) const {
    1481             :     return AggregateLiteral::ComputeFlags(disable_mementos);
    1482             :   }
    1483             : 
    1484             :  private:
    1485             :   friend class AstNodeFactory;
    1486             : 
    1487      734197 :   ArrayLiteral(Zone* zone, const ScopedPtrList<Expression>& values,
    1488             :                int first_spread_index, int pos)
    1489             :       : AggregateLiteral(pos, kArrayLiteral),
    1490             :         first_spread_index_(first_spread_index),
    1491     1468394 :         values_(0, nullptr) {
    1492      734182 :     values.CopyTo(&values_, zone);
    1493      734210 :   }
    1494             : 
    1495             :   int first_spread_index_;
    1496             :   Handle<ArrayBoilerplateDescription> boilerplate_description_;
    1497             :   ZonePtrList<Expression> values_;
    1498             : };
    1499             : 
    1500             : enum class HoleCheckMode { kRequired, kElided };
    1501             : 
    1502             : class ThisExpression final : public Expression {
    1503             :  private:
    1504             :   friend class AstNodeFactory;
    1505             :   ThisExpression() : Expression(kNoSourcePosition, kThisExpression) {}
    1506             : };
    1507             : 
    1508             : class VariableProxy final : public Expression {
    1509             :  public:
    1510           0 :   bool IsValidReferenceExpression() const { return !is_new_target(); }
    1511             : 
    1512       72474 :   Handle<String> name() const { return raw_name()->string(); }
    1513   102173025 :   const AstRawString* raw_name() const {
    1514   108579671 :     return is_resolved() ? var_->raw_name() : raw_name_;
    1515             :   }
    1516             : 
    1517             :   Variable* var() const {
    1518             :     DCHECK(is_resolved());
    1519             :     return var_;
    1520             :   }
    1521             :   void set_var(Variable* v) {
    1522             :     DCHECK(!is_resolved());
    1523             :     DCHECK_NOT_NULL(v);
    1524    42157293 :     var_ = v;
    1525             :   }
    1526             : 
    1527        1281 :   Scanner::Location location() {
    1528        2562 :     return Scanner::Location(position(), position() + raw_name()->length());
    1529             :   }
    1530             : 
    1531             :   bool is_assigned() const { return IsAssignedField::decode(bit_field_); }
    1532     1199640 :   void set_is_assigned() {
    1533    14732486 :     bit_field_ = IsAssignedField::update(bit_field_, true);
    1534     7366243 :     if (is_resolved()) {
    1535             :       var()->set_maybe_assigned();
    1536             :     }
    1537             :   }
    1538             : 
    1539             :   bool is_resolved() const { return IsResolvedField::decode(bit_field_); }
    1540             :   void set_is_resolved() {
    1541    81416788 :     bit_field_ = IsResolvedField::update(bit_field_, true);
    1542             :   }
    1543             : 
    1544    60211308 :   bool is_new_target() const { return IsNewTargetField::decode(bit_field_); }
    1545             :   void set_is_new_target() {
    1546        4064 :     bit_field_ = IsNewTargetField::update(bit_field_, true);
    1547             :   }
    1548             : 
    1549             :   HoleCheckMode hole_check_mode() const {
    1550             :     HoleCheckMode mode = HoleCheckModeField::decode(bit_field_);
    1551             :     DCHECK_IMPLIES(mode == HoleCheckMode::kRequired,
    1552             :                    var()->binding_needs_init() ||
    1553             :                        var()->local_if_not_shadowed()->binding_needs_init());
    1554             :     return mode;
    1555             :   }
    1556             :   void set_needs_hole_check() {
    1557             :     bit_field_ =
    1558     1186444 :         HoleCheckModeField::update(bit_field_, HoleCheckMode::kRequired);
    1559             :   }
    1560             : 
    1561     6406651 :   bool IsPrivateName() const {
    1562    12813297 :     return raw_name()->length() > 0 && raw_name()->FirstCharacter() == '#';
    1563             :   }
    1564             : 
    1565             :   // Bind this proxy to the variable var.
    1566             :   void BindTo(Variable* var);
    1567             : 
    1568             :   V8_INLINE VariableProxy* next_unresolved() { return next_unresolved_; }
    1569             :   V8_INLINE bool is_removed_from_unresolved() const {
    1570    25149182 :     return IsRemovedFromUnresolvedField::decode(bit_field_);
    1571             :   }
    1572             : 
    1573             :   void mark_removed_from_unresolved() {
    1574       31426 :     bit_field_ = IsRemovedFromUnresolvedField::update(bit_field_, true);
    1575             :   }
    1576             : 
    1577             :   // Provides filtered access to the unresolved variable proxy threaded list.
    1578             :   struct UnresolvedNext {
    1579    87290364 :     static VariableProxy** filter(VariableProxy** t) {
    1580             :       VariableProxy** n = t;
    1581             :       // Skip over possibly removed values.
    1582   199737634 :       while (*n != nullptr && (*n)->is_removed_from_unresolved()) {
    1583    25156690 :         n = (*n)->next();
    1584             :       }
    1585    87290580 :       return n;
    1586             :     }
    1587             : 
    1588     5619231 :     static VariableProxy** start(VariableProxy** head) { return filter(head); }
    1589             : 
    1590    81689753 :     static VariableProxy** next(VariableProxy* t) { return filter(t->next()); }
    1591             :   };
    1592             : 
    1593             :  private:
    1594             :   friend class AstNodeFactory;
    1595             : 
    1596             :   VariableProxy(Variable* var, int start_position);
    1597             : 
    1598             :   VariableProxy(const AstRawString* name, VariableKind variable_kind,
    1599             :                 int start_position)
    1600             :       : Expression(start_position, kVariableProxy),
    1601             :         raw_name_(name),
    1602    71099921 :         next_unresolved_(nullptr) {
    1603             :     DCHECK_NE(THIS_VARIABLE, variable_kind);
    1604             :     bit_field_ |= IsAssignedField::encode(false) |
    1605             :                   IsResolvedField::encode(false) |
    1606             :                   IsRemovedFromUnresolvedField::encode(false) |
    1607    71099921 :                   HoleCheckModeField::encode(HoleCheckMode::kElided);
    1608             :   }
    1609             : 
    1610             :   explicit VariableProxy(const VariableProxy* copy_from);
    1611             : 
    1612             :   class IsAssignedField
    1613             :       : public BitField<bool, Expression::kNextBitFieldIndex, 1> {};
    1614             :   class IsResolvedField : public BitField<bool, IsAssignedField::kNext, 1> {};
    1615             :   class IsRemovedFromUnresolvedField
    1616             :       : public BitField<bool, IsResolvedField::kNext, 1> {};
    1617             :   class IsNewTargetField
    1618             :       : public BitField<bool, IsRemovedFromUnresolvedField::kNext, 1> {};
    1619             :   class HoleCheckModeField
    1620             :       : public BitField<HoleCheckMode, IsNewTargetField::kNext, 1> {};
    1621             : 
    1622             :   union {
    1623             :     const AstRawString* raw_name_;  // if !is_resolved_
    1624             :     Variable* var_;                 // if is_resolved_
    1625             :   };
    1626             : 
    1627             :   V8_INLINE VariableProxy** next() { return &next_unresolved_; }
    1628             :   VariableProxy* next_unresolved_;
    1629             : 
    1630             :   friend base::ThreadedListTraits<VariableProxy>;
    1631             : };
    1632             : 
    1633             : // Assignments to a property will use one of several types of property access.
    1634             : // Otherwise, the assignment is to a non-property (a global, a local slot, a
    1635             : // parameter slot, or a destructuring pattern).
    1636             : enum AssignType {
    1637             :   NON_PROPERTY,
    1638             :   NAMED_PROPERTY,
    1639             :   KEYED_PROPERTY,
    1640             :   NAMED_SUPER_PROPERTY,
    1641             :   KEYED_SUPER_PROPERTY
    1642             : };
    1643             : 
    1644             : class Property final : public Expression {
    1645             :  public:
    1646             :   bool IsValidReferenceExpression() const { return true; }
    1647             : 
    1648     3945838 :   Expression* obj() const { return obj_; }
    1649             :   Expression* key() const { return key_; }
    1650             : 
    1651     7377419 :   bool IsSuperAccess() { return obj()->IsSuperPropertyReference(); }
    1652             : 
    1653             :   // Returns the properties assign type.
    1654    18460344 :   static AssignType GetAssignType(Property* property) {
    1655    11873204 :     if (property == nullptr) return NON_PROPERTY;
    1656             :     bool super_access = property->IsSuperAccess();
    1657     6587140 :     return (property->key()->IsPropertyName())
    1658             :                ? (super_access ? NAMED_SUPER_PROPERTY : NAMED_PROPERTY)
    1659     6587062 :                : (super_access ? KEYED_SUPER_PROPERTY : KEYED_PROPERTY);
    1660             :   }
    1661             : 
    1662             :  private:
    1663             :   friend class AstNodeFactory;
    1664             : 
    1665             :   Property(Expression* obj, Expression* key, int pos)
    1666     7307896 :       : Expression(pos, kProperty), obj_(obj), key_(key) {
    1667             :   }
    1668             : 
    1669             :   Expression* obj_;
    1670             :   Expression* key_;
    1671             : };
    1672             : 
    1673             : // ResolvedProperty pairs a receiver field with a value field. It allows Call
    1674             : // to support arbitrary receivers while still taking advantage of TypeFeedback.
    1675             : class ResolvedProperty final : public Expression {
    1676             :  public:
    1677             :   VariableProxy* object() const { return object_; }
    1678             :   VariableProxy* property() const { return property_; }
    1679             : 
    1680             :   void set_object(VariableProxy* e) { object_ = e; }
    1681             :   void set_property(VariableProxy* e) { property_ = e; }
    1682             : 
    1683             :  private:
    1684             :   friend class AstNodeFactory;
    1685             : 
    1686             :   ResolvedProperty(VariableProxy* obj, VariableProxy* property, int pos)
    1687             :       : Expression(pos, kResolvedProperty), object_(obj), property_(property) {}
    1688             : 
    1689             :   VariableProxy* object_;
    1690             :   VariableProxy* property_;
    1691             : };
    1692             : 
    1693             : class Call final : public Expression {
    1694             :  public:
    1695             :   Expression* expression() const { return expression_; }
    1696             :   const ZonePtrList<Expression>* arguments() const { return &arguments_; }
    1697             : 
    1698             :   bool is_possibly_eval() const {
    1699             :     return IsPossiblyEvalField::decode(bit_field_);
    1700             :   }
    1701             : 
    1702             :   bool is_tagged_template() const {
    1703             :     return IsTaggedTemplateField::decode(bit_field_);
    1704             :   }
    1705             : 
    1706     5104286 :   bool only_last_arg_is_spread() {
    1707    10020558 :     return !arguments_.is_empty() && arguments_.last()->IsSpread();
    1708             :   }
    1709             : 
    1710             :   enum CallType {
    1711             :     GLOBAL_CALL,
    1712             :     WITH_CALL,
    1713             :     NAMED_PROPERTY_CALL,
    1714             :     KEYED_PROPERTY_CALL,
    1715             :     NAMED_SUPER_PROPERTY_CALL,
    1716             :     KEYED_SUPER_PROPERTY_CALL,
    1717             :     SUPER_CALL,
    1718             :     RESOLVED_PROPERTY_CALL,
    1719             :     OTHER_CALL
    1720             :   };
    1721             : 
    1722             :   enum PossiblyEval {
    1723             :     IS_POSSIBLY_EVAL,
    1724             :     NOT_EVAL,
    1725             :   };
    1726             : 
    1727             :   // Helpers to determine how to handle the call.
    1728             :   CallType GetCallType() const;
    1729             : 
    1730             :   enum class TaggedTemplateTag { kTrue };
    1731             : 
    1732             :  private:
    1733             :   friend class AstNodeFactory;
    1734             : 
    1735     6425383 :   Call(Zone* zone, Expression* expression,
    1736             :        const ScopedPtrList<Expression>& arguments, int pos,
    1737             :        PossiblyEval possibly_eval)
    1738             :       : Expression(pos, kCall),
    1739             :         expression_(expression),
    1740     6425383 :         arguments_(0, nullptr) {
    1741             :     bit_field_ |=
    1742     6425237 :         IsPossiblyEvalField::encode(possibly_eval == IS_POSSIBLY_EVAL) |
    1743     6425237 :         IsTaggedTemplateField::encode(false);
    1744     6425237 :     arguments.CopyTo(&arguments_, zone);
    1745     6425234 :   }
    1746             : 
    1747        7176 :   Call(Zone* zone, Expression* expression,
    1748             :        const ScopedPtrList<Expression>& arguments, int pos,
    1749             :        TaggedTemplateTag tag)
    1750             :       : Expression(pos, kCall),
    1751             :         expression_(expression),
    1752        7176 :         arguments_(0, nullptr) {
    1753             :     bit_field_ |= IsPossiblyEvalField::encode(false) |
    1754        7176 :                   IsTaggedTemplateField::encode(true);
    1755        7176 :     arguments.CopyTo(&arguments_, zone);
    1756        7176 :   }
    1757             : 
    1758             :   class IsPossiblyEvalField
    1759             :       : public BitField<bool, Expression::kNextBitFieldIndex, 1> {};
    1760             :   class IsTaggedTemplateField
    1761             :       : public BitField<bool, IsPossiblyEvalField::kNext, 1> {};
    1762             : 
    1763             :   Expression* expression_;
    1764             :   ZonePtrList<Expression> arguments_;
    1765             : };
    1766             : 
    1767             : 
    1768             : class CallNew final : public Expression {
    1769             :  public:
    1770             :   Expression* expression() const { return expression_; }
    1771             :   const ZonePtrList<Expression>* arguments() const { return &arguments_; }
    1772             : 
    1773      137952 :   bool only_last_arg_is_spread() {
    1774      282517 :     return !arguments_.is_empty() && arguments_.last()->IsSpread();
    1775             :   }
    1776             : 
    1777             :  private:
    1778             :   friend class AstNodeFactory;
    1779             : 
    1780      167872 :   CallNew(Zone* zone, Expression* expression,
    1781             :           const ScopedPtrList<Expression>& arguments, int pos)
    1782             :       : Expression(pos, kCallNew),
    1783             :         expression_(expression),
    1784      167872 :         arguments_(0, nullptr) {
    1785      167871 :     arguments.CopyTo(&arguments_, zone);
    1786      167887 :   }
    1787             : 
    1788             :   Expression* expression_;
    1789             :   ZonePtrList<Expression> arguments_;
    1790             : };
    1791             : 
    1792             : // The CallRuntime class does not represent any official JavaScript
    1793             : // language construct. Instead it is used to call a C or JS function
    1794             : // with a set of arguments. This is used from the builtins that are
    1795             : // implemented in JavaScript.
    1796             : class CallRuntime final : public Expression {
    1797             :  public:
    1798             :   const ZonePtrList<Expression>* arguments() const { return &arguments_; }
    1799             :   bool is_jsruntime() const { return function_ == nullptr; }
    1800             : 
    1801             :   int context_index() const {
    1802             :     DCHECK(is_jsruntime());
    1803             :     return context_index_;
    1804             :   }
    1805             :   const Runtime::Function* function() const {
    1806             :     DCHECK(!is_jsruntime());
    1807             :     return function_;
    1808             :   }
    1809             : 
    1810             :   const char* debug_name();
    1811             : 
    1812             :  private:
    1813             :   friend class AstNodeFactory;
    1814             : 
    1815      152261 :   CallRuntime(Zone* zone, const Runtime::Function* function,
    1816             :               const ScopedPtrList<Expression>& arguments, int pos)
    1817             :       : Expression(pos, kCallRuntime),
    1818             :         function_(function),
    1819      152261 :         arguments_(0, nullptr) {
    1820      152261 :     arguments.CopyTo(&arguments_, zone);
    1821      152272 :   }
    1822         701 :   CallRuntime(Zone* zone, int context_index,
    1823             :               const ScopedPtrList<Expression>& arguments, int pos)
    1824             :       : Expression(pos, kCallRuntime),
    1825             :         context_index_(context_index),
    1826             :         function_(nullptr),
    1827         701 :         arguments_(0, nullptr) {
    1828         701 :     arguments.CopyTo(&arguments_, zone);
    1829         702 :   }
    1830             : 
    1831             :   int context_index_;
    1832             :   const Runtime::Function* function_;
    1833             :   ZonePtrList<Expression> arguments_;
    1834             : };
    1835             : 
    1836             : 
    1837             : class UnaryOperation final : public Expression {
    1838             :  public:
    1839             :   Token::Value op() const { return OperatorField::decode(bit_field_); }
    1840             :   Expression* expression() const { return expression_; }
    1841             : 
    1842             :  private:
    1843             :   friend class AstNodeFactory;
    1844             : 
    1845             :   UnaryOperation(Token::Value op, Expression* expression, int pos)
    1846      544046 :       : Expression(pos, kUnaryOperation), expression_(expression) {
    1847      544046 :     bit_field_ |= OperatorField::encode(op);
    1848             :     DCHECK(Token::IsUnaryOp(op));
    1849             :   }
    1850             : 
    1851             :   Expression* expression_;
    1852             : 
    1853             :   class OperatorField
    1854             :       : public BitField<Token::Value, Expression::kNextBitFieldIndex, 7> {};
    1855             : };
    1856             : 
    1857             : 
    1858             : class BinaryOperation final : public Expression {
    1859             :  public:
    1860             :   Token::Value op() const { return OperatorField::decode(bit_field_); }
    1861             :   Expression* left() const { return left_; }
    1862             :   Expression* right() const { return right_; }
    1863             : 
    1864             :   // Returns true if one side is a Smi literal, returning the other side's
    1865             :   // sub-expression in |subexpr| and the literal Smi in |literal|.
    1866             :   bool IsSmiLiteralOperation(Expression** subexpr, Smi* literal);
    1867             : 
    1868             :  private:
    1869             :   friend class AstNodeFactory;
    1870             : 
    1871             :   BinaryOperation(Token::Value op, Expression* left, Expression* right, int pos)
    1872      901555 :       : Expression(pos, kBinaryOperation), left_(left), right_(right) {
    1873      901555 :     bit_field_ |= OperatorField::encode(op);
    1874             :     DCHECK(Token::IsBinaryOp(op));
    1875             :   }
    1876             : 
    1877             :   Expression* left_;
    1878             :   Expression* right_;
    1879             : 
    1880             :   class OperatorField
    1881             :       : public BitField<Token::Value, Expression::kNextBitFieldIndex, 7> {};
    1882             : };
    1883             : 
    1884             : class NaryOperation final : public Expression {
    1885             :  public:
    1886             :   Token::Value op() const { return OperatorField::decode(bit_field_); }
    1887             :   Expression* first() const { return first_; }
    1888             :   Expression* subsequent(size_t index) const {
    1889     3701226 :     return subsequent_[index].expression;
    1890             :   }
    1891             : 
    1892     3126065 :   size_t subsequent_length() const { return subsequent_.size(); }
    1893             :   int subsequent_op_position(size_t index) const {
    1894      670502 :     return subsequent_[index].op_position;
    1895             :   }
    1896             : 
    1897             :   void AddSubsequent(Expression* expr, int pos) {
    1898     3090042 :     subsequent_.emplace_back(expr, pos);
    1899             :   }
    1900             : 
    1901             :  private:
    1902             :   friend class AstNodeFactory;
    1903             : 
    1904             :   NaryOperation(Zone* zone, Token::Value op, Expression* first,
    1905             :                 size_t initial_subsequent_size)
    1906             :       : Expression(first->position(), kNaryOperation),
    1907             :         first_(first),
    1908      262356 :         subsequent_(zone) {
    1909      131178 :     bit_field_ |= OperatorField::encode(op);
    1910             :     DCHECK(Token::IsBinaryOp(op));
    1911             :     DCHECK_NE(op, Token::EXP);
    1912      131178 :     subsequent_.reserve(initial_subsequent_size);
    1913             :   }
    1914             : 
    1915             :   // Nary operations store the first (lhs) child expression inline, and the
    1916             :   // child expressions (rhs of each op) are stored out-of-line, along with
    1917             :   // their operation's position. Note that the Nary operation expression's
    1918             :   // position has no meaning.
    1919             :   //
    1920             :   // So an nary add:
    1921             :   //
    1922             :   //    expr + expr + expr + ...
    1923             :   //
    1924             :   // is stored as:
    1925             :   //
    1926             :   //    (expr) [(+ expr), (+ expr), ...]
    1927             :   //    '-.--' '-----------.-----------'
    1928             :   //    first    subsequent entry list
    1929             : 
    1930             :   Expression* first_;
    1931             : 
    1932             :   struct NaryOperationEntry {
    1933             :     Expression* expression;
    1934             :     int op_position;
    1935             :     NaryOperationEntry(Expression* e, int pos)
    1936     3090032 :         : expression(e), op_position(pos) {}
    1937             :   };
    1938             :   ZoneVector<NaryOperationEntry> subsequent_;
    1939             : 
    1940             :   class OperatorField
    1941             :       : public BitField<Token::Value, Expression::kNextBitFieldIndex, 7> {};
    1942             : };
    1943             : 
    1944             : class CountOperation final : public Expression {
    1945             :  public:
    1946             :   bool is_prefix() const { return IsPrefixField::decode(bit_field_); }
    1947      240753 :   bool is_postfix() const { return !is_prefix(); }
    1948             : 
    1949             :   Token::Value op() const { return TokenField::decode(bit_field_); }
    1950             : 
    1951             :   Expression* expression() const { return expression_; }
    1952             : 
    1953             :  private:
    1954             :   friend class AstNodeFactory;
    1955             : 
    1956             :   CountOperation(Token::Value op, bool is_prefix, Expression* expr, int pos)
    1957      315859 :       : Expression(pos, kCountOperation), expression_(expr) {
    1958      315859 :     bit_field_ |= IsPrefixField::encode(is_prefix) | TokenField::encode(op);
    1959             :   }
    1960             : 
    1961             :   class IsPrefixField
    1962             :       : public BitField<bool, Expression::kNextBitFieldIndex, 1> {};
    1963             :   class TokenField : public BitField<Token::Value, IsPrefixField::kNext, 7> {};
    1964             : 
    1965             :   Expression* expression_;
    1966             : };
    1967             : 
    1968             : 
    1969             : class CompareOperation final : public Expression {
    1970             :  public:
    1971             :   Token::Value op() const { return OperatorField::decode(bit_field_); }
    1972             :   Expression* left() const { return left_; }
    1973             :   Expression* right() const { return right_; }
    1974             : 
    1975             :   // Match special cases.
    1976             :   bool IsLiteralCompareTypeof(Expression** expr, Literal** literal);
    1977             :   bool IsLiteralCompareUndefined(Expression** expr);
    1978             :   bool IsLiteralCompareNull(Expression** expr);
    1979             : 
    1980             :  private:
    1981             :   friend class AstNodeFactory;
    1982             : 
    1983             :   CompareOperation(Token::Value op, Expression* left, Expression* right,
    1984             :                    int pos)
    1985     1021998 :       : Expression(pos, kCompareOperation), left_(left), right_(right) {
    1986     1021998 :     bit_field_ |= OperatorField::encode(op);
    1987             :     DCHECK(Token::IsCompareOp(op));
    1988             :   }
    1989             : 
    1990             :   Expression* left_;
    1991             :   Expression* right_;
    1992             : 
    1993             :   class OperatorField
    1994             :       : public BitField<Token::Value, Expression::kNextBitFieldIndex, 7> {};
    1995             : };
    1996             : 
    1997             : 
    1998             : class Spread final : public Expression {
    1999             :  public:
    2000             :   Expression* expression() const { return expression_; }
    2001             : 
    2002             :   int expression_position() const { return expr_pos_; }
    2003             : 
    2004             :  private:
    2005             :   friend class AstNodeFactory;
    2006             : 
    2007             :   Spread(Expression* expression, int pos, int expr_pos)
    2008             :       : Expression(pos, kSpread),
    2009             :         expr_pos_(expr_pos),
    2010       56510 :         expression_(expression) {}
    2011             : 
    2012             :   int expr_pos_;
    2013             :   Expression* expression_;
    2014             : };
    2015             : 
    2016             : // The StoreInArrayLiteral node corresponds to the StaInArrayLiteral bytecode.
    2017             : // It is used in the rewriting of destructuring assignments that contain an
    2018             : // array rest pattern.
    2019             : class StoreInArrayLiteral final : public Expression {
    2020             :  public:
    2021             :   Expression* array() const { return array_; }
    2022             :   Expression* index() const { return index_; }
    2023             :   Expression* value() const { return value_; }
    2024             : 
    2025             :  private:
    2026             :   friend class AstNodeFactory;
    2027             : 
    2028             :   StoreInArrayLiteral(Expression* array, Expression* index, Expression* value,
    2029             :                       int position)
    2030             :       : Expression(position, kStoreInArrayLiteral),
    2031             :         array_(array),
    2032             :         index_(index),
    2033             :         value_(value) {}
    2034             : 
    2035             :   Expression* array_;
    2036             :   Expression* index_;
    2037             :   Expression* value_;
    2038             : };
    2039             : 
    2040             : class Conditional final : public Expression {
    2041             :  public:
    2042             :   Expression* condition() const { return condition_; }
    2043             :   Expression* then_expression() const { return then_expression_; }
    2044             :   Expression* else_expression() const { return else_expression_; }
    2045             : 
    2046             :  private:
    2047             :   friend class AstNodeFactory;
    2048             : 
    2049             :   Conditional(Expression* condition, Expression* then_expression,
    2050             :               Expression* else_expression, int position)
    2051             :       : Expression(position, kConditional),
    2052             :         condition_(condition),
    2053             :         then_expression_(then_expression),
    2054       67678 :         else_expression_(else_expression) {}
    2055             : 
    2056             :   Expression* condition_;
    2057             :   Expression* then_expression_;
    2058             :   Expression* else_expression_;
    2059             : };
    2060             : 
    2061             : class Assignment : public Expression {
    2062             :  public:
    2063             :   Token::Value op() const { return TokenField::decode(bit_field_); }
    2064             :   Expression* target() const { return target_; }
    2065             :   Expression* value() const { return value_; }
    2066             : 
    2067             :   // The assignment was generated as part of block-scoped sloppy-mode
    2068             :   // function hoisting, see
    2069             :   // ES#sec-block-level-function-declarations-web-legacy-compatibility-semantics
    2070             :   LookupHoistingMode lookup_hoisting_mode() const {
    2071             :     return static_cast<LookupHoistingMode>(
    2072     7407451 :         LookupHoistingModeField::decode(bit_field_));
    2073             :   }
    2074             :   void set_lookup_hoisting_mode(LookupHoistingMode mode) {
    2075             :     bit_field_ =
    2076       14994 :         LookupHoistingModeField::update(bit_field_, static_cast<bool>(mode));
    2077             :   }
    2078             : 
    2079             :  protected:
    2080             :   Assignment(NodeType type, Token::Value op, Expression* target,
    2081             :              Expression* value, int pos);
    2082             : 
    2083             :  private:
    2084             :   friend class AstNodeFactory;
    2085             : 
    2086             :   class TokenField
    2087             :       : public BitField<Token::Value, Expression::kNextBitFieldIndex, 7> {};
    2088             :   class LookupHoistingModeField : public BitField<bool, TokenField::kNext, 1> {
    2089             :   };
    2090             : 
    2091             :   Expression* target_;
    2092             :   Expression* value_;
    2093             : };
    2094             : 
    2095             : class CompoundAssignment final : public Assignment {
    2096             :  public:
    2097             :   BinaryOperation* binary_operation() const { return binary_operation_; }
    2098             : 
    2099             :  private:
    2100             :   friend class AstNodeFactory;
    2101             : 
    2102             :   CompoundAssignment(Token::Value op, Expression* target, Expression* value,
    2103             :                      int pos, BinaryOperation* binary_operation)
    2104             :       : Assignment(kCompoundAssignment, op, target, value, pos),
    2105      102705 :         binary_operation_(binary_operation) {}
    2106             : 
    2107             :   BinaryOperation* binary_operation_;
    2108             : };
    2109             : 
    2110             : // There are several types of Suspend node:
    2111             : //
    2112             : // Yield
    2113             : // YieldStar
    2114             : // Await
    2115             : //
    2116             : // Our Yield is different from the JS yield in that it "returns" its argument as
    2117             : // is, without wrapping it in an iterator result object.  Such wrapping, if
    2118             : // desired, must be done beforehand (see the parser).
    2119             : class Suspend : public Expression {
    2120             :  public:
    2121             :   // With {kNoControl}, the {Suspend} behaves like yield, except that it never
    2122             :   // throws and never causes the current generator to return. This is used to
    2123             :   // desugar yield*.
    2124             :   // TODO(caitp): remove once yield* desugaring for async generators is handled
    2125             :   // in BytecodeGenerator.
    2126             :   enum OnAbruptResume { kOnExceptionThrow, kNoControl };
    2127             : 
    2128             :   Expression* expression() const { return expression_; }
    2129             :   OnAbruptResume on_abrupt_resume() const {
    2130             :     return OnAbruptResumeField::decode(bit_field_);
    2131             :   }
    2132             : 
    2133             :  private:
    2134             :   friend class AstNodeFactory;
    2135             :   friend class Yield;
    2136             :   friend class YieldStar;
    2137             :   friend class Await;
    2138             : 
    2139             :   Suspend(NodeType node_type, Expression* expression, int pos,
    2140             :           OnAbruptResume on_abrupt_resume)
    2141      163263 :       : Expression(pos, node_type), expression_(expression) {
    2142      110705 :     bit_field_ |= OnAbruptResumeField::encode(on_abrupt_resume);
    2143             :   }
    2144             : 
    2145             :   Expression* expression_;
    2146             : 
    2147             :   class OnAbruptResumeField
    2148             :       : public BitField<OnAbruptResume, Expression::kNextBitFieldIndex, 1> {};
    2149             : };
    2150             : 
    2151             : class Yield final : public Suspend {
    2152             :  private:
    2153             :   friend class AstNodeFactory;
    2154             :   Yield(Expression* expression, int pos, OnAbruptResume on_abrupt_resume)
    2155             :       : Suspend(kYield, expression, pos, on_abrupt_resume) {}
    2156             : };
    2157             : 
    2158             : class YieldStar final : public Suspend {
    2159             :  private:
    2160             :   friend class AstNodeFactory;
    2161             :   YieldStar(Expression* expression, int pos)
    2162             :       : Suspend(kYieldStar, expression, pos,
    2163             :                 Suspend::OnAbruptResume::kNoControl) {}
    2164             : };
    2165             : 
    2166             : class Await final : public Suspend {
    2167             :  private:
    2168             :   friend class AstNodeFactory;
    2169             : 
    2170             :   Await(Expression* expression, int pos)
    2171             :       : Suspend(kAwait, expression, pos, Suspend::kOnExceptionThrow) {}
    2172             : };
    2173             : 
    2174             : class Throw final : public Expression {
    2175             :  public:
    2176             :   Expression* exception() const { return exception_; }
    2177             : 
    2178             :  private:
    2179             :   friend class AstNodeFactory;
    2180             : 
    2181             :   Throw(Expression* exception, int pos)
    2182       41400 :       : Expression(pos, kThrow), exception_(exception) {}
    2183             : 
    2184             :   Expression* exception_;
    2185             : };
    2186             : 
    2187             : 
    2188             : class FunctionLiteral final : public Expression {
    2189             :  public:
    2190             :   enum FunctionType {
    2191             :     kAnonymousExpression,
    2192             :     kNamedExpression,
    2193             :     kDeclaration,
    2194             :     kAccessorOrMethod,
    2195             :     kWrapped,
    2196             :   };
    2197             : 
    2198             :   enum IdType { kIdTypeInvalid = -1, kIdTypeTopLevel = 0 };
    2199             : 
    2200             :   enum ParameterFlag : uint8_t {
    2201             :     kNoDuplicateParameters,
    2202             :     kHasDuplicateParameters
    2203             :   };
    2204             :   enum EagerCompileHint : uint8_t { kShouldEagerCompile, kShouldLazyCompile };
    2205             : 
    2206             :   // Empty handle means that the function does not have a shared name (i.e.
    2207             :   // the name will be set dynamically after creation of the function closure).
    2208             :   MaybeHandle<String> name() const {
    2209     3576876 :     return raw_name_ ? raw_name_->string() : MaybeHandle<String>();
    2210             :   }
    2211             :   Handle<String> name(Isolate* isolate) const;
    2212             :   bool has_shared_name() const { return raw_name_ != nullptr; }
    2213             :   const AstConsString* raw_name() const { return raw_name_; }
    2214      748623 :   void set_raw_name(const AstConsString* name) { raw_name_ = name; }
    2215             :   DeclarationScope* scope() const { return scope_; }
    2216             :   ZonePtrList<Statement>* body() { return &body_; }
    2217     4310323 :   void set_function_token_position(int pos) { function_token_position_ = pos; }
    2218             :   int function_token_position() const { return function_token_position_; }
    2219             :   int start_position() const;
    2220             :   int end_position() const;
    2221     7153838 :   bool is_declaration() const { return function_type() == kDeclaration; }
    2222     3576958 :   bool is_named_expression() const {
    2223     3576878 :     return function_type() == kNamedExpression;
    2224             :   }
    2225     5184548 :   bool is_anonymous_expression() const {
    2226     3576878 :     return function_type() == kAnonymousExpression;
    2227             :   }
    2228             : 
    2229             :   void mark_as_oneshot_iife() {
    2230      131244 :     bit_field_ = OneshotIIFEBit::update(bit_field_, true);
    2231             :   }
    2232             :   bool is_oneshot_iife() const { return OneshotIIFEBit::decode(bit_field_); }
    2233    10021769 :   bool is_toplevel() const {
    2234             :     return function_literal_id() == FunctionLiteral::kIdTypeTopLevel;
    2235             :   }
    2236     7153838 :   bool is_wrapped() const { return function_type() == kWrapped; }
    2237             :   LanguageMode language_mode() const;
    2238             : 
    2239             :   static bool NeedsHomeObject(Expression* expr);
    2240             : 
    2241             :   int expected_property_count() {
    2242             :     // Not valid for lazy functions.
    2243             :     DCHECK(ShouldEagerCompile());
    2244             :     return expected_property_count_;
    2245             :   }
    2246             :   int parameter_count() { return parameter_count_; }
    2247             :   int function_length() { return function_length_; }
    2248             : 
    2249             :   bool AllowsLazyCompilation();
    2250             : 
    2251     2093091 :   bool CanSuspend() {
    2252     2093091 :     if (suspend_count() > 0) {
    2253             :       DCHECK(IsResumableFunction(kind()));
    2254             :       return true;
    2255             :     }
    2256             :     return false;
    2257             :   }
    2258             : 
    2259             :   // Returns either name or inferred name as a cstring.
    2260             :   std::unique_ptr<char[]> GetDebugName() const;
    2261             : 
    2262     2068449 :   Handle<String> inferred_name() const {
    2263     2068449 :     if (!inferred_name_.is_null()) {
    2264             :       DCHECK_NULL(raw_inferred_name_);
    2265           0 :       return inferred_name_;
    2266             :     }
    2267     2068449 :     if (raw_inferred_name_ != nullptr) {
    2268             :       return raw_inferred_name_->string();
    2269             :     }
    2270           0 :     UNREACHABLE();
    2271             :   }
    2272             :   const AstConsString* raw_inferred_name() { return raw_inferred_name_; }
    2273             : 
    2274             :   // Only one of {set_inferred_name, set_raw_inferred_name} should be called.
    2275             :   void set_inferred_name(Handle<String> inferred_name);
    2276             :   void set_raw_inferred_name(const AstConsString* raw_inferred_name);
    2277             : 
    2278             :   bool pretenure() const { return Pretenure::decode(bit_field_); }
    2279      165798 :   void set_pretenure() { bit_field_ = Pretenure::update(bit_field_, true); }
    2280             : 
    2281             :   bool has_duplicate_parameters() const {
    2282             :     // Not valid for lazy functions.
    2283             :     DCHECK(ShouldEagerCompile());
    2284             :     return HasDuplicateParameters::decode(bit_field_);
    2285             :   }
    2286             : 
    2287             :   // This is used as a heuristic on when to eagerly compile a function
    2288             :   // literal. We consider the following constructs as hints that the
    2289             :   // function will be called immediately:
    2290             :   // - (function() { ... })();
    2291             :   // - var x = function() { ... }();
    2292             :   bool ShouldEagerCompile() const;
    2293             :   V8_EXPORT_PRIVATE void SetShouldEagerCompile();
    2294             : 
    2295             :   FunctionType function_type() const {
    2296             :     return FunctionTypeBits::decode(bit_field_);
    2297             :   }
    2298             :   FunctionKind kind() const;
    2299             : 
    2300             :   bool dont_optimize() {
    2301             :     return dont_optimize_reason() != BailoutReason::kNoReason;
    2302             :   }
    2303             :   BailoutReason dont_optimize_reason() {
    2304             :     return DontOptimizeReasonField::decode(bit_field_);
    2305             :   }
    2306             :   void set_dont_optimize_reason(BailoutReason reason) {
    2307             :     bit_field_ = DontOptimizeReasonField::update(bit_field_, reason);
    2308             :   }
    2309             : 
    2310             :   bool IsAnonymousFunctionDefinition() const {
    2311             :     return is_anonymous_expression();
    2312             :   }
    2313             : 
    2314             :   int suspend_count() { return suspend_count_; }
    2315     6041377 :   void set_suspend_count(int suspend_count) { suspend_count_ = suspend_count; }
    2316             : 
    2317     3040702 :   int return_position() {
    2318             :     return std::max(
    2319     3040754 :         start_position(),
    2320    12163102 :         end_position() - (HasBracesField::decode(bit_field_) ? 1 : 0));
    2321             :   }
    2322             : 
    2323             :   int function_literal_id() const { return function_literal_id_; }
    2324             :   void set_function_literal_id(int function_literal_id) {
    2325         320 :     function_literal_id_ = function_literal_id;
    2326             :   }
    2327             : 
    2328             :   void set_requires_instance_members_initializer(bool value) {
    2329     1439630 :     bit_field_ = RequiresInstanceMembersInitializer::update(bit_field_, value);
    2330             :   }
    2331             :   bool requires_instance_members_initializer() const {
    2332             :     return RequiresInstanceMembersInitializer::decode(bit_field_);
    2333             :   }
    2334             : 
    2335             :   ProducedPreparseData* produced_preparse_data() const {
    2336             :     return produced_preparse_data_;
    2337             :   }
    2338             : 
    2339             :  private:
    2340             :   friend class AstNodeFactory;
    2341             : 
    2342     6168102 :   FunctionLiteral(Zone* zone, const AstRawString* name,
    2343     6168122 :                   AstValueFactory* ast_value_factory, DeclarationScope* scope,
    2344             :                   const ScopedPtrList<Statement>& body,
    2345             :                   int expected_property_count, int parameter_count,
    2346             :                   int function_length, FunctionType function_type,
    2347             :                   ParameterFlag has_duplicate_parameters,
    2348             :                   EagerCompileHint eager_compile_hint, int position,
    2349             :                   bool has_braces, int function_literal_id,
    2350             :                   ProducedPreparseData* produced_preparse_data = nullptr)
    2351             :       : Expression(position, kFunctionLiteral),
    2352             :         expected_property_count_(expected_property_count),
    2353             :         parameter_count_(parameter_count),
    2354             :         function_length_(function_length),
    2355             :         function_token_position_(kNoSourcePosition),
    2356             :         suspend_count_(0),
    2357             :         function_literal_id_(function_literal_id),
    2358             :         raw_name_(name ? ast_value_factory->NewConsString(name) : nullptr),
    2359             :         scope_(scope),
    2360             :         body_(0, nullptr),
    2361             :         raw_inferred_name_(ast_value_factory->empty_cons_string()),
    2362    18504346 :         produced_preparse_data_(produced_preparse_data) {
    2363             :     bit_field_ |=
    2364     6168122 :         FunctionTypeBits::encode(function_type) | Pretenure::encode(false) |
    2365             :         HasDuplicateParameters::encode(has_duplicate_parameters ==
    2366     6168122 :                                        kHasDuplicateParameters) |
    2367             :         DontOptimizeReasonField::encode(BailoutReason::kNoReason) |
    2368     6168122 :         RequiresInstanceMembersInitializer::encode(false) |
    2369     6168122 :         HasBracesField::encode(has_braces) | OneshotIIFEBit::encode(false);
    2370     6168122 :     if (eager_compile_hint == kShouldEagerCompile) SetShouldEagerCompile();
    2371     6168097 :     body.CopyTo(&body_, zone);
    2372     6168204 :   }
    2373             : 
    2374             :   class FunctionTypeBits
    2375             :       : public BitField<FunctionType, Expression::kNextBitFieldIndex, 3> {};
    2376             :   class Pretenure : public BitField<bool, FunctionTypeBits::kNext, 1> {};
    2377             :   class HasDuplicateParameters : public BitField<bool, Pretenure::kNext, 1> {};
    2378             :   class DontOptimizeReasonField
    2379             :       : public BitField<BailoutReason, HasDuplicateParameters::kNext, 8> {};
    2380             :   class RequiresInstanceMembersInitializer
    2381             :       : public BitField<bool, DontOptimizeReasonField::kNext, 1> {};
    2382             :   class HasBracesField
    2383             :       : public BitField<bool, RequiresInstanceMembersInitializer::kNext, 1> {};
    2384             :   class OneshotIIFEBit : public BitField<bool, HasBracesField::kNext, 1> {};
    2385             : 
    2386             :   int expected_property_count_;
    2387             :   int parameter_count_;
    2388             :   int function_length_;
    2389             :   int function_token_position_;
    2390             :   int suspend_count_;
    2391             :   int function_literal_id_;
    2392             : 
    2393             :   const AstConsString* raw_name_;
    2394             :   DeclarationScope* scope_;
    2395             :   ZonePtrList<Statement> body_;
    2396             :   const AstConsString* raw_inferred_name_;
    2397             :   Handle<String> inferred_name_;
    2398             :   ProducedPreparseData* produced_preparse_data_;
    2399             : };
    2400             : 
    2401             : // Property is used for passing information
    2402             : // about a class literal's properties from the parser to the code generator.
    2403             : class ClassLiteralProperty final : public LiteralProperty {
    2404             :  public:
    2405             :   enum Kind : uint8_t { METHOD, GETTER, SETTER, FIELD };
    2406             : 
    2407             :   Kind kind() const { return kind_; }
    2408             : 
    2409             :   bool is_static() const { return is_static_; }
    2410             : 
    2411             :   bool is_private() const { return is_private_; }
    2412             : 
    2413             :   void set_computed_name_var(Variable* var) {
    2414             :     DCHECK_EQ(FIELD, kind());
    2415             :     DCHECK(!is_private());
    2416        5214 :     private_or_computed_name_var_ = var;
    2417             :   }
    2418             : 
    2419             :   Variable* computed_name_var() const {
    2420             :     DCHECK_EQ(FIELD, kind());
    2421             :     DCHECK(!is_private());
    2422             :     return private_or_computed_name_var_;
    2423             :   }
    2424             : 
    2425             :   void set_private_name_var(Variable* var) {
    2426             :     DCHECK_EQ(FIELD, kind());
    2427             :     DCHECK(is_private());
    2428        9803 :     private_or_computed_name_var_ = var;
    2429             :   }
    2430             :   Variable* private_name_var() const {
    2431             :     DCHECK_EQ(FIELD, kind());
    2432             :     DCHECK(is_private());
    2433             :     return private_or_computed_name_var_;
    2434             :   }
    2435             : 
    2436             :  private:
    2437             :   friend class AstNodeFactory;
    2438             : 
    2439             :   ClassLiteralProperty(Expression* key, Expression* value, Kind kind,
    2440             :                        bool is_static, bool is_computed_name, bool is_private);
    2441             : 
    2442             :   Kind kind_;
    2443             :   bool is_static_;
    2444             :   bool is_private_;
    2445             :   Variable* private_or_computed_name_var_;
    2446             : };
    2447             : 
    2448             : class InitializeClassMembersStatement final : public Statement {
    2449             :  public:
    2450             :   typedef ClassLiteralProperty Property;
    2451             : 
    2452             :   ZonePtrList<Property>* fields() const { return fields_; }
    2453             : 
    2454             :  private:
    2455             :   friend class AstNodeFactory;
    2456             : 
    2457             :   InitializeClassMembersStatement(ZonePtrList<Property>* fields, int pos)
    2458       26939 :       : Statement(pos, kInitializeClassMembersStatement), fields_(fields) {}
    2459             : 
    2460             :   ZonePtrList<Property>* fields_;
    2461             : };
    2462             : 
    2463             : class ClassLiteral final : public Expression {
    2464             :  public:
    2465             :   typedef ClassLiteralProperty Property;
    2466             : 
    2467             :   Scope* scope() const { return scope_; }
    2468             :   Variable* class_variable() const { return class_variable_; }
    2469             :   Expression* extends() const { return extends_; }
    2470             :   FunctionLiteral* constructor() const { return constructor_; }
    2471             :   ZonePtrList<Property>* properties() const { return properties_; }
    2472       39434 :   int start_position() const { return position(); }
    2473             :   int end_position() const { return end_position_; }
    2474             :   bool has_name_static_property() const {
    2475             :     return HasNameStaticProperty::decode(bit_field_);
    2476             :   }
    2477             :   bool has_static_computed_names() const {
    2478             :     return HasStaticComputedNames::decode(bit_field_);
    2479             :   }
    2480             : 
    2481             :   bool is_anonymous_expression() const {
    2482             :     return IsAnonymousExpression::decode(bit_field_);
    2483             :   }
    2484        3687 :   bool IsAnonymousFunctionDefinition() const {
    2485             :     return is_anonymous_expression();
    2486             :   }
    2487             : 
    2488             :   FunctionLiteral* static_fields_initializer() const {
    2489             :     return static_fields_initializer_;
    2490             :   }
    2491             : 
    2492             :   FunctionLiteral* instance_members_initializer_function() const {
    2493             :     return instance_members_initializer_function_;
    2494             :   }
    2495             : 
    2496             :  private:
    2497             :   friend class AstNodeFactory;
    2498             : 
    2499             :   ClassLiteral(Scope* scope, Variable* class_variable, Expression* extends,
    2500             :                FunctionLiteral* constructor, ZonePtrList<Property>* properties,
    2501             :                FunctionLiteral* static_fields_initializer,
    2502             :                FunctionLiteral* instance_members_initializer_function,
    2503             :                int start_position, int end_position,
    2504             :                bool has_name_static_property, bool has_static_computed_names,
    2505             :                bool is_anonymous)
    2506             :       : Expression(start_position, kClassLiteral),
    2507             :         end_position_(end_position),
    2508             :         scope_(scope),
    2509             :         class_variable_(class_variable),
    2510             :         extends_(extends),
    2511             :         constructor_(constructor),
    2512             :         properties_(properties),
    2513             :         static_fields_initializer_(static_fields_initializer),
    2514             :         instance_members_initializer_function_(
    2515      109002 :             instance_members_initializer_function) {
    2516      109002 :     bit_field_ |= HasNameStaticProperty::encode(has_name_static_property) |
    2517             :                   HasStaticComputedNames::encode(has_static_computed_names) |
    2518      109002 :                   IsAnonymousExpression::encode(is_anonymous);
    2519             :   }
    2520             : 
    2521             :   int end_position_;
    2522             :   Scope* scope_;
    2523             :   Variable* class_variable_;
    2524             :   Expression* extends_;
    2525             :   FunctionLiteral* constructor_;
    2526             :   ZonePtrList<Property>* properties_;
    2527             :   FunctionLiteral* static_fields_initializer_;
    2528             :   FunctionLiteral* instance_members_initializer_function_;
    2529             :   class HasNameStaticProperty
    2530             :       : public BitField<bool, Expression::kNextBitFieldIndex, 1> {};
    2531             :   class HasStaticComputedNames
    2532             :       : public BitField<bool, HasNameStaticProperty::kNext, 1> {};
    2533             :   class IsAnonymousExpression
    2534             :       : public BitField<bool, HasStaticComputedNames::kNext, 1> {};
    2535             : };
    2536             : 
    2537             : 
    2538             : class NativeFunctionLiteral final : public Expression {
    2539             :  public:
    2540        3468 :   Handle<String> name() const { return name_->string(); }
    2541             :   const AstRawString* raw_name() const { return name_; }
    2542             :   v8::Extension* extension() const { return extension_; }
    2543             : 
    2544             :  private:
    2545             :   friend class AstNodeFactory;
    2546             : 
    2547             :   NativeFunctionLiteral(const AstRawString* name, v8::Extension* extension,
    2548             :                         int pos)
    2549             :       : Expression(pos, kNativeFunctionLiteral),
    2550             :         name_(name),
    2551        1734 :         extension_(extension) {}
    2552             : 
    2553             :   const AstRawString* name_;
    2554             :   v8::Extension* extension_;
    2555             : };
    2556             : 
    2557             : 
    2558             : class SuperPropertyReference final : public Expression {
    2559             :  public:
    2560             :   Expression* home_object() const { return home_object_; }
    2561             : 
    2562             :  private:
    2563             :   friend class AstNodeFactory;
    2564             : 
    2565             :   // We take in ThisExpression* only as a proof that it was accessed.
    2566             :   SuperPropertyReference(Expression* home_object, int pos)
    2567        2758 :       : Expression(pos, kSuperPropertyReference), home_object_(home_object) {
    2568             :     DCHECK(home_object->IsProperty());
    2569             :   }
    2570             : 
    2571             :   Expression* home_object_;
    2572             : };
    2573             : 
    2574             : 
    2575             : class SuperCallReference final : public Expression {
    2576             :  public:
    2577             :   VariableProxy* new_target_var() const { return new_target_var_; }
    2578             :   VariableProxy* this_function_var() const { return this_function_var_; }
    2579             : 
    2580             :  private:
    2581             :   friend class AstNodeFactory;
    2582             : 
    2583             :   // We take in ThisExpression* only as a proof that it was accessed.
    2584             :   SuperCallReference(VariableProxy* new_target_var,
    2585             :                      VariableProxy* this_function_var, int pos)
    2586             :       : Expression(pos, kSuperCallReference),
    2587             :         new_target_var_(new_target_var),
    2588       30630 :         this_function_var_(this_function_var) {
    2589             :     DCHECK(new_target_var->raw_name()->IsOneByteEqualTo(".new.target"));
    2590             :     DCHECK(this_function_var->raw_name()->IsOneByteEqualTo(".this_function"));
    2591             :   }
    2592             : 
    2593             :   VariableProxy* new_target_var_;
    2594             :   VariableProxy* this_function_var_;
    2595             : };
    2596             : 
    2597             : // This AST Node is used to represent a dynamic import call --
    2598             : // import(argument).
    2599             : class ImportCallExpression final : public Expression {
    2600             :  public:
    2601             :   Expression* argument() const { return argument_; }
    2602             : 
    2603             :  private:
    2604             :   friend class AstNodeFactory;
    2605             : 
    2606             :   ImportCallExpression(Expression* argument, int pos)
    2607        3598 :       : Expression(pos, kImportCallExpression), argument_(argument) {}
    2608             : 
    2609             :   Expression* argument_;
    2610             : };
    2611             : 
    2612             : // This class is produced when parsing the () in arrow functions without any
    2613             : // arguments and is not actually a valid expression.
    2614             : class EmptyParentheses final : public Expression {
    2615             :  private:
    2616             :   friend class AstNodeFactory;
    2617             : 
    2618             :   explicit EmptyParentheses(int pos) : Expression(pos, kEmptyParentheses) {
    2619             :     mark_parenthesized();
    2620             :   }
    2621             : };
    2622             : 
    2623             : // Represents the spec operation `GetTemplateObject(templateLiteral)`
    2624             : // (defined at https://tc39.github.io/ecma262/#sec-gettemplateobject).
    2625             : class GetTemplateObject final : public Expression {
    2626             :  public:
    2627             :   const ZonePtrList<const AstRawString>* cooked_strings() const {
    2628             :     return cooked_strings_;
    2629             :   }
    2630             :   const ZonePtrList<const AstRawString>* raw_strings() const {
    2631             :     return raw_strings_;
    2632             :   }
    2633             : 
    2634             :   Handle<TemplateObjectDescription> GetOrBuildDescription(Isolate* isolate);
    2635             : 
    2636             :  private:
    2637             :   friend class AstNodeFactory;
    2638             : 
    2639             :   GetTemplateObject(const ZonePtrList<const AstRawString>* cooked_strings,
    2640             :                     const ZonePtrList<const AstRawString>* raw_strings, int pos)
    2641             :       : Expression(pos, kGetTemplateObject),
    2642             :         cooked_strings_(cooked_strings),
    2643        7176 :         raw_strings_(raw_strings) {}
    2644             : 
    2645             :   const ZonePtrList<const AstRawString>* cooked_strings_;
    2646             :   const ZonePtrList<const AstRawString>* raw_strings_;
    2647             : };
    2648             : 
    2649             : class TemplateLiteral final : public Expression {
    2650             :  public:
    2651             :   const ZonePtrList<const AstRawString>* string_parts() const {
    2652             :     return string_parts_;
    2653             :   }
    2654             :   const ZonePtrList<Expression>* substitutions() const {
    2655             :     return substitutions_;
    2656             :   }
    2657             : 
    2658             :  private:
    2659             :   friend class AstNodeFactory;
    2660             :   TemplateLiteral(const ZonePtrList<const AstRawString>* parts,
    2661             :                   const ZonePtrList<Expression>* substitutions, int pos)
    2662             :       : Expression(pos, kTemplateLiteral),
    2663             :         string_parts_(parts),
    2664       20613 :         substitutions_(substitutions) {}
    2665             : 
    2666             :   const ZonePtrList<const AstRawString>* string_parts_;
    2667             :   const ZonePtrList<Expression>* substitutions_;
    2668             : };
    2669             : 
    2670             : // ----------------------------------------------------------------------------
    2671             : // Basic visitor
    2672             : // Sub-class should parametrize AstVisitor with itself, e.g.:
    2673             : //   class SpecificVisitor : public AstVisitor<SpecificVisitor> { ... }
    2674             : 
    2675             : template <class Subclass>
    2676             : class AstVisitor {
    2677             :  public:
    2678             :   void Visit(AstNode* node) { impl()->Visit(node); }
    2679             : 
    2680             :   void VisitDeclarations(Declaration::List* declarations) {
    2681             :     for (Declaration* decl : *declarations) Visit(decl);
    2682             :   }
    2683             : 
    2684             :   void VisitStatements(const ZonePtrList<Statement>* statements) {
    2685             :     for (int i = 0; i < statements->length(); i++) {
    2686             :       Statement* stmt = statements->at(i);
    2687             :       Visit(stmt);
    2688             :     }
    2689             :   }
    2690             : 
    2691             :   void VisitExpressions(const ZonePtrList<Expression>* expressions) {
    2692             :     for (int i = 0; i < expressions->length(); i++) {
    2693             :       // The variable statement visiting code may pass null expressions
    2694             :       // to this code. Maybe this should be handled by introducing an
    2695             :       // undefined expression or literal? Revisit this code if this
    2696             :       // changes.
    2697             :       Expression* expression = expressions->at(i);
    2698             :       if (expression != nullptr) Visit(expression);
    2699             :     }
    2700             :   }
    2701             : 
    2702             :  protected:
    2703             :   Subclass* impl() { return static_cast<Subclass*>(this); }
    2704             : };
    2705             : 
    2706             : #define GENERATE_VISIT_CASE(NodeType)                                   \
    2707             :   case AstNode::k##NodeType:                                            \
    2708             :     return this->impl()->Visit##NodeType(static_cast<NodeType*>(node));
    2709             : 
    2710             : #define GENERATE_FAILURE_CASE(NodeType) \
    2711             :   case AstNode::k##NodeType:            \
    2712             :     UNREACHABLE();
    2713             : 
    2714             : #define GENERATE_AST_VISITOR_SWITCH()        \
    2715             :   switch (node->node_type()) {               \
    2716             :     AST_NODE_LIST(GENERATE_VISIT_CASE)       \
    2717             :     FAILURE_NODE_LIST(GENERATE_FAILURE_CASE) \
    2718             :   }
    2719             : 
    2720             : #define DEFINE_AST_VISITOR_SUBCLASS_MEMBERS()               \
    2721             :  public:                                                    \
    2722             :   void VisitNoStackOverflowCheck(AstNode* node) {           \
    2723             :     GENERATE_AST_VISITOR_SWITCH()                           \
    2724             :   }                                                         \
    2725             :                                                             \
    2726             :   void Visit(AstNode* node) {                               \
    2727             :     if (CheckStackOverflow()) return;                       \
    2728             :     VisitNoStackOverflowCheck(node);                        \
    2729             :   }                                                         \
    2730             :                                                             \
    2731             :   void SetStackOverflow() { stack_overflow_ = true; }       \
    2732             :   void ClearStackOverflow() { stack_overflow_ = false; }    \
    2733             :   bool HasStackOverflow() const { return stack_overflow_; } \
    2734             :                                                             \
    2735             :   bool CheckStackOverflow() {                               \
    2736             :     if (stack_overflow_) return true;                       \
    2737             :     if (GetCurrentStackPosition() < stack_limit_) {         \
    2738             :       stack_overflow_ = true;                               \
    2739             :       return true;                                          \
    2740             :     }                                                       \
    2741             :     return false;                                           \
    2742             :   }                                                         \
    2743             :                                                             \
    2744             :  private:                                                   \
    2745             :   void InitializeAstVisitor(Isolate* isolate) {             \
    2746             :     stack_limit_ = isolate->stack_guard()->real_climit();   \
    2747             :     stack_overflow_ = false;                                \
    2748             :   }                                                         \
    2749             :                                                             \
    2750             :   void InitializeAstVisitor(uintptr_t stack_limit) {        \
    2751             :     stack_limit_ = stack_limit;                             \
    2752             :     stack_overflow_ = false;                                \
    2753             :   }                                                         \
    2754             :                                                             \
    2755             :   uintptr_t stack_limit_;                                   \
    2756             :   bool stack_overflow_
    2757             : 
    2758             : #define DEFINE_AST_VISITOR_MEMBERS_WITHOUT_STACKOVERFLOW()    \
    2759             :  public:                                                      \
    2760             :   void Visit(AstNode* node) { GENERATE_AST_VISITOR_SWITCH() } \
    2761             :                                                               \
    2762             :  private:
    2763             : 
    2764             : // ----------------------------------------------------------------------------
    2765             : // AstNode factory
    2766             : 
    2767             : class AstNodeFactory final {
    2768             :  public:
    2769     5158924 :   AstNodeFactory(AstValueFactory* ast_value_factory, Zone* zone)
    2770             :       : zone_(zone),
    2771             :         ast_value_factory_(ast_value_factory),
    2772             :         empty_statement_(new (zone) class EmptyStatement()),
    2773             :         this_expression_(new (zone) class ThisExpression()),
    2774    20635566 :         failure_expression_(new (zone) class FailureExpression()) {}
    2775             : 
    2776             :   AstNodeFactory* ast_node_factory() { return this; }
    2777             :   AstValueFactory* ast_value_factory() const { return ast_value_factory_; }
    2778             : 
    2779             :   VariableDeclaration* NewVariableDeclaration(int pos) {
    2780             :     return new (zone_) VariableDeclaration(pos);
    2781             :   }
    2782             : 
    2783             :   NestedVariableDeclaration* NewNestedVariableDeclaration(Scope* scope,
    2784             :                                                           int pos) {
    2785             :     return new (zone_) NestedVariableDeclaration(scope, pos);
    2786             :   }
    2787             : 
    2788             :   FunctionDeclaration* NewFunctionDeclaration(FunctionLiteral* fun, int pos) {
    2789             :     return new (zone_) FunctionDeclaration(fun, pos);
    2790             :   }
    2791             : 
    2792      588582 :   Block* NewBlock(int capacity, bool ignore_completion_value) {
    2793     1177179 :     return new (zone_) Block(zone_, nullptr, capacity, ignore_completion_value);
    2794             :   }
    2795             : 
    2796    10109912 :   Block* NewBlock(bool ignore_completion_value,
    2797             :                   ZonePtrList<const AstRawString>* labels) {
    2798             :     return labels != nullptr
    2799        6635 :                ? new (zone_) LabeledBlock(labels, ignore_completion_value)
    2800    30323099 :                : new (zone_) Block(labels, ignore_completion_value);
    2801             :   }
    2802             : 
    2803     9163649 :   Block* NewBlock(bool ignore_completion_value,
    2804     9163649 :                   const ScopedPtrList<Statement>& statements) {
    2805    18327298 :     Block* result = NewBlock(ignore_completion_value, nullptr);
    2806     9163597 :     result->InitializeStatements(statements, zone_);
    2807     9163602 :     return result;
    2808             :   }
    2809             : 
    2810             : #define STATEMENT_WITH_LABELS(NodeType)                                \
    2811             :   NodeType* New##NodeType(ZonePtrList<const AstRawString>* labels,     \
    2812             :                           ZonePtrList<const AstRawString>* own_labels, \
    2813             :                           int pos) {                                   \
    2814             :     return new (zone_) NodeType(labels, own_labels, pos);              \
    2815             :   }
    2816             :   STATEMENT_WITH_LABELS(DoWhileStatement)
    2817             :   STATEMENT_WITH_LABELS(WhileStatement)
    2818      608810 :   STATEMENT_WITH_LABELS(ForStatement)
    2819             : #undef STATEMENT_WITH_LABELS
    2820             : 
    2821       14302 :   SwitchStatement* NewSwitchStatement(ZonePtrList<const AstRawString>* labels,
    2822             :                                       Expression* tag, int pos) {
    2823       42905 :     return new (zone_) SwitchStatement(zone_, labels, tag, pos);
    2824             :   }
    2825             : 
    2826      149101 :   ForEachStatement* NewForEachStatement(
    2827             :       ForEachStatement::VisitMode visit_mode,
    2828             :       ZonePtrList<const AstRawString>* labels,
    2829             :       ZonePtrList<const AstRawString>* own_labels, int pos) {
    2830      149101 :     switch (visit_mode) {
    2831             :       case ForEachStatement::ENUMERATE: {
    2832       47500 :         return new (zone_) ForInStatement(labels, own_labels, pos);
    2833             :       }
    2834             :       case ForEachStatement::ITERATE: {
    2835             :         return new (zone_)
    2836      101601 :             ForOfStatement(labels, own_labels, pos, IteratorType::kNormal);
    2837             :       }
    2838             :     }
    2839           0 :     UNREACHABLE();
    2840             :   }
    2841             : 
    2842             :   ForOfStatement* NewForOfStatement(ZonePtrList<const AstRawString>* labels,
    2843             :                                     ZonePtrList<const AstRawString>* own_labels,
    2844             :                                     int pos, IteratorType type) {
    2845             :     return new (zone_) ForOfStatement(labels, own_labels, pos, type);
    2846             :   }
    2847             : 
    2848       40177 :   ExpressionStatement* NewExpressionStatement(Expression* expression, int pos) {
    2849       80355 :     return new (zone_) ExpressionStatement(expression, pos);
    2850             :   }
    2851             : 
    2852             :   ContinueStatement* NewContinueStatement(IterationStatement* target, int pos) {
    2853             :     return new (zone_) ContinueStatement(target, pos);
    2854             :   }
    2855             : 
    2856             :   BreakStatement* NewBreakStatement(BreakableStatement* target, int pos) {
    2857             :     return new (zone_) BreakStatement(target, pos);
    2858             :   }
    2859             : 
    2860             :   ReturnStatement* NewReturnStatement(Expression* expression, int pos,
    2861             :                                       int end_position = kNoSourcePosition) {
    2862             :     return new (zone_) ReturnStatement(expression, ReturnStatement::kNormal,
    2863             :                                        pos, end_position);
    2864             :   }
    2865             : 
    2866             :   ReturnStatement* NewAsyncReturnStatement(
    2867             :       Expression* expression, int pos, int end_position = kNoSourcePosition) {
    2868             :     return new (zone_) ReturnStatement(
    2869             :         expression, ReturnStatement::kAsyncReturn, pos, end_position);
    2870             :   }
    2871             : 
    2872             :   WithStatement* NewWithStatement(Scope* scope,
    2873             :                                   Expression* expression,
    2874             :                                   Statement* statement,
    2875             :                                   int pos) {
    2876             :     return new (zone_) WithStatement(scope, expression, statement, pos);
    2877             :   }
    2878             : 
    2879             :   IfStatement* NewIfStatement(Expression* condition, Statement* then_statement,
    2880             :                               Statement* else_statement, int pos) {
    2881             :     return new (zone_)
    2882             :         IfStatement(condition, then_statement, else_statement, pos);
    2883             :   }
    2884             : 
    2885             :   TryCatchStatement* NewTryCatchStatement(Block* try_block, Scope* scope,
    2886             :                                           Block* catch_block, int pos) {
    2887             :     return new (zone_) TryCatchStatement(try_block, scope, catch_block,
    2888             :                                          HandlerTable::CAUGHT, pos);
    2889             :   }
    2890             : 
    2891             :   TryCatchStatement* NewTryCatchStatementForReThrow(Block* try_block,
    2892             :                                                     Scope* scope,
    2893             :                                                     Block* catch_block,
    2894             :                                                     int pos) {
    2895             :     return new (zone_) TryCatchStatement(try_block, scope, catch_block,
    2896             :                                          HandlerTable::UNCAUGHT, pos);
    2897             :   }
    2898             : 
    2899             :   TryCatchStatement* NewTryCatchStatementForDesugaring(Block* try_block,
    2900             :                                                        Scope* scope,
    2901             :                                                        Block* catch_block,
    2902             :                                                        int pos) {
    2903             :     return new (zone_) TryCatchStatement(try_block, scope, catch_block,
    2904             :                                          HandlerTable::DESUGARING, pos);
    2905             :   }
    2906             : 
    2907             :   TryCatchStatement* NewTryCatchStatementForAsyncAwait(Block* try_block,
    2908             :                                                        Scope* scope,
    2909             :                                                        Block* catch_block,
    2910             :                                                        int pos) {
    2911             :     return new (zone_) TryCatchStatement(try_block, scope, catch_block,
    2912             :                                          HandlerTable::ASYNC_AWAIT, pos);
    2913             :   }
    2914             : 
    2915             :   TryFinallyStatement* NewTryFinallyStatement(Block* try_block,
    2916             :                                               Block* finally_block, int pos) {
    2917             :     return new (zone_) TryFinallyStatement(try_block, finally_block, pos);
    2918             :   }
    2919             : 
    2920             :   DebuggerStatement* NewDebuggerStatement(int pos) {
    2921             :     return new (zone_) DebuggerStatement(pos);
    2922             :   }
    2923             : 
    2924             :   class EmptyStatement* EmptyStatement() {
    2925             :     return empty_statement_;
    2926             :   }
    2927             : 
    2928             :   class ThisExpression* ThisExpression() {
    2929             :     return this_expression_;
    2930             :   }
    2931             : 
    2932             :   class FailureExpression* FailureExpression() {
    2933             :     return failure_expression_;
    2934             :   }
    2935             : 
    2936       11610 :   SloppyBlockFunctionStatement* NewSloppyBlockFunctionStatement(
    2937       11610 :       int pos, Variable* var, Token::Value init) {
    2938             :     return new (zone_)
    2939       23220 :         SloppyBlockFunctionStatement(pos, var, init, EmptyStatement());
    2940             :   }
    2941             : 
    2942       88854 :   CaseClause* NewCaseClause(Expression* label,
    2943             :                             const ScopedPtrList<Statement>& statements) {
    2944      177708 :     return new (zone_) CaseClause(zone_, label, statements);
    2945             :   }
    2946             : 
    2947             :   Literal* NewStringLiteral(const AstRawString* string, int pos) {
    2948             :     DCHECK_NOT_NULL(string);
    2949             :     return new (zone_) Literal(string, pos);
    2950             :   }
    2951             : 
    2952             :   // A JavaScript symbol (ECMA-262 edition 6).
    2953             :   Literal* NewSymbolLiteral(AstSymbol symbol, int pos) {
    2954             :     return new (zone_) Literal(symbol, pos);
    2955             :   }
    2956             : 
    2957             :   Literal* NewNumberLiteral(double number, int pos);
    2958             : 
    2959             :   Literal* NewSmiLiteral(int number, int pos) {
    2960             :     return new (zone_) Literal(number, pos);
    2961             :   }
    2962             : 
    2963             :   Literal* NewBigIntLiteral(AstBigInt bigint, int pos) {
    2964             :     return new (zone_) Literal(bigint, pos);
    2965             :   }
    2966             : 
    2967             :   Literal* NewBooleanLiteral(bool b, int pos) {
    2968             :     return new (zone_) Literal(b, pos);
    2969             :   }
    2970             : 
    2971             :   Literal* NewNullLiteral(int pos) {
    2972             :     return new (zone_) Literal(Literal::kNull, pos);
    2973             :   }
    2974             : 
    2975             :   Literal* NewUndefinedLiteral(int pos) {
    2976             :     return new (zone_) Literal(Literal::kUndefined, pos);
    2977             :   }
    2978             : 
    2979             :   Literal* NewTheHoleLiteral() {
    2980             :     return new (zone_) Literal(Literal::kTheHole, kNoSourcePosition);
    2981             :   }
    2982             : 
    2983      586979 :   ObjectLiteral* NewObjectLiteral(
    2984             :       const ScopedPtrList<ObjectLiteral::Property>& properties,
    2985             :       uint32_t boilerplate_properties, int pos, bool has_rest_property) {
    2986             :     return new (zone_) ObjectLiteral(zone_, properties, boilerplate_properties,
    2987     1174003 :                                      pos, has_rest_property);
    2988             :   }
    2989             : 
    2990             :   ObjectLiteral::Property* NewObjectLiteralProperty(
    2991             :       Expression* key, Expression* value, ObjectLiteralProperty::Kind kind,
    2992             :       bool is_computed_name) {
    2993             :     return new (zone_)
    2994      136954 :         ObjectLiteral::Property(key, value, kind, is_computed_name);
    2995             :   }
    2996             : 
    2997     2899190 :   ObjectLiteral::Property* NewObjectLiteralProperty(Expression* key,
    2998             :                                                     Expression* value,
    2999             :                                                     bool is_computed_name) {
    3000             :     return new (zone_) ObjectLiteral::Property(ast_value_factory_, key, value,
    3001     5798399 :                                                is_computed_name);
    3002             :   }
    3003             : 
    3004             :   RegExpLiteral* NewRegExpLiteral(const AstRawString* pattern, int flags,
    3005             :                                   int pos) {
    3006             :     return new (zone_) RegExpLiteral(pattern, flags, pos);
    3007             :   }
    3008             : 
    3009             :   ArrayLiteral* NewArrayLiteral(const ScopedPtrList<Expression>& values,
    3010             :                                 int pos) {
    3011             :     return new (zone_) ArrayLiteral(zone_, values, -1, pos);
    3012             :   }
    3013             : 
    3014      734191 :   ArrayLiteral* NewArrayLiteral(const ScopedPtrList<Expression>& values,
    3015             :                                 int first_spread_index, int pos) {
    3016     1468392 :     return new (zone_) ArrayLiteral(zone_, values, first_spread_index, pos);
    3017             :   }
    3018             : 
    3019             :   VariableProxy* NewVariableProxy(Variable* var,
    3020             :                                   int start_position = kNoSourcePosition) {
    3021     2897818 :     return new (zone_) VariableProxy(var, start_position);
    3022             :   }
    3023             : 
    3024             :   VariableProxy* NewVariableProxy(const AstRawString* name,
    3025             :                                   VariableKind variable_kind,
    3026             :                                   int start_position = kNoSourcePosition) {
    3027             :     DCHECK_NOT_NULL(name);
    3028             :     return new (zone_) VariableProxy(name, variable_kind, start_position);
    3029             :   }
    3030             : 
    3031             :   // Recreates the VariableProxy in this Zone.
    3032             :   VariableProxy* CopyVariableProxy(VariableProxy* proxy) {
    3033     6503522 :     return new (zone_) VariableProxy(proxy);
    3034             :   }
    3035             : 
    3036             :   Variable* CopyVariable(Variable* variable) {
    3037      844289 :     return new (zone_) Variable(variable);
    3038             :   }
    3039             : 
    3040             :   Property* NewProperty(Expression* obj, Expression* key, int pos) {
    3041             :     return new (zone_) Property(obj, key, pos);
    3042             :   }
    3043             : 
    3044             :   ResolvedProperty* NewResolvedProperty(VariableProxy* obj,
    3045             :                                         VariableProxy* property,
    3046             :                                         int pos = kNoSourcePosition) {
    3047             :     return new (zone_) ResolvedProperty(obj, property, pos);
    3048             :   }
    3049             : 
    3050     6425413 :   Call* NewCall(Expression* expression,
    3051             :                 const ScopedPtrList<Expression>& arguments, int pos,
    3052             :                 Call::PossiblyEval possibly_eval = Call::NOT_EVAL) {
    3053    12850847 :     return new (zone_) Call(zone_, expression, arguments, pos, possibly_eval);
    3054             :   }
    3055             : 
    3056        7176 :   Call* NewTaggedTemplate(Expression* expression,
    3057             :                           const ScopedPtrList<Expression>& arguments, int pos) {
    3058             :     return new (zone_)
    3059       14352 :         Call(zone_, expression, arguments, pos, Call::TaggedTemplateTag::kTrue);
    3060             :   }
    3061             : 
    3062      167892 :   CallNew* NewCallNew(Expression* expression,
    3063             :                       const ScopedPtrList<Expression>& arguments, int pos) {
    3064      335793 :     return new (zone_) CallNew(zone_, expression, arguments, pos);
    3065             :   }
    3066             : 
    3067       98227 :   CallRuntime* NewCallRuntime(Runtime::FunctionId id,
    3068             :                               const ScopedPtrList<Expression>& arguments,
    3069             :                               int pos) {
    3070             :     return new (zone_)
    3071      196453 :         CallRuntime(zone_, Runtime::FunctionForId(id), arguments, pos);
    3072             :   }
    3073             : 
    3074       54044 :   CallRuntime* NewCallRuntime(const Runtime::Function* function,
    3075             :                               const ScopedPtrList<Expression>& arguments,
    3076             :                               int pos) {
    3077      108097 :     return new (zone_) CallRuntime(zone_, function, arguments, pos);
    3078             :   }
    3079             : 
    3080         702 :   CallRuntime* NewCallRuntime(int context_index,
    3081             :                               const ScopedPtrList<Expression>& arguments,
    3082             :                               int pos) {
    3083        1404 :     return new (zone_) CallRuntime(zone_, context_index, arguments, pos);
    3084             :   }
    3085             : 
    3086             :   UnaryOperation* NewUnaryOperation(Token::Value op,
    3087             :                                     Expression* expression,
    3088             :                                     int pos) {
    3089             :     return new (zone_) UnaryOperation(op, expression, pos);
    3090             :   }
    3091             : 
    3092             :   BinaryOperation* NewBinaryOperation(Token::Value op,
    3093             :                                       Expression* left,
    3094             :                                       Expression* right,
    3095             :                                       int pos) {
    3096             :     return new (zone_) BinaryOperation(op, left, right, pos);
    3097             :   }
    3098             : 
    3099      131174 :   NaryOperation* NewNaryOperation(Token::Value op, Expression* first,
    3100             :                                   size_t initial_subsequent_size) {
    3101      393530 :     return new (zone_) NaryOperation(zone_, op, first, initial_subsequent_size);
    3102             :   }
    3103             : 
    3104      215911 :   CountOperation* NewCountOperation(Token::Value op,
    3105             :                                     bool is_prefix,
    3106             :                                     Expression* expr,
    3107             :                                     int pos) {
    3108      431827 :     return new (zone_) CountOperation(op, is_prefix, expr, pos);
    3109             :   }
    3110             : 
    3111             :   CompareOperation* NewCompareOperation(Token::Value op,
    3112             :                                         Expression* left,
    3113             :                                         Expression* right,
    3114             :                                         int pos) {
    3115             :     return new (zone_) CompareOperation(op, left, right, pos);
    3116             :   }
    3117             : 
    3118             :   Spread* NewSpread(Expression* expression, int pos, int expr_pos) {
    3119             :     return new (zone_) Spread(expression, pos, expr_pos);
    3120             :   }
    3121             : 
    3122             :   StoreInArrayLiteral* NewStoreInArrayLiteral(Expression* array,
    3123             :                                               Expression* index,
    3124             :                                               Expression* value, int pos) {
    3125             :     return new (zone_) StoreInArrayLiteral(array, index, value, pos);
    3126             :   }
    3127             : 
    3128             :   Conditional* NewConditional(Expression* condition,
    3129             :                               Expression* then_expression,
    3130             :                               Expression* else_expression,
    3131             :                               int position) {
    3132             :     return new (zone_)
    3133             :         Conditional(condition, then_expression, else_expression, position);
    3134             :   }
    3135             : 
    3136    14168272 :   Assignment* NewAssignment(Token::Value op,
    3137             :                             Expression* target,
    3138             :                             Expression* value,
    3139      102709 :                             int pos) {
    3140             :     DCHECK(Token::IsAssignmentOp(op));
    3141             :     DCHECK_NOT_NULL(target);
    3142             :     DCHECK_NOT_NULL(value);
    3143             : 
    3144    21034869 :     if (op != Token::INIT && target->IsVariableProxy()) {
    3145     2812420 :       target->AsVariableProxy()->set_is_assigned();
    3146             :     }
    3147             : 
    3148    14168306 :     if (op == Token::ASSIGN || op == Token::INIT) {
    3149             :       return new (zone_)
    3150    28131259 :           Assignment(AstNode::kAssignment, op, target, value, pos);
    3151             :     } else {
    3152             :       return new (zone_) CompoundAssignment(
    3153             :           op, target, value, pos,
    3154             :           NewBinaryOperation(Token::BinaryOpForAssignment(op), target, value,
    3155      308125 :                              pos + 1));
    3156             :     }
    3157             :   }
    3158             : 
    3159      108492 :   Suspend* NewYield(Expression* expression, int pos,
    3160        5433 :                     Suspend::OnAbruptResume on_abrupt_resume) {
    3161      108492 :     if (!expression) expression = NewUndefinedLiteral(pos);
    3162      216984 :     return new (zone_) Yield(expression, pos, on_abrupt_resume);
    3163             :   }
    3164             : 
    3165             :   YieldStar* NewYieldStar(Expression* expression, int pos) {
    3166             :     return new (zone_) YieldStar(expression, pos);
    3167             :   }
    3168             : 
    3169       52558 :   Await* NewAwait(Expression* expression, int pos) {
    3170       52558 :     if (!expression) expression = NewUndefinedLiteral(pos);
    3171      105116 :     return new (zone_) Await(expression, pos);
    3172             :   }
    3173             : 
    3174       40180 :   Throw* NewThrow(Expression* exception, int pos) {
    3175       80361 :     return new (zone_) Throw(exception, pos);
    3176             :   }
    3177             : 
    3178     4437158 :   FunctionLiteral* NewFunctionLiteral(
    3179             :       const AstRawString* name, DeclarationScope* scope,
    3180             :       const ScopedPtrList<Statement>& body, int expected_property_count,
    3181             :       int parameter_count, int function_length,
    3182             :       FunctionLiteral::ParameterFlag has_duplicate_parameters,
    3183             :       FunctionLiteral::FunctionType function_type,
    3184             :       FunctionLiteral::EagerCompileHint eager_compile_hint, int position,
    3185             :       bool has_braces, int function_literal_id,
    3186             :       ProducedPreparseData* produced_preparse_data = nullptr) {
    3187             :     return new (zone_) FunctionLiteral(
    3188             :         zone_, name, ast_value_factory_, scope, body, expected_property_count,
    3189             :         parameter_count, function_length, function_type,
    3190             :         has_duplicate_parameters, eager_compile_hint, position, has_braces,
    3191     8874353 :         function_literal_id, produced_preparse_data);
    3192             :   }
    3193             : 
    3194             :   // Creates a FunctionLiteral representing a top-level script, the
    3195             :   // result of an eval (top-level or otherwise), or the result of calling
    3196             :   // the Function constructor.
    3197     1730840 :   FunctionLiteral* NewScriptOrEvalFunctionLiteral(
    3198             :       DeclarationScope* scope, const ScopedPtrList<Statement>& body,
    3199             :       int expected_property_count, int parameter_count) {
    3200             :     return new (zone_) FunctionLiteral(
    3201     1730840 :         zone_, ast_value_factory_->empty_string(), ast_value_factory_, scope,
    3202             :         body, expected_property_count, parameter_count, parameter_count,
    3203             :         FunctionLiteral::kAnonymousExpression,
    3204             :         FunctionLiteral::kNoDuplicateParameters,
    3205             :         FunctionLiteral::kShouldLazyCompile, 0, /* has_braces */ false,
    3206     3461766 :         FunctionLiteral::kIdTypeTopLevel);
    3207             :   }
    3208             : 
    3209             :   ClassLiteral::Property* NewClassLiteralProperty(
    3210             :       Expression* key, Expression* value, ClassLiteralProperty::Kind kind,
    3211             :       bool is_static, bool is_computed_name, bool is_private) {
    3212             :     return new (zone_) ClassLiteral::Property(key, value, kind, is_static,
    3213      436430 :                                               is_computed_name, is_private);
    3214             :   }
    3215             : 
    3216      109003 :   ClassLiteral* NewClassLiteral(
    3217             :       Scope* scope, Variable* variable, Expression* extends,
    3218             :       FunctionLiteral* constructor,
    3219             :       ZonePtrList<ClassLiteral::Property>* properties,
    3220             :       FunctionLiteral* static_fields_initializer,
    3221             :       FunctionLiteral* instance_members_initializer_function,
    3222             :       int start_position, int end_position, bool has_name_static_property,
    3223             :       bool has_static_computed_names, bool is_anonymous) {
    3224             :     return new (zone_) ClassLiteral(
    3225             :         scope, variable, extends, constructor, properties,
    3226             :         static_fields_initializer, instance_members_initializer_function,
    3227             :         start_position, end_position, has_name_static_property,
    3228      218005 :         has_static_computed_names, is_anonymous);
    3229             :   }
    3230             : 
    3231             :   NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name,
    3232             :                                                   v8::Extension* extension,
    3233             :                                                   int pos) {
    3234             :     return new (zone_) NativeFunctionLiteral(name, extension, pos);
    3235             :   }
    3236             : 
    3237             :   DoExpression* NewDoExpression(Block* block, Variable* result_var, int pos) {
    3238             :     VariableProxy* result = NewVariableProxy(result_var, pos);
    3239             :     return new (zone_) DoExpression(block, result, pos);
    3240             :   }
    3241             : 
    3242             :   SuperPropertyReference* NewSuperPropertyReference(Expression* home_object,
    3243             :                                                     int pos) {
    3244             :     return new (zone_) SuperPropertyReference(home_object, pos);
    3245             :   }
    3246             : 
    3247             :   SuperCallReference* NewSuperCallReference(VariableProxy* new_target_var,
    3248             :                                             VariableProxy* this_function_var,
    3249             :                                             int pos) {
    3250             :     return new (zone_)
    3251             :         SuperCallReference(new_target_var, this_function_var, pos);
    3252             :   }
    3253             : 
    3254             :   EmptyParentheses* NewEmptyParentheses(int pos) {
    3255             :     return new (zone_) EmptyParentheses(pos);
    3256             :   }
    3257             : 
    3258             :   GetTemplateObject* NewGetTemplateObject(
    3259             :       const ZonePtrList<const AstRawString>* cooked_strings,
    3260             :       const ZonePtrList<const AstRawString>* raw_strings, int pos) {
    3261             :     return new (zone_) GetTemplateObject(cooked_strings, raw_strings, pos);
    3262             :   }
    3263             : 
    3264             :   TemplateLiteral* NewTemplateLiteral(
    3265             :       const ZonePtrList<const AstRawString>* string_parts,
    3266             :       const ZonePtrList<Expression>* substitutions, int pos) {
    3267             :     return new (zone_) TemplateLiteral(string_parts, substitutions, pos);
    3268             :   }
    3269             : 
    3270             :   ImportCallExpression* NewImportCallExpression(Expression* args, int pos) {
    3271             :     return new (zone_) ImportCallExpression(args, pos);
    3272             :   }
    3273             : 
    3274             :   InitializeClassMembersStatement* NewInitializeClassMembersStatement(
    3275             :       ZonePtrList<ClassLiteral::Property>* args, int pos) {
    3276             :     return new (zone_) InitializeClassMembersStatement(args, pos);
    3277             :   }
    3278             : 
    3279             :   Zone* zone() const { return zone_; }
    3280             : 
    3281             :  private:
    3282             :   // This zone may be deallocated upon returning from parsing a function body
    3283             :   // which we can guarantee is not going to be compiled or have its AST
    3284             :   // inspected.
    3285             :   // See ParseFunctionLiteral in parser.cc for preconditions.
    3286             :   Zone* zone_;
    3287             :   AstValueFactory* ast_value_factory_;
    3288             :   class EmptyStatement* empty_statement_;
    3289             :   class ThisExpression* this_expression_;
    3290             :   class FailureExpression* failure_expression_;
    3291             : };
    3292             : 
    3293             : 
    3294             : // Type testing & conversion functions overridden by concrete subclasses.
    3295             : // Inline functions for AstNode.
    3296             : 
    3297             : #define DECLARE_NODE_FUNCTIONS(type)                                         \
    3298             :   bool AstNode::Is##type() const { return node_type() == AstNode::k##type; } \
    3299             :   type* AstNode::As##type() {                                                \
    3300             :     return node_type() == AstNode::k##type ? reinterpret_cast<type*>(this)   \
    3301             :                                            : nullptr;                        \
    3302             :   }                                                                          \
    3303             :   const type* AstNode::As##type() const {                                    \
    3304             :     return node_type() == AstNode::k##type                                   \
    3305             :                ? reinterpret_cast<const type*>(this)                         \
    3306             :                : nullptr;                                                    \
    3307             :   }
    3308   399719364 : AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
    3309    17806989 : FAILURE_NODE_LIST(DECLARE_NODE_FUNCTIONS)
    3310             : #undef DECLARE_NODE_FUNCTIONS
    3311             : 
    3312             : }  // namespace internal
    3313             : }  // namespace v8
    3314             : 
    3315             : #endif  // V8_AST_AST_H_

Generated by: LCOV version 1.10