LCOV - code coverage report
Current view: top level - src/parsing - parser-base.h (source / functions) Hit Total Coverage
Test: app.info Lines: 2087 2121 98.4 %
Date: 2017-10-20 Functions: 288 290 99.3 %

          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_PARSING_PARSER_BASE_H
       6             : #define V8_PARSING_PARSER_BASE_H
       7             : 
       8             : #include <vector>
       9             : 
      10             : #include "src/ast/ast-source-ranges.h"
      11             : #include "src/ast/ast.h"
      12             : #include "src/ast/scopes.h"
      13             : #include "src/bailout-reason.h"
      14             : #include "src/base/hashmap.h"
      15             : #include "src/counters.h"
      16             : #include "src/globals.h"
      17             : #include "src/messages.h"
      18             : #include "src/parsing/expression-classifier.h"
      19             : #include "src/parsing/func-name-inferrer.h"
      20             : #include "src/parsing/scanner.h"
      21             : #include "src/parsing/token.h"
      22             : 
      23             : namespace v8 {
      24             : namespace internal {
      25             : 
      26             : enum FunctionNameValidity {
      27             :   kFunctionNameIsStrictReserved,
      28             :   kSkipFunctionNameCheck,
      29             :   kFunctionNameValidityUnknown
      30             : };
      31             : 
      32             : enum AllowLabelledFunctionStatement {
      33             :   kAllowLabelledFunctionStatement,
      34             :   kDisallowLabelledFunctionStatement,
      35             : };
      36             : 
      37             : enum class ParseFunctionFlags {
      38             :   kIsNormal = 0,
      39             :   kIsGenerator = 1,
      40             :   kIsAsync = 2,
      41             :   kIsDefault = 4
      42             : };
      43             : 
      44             : static inline ParseFunctionFlags operator|(ParseFunctionFlags lhs,
      45             :                                            ParseFunctionFlags rhs) {
      46             :   typedef unsigned char T;
      47             :   return static_cast<ParseFunctionFlags>(static_cast<T>(lhs) |
      48             :                                          static_cast<T>(rhs));
      49             : }
      50             : 
      51             : static inline ParseFunctionFlags& operator|=(ParseFunctionFlags& lhs,
      52             :                                              const ParseFunctionFlags& rhs) {
      53             :   lhs = lhs | rhs;
      54             :   return lhs;
      55             : }
      56             : 
      57             : static inline bool operator&(ParseFunctionFlags bitfield,
      58             :                              ParseFunctionFlags mask) {
      59             :   typedef unsigned char T;
      60     1522813 :   return static_cast<T>(bitfield) & static_cast<T>(mask);
      61             : }
      62             : 
      63             : struct FormalParametersBase {
      64     6516395 :   explicit FormalParametersBase(DeclarationScope* scope) : scope(scope) {}
      65             : 
      66             :   int num_parameters() const {
      67             :     // Don't include the rest parameter into the function's formal parameter
      68             :     // count (esp. the SharedFunctionInfo::internal_formal_parameter_count,
      69             :     // which says whether we need to create an arguments adaptor frame).
      70     5748381 :     return arity - has_rest;
      71             :   }
      72             : 
      73     8591185 :   void UpdateArityAndFunctionLength(bool is_optional, bool is_rest) {
      74     8591185 :     if (!is_optional && !is_rest && function_length == arity) {
      75     8482612 :       ++function_length;
      76             :     }
      77     8591185 :     ++arity;
      78     8591185 :   }
      79             : 
      80             :   DeclarationScope* scope;
      81             :   bool has_rest = false;
      82             :   bool is_simple = true;
      83             :   int function_length = 0;
      84             :   int arity = 0;
      85             : };
      86             : 
      87             : // Stack-allocated scope to collect source ranges from the parser.
      88             : class SourceRangeScope final {
      89             :  public:
      90             :   enum PositionKind {
      91             :     POSITION_BEG,
      92             :     POSITION_END,
      93             :     PEEK_POSITION_BEG,
      94             :     PEEK_POSITION_END,
      95             :   };
      96             : 
      97             :   SourceRangeScope(Scanner* scanner, SourceRange* range,
      98             :                    PositionKind pre_kind = PEEK_POSITION_BEG,
      99             :                    PositionKind post_kind = POSITION_END)
     100     8384502 :       : scanner_(scanner), range_(range), post_kind_(post_kind) {
     101     8384502 :     range_->start = GetPosition(pre_kind);
     102             :     DCHECK_NE(range_->start, kNoSourcePosition);
     103             :   }
     104             : 
     105     2324649 :   ~SourceRangeScope() { Finalize(); }
     106             : 
     107     9664060 :   const SourceRange& Finalize() {
     108     9664060 :     if (is_finalized_) return *range_;
     109     8384501 :     is_finalized_ = true;
     110     8384501 :     range_->end = GetPosition(post_kind_);
     111             :     DCHECK_NE(range_->end, kNoSourcePosition);
     112     8384501 :     return *range_;
     113             :   }
     114             : 
     115             :  private:
     116    16769002 :   int32_t GetPosition(PositionKind kind) {
     117    16769002 :     switch (kind) {
     118             :       case POSITION_BEG:
     119           0 :         return scanner_->location().beg_pos;
     120             :       case POSITION_END:
     121     8384501 :         return scanner_->location().end_pos;
     122             :       case PEEK_POSITION_BEG:
     123     8384501 :         return scanner_->peek_location().beg_pos;
     124             :       case PEEK_POSITION_END:
     125           0 :         return scanner_->peek_location().end_pos;
     126             :       default:
     127           0 :         UNREACHABLE();
     128             :     }
     129             :   }
     130             : 
     131             :   Scanner* scanner_;
     132             :   SourceRange* range_;
     133             :   PositionKind post_kind_;
     134             :   bool is_finalized_ = false;
     135             : 
     136             :   DISALLOW_IMPLICIT_CONSTRUCTORS(SourceRangeScope);
     137             : };
     138             : 
     139             : // ----------------------------------------------------------------------------
     140             : // The CHECK_OK macro is a convenient macro to enforce error
     141             : // handling for functions that may fail (by returning !*ok).
     142             : //
     143             : // CAUTION: This macro appends extra statements after a call,
     144             : // thus it must never be used where only a single statement
     145             : // is correct (e.g. an if statement branch w/o braces)!
     146             : 
     147             : #define CHECK_OK_CUSTOM(x, ...) ok);       \
     148             :   if (!*ok) return impl()->x(__VA_ARGS__); \
     149             :   ((void)0
     150             : #define DUMMY )  // to make indentation work
     151             : #undef DUMMY
     152             : 
     153             : // Used in functions where the return type is ExpressionT.
     154             : #define CHECK_OK CHECK_OK_CUSTOM(NullExpression)
     155             : 
     156             : #define CHECK_OK_VOID ok); \
     157             :   if (!*ok) return;        \
     158             :   ((void)0
     159             : #define DUMMY )  // to make indentation work
     160             : #undef DUMMY
     161             : 
     162             : // Common base class template shared between parser and pre-parser.
     163             : // The Impl parameter is the actual class of the parser/pre-parser,
     164             : // following the Curiously Recurring Template Pattern (CRTP).
     165             : // The structure of the parser objects is roughly the following:
     166             : //
     167             : //   // A structure template containing type definitions, needed to
     168             : //   // avoid a cyclic dependency.
     169             : //   template <typename Impl>
     170             : //   struct ParserTypes;
     171             : //
     172             : //   // The parser base object, which should just implement pure
     173             : //   // parser behavior.  The Impl parameter is the actual derived
     174             : //   // class (according to CRTP), which implements impure parser
     175             : //   // behavior.
     176             : //   template <typename Impl>
     177             : //   class ParserBase { ... };
     178             : //
     179             : //   // And then, for each parser variant (e.g., parser, preparser, etc):
     180             : //   class Parser;
     181             : //
     182             : //   template <>
     183             : //   class ParserTypes<Parser> { ... };
     184             : //
     185             : //   class Parser : public ParserBase<Parser> { ... };
     186             : //
     187             : // The parser base object implements pure parsing, according to the
     188             : // language grammar.  Different parser implementations may exhibit
     189             : // different parser-driven behavior that is not considered as pure
     190             : // parsing, e.g., early error detection and reporting, AST generation, etc.
     191             : 
     192             : // The ParserTypes structure encapsulates the differences in the
     193             : // types used in parsing methods.  E.g., Parser methods use Expression*
     194             : // and PreParser methods use PreParserExpression.  For any given parser
     195             : // implementation class Impl, it is expected to contain the following typedefs:
     196             : //
     197             : // template <>
     198             : // struct ParserTypes<Impl> {
     199             : //   // Synonyms for ParserBase<Impl> and Impl, respectively.
     200             : //   typedef Base;
     201             : //   typedef Impl;
     202             : //   // Return types for traversing functions.
     203             : //   typedef Identifier;
     204             : //   typedef Expression;
     205             : //   typedef FunctionLiteral;
     206             : //   typedef ObjectLiteralProperty;
     207             : //   typedef ClassLiteralProperty;
     208             : //   typedef ExpressionList;
     209             : //   typedef ObjectPropertyList;
     210             : //   typedef ClassPropertyList;
     211             : //   typedef FormalParameters;
     212             : //   typedef Statement;
     213             : //   typedef StatementList;
     214             : //   typedef Block;
     215             : //   typedef BreakableStatement;
     216             : //   typedef ForStatement;
     217             : //   typedef IterationStatement;
     218             : //   // For constructing objects returned by the traversing functions.
     219             : //   typedef Factory;
     220             : //   // For other implementation-specific tasks.
     221             : //   typedef Target;
     222             : //   typedef TargetScope;
     223             : // };
     224             : 
     225             : template <typename Impl>
     226             : struct ParserTypes;
     227             : 
     228             : template <typename Impl>
     229             : class ParserBase {
     230             :  public:
     231             :   // Shorten type names defined by ParserTypes<Impl>.
     232             :   typedef ParserTypes<Impl> Types;
     233             :   typedef typename Types::Identifier IdentifierT;
     234             :   typedef typename Types::Expression ExpressionT;
     235             :   typedef typename Types::FunctionLiteral FunctionLiteralT;
     236             :   typedef typename Types::ObjectLiteralProperty ObjectLiteralPropertyT;
     237             :   typedef typename Types::ClassLiteralProperty ClassLiteralPropertyT;
     238             :   typedef typename Types::Suspend SuspendExpressionT;
     239             :   typedef typename Types::ExpressionList ExpressionListT;
     240             :   typedef typename Types::FormalParameters FormalParametersT;
     241             :   typedef typename Types::Statement StatementT;
     242             :   typedef typename Types::StatementList StatementListT;
     243             :   typedef typename Types::Block BlockT;
     244             :   typedef typename Types::ForStatement ForStatementT;
     245             :   typedef typename v8::internal::ExpressionClassifier<Types>
     246             :       ExpressionClassifier;
     247             : 
     248             :   // All implementation-specific methods must be called through this.
     249    29503997 :   Impl* impl() { return static_cast<Impl*>(this); }
     250             :   const Impl* impl() const { return static_cast<const Impl*>(this); }
     251             : 
     252             :   ParserBase(Zone* zone, Scanner* scanner, uintptr_t stack_limit,
     253             :              v8::Extension* extension, AstValueFactory* ast_value_factory,
     254             :              RuntimeCallStats* runtime_call_stats,
     255             :              bool parsing_on_main_thread = true)
     256             :       : scope_(nullptr),
     257             :         original_scope_(nullptr),
     258             :         function_state_(nullptr),
     259             :         extension_(extension),
     260             :         fni_(nullptr),
     261             :         ast_value_factory_(ast_value_factory),
     262             :         ast_node_factory_(ast_value_factory, zone),
     263             :         runtime_call_stats_(runtime_call_stats),
     264             :         parsing_on_main_thread_(parsing_on_main_thread),
     265             :         parsing_module_(false),
     266             :         stack_limit_(stack_limit),
     267             :         zone_(zone),
     268             :         classifier_(nullptr),
     269             :         scanner_(scanner),
     270             :         stack_overflow_(false),
     271             :         default_eager_compile_hint_(FunctionLiteral::kShouldLazyCompile),
     272             :         function_literal_id_(0),
     273             :         allow_natives_(false),
     274             :         allow_harmony_do_expressions_(false),
     275             :         allow_harmony_function_sent_(false),
     276             :         allow_harmony_restrictive_generators_(false),
     277             :         allow_harmony_class_fields_(false),
     278             :         allow_harmony_object_rest_spread_(false),
     279             :         allow_harmony_dynamic_import_(false),
     280             :         allow_harmony_import_meta_(false),
     281             :         allow_harmony_async_iteration_(false),
     282     6286744 :         allow_harmony_template_escapes_(false) {}
     283             : 
     284             : #define ALLOW_ACCESSORS(name)                           \
     285             :   bool allow_##name() const { return allow_##name##_; } \
     286             :   void set_allow_##name(bool allow) { allow_##name##_ = allow; }
     287             : 
     288     2784386 :   ALLOW_ACCESSORS(natives);
     289     2706851 :   ALLOW_ACCESSORS(harmony_do_expressions);
     290     3143200 :   ALLOW_ACCESSORS(harmony_function_sent);
     291     3143200 :   ALLOW_ACCESSORS(harmony_restrictive_generators);
     292     3143200 :   ALLOW_ACCESSORS(harmony_class_fields);
     293     3143200 :   ALLOW_ACCESSORS(harmony_object_rest_spread);
     294     3143200 :   ALLOW_ACCESSORS(harmony_dynamic_import);
     295     3143200 :   ALLOW_ACCESSORS(harmony_import_meta);
     296     3143200 :   ALLOW_ACCESSORS(harmony_async_iteration);
     297     3143200 :   ALLOW_ACCESSORS(harmony_template_escapes);
     298             : 
     299             : #undef ALLOW_ACCESSORS
     300             : 
     301      358844 :   bool allow_harmony_bigint() const {
     302      358844 :     return scanner()->allow_harmony_bigint();
     303             :   }
     304     2706851 :   void set_allow_harmony_bigint(bool allow) {
     305             :     scanner()->set_allow_harmony_bigint(allow);
     306             :   }
     307             : 
     308             :   uintptr_t stack_limit() const { return stack_limit_; }
     309             : 
     310         137 :   void set_stack_limit(uintptr_t stack_limit) { stack_limit_ = stack_limit; }
     311             : 
     312             :   void set_default_eager_compile_hint(
     313             :       FunctionLiteral::EagerCompileHint eager_compile_hint) {
     314     2348007 :     default_eager_compile_hint_ = eager_compile_hint;
     315             :   }
     316             : 
     317             :   FunctionLiteral::EagerCompileHint default_eager_compile_hint() const {
     318             :     return default_eager_compile_hint_;
     319             :   }
     320             : 
     321     6647769 :   int GetNextFunctionLiteralId() { return ++function_literal_id_; }
     322             :   int GetLastFunctionLiteralId() const { return function_literal_id_; }
     323             : 
     324     2888754 :   void SkipFunctionLiterals(int delta) { function_literal_id_ += delta; }
     325             : 
     326     4582657 :   void ResetFunctionLiteralId() { function_literal_id_ = 0; }
     327             : 
     328             :   // The Zone where the parsing outputs are stored.
     329     2396997 :   Zone* main_zone() const { return ast_value_factory()->zone(); }
     330             : 
     331             :   // The current Zone, which might be the main zone or a temporary Zone.
     332    27442335 :   Zone* zone() const { return zone_; }
     333             : 
     334             :  protected:
     335             :   friend class v8::internal::ExpressionClassifier<ParserTypes<Impl>>;
     336             : 
     337             :   enum AllowRestrictedIdentifiers {
     338             :     kAllowRestrictedIdentifiers,
     339             :     kDontAllowRestrictedIdentifiers
     340             :   };
     341             : 
     342             :   enum LazyParsingResult { kLazyParsingComplete, kLazyParsingAborted };
     343             : 
     344             :   enum VariableDeclarationContext {
     345             :     kStatementListItem,
     346             :     kStatement,
     347             :     kForStatement
     348             :   };
     349             : 
     350             :   class ClassLiteralChecker;
     351             :   class ObjectLiteralChecker;
     352             : 
     353             :   // ---------------------------------------------------------------------------
     354             :   // BlockState and FunctionState implement the parser's scope stack.
     355             :   // The parser's current scope is in scope_. BlockState and FunctionState
     356             :   // constructors push on the scope stack and the destructors pop. They are also
     357             :   // used to hold the parser's per-funcion state.
     358             :   class BlockState BASE_EMBEDDED {
     359             :    public:
     360       60758 :     BlockState(Scope** scope_stack, Scope* scope)
     361    25570860 :         : scope_stack_(scope_stack), outer_scope_(*scope_stack) {
     362    25570860 :       *scope_stack_ = scope;
     363       60758 :     }
     364             : 
     365     5811686 :     BlockState(Zone* zone, Scope** scope_stack)
     366             :         : BlockState(scope_stack,
     367    11623371 :                      new (zone) Scope(zone, *scope_stack, BLOCK_SCOPE)) {}
     368             : 
     369    25009823 :     ~BlockState() { *scope_stack_ = outer_scope_; }
     370             : 
     371             :    private:
     372             :     Scope** const scope_stack_;
     373             :     Scope* const outer_scope_;
     374             :   };
     375             : 
     376             :   struct DestructuringAssignment {
     377             :    public:
     378       77428 :     DestructuringAssignment(ExpressionT expression, Scope* scope)
     379       77428 :         : assignment(expression), scope(scope) {}
     380             : 
     381             :     ExpressionT assignment;
     382             :     Scope* scope;
     383             :   };
     384             : 
     385             :   class FunctionState final : public BlockState {
     386             :    public:
     387             :     FunctionState(FunctionState** function_state_stack, Scope** scope_stack,
     388             :                   DeclarationScope* scope);
     389             :     ~FunctionState();
     390             : 
     391    75943506 :     DeclarationScope* scope() const { return scope_->AsDeclarationScope(); }
     392             : 
     393      939989 :     void AddProperty() { expected_property_count_++; }
     394             :     int expected_property_count() { return expected_property_count_; }
     395             : 
     396   148707322 :     FunctionKind kind() const { return scope()->function_kind(); }
     397             :     FunctionState* outer() const { return outer_function_state_; }
     398             : 
     399             :     void RewindDestructuringAssignments(int pos) {
     400             :       destructuring_assignments_to_rewrite_.Rewind(pos);
     401             :     }
     402             : 
     403             :     void SetDestructuringAssignmentsScope(int pos, Scope* scope) {
     404      781254 :       for (int i = pos; i < destructuring_assignments_to_rewrite_.length();
     405             :            ++i) {
     406      783242 :         destructuring_assignments_to_rewrite_[i].scope = scope;
     407             :       }
     408             :     }
     409             : 
     410             :     const ZoneList<DestructuringAssignment>&
     411     5000840 :         destructuring_assignments_to_rewrite() const {
     412     5000840 :       return destructuring_assignments_to_rewrite_;
     413             :     }
     414             : 
     415   211677765 :     ZoneList<typename ExpressionClassifier::Error>* GetReportedErrorList() {
     416   211677765 :       return &reported_errors_;
     417             :     }
     418             : 
     419   289615486 :     ZoneList<ExpressionT>* non_patterns_to_rewrite() {
     420   289615486 :       return &non_patterns_to_rewrite_;
     421             :     }
     422             : 
     423             :     bool next_function_is_likely_called() const {
     424             :       return next_function_is_likely_called_;
     425             :     }
     426             : 
     427             :     bool previous_function_was_likely_called() const {
     428             :       return previous_function_was_likely_called_;
     429             :     }
     430             : 
     431             :     void set_next_function_is_likely_called() {
     432      674564 :       next_function_is_likely_called_ = true;
     433             :     }
     434             : 
     435     7045330 :     void RecordFunctionOrEvalCall() { contains_function_or_eval_ = true; }
     436             :     bool contains_function_or_eval() const {
     437             :       return contains_function_or_eval_;
     438             :     }
     439             : 
     440             :     class FunctionOrEvalRecordingScope {
     441             :      public:
     442             :       explicit FunctionOrEvalRecordingScope(FunctionState* state)
     443             :           : state_(state) {
     444      180829 :         prev_value_ = state->contains_function_or_eval_;
     445      180829 :         state->contains_function_or_eval_ = false;
     446             :       }
     447             :       ~FunctionOrEvalRecordingScope() {
     448      180829 :         bool found = state_->contains_function_or_eval_;
     449      180829 :         if (!found) {
     450      155555 :           state_->contains_function_or_eval_ = prev_value_;
     451             :         }
     452             :       }
     453             : 
     454             :      private:
     455             :       FunctionState* state_;
     456             :       bool prev_value_;
     457             :     };
     458             : 
     459             :    private:
     460       77428 :     void AddDestructuringAssignment(DestructuringAssignment pair) {
     461       77428 :       destructuring_assignments_to_rewrite_.Add(pair, scope_->zone());
     462       77428 :     }
     463             : 
     464       15205 :     void AddNonPatternForRewriting(ExpressionT expr, bool* ok) {
     465       15205 :       non_patterns_to_rewrite_.Add(expr, scope_->zone());
     466       15205 :       if (non_patterns_to_rewrite_.length() >=
     467             :           std::numeric_limits<uint16_t>::max())
     468           0 :         *ok = false;
     469       15205 :     }
     470             : 
     471             :     // Properties count estimation.
     472             :     int expected_property_count_;
     473             : 
     474             :     FunctionState** function_state_stack_;
     475             :     FunctionState* outer_function_state_;
     476             :     DeclarationScope* scope_;
     477             : 
     478             :     ZoneList<DestructuringAssignment> destructuring_assignments_to_rewrite_;
     479             :     ZoneList<ExpressionT> non_patterns_to_rewrite_;
     480             : 
     481             :     ZoneList<typename ExpressionClassifier::Error> reported_errors_;
     482             : 
     483             :     // Record whether the next (=== immediately following) function literal is
     484             :     // preceded by a parenthesis / exclamation mark. Also record the previous
     485             :     // state.
     486             :     // These are managed by the FunctionState constructor; the caller may only
     487             :     // call set_next_function_is_likely_called.
     488             :     bool next_function_is_likely_called_;
     489             :     bool previous_function_was_likely_called_;
     490             : 
     491             :     // Track if a function or eval occurs within this FunctionState
     492             :     bool contains_function_or_eval_;
     493             : 
     494             :     friend Impl;
     495             :   };
     496             : 
     497             :   struct DeclarationDescriptor {
     498             :     enum Kind { NORMAL, PARAMETER, FOR_EACH };
     499             :     Scope* scope;
     500             :     VariableMode mode;
     501             :     int declaration_pos;
     502             :     int initialization_pos;
     503             :     Kind declaration_kind;
     504             :   };
     505             : 
     506             :   struct DeclarationParsingResult {
     507             :     struct Declaration {
     508             :       Declaration(ExpressionT pattern, int initializer_position,
     509             :                   ExpressionT initializer)
     510             :           : pattern(pattern),
     511             :             initializer_position(initializer_position),
     512    13546864 :             initializer(initializer) {}
     513             : 
     514             :       ExpressionT pattern;
     515             :       int initializer_position;
     516             :       int value_beg_position = kNoSourcePosition;
     517             :       ExpressionT initializer;
     518             :     };
     519             : 
     520             :     DeclarationParsingResult()
     521             :         : first_initializer_loc(Scanner::Location::invalid()),
     522    13319461 :           bindings_loc(Scanner::Location::invalid()) {}
     523             : 
     524             :     DeclarationDescriptor descriptor;
     525             :     std::vector<Declaration> declarations;
     526             :     Scanner::Location first_initializer_loc;
     527             :     Scanner::Location bindings_loc;
     528             :   };
     529             : 
     530             :   struct CatchInfo {
     531             :    public:
     532      607537 :     explicit CatchInfo(ParserBase* parser)
     533             :         : name(parser->impl()->NullIdentifier()),
     534             :           pattern(parser->impl()->NullExpression()),
     535             :           scope(nullptr),
     536             :           init_block(parser->impl()->NullStatement()),
     537             :           inner_block(parser->impl()->NullStatement()),
     538     1472313 :           bound_names(1, parser->zone()) {}
     539             :     IdentifierT name;
     540             :     ExpressionT pattern;
     541             :     Scope* scope;
     542             :     BlockT init_block;
     543             :     BlockT inner_block;
     544             :     ZoneList<const AstRawString*> bound_names;
     545             :   };
     546             : 
     547             :   struct ForInfo {
     548             :    public:
     549     1065005 :     explicit ForInfo(ParserBase* parser)
     550             :         : bound_names(1, parser->zone()),
     551             :           mode(ForEachStatement::ENUMERATE),
     552             :           position(kNoSourcePosition),
     553     2130010 :           parsing_result() {}
     554             :     ZoneList<const AstRawString*> bound_names;
     555             :     ForEachStatement::VisitMode mode;
     556             :     int position;
     557             :     DeclarationParsingResult parsing_result;
     558             :   };
     559             : 
     560             :   struct ClassInfo {
     561             :    public:
     562      169205 :     explicit ClassInfo(ParserBase* parser)
     563             :         : variable(nullptr),
     564             :           extends(parser->impl()->NullExpression()),
     565             :           properties(parser->impl()->NewClassPropertyList(4)),
     566             :           constructor(parser->impl()->NullExpression()),
     567             :           has_seen_constructor(false),
     568             :           has_name_static_property(false),
     569             :           has_static_computed_names(false),
     570      425660 :           is_anonymous(false) {}
     571             :     Variable* variable;
     572             :     ExpressionT extends;
     573             :     typename Types::ClassPropertyList properties;
     574             :     FunctionLiteralT constructor;
     575             :     bool has_seen_constructor;
     576             :     bool has_name_static_property;
     577             :     bool has_static_computed_names;
     578             :     bool is_anonymous;
     579             :   };
     580             : 
     581     2784527 :   DeclarationScope* NewScriptScope() const {
     582     2784527 :     return new (zone()) DeclarationScope(zone(), ast_value_factory());
     583             :   }
     584             : 
     585      124165 :   DeclarationScope* NewVarblockScope() const {
     586      124165 :     return new (zone()) DeclarationScope(zone(), scope(), BLOCK_SCOPE);
     587             :   }
     588             : 
     589       46326 :   ModuleScope* NewModuleScope(DeclarationScope* parent) const {
     590       46326 :     return new (zone()) ModuleScope(parent, ast_value_factory());
     591             :   }
     592             : 
     593      978149 :   DeclarationScope* NewEvalScope(Scope* parent) const {
     594      978149 :     return new (zone()) DeclarationScope(zone(), parent, EVAL_SCOPE);
     595             :   }
     596             : 
     597      976975 :   Scope* NewScope(ScopeType scope_type) const {
     598      976975 :     return NewScopeWithParent(scope(), scope_type);
     599             :   }
     600             : 
     601             :   // This constructor should only be used when absolutely necessary. Most scopes
     602             :   // should automatically use scope() as parent, and be fine with
     603             :   // NewScope(ScopeType) above.
     604     1350642 :   Scope* NewScopeWithParent(Scope* parent, ScopeType scope_type) const {
     605             :     // Must always use the specific constructors for the blacklisted scope
     606             :     // types.
     607             :     DCHECK_NE(FUNCTION_SCOPE, scope_type);
     608             :     DCHECK_NE(SCRIPT_SCOPE, scope_type);
     609             :     DCHECK_NE(MODULE_SCOPE, scope_type);
     610             :     DCHECK_NOT_NULL(parent);
     611     1350642 :     return new (zone()) Scope(zone(), parent, scope_type);
     612             :   }
     613             : 
     614             :   // Creates a function scope that always allocates in zone(). The function
     615             :   // scope itself is either allocated in zone() or in target_zone if one is
     616             :   // passed in.
     617     6653212 :   DeclarationScope* NewFunctionScope(FunctionKind kind,
     618     7159770 :                                      Zone* target_zone = nullptr) const {
     619             :     DCHECK(ast_value_factory());
     620     6653212 :     if (target_zone == nullptr) target_zone = zone();
     621             :     DeclarationScope* result = new (target_zone)
     622     6653210 :         DeclarationScope(zone(), scope(), FUNCTION_SCOPE, kind);
     623             : 
     624             :     // Record presence of an inner function scope
     625     6653211 :     function_state_->RecordFunctionOrEvalCall();
     626             : 
     627             :     // TODO(verwaest): Move into the DeclarationScope constructor.
     628     6653211 :     if (!IsArrowFunction(kind)) {
     629     5740865 :       result->DeclareDefaultFunctionVariables(ast_value_factory());
     630             :     }
     631     6653211 :     return result;
     632             :   }
     633             : 
     634     4844075 :   V8_INLINE DeclarationScope* GetDeclarationScope() const {
     635     4852641 :     return scope()->GetDeclarationScope();
     636             :   }
     637        2295 :   V8_INLINE DeclarationScope* GetClosureScope() const {
     638        2295 :     return scope()->GetClosureScope();
     639             :   }
     640             : 
     641  2779217363 :   Scanner* scanner() const { return scanner_; }
     642   191393289 :   AstValueFactory* ast_value_factory() const { return ast_value_factory_; }
     643             :   int position() const { return scanner_->location().beg_pos; }
     644             :   int peek_position() const { return scanner_->peek_location().beg_pos; }
     645      276295 :   bool stack_overflow() const { return stack_overflow_; }
     646          25 :   void set_stack_overflow() { stack_overflow_ = true; }
     647             : 
     648  1666209708 :   INLINE(Token::Value peek()) {
     649  2210003854 :     if (stack_overflow_) return Token::ILLEGAL;
     650  2209965194 :     return scanner()->peek();
     651             :   }
     652             : 
     653             :   // Returns the position past the following semicolon (if it exists), and the
     654             :   // position past the end of the current token otherwise.
     655       73253 :   int PositionAfterSemicolon() {
     656       42628 :     return (peek() == Token::SEMICOLON) ? scanner_->peek_location().end_pos
     657      103878 :                                         : scanner_->location().end_pos;
     658             :   }
     659             : 
     660    86316960 :   INLINE(Token::Value PeekAhead()) {
     661    86316971 :     if (stack_overflow_) return Token::ILLEGAL;
     662    86316960 :     return scanner()->PeekAhead();
     663             :   }
     664             : 
     665   394054671 :   INLINE(Token::Value Next()) {
     666   407279101 :     if (stack_overflow_) return Token::ILLEGAL;
     667             :     {
     668   407275158 :       if (GetCurrentStackPosition() < stack_limit_) {
     669             :         // Any further calls to Next or peek will return the illegal token.
     670             :         // The current call must return the next token, which might already
     671             :         // have been peek'ed.
     672        4982 :         stack_overflow_ = true;
     673             :       }
     674             :     }
     675   407275160 :     return scanner()->Next();
     676             :   }
     677             : 
     678    91172206 :   void Consume(Token::Value token) {
     679             :     Token::Value next = Next();
     680             :     USE(next);
     681             :     USE(token);
     682             :     DCHECK(next == token);
     683    91172218 :   }
     684             : 
     685   174142534 :   bool Check(Token::Value token) {
     686             :     Token::Value next = peek();
     687   174142596 :     if (next == token) {
     688    20350411 :       Consume(next);
     689    20350411 :       return true;
     690             :     }
     691             :     return false;
     692             :   }
     693             : 
     694   105071580 :   void Expect(Token::Value token, bool* ok) {
     695             :     Token::Value next = Next();
     696   105071585 :     if (next != token) {
     697       53049 :       ReportUnexpectedToken(next);
     698       53049 :       *ok = false;
     699             :     }
     700   105071585 :   }
     701             : 
     702    37722247 :   void ExpectSemicolon(bool* ok) {
     703             :     // Check for automatic semicolon insertion according to
     704             :     // the rules given in ECMA-262, section 7.9, page 21.
     705             :     Token::Value tok = peek();
     706    35619950 :     if (tok == Token::SEMICOLON) {
     707             :       Next();
     708    22385776 :       return;
     709             :     }
     710     4204568 :     if (scanner()->HasAnyLineTerminatorBeforeNext() ||
     711             :         tok == Token::RBRACE ||
     712             :         tok == Token::EOS) {
     713             :       return;
     714             :     }
     715             : 
     716        9811 :     Token::Value current = scanner()->current_token();
     717        5079 :     Scanner::Location current_location = scanner()->location();
     718             :     Token::Value next = Next();
     719             : 
     720        9811 :     if (next == Token::SEMICOLON) {
     721             :       return;
     722             :     }
     723             : 
     724        9811 :     *ok = false;
     725        9821 :     if (current == Token::AWAIT && !is_async_function()) {
     726           0 :       ReportMessageAt(current_location,
     727             :                       MessageTemplate::kAwaitNotInAsyncFunction, kSyntaxError);
     728           0 :       return;
     729             :     }
     730             : 
     731        9811 :     ReportUnexpectedToken(next);
     732             :   }
     733             : 
     734             :   // Dummy functions, just useful as arguments to CHECK_OK_CUSTOM.
     735             :   static void Void() {}
     736             :   template <typename T>
     737             :   static T Return(T result) {
     738             :     return result;
     739             :   }
     740             : 
     741    21618077 :   bool is_any_identifier(Token::Value token) {
     742             :     return token == Token::IDENTIFIER || token == Token::ENUM ||
     743             :            token == Token::AWAIT || token == Token::ASYNC ||
     744             :            token == Token::ESCAPED_STRICT_RESERVED_WORD ||
     745             :            token == Token::FUTURE_STRICT_RESERVED_WORD || token == Token::LET ||
     746    21618077 :            token == Token::STATIC || token == Token::YIELD;
     747             :   }
     748    43158116 :   bool peek_any_identifier() { return is_any_identifier(peek()); }
     749             : 
     750      811874 :   bool CheckContextualKeyword(Token::Value token) {
     751      811874 :     if (PeekContextualKeyword(token)) {
     752      149185 :       Consume(Token::IDENTIFIER);
     753      149185 :       return true;
     754             :     }
     755             :     return false;
     756             :   }
     757             : 
     758     1295845 :   bool PeekContextualKeyword(Token::Value token) {
     759             :     DCHECK(Token::IsContextualKeyword(token));
     760             :     return peek() == Token::IDENTIFIER &&
     761     1295845 :            scanner()->next_contextual_token() == token;
     762             :   }
     763             : 
     764             :   void ExpectMetaProperty(Token::Value property_name, const char* full_name,
     765             :                           int pos, bool* ok);
     766             : 
     767      256827 :   void ExpectContextualKeyword(Token::Value token, bool* ok) {
     768             :     DCHECK(Token::IsContextualKeyword(token));
     769      262362 :     Expect(Token::IDENTIFIER, CHECK_OK_CUSTOM(Void));
     770      125646 :     if (scanner()->current_contextual_token() != token) {
     771           0 :       ReportUnexpectedToken(scanner()->current_token());
     772           0 :       *ok = false;
     773             :     }
     774             :   }
     775             : 
     776      913468 :   bool CheckInOrOf(ForEachStatement::VisitMode* visit_mode) {
     777      913468 :     if (Check(Token::IN)) {
     778      103758 :       *visit_mode = ForEachStatement::ENUMERATE;
     779      103758 :       return true;
     780      809710 :     } else if (CheckContextualKeyword(Token::OF)) {
     781      148202 :       *visit_mode = ForEachStatement::ITERATE;
     782      148202 :       return true;
     783             :     }
     784             :     return false;
     785             :   }
     786             : 
     787      227408 :   bool PeekInOrOf() {
     788      227408 :     return peek() == Token::IN || PeekContextualKeyword(Token::OF);
     789             :   }
     790             : 
     791             :   // Checks whether an octal literal was last seen between beg_pos and end_pos.
     792             :   // Only called for strict mode strings.
     793     4225734 :   void CheckStrictOctalLiteral(int beg_pos, int end_pos, bool* ok) {
     794             :     Scanner::Location octal = scanner()->octal_position();
     795     4224770 :     if (octal.IsValid() && beg_pos <= octal.beg_pos &&
     796             :         octal.end_pos <= end_pos) {
     797         964 :       MessageTemplate::Template message = scanner()->octal_message();
     798             :       DCHECK_NE(message, MessageTemplate::kNone);
     799         405 :       impl()->ReportMessageAt(octal, message);
     800             :       scanner()->clear_octal_position();
     801         964 :       if (message == MessageTemplate::kStrictDecimalWithLeadingZero) {
     802           0 :         impl()->CountUsage(v8::Isolate::kDecimalWithLeadingZeroInStrictMode);
     803             :       }
     804         964 :       *ok = false;
     805             :     }
     806     4224770 :   }
     807             : 
     808             :   // Checks if an octal literal or an invalid hex or unicode escape sequence
     809             :   // appears in the current template literal token. In the presence of such,
     810             :   // either returns false or reports an error, depending on should_throw.
     811             :   // Otherwise returns true.
     812      133753 :   inline bool CheckTemplateEscapes(bool should_throw, bool* ok) {
     813             :     DCHECK(scanner()->current_token() == Token::TEMPLATE_SPAN ||
     814             :            scanner()->current_token() == Token::TEMPLATE_TAIL);
     815      133753 :     if (!scanner()->has_invalid_template_escape()) {
     816             :       return true;
     817             :     }
     818             : 
     819             :     // Handle error case(s)
     820       22902 :     if (should_throw) {
     821        8200 :       impl()->ReportMessageAt(scanner()->invalid_template_escape_location(),
     822             :                               scanner()->invalid_template_escape_message());
     823       16582 :       *ok = false;
     824             :     }
     825             :     return false;
     826             :   }
     827             : 
     828             :   void CheckDestructuringElement(ExpressionT element, int beg_pos, int end_pos);
     829             : 
     830             :   // Checking the name of a function literal. This has to be done after parsing
     831             :   // the function, since the function can declare itself strict.
     832     5401670 :   void CheckFunctionName(LanguageMode language_mode, IdentifierT function_name,
     833             :                          FunctionNameValidity function_name_validity,
     834             :                          const Scanner::Location& function_name_loc, bool* ok) {
     835     5401670 :     if (impl()->IsNull(function_name)) return;
     836     5354103 :     if (function_name_validity == kSkipFunctionNameCheck) return;
     837             :     // The function name needs to be checked in strict mode.
     838     4279152 :     if (is_sloppy(language_mode)) return;
     839             : 
     840     2051683 :     if (impl()->IsEvalOrArguments(function_name)) {
     841         282 :       impl()->ReportMessageAt(function_name_loc,
     842             :                               MessageTemplate::kStrictEvalArguments);
     843         590 :       *ok = false;
     844         590 :       return;
     845             :     }
     846     2051093 :     if (function_name_validity == kFunctionNameIsStrictReserved) {
     847        1279 :       impl()->ReportMessageAt(function_name_loc,
     848             :                               MessageTemplate::kUnexpectedStrictReserved);
     849        2187 :       *ok = false;
     850        2187 :       return;
     851             :     }
     852             :   }
     853             : 
     854             :   // Determine precedence of given token.
     855             :   static int Precedence(Token::Value token, bool accept_IN) {
     856   135316440 :     if (token == Token::IN && !accept_IN)
     857             :       return 0;  // 0 precedence will terminate binary expression parsing
     858             :     return Token::Precedence(token);
     859             :   }
     860             : 
     861     9239605 :   typename Types::Factory* factory() { return &ast_node_factory_; }
     862             : 
     863       43290 :   DeclarationScope* GetReceiverScope() const {
     864       43290 :     return scope()->GetReceiverScope();
     865             :   }
     866    47725310 :   LanguageMode language_mode() { return scope()->language_mode(); }
     867    30691490 :   void RaiseLanguageMode(LanguageMode mode) {
     868             :     LanguageMode old = scope()->language_mode();
     869    30691490 :     impl()->SetLanguageMode(scope(), old > mode ? old : mode);
     870    30691490 :   }
     871             :   bool is_generator() const {
     872             :     return IsGeneratorFunction(function_state_->kind());
     873             :   }
     874             :   bool is_async_function() const {
     875             :     return IsAsyncFunction(function_state_->kind());
     876             :   }
     877             :   bool is_async_generator() const {
     878             :     return IsAsyncGeneratorFunction(function_state_->kind());
     879             :   }
     880             :   bool is_resumable() const {
     881             :     return IsResumableFunction(function_state_->kind());
     882             :   }
     883             : 
     884             :   // Report syntax errors.
     885        4996 :   void ReportMessage(MessageTemplate::Template message) {
     886             :     Scanner::Location source_location = scanner()->location();
     887        2168 :     impl()->ReportMessageAt(source_location, message,
     888             :                             static_cast<const char*>(nullptr), kSyntaxError);
     889        4996 :   }
     890             : 
     891             :   template <typename T>
     892         368 :   void ReportMessage(MessageTemplate::Template message, T arg,
     893         368 :                      ParseErrorType error_type = kSyntaxError) {
     894             :     Scanner::Location source_location = scanner()->location();
     895             :     impl()->ReportMessageAt(source_location, message, arg, error_type);
     896         368 :   }
     897             : 
     898        7912 :   void ReportMessageAt(Scanner::Location location,
     899             :                        MessageTemplate::Template message,
     900             :                        ParseErrorType error_type) {
     901       11351 :     impl()->ReportMessageAt(location, message,
     902             :                             static_cast<const char*>(nullptr), error_type);
     903        7912 :   }
     904             : 
     905             :   void GetUnexpectedTokenMessage(
     906             :       Token::Value token, MessageTemplate::Template* message,
     907             :       Scanner::Location* location, const char** arg,
     908             :       MessageTemplate::Template default_ = MessageTemplate::kUnexpectedToken);
     909             : 
     910             :   void ReportUnexpectedToken(Token::Value token);
     911             :   void ReportUnexpectedTokenAt(
     912             :       Scanner::Location location, Token::Value token,
     913             :       MessageTemplate::Template message = MessageTemplate::kUnexpectedToken);
     914             : 
     915      111175 :   void ReportClassifierError(
     916             :       const typename ExpressionClassifier::Error& error) {
     917      111175 :     impl()->ReportMessageAt(error.location, error.message, error.arg,
     918             :                             error.type);
     919      111175 :   }
     920             : 
     921   142021582 :   void ValidateExpression(bool* ok) {
     922   142021582 :     if (!classifier()->is_valid_expression()) {
     923        9686 :       ReportClassifierError(classifier()->expression_error());
     924        9686 :       *ok = false;
     925             :     }
     926   142021582 :   }
     927             : 
     928      894079 :   void ValidateFormalParameterInitializer(bool* ok) {
     929      894079 :     if (!classifier()->is_valid_formal_parameter_initializer()) {
     930        7440 :       ReportClassifierError(classifier()->formal_parameter_initializer_error());
     931        7440 :       *ok = false;
     932             :     }
     933      894079 :   }
     934             : 
     935    22309191 :   void ValidateBindingPattern(bool* ok) {
     936    22309191 :     if (!classifier()->is_valid_binding_pattern()) {
     937       30370 :       ReportClassifierError(classifier()->binding_pattern_error());
     938       30370 :       *ok = false;
     939             :     }
     940    22309191 :   }
     941             : 
     942      523385 :   void ValidateAssignmentPattern(bool* ok) {
     943      523385 :     if (!classifier()->is_valid_assignment_pattern()) {
     944       20259 :       ReportClassifierError(classifier()->assignment_pattern_error());
     945       20259 :       *ok = false;
     946             :     }
     947      523385 :   }
     948             : 
     949     6317406 :   void ValidateFormalParameters(LanguageMode language_mode,
     950     7170152 :                                 bool allow_duplicates, bool* ok) {
     951    10141894 :     if (!allow_duplicates &&
     952             :         !classifier()->is_valid_formal_parameter_list_without_duplicates()) {
     953        4443 :       ReportClassifierError(classifier()->duplicate_formal_parameter_error());
     954        4443 :       *ok = false;
     955     9651427 :     } else if (is_strict(language_mode) &&
     956             :                !classifier()->is_valid_strict_mode_formal_parameters()) {
     957        2757 :       ReportClassifierError(classifier()->strict_mode_formal_parameter_error());
     958        2757 :       *ok = false;
     959             :     }
     960     6317406 :   }
     961             : 
     962             :   bool IsValidArrowFormalParametersStart(Token::Value token) {
     963       39018 :     return is_any_identifier(token) || token == Token::LPAREN;
     964             :   }
     965             : 
     966      809858 :   void ValidateArrowFormalParameters(ExpressionT expr,
     967             :                                      bool parenthesized_formals, bool is_async,
     968      818178 :                                      bool* ok) {
     969      809858 :     if (classifier()->is_valid_binding_pattern()) {
     970             :       // A simple arrow formal parameter: IDENTIFIER => BODY.
     971      115134 :       if (!impl()->IsIdentifier(expr)) {
     972         880 :         impl()->ReportMessageAt(scanner()->location(),
     973             :                                 MessageTemplate::kUnexpectedToken,
     974             :                                 Token::String(scanner()->current_token()));
     975         560 :         *ok = false;
     976             :       }
     977      694724 :     } else if (!classifier()->is_valid_arrow_formal_parameters()) {
     978             :       // If after parsing the expr, we see an error but the expression is
     979             :       // neither a valid binding pattern nor a valid parenthesized formal
     980             :       // parameter list, show the "arrow formal parameters" error if the formals
     981             :       // started with a parenthesis, and the binding pattern error otherwise.
     982             :       const typename ExpressionClassifier::Error& error =
     983             :           parenthesized_formals ? classifier()->arrow_formal_parameters_error()
     984       31940 :                                 : classifier()->binding_pattern_error();
     985       31940 :       ReportClassifierError(error);
     986       31940 :       *ok = false;
     987             :     }
     988      817538 :     if (is_async && !classifier()->is_valid_async_arrow_formal_parameters()) {
     989             :       const typename ExpressionClassifier::Error& error =
     990             :           classifier()->async_arrow_formal_parameters_error();
     991          80 :       ReportClassifierError(error);
     992          80 :       *ok = false;
     993             :     }
     994      809858 :   }
     995             : 
     996     1796305 :   void ValidateLetPattern(bool* ok) {
     997     1796305 :     if (!classifier()->is_valid_let_pattern()) {
     998        2280 :       ReportClassifierError(classifier()->let_pattern_error());
     999        2280 :       *ok = false;
    1000             :     }
    1001     1796305 :   }
    1002             : 
    1003   296194928 :   void BindingPatternUnexpectedToken() {
    1004    98731644 :     MessageTemplate::Template message = MessageTemplate::kUnexpectedToken;
    1005             :     const char* arg;
    1006    98731644 :     Scanner::Location location = scanner()->peek_location();
    1007    98731626 :     GetUnexpectedTokenMessage(peek(), &message, &location, &arg);
    1008   197463280 :     classifier()->RecordBindingPatternError(location, message, arg);
    1009    98731716 :   }
    1010             : 
    1011   447330992 :   void ArrowFormalParametersUnexpectedToken() {
    1012   149110350 :     MessageTemplate::Template message = MessageTemplate::kUnexpectedToken;
    1013             :     const char* arg;
    1014   149110350 :     Scanner::Location location = scanner()->peek_location();
    1015   149110276 :     GetUnexpectedTokenMessage(peek(), &message, &location, &arg);
    1016   298220584 :     classifier()->RecordArrowFormalParametersError(location, message, arg);
    1017   149110442 :   }
    1018             : 
    1019             :   // Recursive descent functions.
    1020             :   // All ParseXXX functions take as the last argument an *ok parameter
    1021             :   // which is set to false if parsing failed; it is unchanged otherwise.
    1022             :   // By making the 'exception handling' explicit, we are forced to check
    1023             :   // for failure at the call sites. The family of CHECK_OK* macros can
    1024             :   // be useful for this.
    1025             : 
    1026             :   // Parses an identifier that is valid for the current scope, in particular it
    1027             :   // fails on strict mode future reserved keywords in a strict scope. If
    1028             :   // allow_eval_or_arguments is kAllowEvalOrArguments, we allow "eval" or
    1029             :   // "arguments" as identifier even in strict mode (this is needed in cases like
    1030             :   // "var foo = eval;").
    1031             :   IdentifierT ParseIdentifier(AllowRestrictedIdentifiers, bool* ok);
    1032             :   IdentifierT ParseAndClassifyIdentifier(bool* ok);
    1033             :   // Parses an identifier or a strict mode future reserved word, and indicate
    1034             :   // whether it is strict mode future reserved. Allows passing in function_kind
    1035             :   // for the case of parsing the identifier in a function expression, where the
    1036             :   // relevant "function_kind" bit is of the function being parsed, not the
    1037             :   // containing function.
    1038             :   IdentifierT ParseIdentifierOrStrictReservedWord(FunctionKind function_kind,
    1039             :                                                   bool* is_strict_reserved,
    1040             :                                                   bool* is_await, bool* ok);
    1041     1654208 :   IdentifierT ParseIdentifierOrStrictReservedWord(bool* is_strict_reserved,
    1042             :                                                   bool* is_await, bool* ok) {
    1043             :     return ParseIdentifierOrStrictReservedWord(
    1044     3308416 :         function_state_->kind(), is_strict_reserved, is_await, ok);
    1045             :   }
    1046             : 
    1047             :   IdentifierT ParseIdentifierName(bool* ok);
    1048             : 
    1049             :   ExpressionT ParseRegExpLiteral(bool* ok);
    1050             : 
    1051             :   ExpressionT ParsePrimaryExpression(bool* is_async, bool* ok);
    1052    13626350 :   ExpressionT ParsePrimaryExpression(bool* ok) {
    1053             :     bool is_async;
    1054    22062757 :     return ParsePrimaryExpression(&is_async, ok);
    1055             :   }
    1056             : 
    1057             :   // This method wraps the parsing of the expression inside a new expression
    1058             :   // classifier and calls RewriteNonPattern if parsing is successful.
    1059             :   // It should be used whenever we're parsing an expression that will be
    1060             :   // used as a non-pattern (i.e., in most cases).
    1061             :   V8_INLINE ExpressionT ParseExpression(bool accept_IN, bool* ok);
    1062             : 
    1063             :   // This method does not wrap the parsing of the expression inside a
    1064             :   // new expression classifier; it uses the top-level classifier instead.
    1065             :   // It should be used whenever we're parsing something with the "cover"
    1066             :   // grammar that recognizes both patterns and non-patterns (which roughly
    1067             :   // corresponds to what's inside the parentheses generated by the symbol
    1068             :   // "CoverParenthesizedExpressionAndArrowParameterList" in the ES 2017
    1069             :   // specification).
    1070             :   ExpressionT ParseExpressionCoverGrammar(bool accept_IN, bool* ok);
    1071             : 
    1072             :   ExpressionT ParseArrayLiteral(bool* ok);
    1073             : 
    1074             :   enum class PropertyKind {
    1075             :     kAccessorProperty,
    1076             :     kValueProperty,
    1077             :     kShorthandProperty,
    1078             :     kMethodProperty,
    1079             :     kClassField,
    1080             :     kSpreadProperty,
    1081             :     kNotSet
    1082             :   };
    1083             : 
    1084             :   bool SetPropertyKindFromToken(Token::Value token, PropertyKind* kind);
    1085             :   ExpressionT ParsePropertyName(IdentifierT* name, PropertyKind* kind,
    1086             :                                 bool* is_generator, bool* is_get, bool* is_set,
    1087             :                                 bool* is_async, bool* is_computed_name,
    1088             :                                 bool* ok);
    1089             :   ExpressionT ParseObjectLiteral(bool* ok);
    1090             :   ClassLiteralPropertyT ParseClassPropertyDefinition(
    1091             :       ClassLiteralChecker* checker, bool has_extends, bool* is_computed_name,
    1092             :       bool* has_seen_constructor, ClassLiteralProperty::Kind* property_kind,
    1093             :       bool* is_static, bool* has_name_static_property, bool* ok);
    1094             :   FunctionLiteralT ParseClassFieldForInitializer(bool has_initializer,
    1095             :                                                  bool* ok);
    1096             :   ObjectLiteralPropertyT ParseObjectPropertyDefinition(
    1097             :       ObjectLiteralChecker* checker, bool* is_computed_name,
    1098             :       bool* is_rest_property, bool* ok);
    1099             :   ExpressionListT ParseArguments(Scanner::Location* first_spread_pos,
    1100             :                                  bool maybe_arrow,
    1101             :                                  bool* is_simple_parameter_list, bool* ok);
    1102    12005476 :   ExpressionListT ParseArguments(Scanner::Location* first_spread_pos,
    1103             :                                  bool* ok) {
    1104    13205142 :     return ParseArguments(first_spread_pos, false, nullptr, ok);
    1105             :   }
    1106             : 
    1107             :   ExpressionT ParseAssignmentExpression(bool accept_IN, bool* ok);
    1108             :   ExpressionT ParseYieldExpression(bool accept_IN, bool* ok);
    1109             :   ExpressionT ParseConditionalExpression(bool accept_IN, bool* ok);
    1110             :   ExpressionT ParseBinaryExpression(int prec, bool accept_IN, bool* ok);
    1111             :   ExpressionT ParseUnaryExpression(bool* ok);
    1112             :   ExpressionT ParsePostfixExpression(bool* ok);
    1113             :   ExpressionT ParseLeftHandSideExpression(bool* ok);
    1114             :   ExpressionT ParseMemberWithNewPrefixesExpression(bool* is_async, bool* ok);
    1115             :   ExpressionT ParseMemberExpression(bool* is_async, bool* ok);
    1116             :   ExpressionT ParseMemberExpressionContinuation(ExpressionT expression,
    1117             :                                                 bool* is_async, bool* ok);
    1118             : 
    1119             :   // `rewritable_length`: length of the destructuring_assignments_to_rewrite()
    1120             :   // queue in the parent function state, prior to parsing of formal parameters.
    1121             :   // If the arrow function is lazy, any items added during formal parameter
    1122             :   // parsing are removed from the queue.
    1123             :   ExpressionT ParseArrowFunctionLiteral(bool accept_IN,
    1124             :                                         const FormalParametersT& parameters,
    1125             :                                         int rewritable_length, bool* ok);
    1126             :   void ParseSingleExpressionFunctionBody(StatementListT body, bool is_async,
    1127             :                                          bool accept_IN, bool* ok);
    1128             :   void ParseAsyncFunctionBody(Scope* scope, StatementListT body, bool* ok);
    1129             :   ExpressionT ParseAsyncFunctionLiteral(bool* ok);
    1130             :   ExpressionT ParseClassLiteral(IdentifierT name,
    1131             :                                 Scanner::Location class_name_location,
    1132             :                                 bool name_is_strict_reserved,
    1133             :                                 int class_token_pos, bool* ok);
    1134             :   ExpressionT ParseTemplateLiteral(ExpressionT tag, int start, bool tagged,
    1135             :                                    bool* ok);
    1136             :   ExpressionT ParseSuperExpression(bool is_new, bool* ok);
    1137             :   ExpressionT ParseImportExpressions(bool* ok);
    1138             :   ExpressionT ParseNewTargetExpression(bool* ok);
    1139             : 
    1140             :   void ParseFormalParameter(FormalParametersT* parameters, bool* ok);
    1141             :   void ParseFormalParameterList(FormalParametersT* parameters, bool* ok);
    1142             :   void CheckArityRestrictions(int param_count, FunctionKind function_type,
    1143             :                               bool has_rest, int formals_start_pos,
    1144             :                               int formals_end_pos, bool* ok);
    1145             : 
    1146             :   BlockT ParseVariableDeclarations(VariableDeclarationContext var_context,
    1147             :                                    DeclarationParsingResult* parsing_result,
    1148             :                                    ZoneList<const AstRawString*>* names,
    1149             :                                    bool* ok);
    1150             :   StatementT ParseAsyncFunctionDeclaration(ZoneList<const AstRawString*>* names,
    1151             :                                            bool default_export, bool* ok);
    1152             :   StatementT ParseFunctionDeclaration(bool* ok);
    1153             :   StatementT ParseHoistableDeclaration(ZoneList<const AstRawString*>* names,
    1154             :                                        bool default_export, bool* ok);
    1155             :   StatementT ParseHoistableDeclaration(int pos, ParseFunctionFlags flags,
    1156             :                                        ZoneList<const AstRawString*>* names,
    1157             :                                        bool default_export, bool* ok);
    1158             :   StatementT ParseClassDeclaration(ZoneList<const AstRawString*>* names,
    1159             :                                    bool default_export, bool* ok);
    1160             :   StatementT ParseNativeDeclaration(bool* ok);
    1161             : 
    1162             :   // Consumes the ending }.
    1163             :   void ParseFunctionBody(StatementListT result, IdentifierT function_name,
    1164             :                          int pos, const FormalParametersT& parameters,
    1165             :                          FunctionKind kind,
    1166             :                          FunctionLiteral::FunctionType function_type, bool* ok);
    1167             : 
    1168             :   // Under some circumstances, we allow preparsing to abort if the preparsed
    1169             :   // function is "long and trivial", and fully parse instead. Our current
    1170             :   // definition of "long and trivial" is:
    1171             :   // - over kLazyParseTrialLimit statements
    1172             :   // - all starting with an identifier (i.e., no if, for, while, etc.)
    1173             :   static const int kLazyParseTrialLimit = 200;
    1174             : 
    1175             :   // TODO(nikolaos, marja): The first argument should not really be passed
    1176             :   // by value. The method is expected to add the parsed statements to the
    1177             :   // list. This works because in the case of the parser, StatementListT is
    1178             :   // a pointer whereas the preparser does not really modify the body.
    1179             :   V8_INLINE void ParseStatementList(StatementListT body, int end_token,
    1180             :                                     bool* ok) {
    1181     5805652 :     LazyParsingResult result = ParseStatementList(body, end_token, false, ok);
    1182             :     USE(result);
    1183             :     DCHECK_EQ(result, kLazyParsingComplete);
    1184             :   }
    1185             :   LazyParsingResult ParseStatementList(StatementListT body, int end_token,
    1186             :                                        bool may_abort, bool* ok);
    1187             :   StatementT ParseStatementListItem(bool* ok);
    1188             :   StatementT ParseStatement(ZoneList<const AstRawString*>* labels, bool* ok) {
    1189     6144952 :     return ParseStatement(labels, kDisallowLabelledFunctionStatement, ok);
    1190             :   }
    1191             :   StatementT ParseStatement(ZoneList<const AstRawString*>* labels,
    1192             :                             AllowLabelledFunctionStatement allow_function,
    1193             :                             bool* ok);
    1194             :   BlockT ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok);
    1195             : 
    1196             :   // Parse a SubStatement in strict mode, or with an extra block scope in
    1197             :   // sloppy mode to handle
    1198             :   // ES#sec-functiondeclarations-in-ifstatement-statement-clauses
    1199             :   StatementT ParseScopedStatement(ZoneList<const AstRawString*>* labels,
    1200             :                                   bool* ok);
    1201             : 
    1202             :   StatementT ParseVariableStatement(VariableDeclarationContext var_context,
    1203             :                                     ZoneList<const AstRawString*>* names,
    1204             :                                     bool* ok);
    1205             : 
    1206             :   // Magical syntax support.
    1207             :   ExpressionT ParseV8Intrinsic(bool* ok);
    1208             : 
    1209             :   ExpressionT ParseDoExpression(bool* ok);
    1210             : 
    1211             :   StatementT ParseDebuggerStatement(bool* ok);
    1212             : 
    1213             :   StatementT ParseExpressionOrLabelledStatement(
    1214             :       ZoneList<const AstRawString*>* labels,
    1215             :       AllowLabelledFunctionStatement allow_function, bool* ok);
    1216             :   StatementT ParseIfStatement(ZoneList<const AstRawString*>* labels, bool* ok);
    1217             :   StatementT ParseContinueStatement(bool* ok);
    1218             :   StatementT ParseBreakStatement(ZoneList<const AstRawString*>* labels,
    1219             :                                  bool* ok);
    1220             :   StatementT ParseReturnStatement(bool* ok);
    1221             :   StatementT ParseWithStatement(ZoneList<const AstRawString*>* labels,
    1222             :                                 bool* ok);
    1223             :   StatementT ParseDoWhileStatement(ZoneList<const AstRawString*>* labels,
    1224             :                                    bool* ok);
    1225             :   StatementT ParseWhileStatement(ZoneList<const AstRawString*>* labels,
    1226             :                                  bool* ok);
    1227             :   StatementT ParseThrowStatement(bool* ok);
    1228             :   StatementT ParseSwitchStatement(ZoneList<const AstRawString*>* labels,
    1229             :                                   bool* ok);
    1230             :   StatementT ParseTryStatement(bool* ok);
    1231             :   StatementT ParseForStatement(ZoneList<const AstRawString*>* labels, bool* ok);
    1232             :   StatementT ParseForEachStatementWithDeclarations(
    1233             :       int stmt_pos, ForInfo* for_info, ZoneList<const AstRawString*>* labels,
    1234             :       Scope* inner_block_scope, bool* ok);
    1235             :   StatementT ParseForEachStatementWithoutDeclarations(
    1236             :       int stmt_pos, ExpressionT expression, int lhs_beg_pos, int lhs_end_pos,
    1237             :       ForInfo* for_info, ZoneList<const AstRawString*>* labels, bool* ok);
    1238             : 
    1239             :   // Parse a C-style for loop: 'for (<init>; <cond>; <next>) { ... }'
    1240             :   // "for (<init>;" is assumed to have been parser already.
    1241             :   ForStatementT ParseStandardForLoop(int stmt_pos,
    1242             :                                      ZoneList<const AstRawString*>* labels,
    1243             :                                      ExpressionT* cond, StatementT* next,
    1244             :                                      StatementT* body, bool* ok);
    1245             :   // Same as the above, but handles those cases where <init> is a
    1246             :   // lexical variable declaration.
    1247             :   StatementT ParseStandardForLoopWithLexicalDeclarations(
    1248             :       int stmt_pos, StatementT init, ForInfo* for_info,
    1249             :       ZoneList<const AstRawString*>* labels, bool* ok);
    1250             :   StatementT ParseForAwaitStatement(ZoneList<const AstRawString*>* labels,
    1251             :                                     bool* ok);
    1252             : 
    1253             :   bool IsNextLetKeyword();
    1254             :   bool IsTrivialExpression();
    1255             : 
    1256             :   // Checks if the expression is a valid reference expression (e.g., on the
    1257             :   // left-hand side of assignments). Although ruled out by ECMA as early errors,
    1258             :   // we allow calls for web compatibility and rewrite them to a runtime throw.
    1259             :   ExpressionT CheckAndRewriteReferenceExpression(
    1260             :       ExpressionT expression, int beg_pos, int end_pos,
    1261             :       MessageTemplate::Template message, bool* ok);
    1262             :   ExpressionT CheckAndRewriteReferenceExpression(
    1263             :       ExpressionT expression, int beg_pos, int end_pos,
    1264             :       MessageTemplate::Template message, ParseErrorType type, bool* ok);
    1265             : 
    1266             :   bool IsValidReferenceExpression(ExpressionT expression);
    1267             : 
    1268   110204930 :   bool IsAssignableIdentifier(ExpressionT expression) {
    1269   110204976 :     if (!impl()->IsIdentifier(expression)) return false;
    1270    39070447 :     if (is_strict(language_mode()) &&
    1271             :         impl()->IsEvalOrArguments(impl()->AsIdentifier(expression))) {
    1272             :       return false;
    1273             :     }
    1274    13798831 :     return true;
    1275             :   }
    1276             : 
    1277    70228502 :   bool IsValidPattern(ExpressionT expression) {
    1278   179986520 :     return expression->IsObjectLiteral() || expression->IsArrayLiteral();
    1279             :   }
    1280             : 
    1281             :   // Due to hoisting, the value of a 'var'-declared variable may actually change
    1282             :   // even if the code contains only the "initial" assignment, namely when that
    1283             :   // assignment occurs inside a loop.  For example:
    1284             :   //
    1285             :   //   let i = 10;
    1286             :   //   do { var x = i } while (i--):
    1287             :   //
    1288             :   // As a simple and very conservative approximation of this, we explicitly mark
    1289             :   // as maybe-assigned any non-lexical variable whose initializing "declaration"
    1290             :   // does not syntactically occur in the function scope.  (In the example above,
    1291             :   // it occurs in a block scope.)
    1292             :   //
    1293             :   // Note that non-lexical variables include temporaries, which may also get
    1294             :   // assigned inside a loop due to the various rewritings that the parser
    1295             :   // performs.
    1296             :   //
    1297             :   // This also handles marking of loop variables in for-in and for-of loops,
    1298             :   // as determined by declaration_kind.
    1299             :   //
    1300             :   static void MarkLoopVariableAsAssigned(
    1301             :       Scope* scope, Variable* var,
    1302             :       typename DeclarationDescriptor::Kind declaration_kind);
    1303             : 
    1304             :   FunctionKind FunctionKindForImpl(bool is_method, bool is_generator,
    1305             :                                    bool is_async) {
    1306             :     static const FunctionKind kFunctionKinds[][2][2] = {
    1307             :         {
    1308             :             // is_method=false
    1309             :             {// is_generator=false
    1310             :              FunctionKind::kNormalFunction, FunctionKind::kAsyncFunction},
    1311             :             {// is_generator=true
    1312             :              FunctionKind::kGeneratorFunction,
    1313             :              FunctionKind::kAsyncGeneratorFunction},
    1314             :         },
    1315             :         {
    1316             :             // is_method=true
    1317             :             {// is_generator=false
    1318             :              FunctionKind::kConciseMethod, FunctionKind::kAsyncConciseMethod},
    1319             :             {// is_generator=true
    1320             :              FunctionKind::kConciseGeneratorMethod,
    1321             :              FunctionKind::kAsyncConciseGeneratorMethod},
    1322             :         }};
    1323     2071126 :     return kFunctionKinds[is_method][is_generator][is_async];
    1324             :   }
    1325             : 
    1326             :   inline FunctionKind FunctionKindFor(bool is_generator, bool is_async) {
    1327             :     const bool kIsMethod = false;
    1328             :     return FunctionKindForImpl(kIsMethod, is_generator, is_async);
    1329             :   }
    1330             : 
    1331             :   inline FunctionKind MethodKindFor(bool is_generator, bool is_async) {
    1332             :     const bool kIsMethod = true;
    1333             :     return FunctionKindForImpl(kIsMethod, is_generator, is_async);
    1334             :   }
    1335             : 
    1336             :   // Keep track of eval() calls since they disable all local variable
    1337             :   // optimizations. This checks if expression is an eval call, and if yes,
    1338             :   // forwards the information to scope.
    1339    11310345 :   Call::PossiblyEval CheckPossibleEvalCall(ExpressionT expression,
    1340             :                                            Scope* scope) {
    1341    17293134 :     if (impl()->IsIdentifier(expression) &&
    1342             :         impl()->IsEval(impl()->AsIdentifier(expression))) {
    1343             :       scope->RecordInnerScopeEvalCall();
    1344      392119 :       function_state_->RecordFunctionOrEvalCall();
    1345      392119 :       if (is_sloppy(scope->language_mode())) {
    1346             :         // For sloppy scopes we also have to record the call at function level,
    1347             :         // in case it includes declarations that will be hoisted.
    1348      181707 :         scope->GetDeclarationScope()->RecordEvalCall();
    1349             :       }
    1350             : 
    1351             :       // This call is only necessary to track evals that may be
    1352             :       // inside arrow function parameter lists. In that case,
    1353             :       // Scope::Snapshot::Reparent will move this bit down into
    1354             :       // the arrow function's scope.
    1355             :       scope->RecordEvalCall();
    1356             : 
    1357      392119 :       return Call::IS_POSSIBLY_EVAL;
    1358             :     }
    1359             :     return Call::NOT_EVAL;
    1360             :   }
    1361             : 
    1362             :   // Convenience method which determines the type of return statement to emit
    1363             :   // depending on the current function type.
    1364     5340047 :   inline StatementT BuildReturnStatement(ExpressionT expr, int pos,
    1365    10406375 :                                          int end_pos = kNoSourcePosition) {
    1366     5340047 :     if (impl()->IsNull(expr)) {
    1367       81777 :       expr = factory()->NewUndefinedLiteral(kNoSourcePosition);
    1368     2885957 :     } else if (is_async_generator()) {
    1369             :       // In async generators, if there is an explicit operand to the return
    1370             :       // statement, await the operand.
    1371       13044 :       expr = factory()->NewAwait(expr, kNoSourcePosition);
    1372             :     }
    1373     5340048 :     if (is_async_function()) {
    1374       33774 :       return factory()->NewAsyncReturnStatement(expr, pos, end_pos);
    1375             :     }
    1376     5901692 :     return factory()->NewReturnStatement(expr, pos, end_pos);
    1377             :   }
    1378             : 
    1379             :   // Validation per ES6 object literals.
    1380             :   class ObjectLiteralChecker {
    1381             :    public:
    1382             :     explicit ObjectLiteralChecker(ParserBase* parser)
    1383     1504276 :         : parser_(parser), has_seen_proto_(false) {}
    1384             : 
    1385             :     void CheckDuplicateProto(Token::Value property);
    1386             : 
    1387             :    private:
    1388     2978118 :     bool IsProto() const {
    1389             :       return this->scanner()->CurrentMatchesContextualEscaped(
    1390     2978118 :           Token::PROTO_UNDERSCORED);
    1391             :     }
    1392             : 
    1393             :     ParserBase* parser() const { return parser_; }
    1394     2980938 :     Scanner* scanner() const { return parser_->scanner(); }
    1395             : 
    1396             :     ParserBase* parser_;
    1397             :     bool has_seen_proto_;
    1398             :   };
    1399             : 
    1400             :   // Validation per ES6 class literals.
    1401             :   class ClassLiteralChecker {
    1402             :    public:
    1403             :     explicit ClassLiteralChecker(ParserBase* parser)
    1404      167809 :         : parser_(parser), has_seen_constructor_(false) {}
    1405             : 
    1406             :     void CheckClassMethodName(Token::Value property, PropertyKind type,
    1407             :                               bool is_generator, bool is_async, bool is_static,
    1408             :                               bool* ok);
    1409             : 
    1410             :    private:
    1411      478924 :     bool IsConstructor() {
    1412             :       return this->scanner()->CurrentMatchesContextualEscaped(
    1413      478924 :           Token::CONSTRUCTOR);
    1414             :     }
    1415       20629 :     bool IsPrototype() {
    1416       20629 :       return this->scanner()->CurrentMatchesContextualEscaped(Token::PROTOTYPE);
    1417             :     }
    1418             : 
    1419             :     ParserBase* parser() const { return parser_; }
    1420      499553 :     Scanner* scanner() const { return parser_->scanner(); }
    1421             : 
    1422             :     ParserBase* parser_;
    1423             :     bool has_seen_constructor_;
    1424             :   };
    1425             : 
    1426       32176 :   ModuleDescriptor* module() const {
    1427       32176 :     return scope()->AsModuleScope()->module();
    1428             :   }
    1429     6811417 :   Scope* scope() const { return scope_; }
    1430             : 
    1431             :   // Stack of expression classifiers.
    1432             :   // The top of the stack is always pointed to by classifier().
    1433             :   V8_INLINE ExpressionClassifier* classifier() const {
    1434             :     DCHECK_NOT_NULL(classifier_);
    1435             :     return classifier_;
    1436             :   }
    1437             : 
    1438             :   // Accumulates the classifier that is on top of the stack (inner) to
    1439             :   // the one that is right below (outer) and pops the inner.
    1440             :   V8_INLINE void Accumulate(unsigned productions,
    1441             :                             bool merge_non_patterns = true) {
    1442             :     DCHECK_NOT_NULL(classifier_);
    1443   145956427 :     ExpressionClassifier* previous = classifier_->previous();
    1444             :     DCHECK_NOT_NULL(previous);
    1445   145956429 :     previous->Accumulate(classifier_, productions, merge_non_patterns);
    1446   145956444 :     classifier_ = previous;
    1447             :   }
    1448             : 
    1449             :   V8_INLINE void AccumulateNonBindingPatternErrors() {
    1450             :     static const bool kMergeNonPatterns = true;
    1451             :     this->Accumulate(ExpressionClassifier::AllProductions &
    1452             :                          ~(ExpressionClassifier::BindingPatternProduction |
    1453             :                            ExpressionClassifier::LetPatternProduction),
    1454             :                      kMergeNonPatterns);
    1455             :   }
    1456             : 
    1457             :   // Pops and discards the classifier that is on top of the stack
    1458             :   // without accumulating.
    1459             :   V8_INLINE void DiscardExpressionClassifier() {
    1460             :     DCHECK_NOT_NULL(classifier_);
    1461      833361 :     classifier_->Discard();
    1462      833361 :     classifier_ = classifier_->previous();
    1463             :   }
    1464             : 
    1465             :   // Accumulate errors that can be arbitrarily deep in an expression.
    1466             :   // These correspond to the ECMAScript spec's 'Contains' operation
    1467             :   // on productions. This includes:
    1468             :   //
    1469             :   // - YieldExpression is disallowed in arrow parameters in a generator.
    1470             :   // - AwaitExpression is disallowed in arrow parameters in an async function.
    1471             :   // - AwaitExpression is disallowed in async arrow parameters.
    1472             :   //
    1473             :   V8_INLINE void AccumulateFormalParameterContainmentErrors() {
    1474             :     Accumulate(ExpressionClassifier::FormalParameterInitializerProduction |
    1475             :                ExpressionClassifier::AsyncArrowFormalParametersProduction);
    1476             :   }
    1477             : 
    1478             :   // Parser base's protected field members.
    1479             : 
    1480             :   Scope* scope_;                   // Scope stack.
    1481             :   Scope* original_scope_;  // The top scope for the current parsing item.
    1482             :   FunctionState* function_state_;  // Function state stack.
    1483             :   v8::Extension* extension_;
    1484             :   FuncNameInferrer* fni_;
    1485             :   AstValueFactory* ast_value_factory_;  // Not owned.
    1486             :   typename Types::Factory ast_node_factory_;
    1487             :   RuntimeCallStats* runtime_call_stats_;
    1488             :   bool parsing_on_main_thread_;
    1489             :   bool parsing_module_;
    1490             :   uintptr_t stack_limit_;
    1491             : 
    1492             :   // Parser base's private field members.
    1493             : 
    1494             :  private:
    1495             :   Zone* zone_;
    1496             :   ExpressionClassifier* classifier_;
    1497             : 
    1498             :   Scanner* scanner_;
    1499             :   bool stack_overflow_;
    1500             : 
    1501             :   FunctionLiteral::EagerCompileHint default_eager_compile_hint_;
    1502             : 
    1503             :   int function_literal_id_;
    1504             : 
    1505             :   bool allow_natives_;
    1506             :   bool allow_harmony_do_expressions_;
    1507             :   bool allow_harmony_function_sent_;
    1508             :   bool allow_harmony_restrictive_generators_;
    1509             :   bool allow_harmony_class_fields_;
    1510             :   bool allow_harmony_object_rest_spread_;
    1511             :   bool allow_harmony_dynamic_import_;
    1512             :   bool allow_harmony_import_meta_;
    1513             :   bool allow_harmony_async_iteration_;
    1514             :   bool allow_harmony_template_escapes_;
    1515             : 
    1516             :   friend class DiscardableZoneScope;
    1517             : };
    1518             : 
    1519             : template <typename Impl>
    1520    11688362 : ParserBase<Impl>::FunctionState::FunctionState(
    1521             :     FunctionState** function_state_stack, Scope** scope_stack,
    1522             :     DeclarationScope* scope)
    1523             :     : BlockState(scope_stack, scope),
    1524             :       expected_property_count_(0),
    1525             :       function_state_stack_(function_state_stack),
    1526             :       outer_function_state_(*function_state_stack),
    1527             :       scope_(scope),
    1528             :       destructuring_assignments_to_rewrite_(16, scope->zone()),
    1529             :       non_patterns_to_rewrite_(0, scope->zone()),
    1530             :       reported_errors_(16, scope->zone()),
    1531             :       next_function_is_likely_called_(false),
    1532             :       previous_function_was_likely_called_(false),
    1533    11688362 :       contains_function_or_eval_(false) {
    1534    11688363 :   *function_state_stack = this;
    1535    11688363 :   if (outer_function_state_) {
    1536     6669493 :     outer_function_state_->previous_function_was_likely_called_ =
    1537             :         outer_function_state_->next_function_is_likely_called_;
    1538     6669493 :     outer_function_state_->next_function_is_likely_called_ = false;
    1539             :   }
    1540    11688363 : }
    1541             : 
    1542             : template <typename Impl>
    1543       29133 : ParserBase<Impl>::FunctionState::~FunctionState() {
    1544    11688364 :   *function_state_stack_ = outer_function_state_;
    1545       29133 : }
    1546             : 
    1547             : template <typename Impl>
    1548   248270160 : void ParserBase<Impl>::GetUnexpectedTokenMessage(
    1549             :     Token::Value token, MessageTemplate::Template* message,
    1550             :     Scanner::Location* location, const char** arg,
    1551       15059 :     MessageTemplate::Template default_) {
    1552   248270160 :   *arg = nullptr;
    1553   248270160 :   switch (token) {
    1554             :     case Token::EOS:
    1555      239671 :       *message = MessageTemplate::kUnexpectedEOS;
    1556      239671 :       break;
    1557             :     case Token::SMI:
    1558             :     case Token::NUMBER:
    1559             :     case Token::BIGINT:
    1560    50581949 :       *message = MessageTemplate::kUnexpectedTokenNumber;
    1561    50581949 :       break;
    1562             :     case Token::STRING:
    1563    19168735 :       *message = MessageTemplate::kUnexpectedTokenString;
    1564    19168735 :       break;
    1565             :     case Token::IDENTIFIER:
    1566    47790866 :       *message = MessageTemplate::kUnexpectedTokenIdentifier;
    1567    47790866 :       break;
    1568             :     case Token::AWAIT:
    1569             :     case Token::ENUM:
    1570       57647 :       *message = MessageTemplate::kUnexpectedReserved;
    1571       57647 :       break;
    1572             :     case Token::LET:
    1573             :     case Token::STATIC:
    1574             :     case Token::YIELD:
    1575             :     case Token::FUTURE_STRICT_RESERVED_WORD:
    1576       72336 :       *message = is_strict(language_mode())
    1577             :                      ? MessageTemplate::kUnexpectedStrictReserved
    1578             :                      : MessageTemplate::kUnexpectedTokenIdentifier;
    1579       72336 :       break;
    1580             :     case Token::TEMPLATE_SPAN:
    1581             :     case Token::TEMPLATE_TAIL:
    1582      144574 :       *message = MessageTemplate::kUnexpectedTemplateString;
    1583      144574 :       break;
    1584             :     case Token::ESCAPED_STRICT_RESERVED_WORD:
    1585             :     case Token::ESCAPED_KEYWORD:
    1586       19386 :       *message = MessageTemplate::kInvalidEscapedReservedWord;
    1587       19386 :       break;
    1588             :     case Token::ILLEGAL:
    1589       11973 :       if (scanner()->has_error()) {
    1590        3086 :         *message = scanner()->error();
    1591        3086 :         *location = scanner()->error_location();
    1592             :       } else {
    1593        8887 :         *message = MessageTemplate::kInvalidOrUnexpectedToken;
    1594             :       }
    1595             :       break;
    1596             :     case Token::REGEXP_LITERAL:
    1597         400 :       *message = MessageTemplate::kUnexpectedTokenRegExp;
    1598         400 :       break;
    1599             :     default:
    1600             :       const char* name = Token::String(token);
    1601             :       DCHECK_NOT_NULL(name);
    1602   130182623 :       *arg = name;
    1603   130182623 :       break;
    1604             :   }
    1605   248270160 : }
    1606             : 
    1607             : template <typename Impl>
    1608      427201 : void ParserBase<Impl>::ReportUnexpectedToken(Token::Value token) {
    1609      427201 :   return ReportUnexpectedTokenAt(scanner_->location(), token);
    1610             : }
    1611             : 
    1612             : template <typename Impl>
    1613      428136 : void ParserBase<Impl>::ReportUnexpectedTokenAt(
    1614             :     Scanner::Location source_location, Token::Value token,
    1615             :     MessageTemplate::Template message) {
    1616             :   const char* arg;
    1617      428136 :   GetUnexpectedTokenMessage(token, &message, &source_location, &arg);
    1618      428136 :   impl()->ReportMessageAt(source_location, message, arg);
    1619      428136 : }
    1620             : 
    1621             : template <typename Impl>
    1622     1527804 : typename ParserBase<Impl>::IdentifierT ParserBase<Impl>::ParseIdentifier(
    1623             :     AllowRestrictedIdentifiers allow_restricted_identifiers, bool* ok) {
    1624     1527804 :   ExpressionClassifier classifier(this);
    1625     1528526 :   auto result = ParseAndClassifyIdentifier(CHECK_OK_CUSTOM(NullIdentifier));
    1626             : 
    1627     1525820 :   if (allow_restricted_identifiers == kDontAllowRestrictedIdentifiers) {
    1628      297858 :     ValidateAssignmentPattern(CHECK_OK_CUSTOM(NullIdentifier));
    1629      297982 :     ValidateBindingPattern(CHECK_OK_CUSTOM(NullIdentifier));
    1630             :   }
    1631             : 
    1632     1525548 :   return result;
    1633             : }
    1634             : 
    1635             : template <typename Impl>
    1636             : typename ParserBase<Impl>::IdentifierT
    1637   166157927 : ParserBase<Impl>::ParseAndClassifyIdentifier(bool* ok) {
    1638             :   Token::Value next = Next();
    1639    78129267 :   if (next == Token::IDENTIFIER || next == Token::ASYNC ||
    1640       21069 :       (next == Token::AWAIT && !parsing_module_ && !is_async_function())) {
    1641    35211564 :     IdentifierT name = impl()->GetSymbol();
    1642             :     // When this function is used to read a formal parameter, we don't always
    1643             :     // know whether the function is going to be strict or sloppy.  Indeed for
    1644             :     // arrow functions we don't always know that the identifier we are reading
    1645             :     // is actually a formal parameter.  Therefore besides the errors that we
    1646             :     // must detect because we know we're in strict mode, we also record any
    1647             :     // error that we might make in the future once we know the language mode.
    1648    78012147 :     if (impl()->IsEvalOrArguments(name)) {
    1649      969686 :       classifier()->RecordStrictModeFormalParameterError(
    1650             :           scanner()->location(), MessageTemplate::kStrictEvalArguments);
    1651      484843 :       if (is_strict(language_mode())) {
    1652      480996 :         classifier()->RecordBindingPatternError(
    1653             :             scanner()->location(), MessageTemplate::kStrictEvalArguments);
    1654             :       }
    1655    77527304 :     } else if (next == Token::AWAIT) {
    1656       35720 :       classifier()->RecordAsyncArrowFormalParametersError(
    1657             :           scanner()->location(), MessageTemplate::kAwaitBindingIdentifier);
    1658             :     }
    1659             : 
    1660    86370164 :     if (classifier()->duplicate_finder() != nullptr &&
    1661             :         scanner()->IsDuplicateSymbol(classifier()->duplicate_finder(),
    1662             :                                      ast_value_factory())) {
    1663       31848 :       classifier()->RecordDuplicateFormalParameterError(scanner()->location());
    1664             :     }
    1665    78012146 :     return name;
    1666       89707 :   } else if (is_sloppy(language_mode()) &&
    1667             :              (next == Token::FUTURE_STRICT_RESERVED_WORD ||
    1668             :               next == Token::ESCAPED_STRICT_RESERVED_WORD ||
    1669             :               next == Token::LET || next == Token::STATIC ||
    1670             :               (next == Token::YIELD && !is_generator()))) {
    1671       90848 :     classifier()->RecordStrictModeFormalParameterError(
    1672             :         scanner()->location(), MessageTemplate::kUnexpectedStrictReserved);
    1673       46596 :     if (next == Token::ESCAPED_STRICT_RESERVED_WORD &&
    1674             :         is_strict(language_mode())) {
    1675           0 :       ReportUnexpectedToken(next);
    1676           0 :       *ok = false;
    1677           0 :       return impl()->NullIdentifier();
    1678             :     }
    1679       45424 :     if (scanner()->IsLet()) {
    1680       23570 :       classifier()->RecordLetPatternError(
    1681             :           scanner()->location(), MessageTemplate::kLetInLexicalBinding);
    1682             :     }
    1683       45424 :     return impl()->GetSymbol();
    1684             :   } else {
    1685       31017 :     ReportUnexpectedToken(next);
    1686       31017 :     *ok = false;
    1687       31017 :     return impl()->NullIdentifier();
    1688             :   }
    1689             : }
    1690             : 
    1691             : template <class Impl>
    1692             : typename ParserBase<Impl>::IdentifierT
    1693     2363348 : ParserBase<Impl>::ParseIdentifierOrStrictReservedWord(
    1694             :     FunctionKind function_kind, bool* is_strict_reserved, bool* is_await,
    1695             :     bool* ok) {
    1696             :   Token::Value next = Next();
    1697     2366228 :   if (next == Token::IDENTIFIER || (next == Token::AWAIT && !parsing_module_ &&
    1698             :                                     !IsAsyncFunction(function_kind)) ||
    1699             :       next == Token::ASYNC) {
    1700     2350594 :     *is_strict_reserved = false;
    1701     2350594 :     *is_await = next == Token::AWAIT;
    1702       16680 :   } else if (next == Token::ESCAPED_STRICT_RESERVED_WORD ||
    1703             :              next == Token::FUTURE_STRICT_RESERVED_WORD || next == Token::LET ||
    1704             :              next == Token::STATIC ||
    1705             :              (next == Token::YIELD && !IsGeneratorFunction(function_kind))) {
    1706        8293 :     *is_strict_reserved = true;
    1707             :   } else {
    1708        4461 :     ReportUnexpectedToken(next);
    1709        4461 :     *ok = false;
    1710        4461 :     return impl()->NullIdentifier();
    1711             :   }
    1712             : 
    1713     2358887 :   return impl()->GetSymbol();
    1714             : }
    1715             : 
    1716             : template <typename Impl>
    1717    17284721 : typename ParserBase<Impl>::IdentifierT ParserBase<Impl>::ParseIdentifierName(
    1718             :     bool* ok) {
    1719             :   Token::Value next = Next();
    1720    17400342 :   if (next != Token::IDENTIFIER && next != Token::ASYNC &&
    1721             :       next != Token::ENUM && next != Token::AWAIT && next != Token::LET &&
    1722             :       next != Token::STATIC && next != Token::YIELD &&
    1723             :       next != Token::FUTURE_STRICT_RESERVED_WORD &&
    1724             :       next != Token::ESCAPED_KEYWORD &&
    1725             :       next != Token::ESCAPED_STRICT_RESERVED_WORD && !Token::IsKeyword(next)) {
    1726       19836 :     ReportUnexpectedToken(next);
    1727       19836 :     *ok = false;
    1728       19836 :     return impl()->NullIdentifier();
    1729             :   }
    1730             : 
    1731    17264888 :   return impl()->GetSymbol();
    1732             : }
    1733             : 
    1734             : template <typename Impl>
    1735       93951 : typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseRegExpLiteral(
    1736      187663 :     bool* ok) {
    1737             :   int pos = peek_position();
    1738       93951 :   if (!scanner()->ScanRegExpPattern()) {
    1739             :     Next();
    1740         239 :     ReportMessage(MessageTemplate::kUnterminatedRegExp);
    1741         239 :     *ok = false;
    1742         239 :     return impl()->NullExpression();
    1743             :   }
    1744             : 
    1745             :   IdentifierT js_pattern = impl()->GetNextSymbol();
    1746       93712 :   Maybe<RegExp::Flags> flags = scanner()->ScanRegExpFlags();
    1747       93712 :   if (flags.IsNothing()) {
    1748             :     Next();
    1749         659 :     ReportMessage(MessageTemplate::kMalformedRegExpFlags);
    1750         659 :     *ok = false;
    1751         659 :     return impl()->NullExpression();
    1752             :   }
    1753       62028 :   int js_flags = flags.FromJust();
    1754             :   Next();
    1755      124056 :   return factory()->NewRegExpLiteral(js_pattern, js_flags, pos);
    1756             : }
    1757             : 
    1758             : template <typename Impl>
    1759   128656662 : typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParsePrimaryExpression(
    1760   139335439 :     bool* is_async, bool* ok) {
    1761             :   // PrimaryExpression ::
    1762             :   //   'this'
    1763             :   //   'null'
    1764             :   //   'true'
    1765             :   //   'false'
    1766             :   //   Identifier
    1767             :   //   Number
    1768             :   //   String
    1769             :   //   ArrayLiteral
    1770             :   //   ObjectLiteral
    1771             :   //   RegExpLiteral
    1772             :   //   ClassLiteral
    1773             :   //   '(' Expression ')'
    1774             :   //   TemplateLiteral
    1775             :   //   do Block
    1776             :   //   AsyncFunctionLiteral
    1777             : 
    1778             :   int beg_pos = peek_position();
    1779   128656713 :   switch (peek()) {
    1780             :     case Token::THIS: {
    1781     4035601 :       BindingPatternUnexpectedToken();
    1782     4035601 :       Consume(Token::THIS);
    1783     2701668 :       return impl()->ThisExpression(beg_pos);
    1784             :     }
    1785             : 
    1786             :     case Token::NULL_LITERAL:
    1787             :     case Token::TRUE_LITERAL:
    1788             :     case Token::FALSE_LITERAL:
    1789             :     case Token::SMI:
    1790             :     case Token::NUMBER:
    1791             :     case Token::BIGINT:
    1792    29104399 :       BindingPatternUnexpectedToken();
    1793    20986392 :       return impl()->ExpressionFromLiteral(Next(), beg_pos);
    1794             : 
    1795             :     case Token::ASYNC:
    1796       86308 :       if (!scanner()->HasAnyLineTerminatorAfterNext() &&
    1797             :           PeekAhead() == Token::FUNCTION) {
    1798       20257 :         BindingPatternUnexpectedToken();
    1799       20257 :         Consume(Token::ASYNC);
    1800       20257 :         return ParseAsyncFunctionLiteral(CHECK_OK);
    1801             :       }
    1802             :       // CoverCallExpressionAndAsyncArrowHead
    1803       22897 :       *is_async = true;
    1804             :     /* falls through */
    1805             :     case Token::IDENTIFIER:
    1806             :     case Token::LET:
    1807             :     case Token::STATIC:
    1808             :     case Token::YIELD:
    1809             :     case Token::AWAIT:
    1810             :     case Token::ESCAPED_STRICT_RESERVED_WORD:
    1811             :     case Token::FUTURE_STRICT_RESERVED_WORD: {
    1812             :       // Using eval or arguments in this context is OK even in strict mode.
    1813    76578197 :       IdentifierT name = ParseAndClassifyIdentifier(CHECK_OK);
    1814    76530575 :       return impl()->ExpressionFromIdentifier(name, beg_pos);
    1815             :     }
    1816             : 
    1817             :     case Token::STRING: {
    1818    10751879 :       BindingPatternUnexpectedToken();
    1819    10751879 :       Consume(Token::STRING);
    1820     5523575 :       return impl()->ExpressionFromString(beg_pos);
    1821             :     }
    1822             : 
    1823             :     case Token::ASSIGN_DIV:
    1824             :     case Token::DIV:
    1825      187902 :       classifier()->RecordBindingPatternError(
    1826             :           scanner()->peek_location(), MessageTemplate::kUnexpectedTokenRegExp);
    1827       93951 :       return ParseRegExpLiteral(ok);
    1828             : 
    1829             :     case Token::LBRACK:
    1830     1029262 :       return ParseArrayLiteral(ok);
    1831             : 
    1832             :     case Token::LBRACE:
    1833     1504276 :       return ParseObjectLiteral(ok);
    1834             : 
    1835             :     case Token::LPAREN: {
    1836             :       // Arrow function formal parameters are either a single identifier or a
    1837             :       // list of BindingPattern productions enclosed in parentheses.
    1838             :       // Parentheses are not valid on the LHS of a BindingPattern, so we use the
    1839             :       // is_valid_binding_pattern() check to detect multiple levels of
    1840             :       // parenthesization.
    1841             :       bool pattern_error = !classifier()->is_valid_binding_pattern();
    1842     4165826 :       classifier()->RecordPatternError(scanner()->peek_location(),
    1843             :                                        MessageTemplate::kUnexpectedToken,
    1844             :                                        Token::String(Token::LPAREN));
    1845     4165826 :       if (pattern_error) ArrowFormalParametersUnexpectedToken();
    1846     4165826 :       Consume(Token::LPAREN);
    1847     4165827 :       if (Check(Token::RPAREN)) {
    1848             :         // ()=>x.  The continuation that looks for the => is in
    1849             :         // ParseAssignmentExpression.
    1850      839332 :         classifier()->RecordExpressionError(scanner()->location(),
    1851             :                                             MessageTemplate::kUnexpectedToken,
    1852             :                                             Token::String(Token::RPAREN));
    1853      539794 :         return factory()->NewEmptyParentheses(beg_pos);
    1854             :       }
    1855             :       // Heuristically try to detect immediately called functions before
    1856             :       // seeing the call parentheses.
    1857     6839639 :       if (peek() == Token::FUNCTION ||
    1858             :           (peek() == Token::ASYNC && PeekAhead() == Token::FUNCTION)) {
    1859      674295 :         function_state_->set_next_function_is_likely_called();
    1860             :       }
    1861     3795526 :       ExpressionT expr = ParseExpressionCoverGrammar(true, CHECK_OK);
    1862     3612252 :       Expect(Token::RPAREN, CHECK_OK);
    1863     3610431 :       return expr;
    1864             :     }
    1865             : 
    1866             :     case Token::CLASS: {
    1867       58358 :       BindingPatternUnexpectedToken();
    1868       58358 :       Consume(Token::CLASS);
    1869             :       int class_token_pos = position();
    1870       19213 :       IdentifierT name = impl()->NullIdentifier();
    1871       58358 :       bool is_strict_reserved_name = false;
    1872       58358 :       Scanner::Location class_name_location = Scanner::Location::invalid();
    1873       58358 :       if (peek_any_identifier()) {
    1874       17733 :         bool is_await = false;
    1875       17733 :         name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved_name,
    1876       18013 :                                                    &is_await, CHECK_OK);
    1877       17333 :         class_name_location = scanner()->location();
    1878       17333 :         if (is_await) {
    1879         320 :           classifier()->RecordAsyncArrowFormalParametersError(
    1880             :               scanner()->location(), MessageTemplate::kAwaitBindingIdentifier);
    1881             :         }
    1882             :       }
    1883             :       return ParseClassLiteral(name, class_name_location,
    1884       57958 :                                is_strict_reserved_name, class_token_pos, ok);
    1885             :     }
    1886             : 
    1887             :     case Token::TEMPLATE_SPAN:
    1888             :     case Token::TEMPLATE_TAIL:
    1889       47451 :       BindingPatternUnexpectedToken();
    1890       47451 :       return ParseTemplateLiteral(impl()->NullExpression(), beg_pos, false, ok);
    1891             : 
    1892             :     case Token::MOD:
    1893     1199774 :       if (allow_natives() || extension_ != nullptr) {
    1894     1199666 :         BindingPatternUnexpectedToken();
    1895     1199666 :         return ParseV8Intrinsic(ok);
    1896             :       }
    1897             :       break;
    1898             : 
    1899             :     case Token::DO:
    1900        1112 :       if (allow_harmony_do_expressions()) {
    1901         975 :         BindingPatternUnexpectedToken();
    1902         975 :         return ParseDoExpression(ok);
    1903             :       }
    1904             :       break;
    1905             : 
    1906             :     default:
    1907             :       break;
    1908             :   }
    1909             : 
    1910       85303 :   ReportUnexpectedToken(Next());
    1911       85303 :   *ok = false;
    1912       85303 :   return impl()->NullExpression();
    1913             : }
    1914             : 
    1915             : template <typename Impl>
    1916             : typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseExpression(
    1917             :     bool accept_IN, bool* ok) {
    1918    29759269 :   ExpressionClassifier classifier(this);
    1919    29759267 :   ExpressionT result = ParseExpressionCoverGrammar(accept_IN, CHECK_OK);
    1920    59007999 :   impl()->RewriteNonPattern(CHECK_OK);
    1921     9266707 :   return result;
    1922             : }
    1923             : 
    1924             : template <typename Impl>
    1925             : typename ParserBase<Impl>::ExpressionT
    1926    71197072 : ParserBase<Impl>::ParseExpressionCoverGrammar(bool accept_IN, bool* ok) {
    1927             :   // Expression ::
    1928             :   //   AssignmentExpression
    1929             :   //   Expression ',' AssignmentExpression
    1930             : 
    1931    33652343 :   ExpressionT result = impl()->NullExpression();
    1932             :   while (true) {
    1933             :     int comma_pos = position();
    1934    39052837 :     ExpressionClassifier binding_classifier(this);
    1935             :     ExpressionT right;
    1936    39052836 :     if (Check(Token::ELLIPSIS)) {
    1937             :       // 'x, y, ...z' in CoverParenthesizedExpressionAndArrowParameterList only
    1938             :       // as the formal parameters of'(x, y, ...z) => foo', and is not itself a
    1939             :       // valid expression.
    1940       22130 :       classifier()->RecordExpressionError(scanner()->location(),
    1941             :                                           MessageTemplate::kUnexpectedToken,
    1942             :                                           Token::String(Token::ELLIPSIS));
    1943             :       int ellipsis_pos = position();
    1944             :       int pattern_pos = peek_position();
    1945       11525 :       ExpressionT pattern = ParsePrimaryExpression(CHECK_OK);
    1946       10305 :       if (peek() == Token::ASSIGN) {
    1947         140 :         ReportMessage(MessageTemplate::kRestDefaultInitializer);
    1948         140 :         *ok = false;
    1949         140 :         return result;
    1950             :       }
    1951       10425 :       ValidateBindingPattern(CHECK_OK);
    1952        9676 :       right = factory()->NewSpread(pattern, ellipsis_pos, pattern_pos);
    1953             :     } else {
    1954    39212860 :       right = ParseAssignmentExpression(accept_IN, CHECK_OK);
    1955             :     }
    1956             :     // No need to accumulate binding pattern-related errors, since
    1957             :     // an Expression can't be a binding pattern anyway.
    1958             :     AccumulateNonBindingPatternErrors();
    1959    38658444 :     if (!impl()->IsIdentifier(right)) classifier()->RecordNonSimpleParameter();
    1960    38658444 :     if (impl()->IsNull(result)) {
    1961             :       // First time through the loop.
    1962    16703078 :       result = right;
    1963             :     } else {
    1964      351266 :       result =
    1965             :           factory()->NewBinaryOperation(Token::COMMA, result, right, comma_pos);
    1966             :     }
    1967             : 
    1968    38658444 :     if (!Check(Token::COMMA)) break;
    1969             : 
    1970      364496 :     if (right->IsSpread()) {
    1971         640 :       classifier()->RecordArrowFormalParametersError(
    1972             :           scanner()->location(), MessageTemplate::kParamAfterRest);
    1973             :     }
    1974             : 
    1975      282601 :     if (peek() == Token::RPAREN && PeekAhead() == Token::ARROW) {
    1976             :       // a trailing comma is allowed at the end of an arrow parameter list
    1977             :       break;
    1978             :     }
    1979             : 
    1980             :     // Pass on the 'set_next_function_is_likely_called' flag if we have
    1981             :     // several function literals separated by comma.
    1982      280852 :     if (peek() == Token::FUNCTION &&
    1983             :         function_state_->previous_function_was_likely_called()) {
    1984          17 :       function_state_->set_next_function_is_likely_called();
    1985             :     }
    1986             :   }
    1987             : 
    1988    38377596 :   return result;
    1989             : }
    1990             : 
    1991             : template <typename Impl>
    1992     1029262 : typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseArrayLiteral(
    1993    18535114 :     bool* ok) {
    1994             :   // ArrayLiteral ::
    1995             :   //   '[' Expression? (',' Expression?)* ']'
    1996             : 
    1997             :   int pos = peek_position();
    1998      394106 :   ExpressionListT values = impl()->NewExpressionList(4);
    1999             :   int first_spread_index = -1;
    2000     1029262 :   Expect(Token::LBRACK, CHECK_OK);
    2001    12271433 :   while (peek() != Token::RBRACK) {
    2002             :     ExpressionT elem;
    2003    11254470 :     if (peek() == Token::COMMA) {
    2004     2325991 :       elem = factory()->NewTheHoleLiteral();
    2005     8928479 :     } else if (peek() == Token::ELLIPSIS) {
    2006             :       int start_pos = peek_position();
    2007       41990 :       Consume(Token::ELLIPSIS);
    2008             :       int expr_pos = peek_position();
    2009       48873 :       ExpressionT argument = ParseAssignmentExpression(true, CHECK_OK);
    2010       55437 :       elem = factory()->NewSpread(argument, start_pos, expr_pos);
    2011             : 
    2012       38910 :       if (first_spread_index < 0) {
    2013       19887 :         first_spread_index = values->length();
    2014             :       }
    2015             : 
    2016       61293 :       if (argument->IsAssignment()) {
    2017        3863 :         classifier()->RecordPatternError(
    2018             :             Scanner::Location(start_pos, scanner()->location().end_pos),
    2019             :             MessageTemplate::kInvalidDestructuringTarget);
    2020             :       } else {
    2021       35047 :         CheckDestructuringElement(argument, start_pos,
    2022             :                                   scanner()->location().end_pos);
    2023             :       }
    2024             : 
    2025       38910 :       if (peek() == Token::COMMA) {
    2026        9298 :         classifier()->RecordPatternError(
    2027             :             Scanner::Location(start_pos, scanner()->location().end_pos),
    2028             :             MessageTemplate::kElementAfterRest);
    2029             :       }
    2030             :     } else {
    2031             :       int beg_pos = peek_position();
    2032     8891887 :       elem = ParseAssignmentExpression(true, CHECK_OK);
    2033     8877288 :       CheckDestructuringElement(elem, beg_pos, scanner()->location().end_pos);
    2034             :     }
    2035    11242189 :     values->Add(elem, zone_);
    2036    11242189 :     if (peek() != Token::RBRACK) {
    2037    10740445 :       Expect(Token::COMMA, CHECK_OK);
    2038             :     }
    2039             :   }
    2040     1016963 :   Expect(Token::RBRACK, CHECK_OK);
    2041             : 
    2042             :   ExpressionT result =
    2043      645468 :       factory()->NewArrayLiteral(values, first_spread_index, pos);
    2044     1016963 :   if (first_spread_index >= 0) {
    2045       15205 :     result = factory()->NewRewritableExpression(result);
    2046       15205 :     impl()->QueueNonPatternForRewriting(result, ok);
    2047       35092 :     if (!*ok) {
    2048             :       // If the non-pattern rewriting mechanism is used in the future for
    2049             :       // rewriting other things than spreads, this error message will have
    2050             :       // to change.  Also, this error message will never appear while pre-
    2051             :       // parsing (this is OK, as it is an implementation limitation).
    2052           0 :       ReportMessage(MessageTemplate::kTooManySpreads);
    2053           0 :       return impl()->NullExpression();
    2054             :     }
    2055             :   }
    2056     1016963 :   return result;
    2057             : }
    2058             : 
    2059             : template <class Impl>
    2060     6030926 : bool ParserBase<Impl>::SetPropertyKindFromToken(Token::Value token,
    2061             :                                                 PropertyKind* kind) {
    2062             :   // This returns true, setting the property kind, iff the given token is one
    2063             :   // which must occur after a property name, indicating that the previous token
    2064             :   // was in fact a name and not a modifier (like the "get" in "get x").
    2065     6030926 :   switch (token) {
    2066             :     case Token::COLON:
    2067     5264239 :       *kind = PropertyKind::kValueProperty;
    2068             :       return true;
    2069             :     case Token::COMMA:
    2070             :     case Token::RBRACE:
    2071             :     case Token::ASSIGN:
    2072      190392 :       *kind = PropertyKind::kShorthandProperty;
    2073             :       return true;
    2074             :     case Token::LPAREN:
    2075      492209 :       *kind = PropertyKind::kMethodProperty;
    2076             :       return true;
    2077             :     case Token::MUL:
    2078             :     case Token::SEMICOLON:
    2079        5107 :       *kind = PropertyKind::kClassField;
    2080             :       return true;
    2081             :     default:
    2082             :       break;
    2083             :   }
    2084             :   return false;
    2085             : }
    2086             : 
    2087             : template <class Impl>
    2088     6100843 : typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParsePropertyName(
    2089     1776012 :     IdentifierT* name, PropertyKind* kind, bool* is_generator, bool* is_get,
    2090     4468671 :     bool* is_set, bool* is_async, bool* is_computed_name, bool* ok) {
    2091             :   DCHECK_EQ(*kind, PropertyKind::kNotSet);
    2092             :   DCHECK(!*is_generator);
    2093             :   DCHECK(!*is_get);
    2094             :   DCHECK(!*is_set);
    2095             :   DCHECK(!*is_async);
    2096             :   DCHECK(!*is_computed_name);
    2097             : 
    2098     6100843 :   *is_generator = Check(Token::MUL);
    2099     6100843 :   if (*is_generator) {
    2100       26380 :     *kind = PropertyKind::kMethodProperty;
    2101             :   }
    2102             : 
    2103             :   Token::Value token = peek();
    2104             :   int pos = peek_position();
    2105             : 
    2106     6118706 :   if (!*is_generator && token == Token::ASYNC &&
    2107             :       !scanner()->HasAnyLineTerminatorAfterNext()) {
    2108       17543 :     Consume(Token::ASYNC);
    2109             :     token = peek();
    2110       24191 :     if (token == Token::MUL && allow_harmony_async_iteration() &&
    2111        2924 :         !scanner()->HasAnyLineTerminatorBeforeNext()) {
    2112        2924 :       Consume(Token::MUL);
    2113             :       token = peek();
    2114        2924 :       *is_generator = true;
    2115       14619 :     } else if (SetPropertyKindFromToken(token, kind)) {
    2116        3440 :       *name = impl()->GetSymbol();  // TODO(bakkot) specialize on 'async'
    2117        1720 :       impl()->PushLiteralName(*name);
    2118        5160 :       return factory()->NewStringLiteral(*name, pos);
    2119             :     }
    2120       14103 :     *kind = PropertyKind::kMethodProperty;
    2121       14103 :     *is_async = true;
    2122             :     pos = peek_position();
    2123             :   }
    2124             : 
    2125     6097403 :   if (token == Token::IDENTIFIER && !*is_generator && !*is_async) {
    2126             :     // This is checking for 'get' and 'set' in particular.
    2127     3560160 :     Consume(Token::IDENTIFIER);
    2128             :     token = peek();
    2129     3624380 :     if (SetPropertyKindFromToken(token, kind) ||
    2130             :         !scanner()->IsGetOrSet(is_get, is_set)) {
    2131     3496939 :       *name = impl()->GetSymbol();
    2132     2488830 :       impl()->PushLiteralName(*name);
    2133     4505048 :       return factory()->NewStringLiteral(*name, pos);
    2134             :     }
    2135       63221 :     *kind = PropertyKind::kAccessorProperty;
    2136             :     pos = peek_position();
    2137             :   }
    2138             : 
    2139             :   // For non computed property names we normalize the name a bit:
    2140             :   //
    2141             :   //   "12" -> 12
    2142             :   //   12.3 -> "12.3"
    2143             :   //   12.30 -> "12.3"
    2144             :   //   identifier -> "identifier"
    2145             :   //
    2146             :   // This is important because we use the property name as a key in a hash
    2147             :   // table when we compute constant properties.
    2148      815341 :   ExpressionT expression = impl()->NullExpression();
    2149     2600464 :   switch (token) {
    2150             :     case Token::STRING:
    2151      134167 :       Consume(Token::STRING);
    2152      134167 :       *name = impl()->GetSymbol();
    2153      134167 :       break;
    2154             : 
    2155             :     case Token::SMI:
    2156     2251131 :       Consume(Token::SMI);
    2157     2251131 :       *name = impl()->GetNumberAsSymbol();
    2158     2251131 :       break;
    2159             : 
    2160             :     case Token::NUMBER:
    2161        7796 :       Consume(Token::NUMBER);
    2162        7796 :       *name = impl()->GetNumberAsSymbol();
    2163        7796 :       break;
    2164             : 
    2165             :     case Token::LBRACK: {
    2166       51107 :       *name = impl()->NullIdentifier();
    2167       51107 :       *is_computed_name = true;
    2168       51107 :       Consume(Token::LBRACK);
    2169       51107 :       ExpressionClassifier computed_name_classifier(this);
    2170       51887 :       expression = ParseAssignmentExpression(true, CHECK_OK);
    2171       49867 :       impl()->RewriteNonPattern(CHECK_OK);
    2172             :       AccumulateFormalParameterContainmentErrors();
    2173       50047 :       Expect(Token::RBRACK, CHECK_OK);
    2174             :       break;
    2175             :     }
    2176             : 
    2177             :     case Token::ELLIPSIS:
    2178       58670 :       if (allow_harmony_object_rest_spread() && !*is_generator && !*is_async &&
    2179       21395 :           !*is_get && !*is_set) {
    2180       21315 :         *name = impl()->NullIdentifier();
    2181       21315 :         Consume(Token::ELLIPSIS);
    2182       22485 :         expression = ParseAssignmentExpression(true, CHECK_OK);
    2183       19395 :         *kind = PropertyKind::kSpreadProperty;
    2184             : 
    2185       19395 :         if (!impl()->IsIdentifier(expression)) {
    2186       13380 :           classifier()->RecordBindingPatternError(
    2187             :               scanner()->location(),
    2188             :               MessageTemplate::kInvalidRestBindingPattern);
    2189             :         }
    2190             : 
    2191       19395 :         if (!expression->IsValidReferenceExpression()) {
    2192        7760 :           classifier()->RecordAssignmentPatternError(
    2193             :               scanner()->location(),
    2194             :               MessageTemplate::kInvalidRestAssignmentPattern);
    2195             :         }
    2196             : 
    2197       19395 :         if (peek() != Token::RBRACE) {
    2198        8850 :           classifier()->RecordPatternError(scanner()->location(),
    2199             :                                            MessageTemplate::kElementAfterRest);
    2200             :         }
    2201       19395 :         return expression;
    2202             :       }
    2203             :     // Fall-through.
    2204             : 
    2205             :     default:
    2206      145748 :       *name = ParseIdentifierName(CHECK_OK);
    2207             :       break;
    2208             :   }
    2209             : 
    2210     2558291 :   if (*kind == PropertyKind::kNotSet) {
    2211     2456147 :     SetPropertyKindFromToken(peek(), kind);
    2212             :   }
    2213             : 
    2214     2558291 :   if (*is_computed_name) {
    2215       25683 :     return expression;
    2216             :   }
    2217             : 
    2218     1742601 :   impl()->PushLiteralName(*name);
    2219             : 
    2220             :   uint32_t index;
    2221             :   return impl()->IsArrayIndex(*name, &index)
    2222     4251385 :              ? factory()->NewNumberLiteral(index, pos)
    2223     4251385 :              : factory()->NewStringLiteral(*name, pos);
    2224             : }
    2225             : 
    2226             : template <typename Impl>
    2227             : typename ParserBase<Impl>::ClassLiteralPropertyT
    2228      526067 : ParserBase<Impl>::ParseClassPropertyDefinition(
    2229             :     ClassLiteralChecker* checker, bool has_extends, bool* is_computed_name,
    2230             :     bool* has_seen_constructor, ClassLiteralProperty::Kind* property_kind,
    2231     1089859 :     bool* is_static, bool* has_name_static_property, bool* ok) {
    2232             :   DCHECK_NOT_NULL(has_seen_constructor);
    2233             :   DCHECK_NOT_NULL(has_name_static_property);
    2234      526067 :   bool is_get = false;
    2235      526067 :   bool is_set = false;
    2236      526067 :   bool is_generator = false;
    2237      526067 :   bool is_async = false;
    2238      526067 :   *is_static = false;
    2239      526067 :   *property_kind = ClassLiteralProperty::METHOD;
    2240      526067 :   PropertyKind kind = PropertyKind::kNotSet;
    2241             : 
    2242             :   Token::Value name_token = peek();
    2243             : 
    2244             :   int name_token_position = scanner()->peek_location().beg_pos;
    2245      526067 :   IdentifierT name = impl()->NullIdentifier();
    2246             :   ExpressionT name_expression;
    2247      526067 :   if (name_token == Token::STATIC) {
    2248       25054 :     Consume(Token::STATIC);
    2249             :     name_token_position = scanner()->peek_location().beg_pos;
    2250       25054 :     if (peek() == Token::LPAREN) {
    2251         240 :       kind = PropertyKind::kMethodProperty;
    2252         240 :       name = impl()->GetSymbol();  // TODO(bakkot) specialize on 'static'
    2253         240 :       name_expression = factory()->NewStringLiteral(name, position());
    2254       74442 :     } else if (peek() == Token::ASSIGN || peek() == Token::SEMICOLON ||
    2255             :                peek() == Token::RBRACE) {
    2256         160 :       name = impl()->GetSymbol();  // TODO(bakkot) specialize on 'static'
    2257         160 :       name_expression = factory()->NewStringLiteral(name, position());
    2258             :     } else {
    2259       24654 :       *is_static = true;
    2260       24654 :       name_expression = ParsePropertyName(&name, &kind, &is_generator, &is_get,
    2261             :                                           &is_set, &is_async, is_computed_name,
    2262       24774 :                                           CHECK_OK_CUSTOM(NullLiteralProperty));
    2263             :     }
    2264             :   } else {
    2265      501013 :     name_expression = ParsePropertyName(&name, &kind, &is_generator, &is_get,
    2266             :                                         &is_set, &is_async, is_computed_name,
    2267      501553 :                                         CHECK_OK_CUSTOM(NullLiteralProperty));
    2268             :   }
    2269             : 
    2270      549271 :   if (!*has_name_static_property && *is_static && impl()->IsName(name)) {
    2271          93 :     *has_name_static_property = true;
    2272             :   }
    2273             : 
    2274      524782 :   switch (kind) {
    2275             :     case PropertyKind::kClassField:
    2276             :     case PropertyKind::kNotSet:  // This case is a name followed by a name or
    2277             :                                  // other property. Here we have to assume
    2278             :                                  // that's an uninitialized field followed by a
    2279             :                                  // linebreak followed by a property, with ASI
    2280             :                                  // adding the semicolon. If not, there will be
    2281             :                                  // a syntax error after parsing the first name
    2282             :                                  // as an uninitialized field.
    2283             :     case PropertyKind::kShorthandProperty:
    2284             :     case PropertyKind::kValueProperty:
    2285       16267 :       if (allow_harmony_class_fields()) {
    2286       14080 :         bool has_initializer = Check(Token::ASSIGN);
    2287             :         ExpressionT function_literal = ParseClassFieldForInitializer(
    2288       14240 :             has_initializer, CHECK_OK_CUSTOM(NullLiteralProperty));
    2289       14400 :         ExpectSemicolon(CHECK_OK_CUSTOM(NullLiteralProperty));
    2290       12480 :         *property_kind = ClassLiteralProperty::FIELD;
    2291             :         ClassLiteralPropertyT result = factory()->NewClassLiteralProperty(
    2292             :             name_expression, function_literal, *property_kind, *is_static,
    2293        6240 :             *is_computed_name);
    2294        6240 :         impl()->SetFunctionNameFromPropertyName(result, name);
    2295       12480 :         return result;
    2296             : 
    2297             :       } else {
    2298        2187 :         ReportUnexpectedToken(Next());
    2299        2187 :         *ok = false;
    2300        2187 :         return impl()->NullLiteralProperty();
    2301             :       }
    2302             : 
    2303             :     case PropertyKind::kMethodProperty: {
    2304             :       DCHECK(!is_get && !is_set);
    2305             : 
    2306             :       // MethodDefinition
    2307             :       //    PropertyName '(' StrictFormalParameters ')' '{' FunctionBody '}'
    2308             :       //    '*' PropertyName '(' StrictFormalParameters ')' '{' FunctionBody '}'
    2309             :       //    async PropertyName '(' StrictFormalParameters ')'
    2310             :       //        '{' FunctionBody '}'
    2311             :       //    async '*' PropertyName '(' StrictFormalParameters ')'
    2312             :       //        '{' FunctionBody '}'
    2313             : 
    2314      476374 :       if (!*is_computed_name) {
    2315      471157 :         checker->CheckClassMethodName(name_token, PropertyKind::kMethodProperty,
    2316             :                                       is_generator, is_async, *is_static,
    2317      471797 :                                       CHECK_OK_CUSTOM(NullLiteralProperty));
    2318             :       }
    2319             : 
    2320      475058 :       FunctionKind kind = MethodKindFor(is_generator, is_async);
    2321             : 
    2322      935364 :       if (!*is_static && impl()->IsConstructor(name)) {
    2323       42903 :         *has_seen_constructor = true;
    2324       42903 :         kind = has_extends ? FunctionKind::kDerivedConstructor
    2325             :                            : FunctionKind::kBaseConstructor;
    2326             :       }
    2327             : 
    2328             :       ExpressionT value = impl()->ParseFunctionLiteral(
    2329             :           name, scanner()->location(), kSkipFunctionNameCheck, kind,
    2330             :           FLAG_harmony_function_tostring ? name_token_position
    2331             :                                          : kNoSourcePosition,
    2332             :           FunctionLiteral::kAccessorOrMethod, language_mode(),
    2333      954996 :           CHECK_OK_CUSTOM(NullLiteralProperty));
    2334             : 
    2335      465118 :       *property_kind = ClassLiteralProperty::METHOD;
    2336             :       ClassLiteralPropertyT result = factory()->NewClassLiteralProperty(
    2337             :           name_expression, value, *property_kind, *is_static,
    2338      450725 :           *is_computed_name);
    2339      450725 :       impl()->SetFunctionNameFromPropertyName(result, name);
    2340      465118 :       return result;
    2341             :     }
    2342             : 
    2343             :     case PropertyKind::kAccessorProperty: {
    2344             :       DCHECK((is_get || is_set) && !is_generator && !is_async);
    2345             : 
    2346       32131 :       if (!*is_computed_name) {
    2347       28811 :         checker->CheckClassMethodName(
    2348             :             name_token, PropertyKind::kAccessorProperty, false, false,
    2349       29211 :             *is_static, CHECK_OK_CUSTOM(NullLiteralProperty));
    2350             :         // Make sure the name expression is a string since we need a Name for
    2351             :         // Runtime_DefineAccessorPropertyUnchecked and since we can determine
    2352             :         // this statically we can skip the extra runtime check.
    2353       27949 :         name_expression =
    2354             :             factory()->NewStringLiteral(name, name_expression->position());
    2355             :       }
    2356             : 
    2357             :       FunctionKind kind = is_get ? FunctionKind::kGetterFunction
    2358       31259 :                                  : FunctionKind::kSetterFunction;
    2359             : 
    2360             :       FunctionLiteralT value = impl()->ParseFunctionLiteral(
    2361             :           name, scanner()->location(), kSkipFunctionNameCheck, kind,
    2362             :           FLAG_harmony_function_tostring ? name_token_position
    2363             :                                          : kNoSourcePosition,
    2364             :           FunctionLiteral::kAccessorOrMethod, language_mode(),
    2365       66438 :           CHECK_OK_CUSTOM(NullLiteralProperty));
    2366             : 
    2367       23311 :       *property_kind =
    2368             :           is_get ? ClassLiteralProperty::GETTER : ClassLiteralProperty::SETTER;
    2369             :       ClassLiteralPropertyT result = factory()->NewClassLiteralProperty(
    2370             :           name_expression, value, *property_kind, *is_static,
    2371       15954 :           *is_computed_name);
    2372             :       const AstRawString* prefix =
    2373       15954 :           is_get ? ast_value_factory()->get_space_string()
    2374       15954 :                  : ast_value_factory()->set_space_string();
    2375       15954 :       impl()->SetFunctionNameFromPropertyName(result, name, prefix);
    2376       23311 :       return result;
    2377             :     }
    2378             :     case PropertyKind::kSpreadProperty:
    2379          10 :       ReportUnexpectedTokenAt(
    2380             :           Scanner::Location(name_token_position, name_expression->position()),
    2381          10 :           name_token);
    2382          10 :       *ok = false;
    2383          10 :       return impl()->NullLiteralProperty();
    2384             :   }
    2385           0 :   UNREACHABLE();
    2386             : }
    2387             : 
    2388             : template <typename Impl>
    2389             : typename ParserBase<Impl>::FunctionLiteralT
    2390       14080 : ParserBase<Impl>::ParseClassFieldForInitializer(bool has_initializer,
    2391       48800 :                                                 bool* ok) {
    2392             :   // Makes a concise method which evaluates and returns the initialized value
    2393             :   // (or undefined if absent).
    2394             :   FunctionKind kind = FunctionKind::kConciseMethod;
    2395       14080 :   DeclarationScope* initializer_scope = NewFunctionScope(kind);
    2396        6880 :   initializer_scope->set_start_position(scanner()->location().end_pos);
    2397       14080 :   FunctionState initializer_state(&function_state_, &scope_, initializer_scope);
    2398             :   DCHECK_EQ(initializer_scope, scope());
    2399             :   scope()->SetLanguageMode(LanguageMode::kStrict);
    2400       14080 :   ExpressionClassifier expression_classifier(this);
    2401             :   ExpressionT value;
    2402       14080 :   if (has_initializer) {
    2403        4960 :     value =
    2404        5120 :         this->ParseAssignmentExpression(true, CHECK_OK_CUSTOM(NullExpression));
    2405        4640 :     impl()->RewriteNonPattern(CHECK_OK_CUSTOM(NullExpression));
    2406             :   } else {
    2407        4560 :     value = factory()->NewUndefinedLiteral(kNoSourcePosition);
    2408             :   }
    2409             :   initializer_scope->set_end_position(scanner()->location().end_pos);
    2410             :   typename Types::StatementList body = impl()->NewStatementList(1);
    2411       13760 :   body->Add(factory()->NewReturnStatement(value, kNoSourcePosition), zone());
    2412             :   FunctionLiteralT function_literal = factory()->NewFunctionLiteral(
    2413             :       impl()->EmptyIdentifierString(), initializer_scope, body,
    2414             :       initializer_state.expected_property_count(), 0, 0,
    2415             :       FunctionLiteral::kNoDuplicateParameters,
    2416             :       FunctionLiteral::kAnonymousExpression, default_eager_compile_hint_,
    2417       13760 :       initializer_scope->start_position(), true, GetNextFunctionLiteralId());
    2418       13760 :   return function_literal;
    2419             : }
    2420             : 
    2421             : template <typename Impl>
    2422             : typename ParserBase<Impl>::ObjectLiteralPropertyT
    2423     5575176 : ParserBase<Impl>::ParseObjectPropertyDefinition(ObjectLiteralChecker* checker,
    2424             :                                                 bool* is_computed_name,
    2425             :                                                 bool* is_rest_property,
    2426    16956134 :                                                 bool* ok) {
    2427     5575176 :   bool is_get = false;
    2428     5575176 :   bool is_set = false;
    2429     5575176 :   bool is_generator = false;
    2430     5575176 :   bool is_async = false;
    2431     5575176 :   PropertyKind kind = PropertyKind::kNotSet;
    2432             : 
    2433     5575176 :   IdentifierT name = impl()->NullIdentifier();
    2434             :   Token::Value name_token = peek();
    2435             :   int next_beg_pos = scanner()->peek_location().beg_pos;
    2436             :   int next_end_pos = scanner()->peek_location().end_pos;
    2437             : 
    2438             :   ExpressionT name_expression = ParsePropertyName(
    2439             :       &name, &kind, &is_generator, &is_get, &is_set, &is_async,
    2440     5587446 :       is_computed_name, CHECK_OK_CUSTOM(NullLiteralProperty));
    2441             : 
    2442     5553683 :   switch (kind) {
    2443             :     case PropertyKind::kSpreadProperty:
    2444             :       DCHECK(allow_harmony_object_rest_spread());
    2445             :       DCHECK(!is_get && !is_set && !is_generator && !is_async &&
    2446             :              !*is_computed_name);
    2447             :       DCHECK(name_token == Token::ELLIPSIS);
    2448             : 
    2449       19385 :       *is_computed_name = true;
    2450       19385 :       *is_rest_property = true;
    2451             : 
    2452             :       return factory()->NewObjectLiteralProperty(
    2453             :           factory()->NewTheHoleLiteral(), name_expression,
    2454       17680 :           ObjectLiteralProperty::SPREAD, true);
    2455             : 
    2456             :     case PropertyKind::kValueProperty: {
    2457             :       DCHECK(!is_get && !is_set && !is_generator && !is_async);
    2458             : 
    2459     5263359 :       if (!*is_computed_name) {
    2460     5228867 :         checker->CheckDuplicateProto(name_token);
    2461             :       }
    2462     5263359 :       Consume(Token::COLON);
    2463             :       int beg_pos = peek_position();
    2464             :       ExpressionT value =
    2465     5279088 :           ParseAssignmentExpression(true, CHECK_OK_CUSTOM(NullLiteralProperty));
    2466     5242260 :       CheckDestructuringElement(value, beg_pos, scanner()->location().end_pos);
    2467             : 
    2468             :       ObjectLiteralPropertyT result = factory()->NewObjectLiteralProperty(
    2469     3651363 :           name_expression, value, *is_computed_name);
    2470     3651362 :       impl()->SetFunctionNameFromPropertyName(result, name);
    2471     5242261 :       return result;
    2472             :     }
    2473             : 
    2474             :     case PropertyKind::kShorthandProperty: {
    2475             :       // PropertyDefinition
    2476             :       //    IdentifierReference
    2477             :       //    CoverInitializedName
    2478             :       //
    2479             :       // CoverInitializedName
    2480             :       //    IdentifierReference Initializer?
    2481             :       DCHECK(!is_get && !is_set && !is_generator && !is_async);
    2482             : 
    2483      182632 :       if (!Token::IsIdentifier(name_token, language_mode(),
    2484             :                                this->is_generator(),
    2485      727832 :                                parsing_module_ || is_async_function())) {
    2486        8670 :         ReportUnexpectedToken(Next());
    2487        8670 :         *ok = false;
    2488        8670 :         return impl()->NullLiteralProperty();
    2489             :       }
    2490             : 
    2491             :       DCHECK(!*is_computed_name);
    2492             : 
    2493      191511 :       if (classifier()->duplicate_finder() != nullptr &&
    2494             :           scanner()->IsDuplicateSymbol(classifier()->duplicate_finder(),
    2495             :                                        ast_value_factory())) {
    2496         836 :         classifier()->RecordDuplicateFormalParameterError(
    2497             :             scanner()->location());
    2498             :       }
    2499             : 
    2500      238019 :       if (impl()->IsEvalOrArguments(name) && is_strict(language_mode())) {
    2501        3360 :         classifier()->RecordBindingPatternError(
    2502             :             scanner()->location(), MessageTemplate::kStrictEvalArguments);
    2503             :       }
    2504             : 
    2505      173962 :       if (name_token == Token::LET) {
    2506         100 :         classifier()->RecordLetPatternError(
    2507             :             scanner()->location(), MessageTemplate::kLetInLexicalBinding);
    2508             :       }
    2509      173962 :       if (name_token == Token::AWAIT) {
    2510             :         DCHECK(!is_async_function());
    2511         320 :         classifier()->RecordAsyncArrowFormalParametersError(
    2512             :             Scanner::Location(next_beg_pos, next_end_pos),
    2513             :             MessageTemplate::kAwaitBindingIdentifier);
    2514             :       }
    2515      173962 :       ExpressionT lhs = impl()->ExpressionFromIdentifier(name, next_beg_pos);
    2516      173962 :       CheckDestructuringElement(lhs, next_beg_pos, next_end_pos);
    2517             : 
    2518             :       ExpressionT value;
    2519      173962 :       if (peek() == Token::ASSIGN) {
    2520       32955 :         Consume(Token::ASSIGN);
    2521       32955 :         ExpressionClassifier rhs_classifier(this);
    2522             :         ExpressionT rhs = ParseAssignmentExpression(
    2523       33355 :             true, CHECK_OK_CUSTOM(NullLiteralProperty));
    2524       32315 :         impl()->RewriteNonPattern(CHECK_OK_CUSTOM(NullLiteralProperty));
    2525             :         AccumulateFormalParameterContainmentErrors();
    2526       13513 :         value = factory()->NewAssignment(Token::ASSIGN, lhs, rhs,
    2527             :                                          kNoSourcePosition);
    2528       32315 :         classifier()->RecordExpressionError(
    2529             :             Scanner::Location(next_beg_pos, scanner()->location().end_pos),
    2530             :             MessageTemplate::kInvalidCoverInitializedName);
    2531             : 
    2532       13513 :         impl()->SetFunctionNameFromIdentifierRef(rhs, lhs);
    2533             :       } else {
    2534             :         value = lhs;
    2535             :       }
    2536             : 
    2537             :       ObjectLiteralPropertyT result = factory()->NewObjectLiteralProperty(
    2538       60125 :           name_expression, value, ObjectLiteralProperty::COMPUTED, false);
    2539       60125 :       impl()->SetFunctionNameFromPropertyName(result, name);
    2540      173322 :       return result;
    2541             :     }
    2542             : 
    2543             :     case PropertyKind::kMethodProperty: {
    2544             :       DCHECK(!is_get && !is_set);
    2545             : 
    2546             :       // MethodDefinition
    2547             :       //    PropertyName '(' StrictFormalParameters ')' '{' FunctionBody '}'
    2548             :       //    '*' PropertyName '(' StrictFormalParameters ')' '{' FunctionBody '}'
    2549             : 
    2550       55478 :       classifier()->RecordPatternError(
    2551             :           Scanner::Location(next_beg_pos, scanner()->location().end_pos),
    2552             :           MessageTemplate::kInvalidDestructuringTarget);
    2553             : 
    2554       55478 :       FunctionKind kind = MethodKindFor(is_generator, is_async);
    2555             : 
    2556             :       ExpressionT value = impl()->ParseFunctionLiteral(
    2557             :           name, scanner()->location(), kSkipFunctionNameCheck, kind,
    2558             :           FLAG_harmony_function_tostring ? next_beg_pos : kNoSourcePosition,
    2559             :           FunctionLiteral::kAccessorOrMethod, language_mode(),
    2560      117916 :           CHECK_OK_CUSTOM(NullLiteralProperty));
    2561             : 
    2562             :       ObjectLiteralPropertyT result = factory()->NewObjectLiteralProperty(
    2563             :           name_expression, value, ObjectLiteralProperty::COMPUTED,
    2564       24540 :           *is_computed_name);
    2565       24540 :       impl()->SetFunctionNameFromPropertyName(result, name);
    2566       41449 :       return result;
    2567             :     }
    2568             : 
    2569             :     case PropertyKind::kAccessorProperty: {
    2570             :       DCHECK((is_get || is_set) && !(is_set && is_get) && !is_generator &&
    2571             :              !is_async);
    2572             : 
    2573       30610 :       classifier()->RecordPatternError(
    2574             :           Scanner::Location(next_beg_pos, scanner()->location().end_pos),
    2575             :           MessageTemplate::kInvalidDestructuringTarget);
    2576             : 
    2577       30610 :       if (!*is_computed_name) {
    2578             :         // Make sure the name expression is a string since we need a Name for
    2579             :         // Runtime_DefineAccessorPropertyUnchecked and since we can determine
    2580             :         // this statically we can skip the extra runtime check.
    2581       29875 :         name_expression =
    2582             :             factory()->NewStringLiteral(name, name_expression->position());
    2583             :       }
    2584             : 
    2585             :       FunctionKind kind = is_get ? FunctionKind::kGetterFunction
    2586       30610 :                                  : FunctionKind::kSetterFunction;
    2587             : 
    2588             :       FunctionLiteralT value = impl()->ParseFunctionLiteral(
    2589             :           name, scanner()->location(), kSkipFunctionNameCheck, kind,
    2590             :           FLAG_harmony_function_tostring ? next_beg_pos : kNoSourcePosition,
    2591             :           FunctionLiteral::kAccessorOrMethod, language_mode(),
    2592       66445 :           CHECK_OK_CUSTOM(NullLiteralProperty));
    2593             : 
    2594             :       ObjectLiteralPropertyT result = factory()->NewObjectLiteralProperty(
    2595             :           name_expression, value,
    2596             :           is_get ? ObjectLiteralProperty::GETTER
    2597             :                  : ObjectLiteralProperty::SETTER,
    2598       12552 :           *is_computed_name);
    2599             :       const AstRawString* prefix =
    2600       12552 :           is_get ? ast_value_factory()->get_space_string()
    2601       12552 :                  : ast_value_factory()->set_space_string();
    2602       12552 :       impl()->SetFunctionNameFromPropertyName(result, name, prefix);
    2603       19749 :       return result;
    2604             :     }
    2605             : 
    2606             :     case PropertyKind::kClassField:
    2607             :     case PropertyKind::kNotSet:
    2608        2219 :       ReportUnexpectedToken(Next());
    2609        2219 :       *ok = false;
    2610        2219 :       return impl()->NullLiteralProperty();
    2611             :   }
    2612           0 :   UNREACHABLE();
    2613             : }
    2614             : 
    2615             : template <typename Impl>
    2616     1504276 : typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseObjectLiteral(
    2617     7000480 :     bool* ok) {
    2618             :   // ObjectLiteral ::
    2619             :   // '{' (PropertyDefinition (',' PropertyDefinition)* ','? )? '}'
    2620             : 
    2621             :   int pos = peek_position();
    2622        7450 :   typename Types::ObjectPropertyList properties =
    2623      709381 :       impl()->NewObjectPropertyList(4);
    2624             :   int number_of_boilerplate_properties = 0;
    2625             : 
    2626             :   bool has_computed_names = false;
    2627             :   bool has_rest_property = false;
    2628             :   ObjectLiteralChecker checker(this);
    2629             : 
    2630     1504276 :   Expect(Token::LBRACE, CHECK_OK);
    2631             : 
    2632     6998433 :   while (peek() != Token::RBRACE) {
    2633     5575176 :     FuncNameInferrer::State fni_state(fni_);
    2634             : 
    2635     5575176 :     bool is_computed_name = false;
    2636     5575176 :     bool is_rest_property = false;
    2637             :     ObjectLiteralPropertyT property = ParseObjectPropertyDefinition(
    2638     5621430 :         &checker, &is_computed_name, &is_rest_property, CHECK_OK);
    2639             : 
    2640     3757418 :     if (is_computed_name) {
    2641             :       has_computed_names = true;
    2642             :     }
    2643             : 
    2644     5496164 :     if (is_rest_property) {
    2645             :       has_rest_property = true;
    2646             :     }
    2647             : 
    2648     3757418 :     if (impl()->IsBoilerplateProperty(property) && !has_computed_names) {
    2649             :       // Count CONSTANT or COMPUTED properties to maintain the enumeration
    2650             :       // order.
    2651     3697449 :       number_of_boilerplate_properties++;
    2652             :     }
    2653             : 
    2654     5496164 :     properties->Add(property, zone());
    2655             : 
    2656     5496166 :     if (peek() != Token::RBRACE) {
    2657             :       // Need {} because of the CHECK_OK macro.
    2658     4449948 :       Expect(Token::COMMA, CHECK_OK);
    2659             :     }
    2660             : 
    2661     5494157 :     if (fni_ != nullptr) fni_->Infer();
    2662             :   }
    2663     1423257 :   Expect(Token::RBRACE, CHECK_OK);
    2664             : 
    2665             :   // In pattern rewriter, we rewrite rest property to call out to a
    2666             :   // runtime function passing all the other properties as arguments to
    2667             :   // this runtime function. Here, we make sure that the number of
    2668             :   // properties is less than number of arguments allowed for a runtime
    2669             :   // call.
    2670     1430707 :   if (has_rest_property && properties->length() > Code::kMaxArguments) {
    2671          20 :     this->classifier()->RecordPatternError(Scanner::Location(pos, position()),
    2672             :                                            MessageTemplate::kTooManyArguments);
    2673             :   }
    2674             : 
    2675             :   return factory()->NewObjectLiteral(
    2676      761230 :       properties, number_of_boilerplate_properties, pos, has_rest_property);
    2677             : }
    2678             : 
    2679             : template <typename Impl>
    2680    13217907 : typename ParserBase<Impl>::ExpressionListT ParserBase<Impl>::ParseArguments(
    2681             :     Scanner::Location* first_spread_arg_loc, bool maybe_arrow,
    2682    34882995 :     bool* is_simple_parameter_list, bool* ok) {
    2683             :   // Arguments ::
    2684             :   //   '(' (AssignmentExpression)*[','] ')'
    2685             : 
    2686             :   Scanner::Location spread_arg = Scanner::Location::invalid();
    2687    18989404 :   ExpressionListT result = impl()->NewExpressionList(4);
    2688    13217910 :   Expect(Token::LPAREN, CHECK_OK_CUSTOM(NullExpressionList));
    2689    13217907 :   bool done = (peek() == Token::RPAREN);
    2690    48228897 :   while (!done) {
    2691             :     int start_pos = peek_position();
    2692    21800313 :     bool is_spread = Check(Token::ELLIPSIS);
    2693             :     int expr_pos = peek_position();
    2694             : 
    2695             :     ExpressionT argument =
    2696    21807529 :         ParseAssignmentExpression(true, CHECK_OK_CUSTOM(NullExpressionList));
    2697    21793119 :     if (!impl()->IsIdentifier(argument) &&
    2698             :         is_simple_parameter_list != nullptr) {
    2699        3848 :       *is_simple_parameter_list = false;
    2700             :     }
    2701    21793119 :     if (!maybe_arrow) {
    2702    21785216 :       impl()->RewriteNonPattern(CHECK_OK_CUSTOM(NullExpressionList));
    2703             :     }
    2704    21793118 :     if (is_spread) {
    2705        8559 :       if (is_simple_parameter_list != nullptr) {
    2706         427 :         *is_simple_parameter_list = false;
    2707             :       }
    2708        8559 :       if (!spread_arg.IsValid()) {
    2709             :         spread_arg.beg_pos = start_pos;
    2710             :         spread_arg.end_pos = peek_position();
    2711             :       }
    2712       17118 :       if (argument->IsAssignment()) {
    2713         160 :         classifier()->RecordAsyncArrowFormalParametersError(
    2714             :             scanner()->location(), MessageTemplate::kRestDefaultInitializer);
    2715             :       }
    2716       13340 :       argument = factory()->NewSpread(argument, start_pos, expr_pos);
    2717             :     }
    2718    21793118 :     result->Add(argument, zone_);
    2719             : 
    2720    21793118 :     if (result->length() > Code::kMaxArguments) {
    2721          30 :       ReportMessage(MessageTemplate::kTooManyArguments);
    2722          30 :       *ok = false;
    2723          30 :       return impl()->NullExpressionList();
    2724             :     }
    2725    21793083 :     done = (peek() != Token::COMMA);
    2726    21793083 :     if (!done) {
    2727             :       Next();
    2728    22320770 :       if (argument->IsSpread()) {
    2729        3950 :         classifier()->RecordAsyncArrowFormalParametersError(
    2730             :             scanner()->location(), MessageTemplate::kParamAfterRest);
    2731             :       }
    2732    11160385 :       if (peek() == Token::RPAREN) {
    2733             :         // allow trailing comma
    2734             :         done = true;
    2735             :       }
    2736             :     }
    2737             :   }
    2738    13210677 :   Scanner::Location location = scanner_->location();
    2739    13210682 :   if (Token::RPAREN != Next()) {
    2740          77 :     impl()->ReportMessageAt(location, MessageTemplate::kUnterminatedArgList);
    2741         215 :     *ok = false;
    2742         215 :     return impl()->NullExpressionList();
    2743             :   }
    2744    13210467 :   *first_spread_arg_loc = spread_arg;
    2745             : 
    2746    13222512 :   if (!maybe_arrow || peek() != Token::ARROW) {
    2747    13201547 :     if (maybe_arrow) {
    2748        3207 :       impl()->RewriteNonPattern(CHECK_OK_CUSTOM(NullExpressionList));
    2749             :     }
    2750             :   }
    2751             : 
    2752    13210288 :   return result;
    2753             : }
    2754             : 
    2755             : // Precedence = 2
    2756             : template <typename Impl>
    2757             : typename ParserBase<Impl>::ExpressionT
    2758   311821534 : ParserBase<Impl>::ParseAssignmentExpression(bool accept_IN, bool* ok) {
    2759             :   // AssignmentExpression ::
    2760             :   //   ConditionalExpression
    2761             :   //   ArrowFunction
    2762             :   //   YieldExpression
    2763             :   //   LeftHandSideExpression AssignmentOperator AssignmentExpression
    2764             :   int lhs_beg_pos = peek_position();
    2765             : 
    2766    97567822 :   if (peek() == Token::YIELD && is_generator()) {
    2767       42023 :     return ParseYieldExpression(accept_IN, ok);
    2768             :   }
    2769             : 
    2770    97472922 :   FuncNameInferrer::State fni_state(fni_);
    2771             :   ExpressionClassifier arrow_formals_classifier(
    2772    97472933 :       this, classifier()->duplicate_finder());
    2773             : 
    2774   194945912 :   Scope::Snapshot scope_snapshot(scope());
    2775             :   int rewritable_length =
    2776    97472950 :       function_state_->destructuring_assignments_to_rewrite().length();
    2777             : 
    2778             :   bool is_async = peek() == Token::ASYNC &&
    2779             :                   !scanner()->HasAnyLineTerminatorAfterNext() &&
    2780    97550983 :                   IsValidArrowFormalParametersStart(PeekAhead());
    2781             : 
    2782    97472932 :   bool parenthesized_formals = peek() == Token::LPAREN;
    2783    97472932 :   if (!is_async && !parenthesized_formals) {
    2784    94449028 :     ArrowFormalParametersUnexpectedToken();
    2785             :   }
    2786             : 
    2787             :   // Parse a simple, faster sub-grammar (primary expression) if it's evident
    2788             :   // that we have only a trivial expression to parse.
    2789             :   ExpressionT expression;
    2790    97472995 :   if (IsTrivialExpression()) {
    2791    50512219 :     expression = ParsePrimaryExpression(&is_async, CHECK_OK);
    2792             :   } else {
    2793    47163371 :     expression = ParseConditionalExpression(accept_IN, CHECK_OK);
    2794             :   }
    2795             : 
    2796    97042435 :   if (is_async && impl()->IsIdentifier(expression) && peek_any_identifier() &&
    2797             :       PeekAhead() == Token::ARROW) {
    2798             :     // async Identifier => AsyncConciseBody
    2799        1311 :     IdentifierT name = ParseAndClassifyIdentifier(CHECK_OK);
    2800         605 :     expression =
    2801             :         impl()->ExpressionFromIdentifier(name, position(), InferName::kNo);
    2802        1171 :     if (fni_) {
    2803             :       // Remove `async` keyword from inferred name stack.
    2804         566 :       fni_->RemoveAsyncKeywordFromEnd();
    2805             :     }
    2806             :   }
    2807             : 
    2808    97030709 :   if (peek() == Token::ARROW) {
    2809      809858 :     Scanner::Location arrow_loc = scanner()->peek_location();
    2810      809858 :     ValidateArrowFormalParameters(expression, parenthesized_formals, is_async,
    2811     1636126 :                                   CHECK_OK);
    2812             :     // This reads strangely, but is correct: it checks whether any
    2813             :     // sub-expression of the parameter list failed to be a valid formal
    2814             :     // parameter initializer. Since YieldExpressions are banned anywhere
    2815             :     // in an arrow parameter list, this is correct.
    2816             :     // TODO(adamk): Rename "FormalParameterInitializerError" to refer to
    2817             :     // "YieldExpression", which is its only use.
    2818      777278 :     ValidateFormalParameterInitializer(ok);
    2819             : 
    2820             :     Scanner::Location loc(lhs_beg_pos, scanner()->location().end_pos);
    2821             :     DeclarationScope* scope =
    2822             :         NewFunctionScope(is_async ? FunctionKind::kAsyncArrowFunction
    2823      777278 :                                   : FunctionKind::kArrowFunction);
    2824             : 
    2825             :     // Because the arrow's parameters were parsed in the outer scope,
    2826             :     // we need to fix up the scope chain appropriately.
    2827      777278 :     scope_snapshot.Reparent(scope);
    2828      777278 :     function_state_->SetDestructuringAssignmentsScope(rewritable_length, scope);
    2829             : 
    2830             :     FormalParametersT parameters(scope);
    2831      777278 :     if (!classifier()->is_simple_parameter_list()) {
    2832             :       scope->SetHasNonSimpleParameters();
    2833       26951 :       parameters.is_simple = false;
    2834             :     }
    2835             : 
    2836             :     scope->set_start_position(lhs_beg_pos);
    2837      777278 :     Scanner::Location duplicate_loc = Scanner::Location::invalid();
    2838      777278 :     impl()->DeclareArrowFunctionFormalParameters(&parameters, expression, loc,
    2839      779598 :                                                  &duplicate_loc, CHECK_OK);
    2840      772638 :     if (duplicate_loc.IsValid()) {
    2841          48 :       classifier()->RecordDuplicateFormalParameterError(duplicate_loc);
    2842             :     }
    2843      772638 :     expression = ParseArrowFunctionLiteral(accept_IN, parameters,
    2844     1554875 :                                            rewritable_length, CHECK_OK);
    2845             :     DiscardExpressionClassifier();
    2846      755560 :     classifier()->RecordPatternError(arrow_loc,
    2847             :                                      MessageTemplate::kUnexpectedToken,
    2848             :                                      Token::String(Token::ARROW));
    2849             : 
    2850      755560 :     if (fni_ != nullptr) fni_->Infer();
    2851             : 
    2852      755560 :     return expression;
    2853             :   }
    2854             : 
    2855             :   // "expression" was not itself an arrow function parameter list, but it might
    2856             :   // form part of one.  Propagate speculative formal parameter error locations
    2857             :   // (including those for binding patterns, since formal parameters can
    2858             :   // themselves contain binding patterns).
    2859             :   unsigned productions = ExpressionClassifier::AllProductions &
    2860             :                          ~ExpressionClassifier::ArrowFormalParametersProduction;
    2861             : 
    2862             :   // Parenthesized identifiers and property references are allowed as part
    2863             :   // of a larger assignment pattern, even though parenthesized patterns
    2864             :   // themselves are not allowed, e.g., "[(x)] = []". Only accumulate
    2865             :   // assignment pattern errors if the parsed expression is more complex.
    2866    96220851 :   if (IsValidReferenceExpression(expression)) {
    2867             :     productions &= ~ExpressionClassifier::AssignmentPatternProduction;
    2868             :   }
    2869             : 
    2870             :   const bool is_destructuring_assignment =
    2871    98431791 :       IsValidPattern(expression) && peek() == Token::ASSIGN;
    2872    96220888 :   if (is_destructuring_assignment) {
    2873             :     // This is definitely not an expression so don't accumulate
    2874             :     // expression-related errors.
    2875      175046 :     productions &= ~ExpressionClassifier::ExpressionProduction;
    2876             :   }
    2877             : 
    2878    96220888 :   if (!Token::IsAssignmentOp(peek())) {
    2879             :     // Parsed conditional expression only (no assignment).
    2880             :     // Pending non-pattern expressions must be merged.
    2881             :     Accumulate(productions);
    2882    86384161 :     return expression;
    2883             :   } else {
    2884             :     // Pending non-pattern expressions must be discarded.
    2885             :     Accumulate(productions, false);
    2886             :   }
    2887             : 
    2888     9836742 :   if (is_destructuring_assignment) {
    2889      184500 :     ValidateAssignmentPattern(CHECK_OK);
    2890             :   } else {
    2891             :     expression = CheckAndRewriteReferenceExpression(
    2892             :         expression, lhs_beg_pos, scanner()->location().end_pos,
    2893     9666385 :         MessageTemplate::kInvalidLhsInAssignment, CHECK_OK);
    2894             :   }
    2895             : 
    2896             :   impl()->MarkExpressionAsAssigned(expression);
    2897             : 
    2898             :   Token::Value op = Next();  // Get assignment operator.
    2899     9808876 :   if (op != Token::ASSIGN) {
    2900     1631228 :     classifier()->RecordPatternError(scanner()->location(),
    2901             :                                      MessageTemplate::kUnexpectedToken,
    2902             :                                      Token::String(op));
    2903             :   }
    2904             :   int pos = position();
    2905             : 
    2906     9808876 :   ExpressionClassifier rhs_classifier(this);
    2907             : 
    2908     9816438 :   ExpressionT right = ParseAssignmentExpression(accept_IN, CHECK_OK);
    2909     9796220 :   impl()->RewriteNonPattern(CHECK_OK);
    2910             :   AccumulateFormalParameterContainmentErrors();
    2911             : 
    2912             :   // We try to estimate the set of properties set by constructors. We define a
    2913             :   // new property whenever there is an assignment to a property of 'this'. We
    2914             :   // should probably only add properties if we haven't seen them
    2915             :   // before. Otherwise we'll probably overestimate the number of properties.
    2916    18775316 :   if (op == Token::ASSIGN && impl()->IsThisProperty(expression)) {
    2917      939989 :     function_state_->AddProperty();
    2918             :   }
    2919             : 
    2920             :   impl()->CheckAssigningFunctionLiteralToProperty(expression, right);
    2921             : 
    2922     9795460 :   if (fni_ != nullptr) {
    2923             :     // Check if the right hand side is a call to avoid inferring a
    2924             :     // name if we're dealing with "a = function(){...}();"-like
    2925             :     // expression.
    2926    16859089 :     if (op == Token::ASSIGN && !right->IsCall() && !right->IsCallNew()) {
    2927     5214537 :       fni_->Infer();
    2928             :     } else {
    2929      701648 :       fni_->RemoveLastFunction();
    2930             :     }
    2931             :   }
    2932             : 
    2933     5916186 :   if (op == Token::ASSIGN) {
    2934     5583859 :     impl()->SetFunctionNameFromIdentifierRef(right, expression);
    2935             :   }
    2936             : 
    2937     9795459 :   if (op == Token::ASSIGN_EXP) {
    2938             :     DCHECK(!is_destructuring_assignment);
    2939         145 :     return impl()->RewriteAssignExponentiation(expression, right, pos);
    2940             :   }
    2941             : 
    2942             :   DCHECK_NE(op, Token::INIT);
    2943     5916040 :   ExpressionT result = factory()->NewAssignment(op, expression, right, pos);
    2944             : 
    2945     5916040 :   if (is_destructuring_assignment) {
    2946       77428 :     result = factory()->NewRewritableExpression(result);
    2947             :     impl()->QueueDestructuringAssignmentForRewriting(result);
    2948             :   }
    2949             : 
    2950     9795174 :   return result;
    2951             : }
    2952             : 
    2953             : template <typename Impl>
    2954       42023 : typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseYieldExpression(
    2955      210115 :     bool accept_IN, bool* ok) {
    2956             :   // YieldExpression ::
    2957             :   //   'yield' ([no line terminator] '*'? AssignmentExpression)?
    2958             :   int pos = peek_position();
    2959       84046 :   classifier()->RecordPatternError(
    2960             :       scanner()->peek_location(), MessageTemplate::kInvalidDestructuringTarget);
    2961       84046 :   classifier()->RecordFormalParameterInitializerError(
    2962             :       scanner()->peek_location(), MessageTemplate::kYieldInParameter);
    2963       42023 :   Expect(Token::YIELD, CHECK_OK);
    2964             :   // The following initialization is necessary.
    2965             :   ExpressionT expression = impl()->NullExpression();
    2966             :   bool delegating = false;  // yield*
    2967       84046 :   if (!scanner()->HasAnyLineTerminatorBeforeNext()) {
    2968       40336 :     if (Check(Token::MUL)) delegating = true;
    2969       40336 :     switch (peek()) {
    2970             :       case Token::EOS:
    2971             :       case Token::SEMICOLON:
    2972             :       case Token::RBRACE:
    2973             :       case Token::RBRACK:
    2974             :       case Token::RPAREN:
    2975             :       case Token::COLON:
    2976             :       case Token::COMMA:
    2977             :       case Token::IN:
    2978             :         // The above set of tokens is the complete set of tokens that can appear
    2979             :         // after an AssignmentExpression, and none of them can start an
    2980             :         // AssignmentExpression.  This allows us to avoid looking for an RHS for
    2981             :         // a regular yield, given only one look-ahead token.
    2982       15954 :         if (!delegating) break;
    2983             :         // Delegating yields require an RHS; fall through.
    2984             :       default:
    2985       25739 :         expression = ParseAssignmentExpression(accept_IN, CHECK_OK);
    2986       23295 :         impl()->RewriteNonPattern(CHECK_OK);
    2987             :         break;
    2988             :     }
    2989             :   }
    2990             : 
    2991       40616 :   if (delegating) {
    2992        2102 :     ExpressionT yieldstar = factory()->NewYieldStar(expression, pos);
    2993        5151 :     impl()->RecordSuspendSourceRange(yieldstar, PositionAfterSemicolon());
    2994        5151 :     return yieldstar;
    2995             :   }
    2996             : 
    2997             :   // Hackily disambiguate o from o.next and o [Symbol.iterator]().
    2998             :   // TODO(verwaest): Come up with a better solution.
    2999             :   ExpressionT yield =
    3000       16527 :       factory()->NewYield(expression, pos, Suspend::kOnExceptionThrow);
    3001       35465 :   impl()->RecordSuspendSourceRange(yield, PositionAfterSemicolon());
    3002       35465 :   return yield;
    3003             : }
    3004             : 
    3005             : // Precedence = 3
    3006             : template <typename Impl>
    3007             : typename ParserBase<Impl>::ExpressionT
    3008    46960756 : ParserBase<Impl>::ParseConditionalExpression(bool accept_IN,
    3009    27612779 :                                              bool* ok) {
    3010             :   // ConditionalExpression ::
    3011             :   //   LogicalOrExpression
    3012             :   //   LogicalOrExpression '?' AssignmentExpression ':' AssignmentExpression
    3013             : 
    3014             :   SourceRange then_range, else_range;
    3015             :   int pos = peek_position();
    3016             :   // We start using the binary expression parser for prec >= 4 only!
    3017    47160904 :   ExpressionT expression = ParseBinaryExpression(4, accept_IN, CHECK_OK);
    3018    46523524 :   if (peek() != Token::CONDITIONAL) return expression;
    3019      338000 :   impl()->RewriteNonPattern(CHECK_OK);
    3020      337280 :   BindingPatternUnexpectedToken();
    3021      337280 :   ArrowFormalParametersUnexpectedToken();
    3022      337280 :   Consume(Token::CONDITIONAL);
    3023             : 
    3024             :   ExpressionT left;
    3025             :   {
    3026             :     SourceRangeScope range_scope(scanner(), &then_range);
    3027      337280 :     ExpressionClassifier classifier(this);
    3028             :     // In parsing the first assignment expression in conditional
    3029             :     // expressions we always accept the 'in' keyword; see ECMA-262,
    3030             :     // section 11.12, page 58.
    3031      338380 :     left = ParseAssignmentExpression(true, CHECK_OK);
    3032             :     AccumulateNonBindingPatternErrors();
    3033             :   }
    3034      335190 :   impl()->RewriteNonPattern(CHECK_OK);
    3035      335057 :   Expect(Token::COLON, CHECK_OK);
    3036             :   ExpressionT right;
    3037             :   {
    3038             :     SourceRangeScope range_scope(scanner(), &else_range);
    3039      334916 :     ExpressionClassifier classifier(this);
    3040      335914 :     right = ParseAssignmentExpression(accept_IN, CHECK_OK);
    3041             :     AccumulateNonBindingPatternErrors();
    3042             :   }
    3043      332930 :   impl()->RewriteNonPattern(CHECK_OK);
    3044      113136 :   ExpressionT expr = factory()->NewConditional(expression, left, right, pos);
    3045             :   impl()->RecordConditionalSourceRange(expr, then_range, else_range);
    3046      332870 :   return expr;
    3047             : }
    3048             : 
    3049             : 
    3050             : // Precedence >= 4
    3051             : template <typename Impl>
    3052    59048598 : typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseBinaryExpression(
    3053     4743758 :     int prec, bool accept_IN, bool* ok) {
    3054             :   DCHECK_GE(prec, 4);
    3055    59248266 :   ExpressionT x = ParseUnaryExpression(CHECK_OK);
    3056   123227632 :   for (int prec1 = Precedence(peek(), accept_IN); prec1 >= prec; prec1--) {
    3057             :     // prec1 >= 4
    3058    76704119 :     while (Precedence(peek(), accept_IN) == prec1) {
    3059    12089289 :       impl()->RewriteNonPattern(CHECK_OK);
    3060    12087849 :       BindingPatternUnexpectedToken();
    3061    12087850 :       ArrowFormalParametersUnexpectedToken();
    3062             :       Token::Value op = Next();
    3063             :       int pos = position();
    3064             : 
    3065             :       const bool is_right_associative = op == Token::EXP;
    3066    12087849 :       const int next_prec = is_right_associative ? prec1 : prec1 + 1;
    3067    12089142 :       ExpressionT y = ParseBinaryExpression(next_prec, accept_IN, CHECK_OK);
    3068    12085062 :       impl()->RewriteNonPattern(CHECK_OK);
    3069             : 
    3070     4742264 :       if (impl()->ShortcutNumericLiteralBinaryExpression(&x, y, op, pos)) {
    3071             :         continue;
    3072             :       }
    3073             : 
    3074             :       // For now we distinguish between comparisons and other binary
    3075             :       // operations.  (We could combine the two and get rid of this
    3076             :       // code and AST node eventually.)
    3077    11503759 :       if (Token::IsCompareOp(op)) {
    3078             :         // We have a comparison.
    3079             :         Token::Value cmp = op;
    3080     2150765 :         switch (op) {
    3081       98446 :           case Token::NE: cmp = Token::EQ; break;
    3082      156170 :           case Token::NE_STRICT: cmp = Token::EQ_STRICT; break;
    3083             :           default: break;
    3084             :         }
    3085     7039741 :         x = factory()->NewCompareOperation(cmp, x, y, pos);
    3086     2150764 :         if (cmp != op) {
    3087             :           // The comparison was negated - add a NOT.
    3088      509232 :           x = factory()->NewUnaryOperation(Token::NOT, x, pos);
    3089             :         }
    3090     6614782 :       } else if (op == Token::EXP) {
    3091        3582 :         x = impl()->RewriteExponentiation(x, y, pos);
    3092             :       } else {
    3093             :         // We have a "normal" binary operation.
    3094    13221878 :         x = factory()->NewBinaryOperation(op, x, y, pos);
    3095             :       }
    3096             :     }
    3097             :   }
    3098    58608575 :   return x;
    3099             : }
    3100             : 
    3101             : template <typename Impl>
    3102    61833496 : typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseUnaryExpression(
    3103    61302023 :     bool* ok) {
    3104             :   // UnaryExpression ::
    3105             :   //   PostfixExpression
    3106             :   //   'delete' UnaryExpression
    3107             :   //   'void' UnaryExpression
    3108             :   //   'typeof' UnaryExpression
    3109             :   //   '++' UnaryExpression
    3110             :   //   '--' UnaryExpression
    3111             :   //   '+' UnaryExpression
    3112             :   //   '-' UnaryExpression
    3113             :   //   '~' UnaryExpression
    3114             :   //   '!' UnaryExpression
    3115             :   //   [+Await] AwaitExpression[?Yield]
    3116             : 
    3117             :   Token::Value op = peek();
    3118    61833500 :   if (Token::IsUnaryOp(op)) {
    3119     2469988 :     BindingPatternUnexpectedToken();
    3120     2469988 :     ArrowFormalParametersUnexpectedToken();
    3121             : 
    3122             :     op = Next();
    3123             :     int pos = position();
    3124             : 
    3125             :     // Assume "! function ..." indicates the function is likely to be called.
    3126     3314313 :     if (op == Token::NOT && peek() == Token::FUNCTION) {
    3127         252 :       function_state_->set_next_function_is_likely_called();
    3128             :     }
    3129             : 
    3130     2472030 :     ExpressionT expression = ParseUnaryExpression(CHECK_OK);
    3131     2465893 :     impl()->RewriteNonPattern(CHECK_OK);
    3132             : 
    3133     2494805 :     if (op == Token::DELETE && is_strict(language_mode())) {
    3134       20779 :       if (impl()->IsIdentifier(expression)) {
    3135             :         // "delete identifier" is a syntax error in strict mode.
    3136         522 :         ReportMessage(MessageTemplate::kStrictDelete);
    3137         522 :         *ok = false;
    3138         522 :         return impl()->NullExpression();
    3139             :       }
    3140             :     }
    3141             : 
    3142     2465371 :     if (peek() == Token::EXP) {
    3143        2880 :       ReportUnexpectedToken(Next());
    3144        2880 :       *ok = false;
    3145        2880 :       return impl()->NullExpression();
    3146             :     }
    3147             : 
    3148             :     // Allow the parser's implementation to rewrite the expression.
    3149     1378769 :     return impl()->BuildUnaryExpression(expression, op, pos);
    3150    59363512 :   } else if (Token::IsCountOp(op)) {
    3151      276069 :     BindingPatternUnexpectedToken();
    3152      276069 :     ArrowFormalParametersUnexpectedToken();
    3153             :     op = Next();
    3154             :     int beg_pos = peek_position();
    3155      277776 :     ExpressionT expression = ParseUnaryExpression(CHECK_OK);
    3156             :     expression = CheckAndRewriteReferenceExpression(
    3157             :         expression, beg_pos, scanner()->location().end_pos,
    3158      274194 :         MessageTemplate::kInvalidLhsInPrefixOp, CHECK_OK);
    3159             :     impl()->MarkExpressionAsAssigned(expression);
    3160      271524 :     impl()->RewriteNonPattern(CHECK_OK);
    3161             : 
    3162             :     return factory()->NewCountOperation(op,
    3163             :                                         true /* prefix */,
    3164             :                                         expression,
    3165      373200 :                                         position());
    3166             : 
    3167    59551180 :   } else if (is_async_function() && peek() == Token::AWAIT) {
    3168       77684 :     classifier()->RecordFormalParameterInitializerError(
    3169             :         scanner()->peek_location(),
    3170             :         MessageTemplate::kAwaitExpressionFormalParameter);
    3171             : 
    3172             :     int await_pos = peek_position();
    3173       38842 :     Consume(Token::AWAIT);
    3174             : 
    3175       43382 :     ExpressionT value = ParseUnaryExpression(CHECK_OK);
    3176             : 
    3177       16798 :     ExpressionT expr = factory()->NewAwait(value, await_pos);
    3178       32637 :     impl()->RecordSuspendSourceRange(expr, PositionAfterSemicolon());
    3179       32637 :     return expr;
    3180             :   } else {
    3181    59048604 :     return ParsePostfixExpression(ok);
    3182             :   }
    3183             : }
    3184             : 
    3185             : template <typename Impl>
    3186    59048599 : typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParsePostfixExpression(
    3187   119187426 :     bool* ok) {
    3188             :   // PostfixExpression ::
    3189             :   //   LeftHandSideExpression ('++' | '--')?
    3190             : 
    3191             :   int lhs_beg_pos = peek_position();
    3192    59244632 :   ExpressionT expression = ParseLeftHandSideExpression(CHECK_OK);
    3193   174745964 :   if (!scanner()->HasAnyLineTerminatorBeforeNext() &&
    3194             :       Token::IsCountOp(peek())) {
    3195     1076621 :     BindingPatternUnexpectedToken();
    3196     1076621 :     ArrowFormalParametersUnexpectedToken();
    3197             : 
    3198      632815 :     expression = CheckAndRewriteReferenceExpression(
    3199             :         expression, lhs_beg_pos, scanner()->location().end_pos,
    3200     1077602 :         MessageTemplate::kInvalidLhsInPostfixOp, CHECK_OK);
    3201             :     impl()->MarkExpressionAsAssigned(expression);
    3202     1074899 :     impl()->RewriteNonPattern(CHECK_OK);
    3203             : 
    3204             :     Token::Value next = Next();
    3205     1074899 :     expression =
    3206             :         factory()->NewCountOperation(next,
    3207             :                                      false /* postfix */,
    3208             :                                      expression,
    3209             :                                      position());
    3210             :   }
    3211    58617421 :   return expression;
    3212             : }
    3213             : 
    3214             : template <typename Impl>
    3215             : typename ParserBase<Impl>::ExpressionT
    3216    82009198 : ParserBase<Impl>::ParseLeftHandSideExpression(bool* ok) {
    3217             :   // LeftHandSideExpression ::
    3218             :   //   (NewExpression | MemberExpression) ...
    3219             : 
    3220    59114270 :   bool is_async = false;
    3221             :   ExpressionT result =
    3222    59306072 :       ParseMemberWithNewPrefixesExpression(&is_async, CHECK_OK);
    3223             : 
    3224             :   while (true) {
    3225    70439163 :     switch (peek()) {
    3226             :       case Token::LBRACK: {
    3227       22832 :         impl()->RewriteNonPattern(CHECK_OK);
    3228       22832 :         BindingPatternUnexpectedToken();
    3229       22832 :         ArrowFormalParametersUnexpectedToken();
    3230       22832 :         Consume(Token::LBRACK);
    3231             :         int pos = position();
    3232       22832 :         ExpressionT index = ParseExpressionCoverGrammar(true, CHECK_OK);
    3233       22822 :         impl()->RewriteNonPattern(CHECK_OK);
    3234       22822 :         result = factory()->NewProperty(result, index, pos);
    3235       22822 :         Expect(Token::RBRACK, CHECK_OK);
    3236        9182 :         break;
    3237             :       }
    3238             : 
    3239             :       case Token::LPAREN: {
    3240             :         int pos;
    3241    11336519 :         impl()->RewriteNonPattern(CHECK_OK);
    3242    11326386 :         BindingPatternUnexpectedToken();
    3243    11326387 :         if (scanner()->current_token() == Token::IDENTIFIER ||
    3244             :             scanner()->current_token() == Token::SUPER ||
    3245             :             scanner()->current_token() == Token::ASYNC) {
    3246             :           // For call of an identifier we want to report position of
    3247             :           // the identifier as position of the call in the stack trace.
    3248             :           pos = position();
    3249             :         } else {
    3250             :           // For other kinds of calls we record position of the parenthesis as
    3251             :           // position of the call. Note that this is extremely important for
    3252             :           // expressions of the form function(){...}() for which call position
    3253             :           // should not point to the closing brace otherwise it will intersect
    3254             :           // with positions recorded for function literal and confuse debugger.
    3255             :           pos = peek_position();
    3256             :           // Also the trailing parenthesis are a hint that the function will
    3257             :           // be called immediately. If we happen to have parsed a preceding
    3258             :           // function literal eagerly, we can also compile it eagerly.
    3259      229361 :           if (result->IsFunctionLiteral()) {
    3260      265380 :             result->AsFunctionLiteral()->SetShouldEagerCompile();
    3261             :           }
    3262             :         }
    3263             :         Scanner::Location spread_pos;
    3264        3382 :         ExpressionListT args;
    3265    11339311 :         if (V8_UNLIKELY(is_async && impl()->IsIdentifier(result))) {
    3266       12766 :           ExpressionClassifier async_classifier(this);
    3267       12766 :           bool is_simple_parameter_list = true;
    3268       12766 :           args = ParseArguments(&spread_pos, true, &is_simple_parameter_list,
    3269       13326 :                                 CHECK_OK);
    3270       11868 :           if (peek() == Token::ARROW) {
    3271        8919 :             if (fni_) {
    3272        4642 :               fni_->RemoveAsyncKeywordFromEnd();
    3273             :             }
    3274        9259 :             ValidateBindingPattern(CHECK_OK);
    3275        8519 :             ValidateFormalParameterInitializer(CHECK_OK);
    3276        8119 :             if (!classifier()->is_valid_async_arrow_formal_parameters()) {
    3277        1920 :               ReportClassifierError(
    3278             :                   classifier()->async_arrow_formal_parameters_error());
    3279        1920 :               *ok = false;
    3280        1920 :               return impl()->NullExpression();
    3281             :             }
    3282        6199 :             if (args->length()) {
    3283             :               // async ( Arguments ) => ...
    3284        2532 :               if (!is_simple_parameter_list) {
    3285         802 :                 async_classifier.previous()->RecordNonSimpleParameter();
    3286             :               }
    3287        1360 :               return impl()->ExpressionListToExpression(args);
    3288             :             }
    3289             :             // async () => ...
    3290        4044 :             return factory()->NewEmptyParentheses(pos);
    3291             :           } else {
    3292             :             AccumulateFormalParameterContainmentErrors();
    3293             :           }
    3294             :         } else {
    3295    11316610 :           args = ParseArguments(&spread_pos, CHECK_OK);
    3296             :         }
    3297             : 
    3298    11310346 :         ArrowFormalParametersUnexpectedToken();
    3299             : 
    3300             :         // Keep track of eval() calls since they disable all local variable
    3301             :         // optimizations.
    3302             :         // The calls that need special treatment are the
    3303             :         // direct eval calls. These calls are all of the form eval(...), with
    3304             :         // no explicit receiver.
    3305             :         // These calls are marked as potentially direct eval calls. Whether
    3306             :         // they are actually direct calls to eval is determined at run time.
    3307             :         Call::PossiblyEval is_possibly_eval =
    3308    11310345 :             CheckPossibleEvalCall(result, scope());
    3309             : 
    3310             :         bool is_super_call = result->IsSuperCallReference();
    3311    11310345 :         if (spread_pos.IsValid()) {
    3312        7120 :           result = impl()->SpreadCall(result, args, pos, is_possibly_eval);
    3313             :         } else {
    3314    11303225 :           result = factory()->NewCall(result, args, pos, is_possibly_eval);
    3315             :         }
    3316             : 
    3317             :         // Explicit calls to the super constructor using super() perform an
    3318             :         // implicit binding assignment to the 'this' variable.
    3319    11310346 :         if (is_super_call) {
    3320        4692 :           classifier()->RecordAssignmentPatternError(
    3321             :               Scanner::Location(pos, scanner()->location().end_pos),
    3322             :               MessageTemplate::kInvalidDestructuringTarget);
    3323             :           ExpressionT this_expr = impl()->ThisExpression(pos);
    3324        4692 :           result =
    3325             :               factory()->NewAssignment(Token::INIT, this_expr, result, pos);
    3326             :         }
    3327             : 
    3328    11310346 :         if (fni_ != nullptr) fni_->RemoveLastFunction();
    3329    11310346 :         break;
    3330             :       }
    3331             : 
    3332             :       case Token::PERIOD: {
    3333      411112 :         impl()->RewriteNonPattern(CHECK_OK);
    3334      411112 :         BindingPatternUnexpectedToken();
    3335      411112 :         ArrowFormalParametersUnexpectedToken();
    3336      411112 :         Consume(Token::PERIOD);
    3337             :         int pos = position();
    3338      411112 :         IdentifierT name = ParseIdentifierName(CHECK_OK);
    3339      596476 :         result = factory()->NewProperty(
    3340             :             result, factory()->NewStringLiteral(name, pos), pos);
    3341      225748 :         impl()->PushLiteralName(name);
    3342      185364 :         break;
    3343             :       }
    3344             : 
    3345             :       case Token::TEMPLATE_SPAN:
    3346             :       case Token::TEMPLATE_TAIL: {
    3347        1295 :         impl()->RewriteNonPattern(CHECK_OK);
    3348        1295 :         BindingPatternUnexpectedToken();
    3349        1295 :         ArrowFormalParametersUnexpectedToken();
    3350        1295 :         result = ParseTemplateLiteral(result, position(), true, CHECK_OK);
    3351             :         break;
    3352             :       }
    3353             : 
    3354             :       default:
    3355    27202809 :         return result;
    3356             :     }
    3357             :   }
    3358             : }
    3359             : 
    3360             : template <typename Impl>
    3361             : typename ParserBase<Impl>::ExpressionT
    3362    59847343 : ParserBase<Impl>::ParseMemberWithNewPrefixesExpression(bool* is_async,
    3363     1241514 :                                                        bool* ok) {
    3364             :   // NewExpression ::
    3365             :   //   ('new')+ MemberExpression
    3366             :   //
    3367             :   // NewTarget ::
    3368             :   //   'new' '.' 'target'
    3369             : 
    3370             :   // The grammar for new expressions is pretty warped. We can have several 'new'
    3371             :   // keywords following each other, and then a MemberExpression. When we see '('
    3372             :   // after the MemberExpression, it's associated with the rightmost unassociated
    3373             :   // 'new' to create a NewExpression with arguments. However, a NewExpression
    3374             :   // can also occur without arguments.
    3375             : 
    3376             :   // Examples of new expression:
    3377             :   // new foo.bar().baz means (new (foo.bar)()).baz
    3378             :   // new foo()() means (new foo())()
    3379             :   // new new foo()() means (new (new foo())())
    3380             :   // new new foo means new (new foo)
    3381             :   // new new foo() means new (new foo())
    3382             :   // new new foo().bar().baz means (new (new foo()).bar()).baz
    3383             : 
    3384    59847348 :   if (peek() == Token::NEW) {
    3385      761056 :     BindingPatternUnexpectedToken();
    3386      761056 :     ArrowFormalParametersUnexpectedToken();
    3387      761056 :     Consume(Token::NEW);
    3388             :     int new_pos = position();
    3389             :     ExpressionT result;
    3390      761056 :     if (peek() == Token::SUPER) {
    3391             :       const bool is_new = true;
    3392       10218 :       result = ParseSuperExpression(is_new, CHECK_OK);
    3393      769085 :     } else if (allow_harmony_dynamic_import() && peek() == Token::IMPORT &&
    3394             :                (!allow_harmony_import_meta() || PeekAhead() == Token::LPAREN)) {
    3395        1000 :       impl()->ReportMessageAt(scanner()->peek_location(),
    3396             :                               MessageTemplate::kImportCallNotNewExpression);
    3397        2000 :       *ok = false;
    3398        2000 :       return impl()->NullExpression();
    3399      752167 :     } else if (peek() == Token::PERIOD) {
    3400       19093 :       *is_async = false;
    3401       19963 :       result = ParseNewTargetExpression(CHECK_OK);
    3402       17413 :       return ParseMemberExpressionContinuation(result, is_async, CHECK_OK);
    3403             :     } else {
    3404      737823 :       result = ParseMemberWithNewPrefixesExpression(is_async, CHECK_OK);
    3405             :     }
    3406      727229 :     impl()->RewriteNonPattern(CHECK_OK);
    3407      727229 :     if (peek() == Token::LPAREN) {
    3408             :       // NewExpression with arguments.
    3409             :       Scanner::Location spread_pos;
    3410      691886 :       ExpressionListT args = ParseArguments(&spread_pos, CHECK_OK);
    3411             : 
    3412      691359 :       if (spread_pos.IsValid()) {
    3413         202 :         result = impl()->SpreadCallNew(result, args, new_pos);
    3414             :       } else {
    3415      691157 :         result = factory()->NewCallNew(result, args, new_pos);
    3416             :       }
    3417             :       // The expression can still continue with . or [ after the arguments.
    3418      691359 :       result = ParseMemberExpressionContinuation(result, is_async, CHECK_OK);
    3419      691359 :       return result;
    3420             :     }
    3421             :     // NewExpression without arguments.
    3422       56904 :     return factory()->NewCallNew(result, impl()->NewExpressionList(0), new_pos);
    3423             :   }
    3424             :   // No 'new' or 'super' keyword.
    3425    59086292 :   return ParseMemberExpression(is_async, ok);
    3426             : }
    3427             : 
    3428             : template <typename Impl>
    3429    59086296 : typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseMemberExpression(
    3430    59771020 :     bool* is_async, bool* ok) {
    3431             :   // MemberExpression ::
    3432             :   //   (PrimaryExpression | FunctionLiteral | ClassLiteral)
    3433             :   //     ('[' Expression ']' | '.' Identifier | Arguments | TemplateLiteral)*
    3434             :   //
    3435             :   // CallExpression ::
    3436             :   //   (SuperCall | ImportCall)
    3437             :   //     ('[' Expression ']' | '.' Identifier | Arguments | TemplateLiteral)*
    3438             :   //
    3439             :   // The '[' Expression ']' and '.' Identifier parts are parsed by
    3440             :   // ParseMemberExpressionContinuation, and the Arguments part is parsed by the
    3441             :   // caller.
    3442             : 
    3443             :   // Parse the initial primary or function expression.
    3444             :   ExpressionT result;
    3445    59086299 :   if (peek() == Token::FUNCTION) {
    3446     2961486 :     BindingPatternUnexpectedToken();
    3447     2961487 :     ArrowFormalParametersUnexpectedToken();
    3448             : 
    3449     2961487 :     Consume(Token::FUNCTION);
    3450             :     int function_token_position = position();
    3451             : 
    3452     2961780 :     if (allow_harmony_function_sent() && peek() == Token::PERIOD) {
    3453             :       // function.sent
    3454             :       int pos = position();
    3455       47766 :       ExpectMetaProperty(Token::SENT, "function.sent", pos, CHECK_OK);
    3456             : 
    3457         113 :       if (!is_generator()) {
    3458             :         // TODO(neis): allow escaping into closures?
    3459          23 :         impl()->ReportMessageAt(scanner()->location(),
    3460             :                                 MessageTemplate::kUnexpectedFunctionSent);
    3461          37 :         *ok = false;
    3462          37 :         return impl()->NullExpression();
    3463             :       }
    3464             : 
    3465          35 :       return impl()->FunctionSentExpression(pos);
    3466             :     }
    3467             : 
    3468     2961364 :     FunctionKind function_kind = Check(Token::MUL)
    3469             :                                      ? FunctionKind::kGeneratorFunction
    3470     2961364 :                                      : FunctionKind::kNormalFunction;
    3471       73420 :     IdentifierT name = impl()->NullIdentifier();
    3472     2961364 :     bool is_strict_reserved_name = false;
    3473     2961364 :     Scanner::Location function_name_location = Scanner::Location::invalid();
    3474             :     FunctionLiteral::FunctionType function_type =
    3475             :         FunctionLiteral::kAnonymousExpression;
    3476     2887944 :     if (impl()->ParsingDynamicFunctionDeclaration()) {
    3477             :       // We don't want dynamic functions to actually declare their name
    3478             :       // "anonymous". We just want that name in the toString().
    3479        2071 :       if (stack_overflow()) {
    3480         487 :         *ok = false;
    3481         487 :         return impl()->NullExpression();
    3482             :       }
    3483        1584 :       Consume(Token::IDENTIFIER);
    3484             :       DCHECK(scanner()->CurrentMatchesContextual(Token::ANONYMOUS));
    3485     2959293 :     } else if (peek_any_identifier()) {
    3486      700391 :       bool is_await = false;
    3487      700391 :       name = ParseIdentifierOrStrictReservedWord(
    3488     1401181 :           function_kind, &is_strict_reserved_name, &is_await, CHECK_OK);
    3489      699742 :       function_name_location = scanner()->location();
    3490             :       function_type = FunctionLiteral::kNamedExpression;
    3491             :     }
    3492     2960228 :     result = impl()->ParseFunctionLiteral(
    3493             :         name, function_name_location,
    3494             :         is_strict_reserved_name ? kFunctionNameIsStrictReserved
    3495             :                                 : kFunctionNameValidityUnknown,
    3496             :         function_kind, function_token_position, function_type, language_mode(),
    3497     2976920 :         CHECK_OK);
    3498    56124795 :   } else if (peek() == Token::SUPER) {
    3499             :     const bool is_new = false;
    3500       22250 :     result = ParseSuperExpression(is_new, CHECK_OK);
    3501    56471474 :   } else if (allow_harmony_dynamic_import() && peek() == Token::IMPORT) {
    3502       34702 :     result = ParseImportExpressions(CHECK_OK);
    3503             :   } else {
    3504    56230918 :     result = ParsePrimaryExpression(is_async, CHECK_OK);
    3505             :   }
    3506             : 
    3507    58694300 :   result = ParseMemberExpressionContinuation(result, is_async, CHECK_OK);
    3508    58674699 :   return result;
    3509             : }
    3510             : 
    3511             : template <typename Impl>
    3512       25682 : typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseImportExpressions(
    3513       80666 :     bool* ok) {
    3514             :   DCHECK(allow_harmony_dynamic_import());
    3515       25682 :   Consume(Token::IMPORT);
    3516             :   int pos = position();
    3517       47685 :   if (allow_harmony_import_meta() && peek() == Token::PERIOD) {
    3518       22003 :     classifier()->RecordPatternError(
    3519             :         Scanner::Location(pos, scanner()->location().end_pos),
    3520             :         MessageTemplate::kInvalidDestructuringTarget);
    3521       22003 :     ArrowFormalParametersUnexpectedToken();
    3522       22003 :     ExpectMetaProperty(Token::META, "import.meta", pos, CHECK_OK);
    3523       22003 :     if (!parsing_module_) {
    3524        7900 :       impl()->ReportMessageAt(scanner()->location(),
    3525             :                               MessageTemplate::kImportMetaOutsideModule);
    3526       10978 :       *ok = false;
    3527       10978 :       return impl()->NullExpression();
    3528             :     }
    3529             : 
    3530        3125 :     return impl()->ImportMetaExpression(pos);
    3531             :   }
    3532        4399 :   Expect(Token::LPAREN, CHECK_OK);
    3533        2779 :   ExpressionT arg = ParseAssignmentExpression(true, CHECK_OK);
    3534        2059 :   Expect(Token::RPAREN, CHECK_OK);
    3535        1744 :   return factory()->NewImportCallExpression(arg, pos);
    3536             : }
    3537             : 
    3538             : template <typename Impl>
    3539       24237 : typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseSuperExpression(
    3540       37303 :     bool is_new, bool* ok) {
    3541       24237 :   Expect(Token::SUPER, CHECK_OK);
    3542             :   int pos = position();
    3543             : 
    3544       24237 :   DeclarationScope* scope = GetReceiverScope();
    3545             :   FunctionKind kind = scope->function_kind();
    3546       55758 :   if (IsConciseMethod(kind) || IsAccessorFunction(kind) ||
    3547             :       IsClassConstructor(kind)) {
    3548       24675 :     if (peek() == Token::PERIOD || peek() == Token::LBRACK) {
    3549             :       scope->RecordSuperPropertyUsage();
    3550        2814 :       return impl()->NewSuperPropertyReference(pos);
    3551             :     }
    3552             :     // new super() is never allowed.
    3553             :     // super() is only allowed in derived constructor
    3554       18877 :     if (!is_new && peek() == Token::LPAREN && IsDerivedConstructor(kind)) {
    3555             :       // TODO(rossberg): This might not be the correct FunctionState for the
    3556             :       // method here.
    3557        2320 :       return impl()->NewSuperCallReference(pos);
    3558             :     }
    3559             :   }
    3560             : 
    3561        8231 :   impl()->ReportMessageAt(scanner()->location(),
    3562             :                           MessageTemplate::kUnexpectedSuper);
    3563       13066 :   *ok = false;
    3564       13066 :   return impl()->NullExpression();
    3565             : }
    3566             : 
    3567             : template <typename Impl>
    3568       41219 : void ParserBase<Impl>::ExpectMetaProperty(Token::Value property_name,
    3569             :                                           const char* full_name, int pos,
    3570       41219 :                                           bool* ok) {
    3571       41219 :   Consume(Token::PERIOD);
    3572       82438 :   ExpectContextualKeyword(property_name, CHECK_OK_CUSTOM(Void));
    3573       41219 :   if (scanner()->literal_contains_escapes()) {
    3574          35 :     impl()->ReportMessageAt(
    3575             :         Scanner::Location(pos, scanner()->location().end_pos),
    3576             :         MessageTemplate::kInvalidEscapedMetaProperty, full_name);
    3577          50 :     *ok = false;
    3578             :   }
    3579             : }
    3580             : 
    3581             : template <typename Impl>
    3582             : typename ParserBase<Impl>::ExpressionT
    3583       58839 : ParserBase<Impl>::ParseNewTargetExpression(bool* ok) {
    3584             :   int pos = position();
    3585       19123 :   ExpectMetaProperty(Token::TARGET, "new.target", pos, CHECK_OK);
    3586             : 
    3587       19053 :   classifier()->RecordAssignmentPatternError(
    3588             :       Scanner::Location(pos, scanner()->location().end_pos),
    3589             :       MessageTemplate::kInvalidDestructuringTarget);
    3590             : 
    3591       19053 :   if (!GetReceiverScope()->is_function_scope()) {
    3592         840 :     impl()->ReportMessageAt(scanner()->location(),
    3593             :                             MessageTemplate::kUnexpectedNewTarget);
    3594        1640 :     *ok = false;
    3595        1640 :     return impl()->NullExpression();
    3596             :   }
    3597             : 
    3598       13404 :   return impl()->NewTargetExpression(pos);
    3599             : }
    3600             : 
    3601             : template <typename Impl>
    3602             : typename ParserBase<Impl>::ExpressionT
    3603    59396689 : ParserBase<Impl>::ParseMemberExpressionContinuation(ExpressionT expression,
    3604    13001651 :                                                     bool* is_async, bool* ok) {
    3605             :   // Parses this part of MemberExpression:
    3606             :   // ('[' Expression ']' | '.' Identifier | TemplateLiteral)*
    3607             :   while (true) {
    3608    81169444 :     switch (peek()) {
    3609             :       case Token::LBRACK: {
    3610     5028198 :         *is_async = false;
    3611     5028678 :         impl()->RewriteNonPattern(CHECK_OK);
    3612     5027238 :         BindingPatternUnexpectedToken();
    3613     5027238 :         ArrowFormalParametersUnexpectedToken();
    3614             : 
    3615     5027238 :         Consume(Token::LBRACK);
    3616             :         int pos = position();
    3617     5027918 :         ExpressionT index = ParseExpressionCoverGrammar(true, CHECK_OK);
    3618     5025948 :         impl()->RewriteNonPattern(CHECK_OK);
    3619     5025708 :         expression = factory()->NewProperty(expression, index, pos);
    3620             :         impl()->PushPropertyName(index);
    3621     5025735 :         Expect(Token::RBRACK, CHECK_OK);
    3622     2353167 :         break;
    3623             :       }
    3624             :       case Token::PERIOD: {
    3625    16736503 :         *is_async = false;
    3626    16736742 :         impl()->RewriteNonPattern(CHECK_OK);
    3627    16736022 :         BindingPatternUnexpectedToken();
    3628    16736024 :         ArrowFormalParametersUnexpectedToken();
    3629             : 
    3630    16736022 :         Consume(Token::PERIOD);
    3631             :         int pos = peek_position();
    3632    16736247 :         IdentifierT name = ParseIdentifierName(CHECK_OK);
    3633    23161352 :         expression = factory()->NewProperty(
    3634             :             expression, factory()->NewStringLiteral(name, pos), pos);
    3635    10309707 :         impl()->PushLiteralName(name);
    3636     6425822 :         break;
    3637             :       }
    3638             :       case Token::TEMPLATE_SPAN:
    3639             :       case Token::TEMPLATE_TAIL: {
    3640       20831 :         *is_async = false;
    3641       22271 :         impl()->RewriteNonPattern(CHECK_OK);
    3642       17951 :         BindingPatternUnexpectedToken();
    3643       17951 :         ArrowFormalParametersUnexpectedToken();
    3644             :         int pos;
    3645       17951 :         if (scanner()->current_token() == Token::IDENTIFIER) {
    3646             :           pos = position();
    3647             :         } else {
    3648             :           pos = peek_position();
    3649        1839 :           if (expression->IsFunctionLiteral()) {
    3650             :             // If the tag function looks like an IIFE, set_parenthesized() to
    3651             :             // force eager compilation.
    3652         676 :             expression->AsFunctionLiteral()->SetShouldEagerCompile();
    3653             :           }
    3654             :         }
    3655       21151 :         expression = ParseTemplateLiteral(expression, pos, true, CHECK_OK);
    3656             :         break;
    3657             :       }
    3658             :       case Token::ILLEGAL: {
    3659         445 :         ReportUnexpectedTokenAt(scanner()->peek_location(), Token::ILLEGAL);
    3660         445 :         *ok = false;
    3661         445 :         return impl()->NullExpression();
    3662             :       }
    3663             :       default:
    3664    27469188 :         return expression;
    3665             :     }
    3666             :   }
    3667             :   DCHECK(false);
    3668             :   return impl()->NullExpression();
    3669             : }
    3670             : 
    3671             : template <typename Impl>
    3672     8411037 : void ParserBase<Impl>::ParseFormalParameter(FormalParametersT* parameters,
    3673     5045155 :                                             bool* ok) {
    3674             :   // FormalParameter[Yield,GeneratorParameter] :
    3675             :   //   BindingElement[?Yield, ?GeneratorParameter]
    3676     8411037 :   bool is_rest = parameters->has_rest;
    3677             : 
    3678     8441678 :   ExpressionT pattern = ParsePrimaryExpression(CHECK_OK_CUSTOM(Void));
    3679     8387220 :   ValidateBindingPattern(CHECK_OK_CUSTOM(Void));
    3680             : 
    3681     8375423 :   if (!impl()->IsIdentifier(pattern)) {
    3682       28720 :     parameters->is_simple = false;
    3683       28720 :     ValidateFormalParameterInitializer(CHECK_OK_CUSTOM(Void));
    3684             :     classifier()->RecordNonSimpleParameter();
    3685             :   }
    3686             : 
    3687             :   ExpressionT initializer = impl()->NullExpression();
    3688     8374783 :   if (Check(Token::ASSIGN)) {
    3689       83802 :     if (is_rest) {
    3690           0 :       ReportMessage(MessageTemplate::kRestDefaultInitializer);
    3691           0 :       *ok = false;
    3692        6000 :       return;
    3693             :     }
    3694       83802 :     ExpressionClassifier init_classifier(this);
    3695       83802 :     initializer = ParseAssignmentExpression(true, CHECK_OK_CUSTOM(Void));
    3696       79722 :     impl()->RewriteNonPattern(CHECK_OK_CUSTOM(Void));
    3697       79722 :     ValidateFormalParameterInitializer(CHECK_OK_CUSTOM(Void));
    3698       77802 :     parameters->is_simple = false;
    3699             :     DiscardExpressionClassifier();
    3700             :     classifier()->RecordNonSimpleParameter();
    3701             : 
    3702       13666 :     impl()->SetFunctionNameFromIdentifierRef(initializer, pattern);
    3703             :   }
    3704             : 
    3705             :   impl()->AddFormalParameter(parameters, pattern, initializer,
    3706             :                              scanner()->location().end_pos, is_rest);
    3707             : }
    3708             : 
    3709             : template <typename Impl>
    3710     5703336 : void ParserBase<Impl>::ParseFormalParameterList(FormalParametersT* parameters,
    3711       15359 :                                                 bool* ok) {
    3712             :   // FormalParameters[Yield] :
    3713             :   //   [empty]
    3714             :   //   FunctionRestParameter[?Yield]
    3715             :   //   FormalParameterList[?Yield]
    3716             :   //   FormalParameterList[?Yield] ,
    3717             :   //   FormalParameterList[?Yield] , FunctionRestParameter[?Yield]
    3718             :   //
    3719             :   // FormalParameterList[Yield] :
    3720             :   //   FormalParameter[?Yield]
    3721             :   //   FormalParameterList[?Yield] , FormalParameter[?Yield]
    3722             : 
    3723             :   DCHECK_EQ(0, parameters->arity);
    3724             : 
    3725     5703335 :   if (peek() != Token::RPAREN) {
    3726             :     while (true) {
    3727     8399234 :       if (parameters->arity > Code::kMaxArguments) {
    3728          10 :         ReportMessage(MessageTemplate::kTooManyParameters);
    3729          10 :         *ok = false;
    3730          10 :         return;
    3731             :       }
    3732     8399224 :       parameters->has_rest = Check(Token::ELLIPSIS);
    3733     8399224 :       ParseFormalParameter(parameters, CHECK_OK_CUSTOM(Void));
    3734             : 
    3735     8356969 :       if (parameters->has_rest) {
    3736       12479 :         parameters->is_simple = false;
    3737             :         classifier()->RecordNonSimpleParameter();
    3738       12479 :         if (peek() == Token::COMMA) {
    3739        1760 :           impl()->ReportMessageAt(scanner()->peek_location(),
    3740             :                                   MessageTemplate::kParamAfterRest);
    3741        2880 :           *ok = false;
    3742        2880 :           return;
    3743             :         }
    3744             :         break;
    3745             :       }
    3746     8344490 :       if (!Check(Token::COMMA)) break;
    3747     5349429 :       if (peek() == Token::RPAREN) {
    3748             :         // allow the trailing comma
    3749             :         break;
    3750             :       }
    3751             :     }
    3752             :   }
    3753             : 
    3754     5658193 :   impl()->DeclareFormalParameters(parameters->scope, parameters->params,
    3755             :                                   parameters->is_simple);
    3756             : }
    3757             : 
    3758             : template <typename Impl>
    3759    13117785 : typename ParserBase<Impl>::BlockT ParserBase<Impl>::ParseVariableDeclarations(
    3760             :     VariableDeclarationContext var_context,
    3761             :     DeclarationParsingResult* parsing_result,
    3762   128356696 :     ZoneList<const AstRawString*>* names, bool* ok) {
    3763             :   // VariableDeclarations ::
    3764             :   //   ('var' | 'const' | 'let') (Identifier ('=' AssignmentExpression)?)+[',']
    3765             :   //
    3766             :   // ES6:
    3767             :   // FIXME(marja, nikolaos): Add an up-to-date comment about ES6 variable
    3768             :   // declaration syntax.
    3769             : 
    3770             :   DCHECK_NOT_NULL(parsing_result);
    3771    13117785 :   parsing_result->descriptor.declaration_kind = DeclarationDescriptor::NORMAL;
    3772    13117785 :   parsing_result->descriptor.declaration_pos = peek_position();
    3773    13117785 :   parsing_result->descriptor.initialization_pos = peek_position();
    3774             : 
    3775             :   BlockT init_block = impl()->NullStatement();
    3776    13117785 :   if (var_context != kForStatement) {
    3777     8386425 :     init_block = factory()->NewBlock(1, true);
    3778             :   }
    3779             : 
    3780    13117786 :   switch (peek()) {
    3781             :     case Token::VAR:
    3782    11489248 :       parsing_result->descriptor.mode = VAR;
    3783    11489248 :       Consume(Token::VAR);
    3784    11489249 :       break;
    3785             :     case Token::CONST:
    3786      454992 :       Consume(Token::CONST);
    3787             :       DCHECK_NE(var_context, kStatement);
    3788      454991 :       parsing_result->descriptor.mode = CONST;
    3789      454991 :       break;
    3790             :     case Token::LET:
    3791     1173546 :       Consume(Token::LET);
    3792             :       DCHECK_NE(var_context, kStatement);
    3793     1173546 :       parsing_result->descriptor.mode = LET;
    3794     1173546 :       break;
    3795             :     default:
    3796           0 :       UNREACHABLE();  // by current callers
    3797             :       break;
    3798             :   }
    3799             : 
    3800    13117786 :   parsing_result->descriptor.scope = scope();
    3801             : 
    3802             :   int bindings_start = peek_position();
    3803    13446464 :   do {
    3804             :     // Parse binding pattern.
    3805    13626350 :     FuncNameInferrer::State fni_state(fni_);
    3806             : 
    3807             :     ExpressionT pattern = impl()->NullExpression();
    3808             :     int decl_pos = peek_position();
    3809             :     {
    3810    13626350 :       ExpressionClassifier pattern_classifier(this);
    3811    13642084 :       pattern = ParsePrimaryExpression(CHECK_OK_CUSTOM(NullStatement));
    3812             : 
    3813    13602331 :       ValidateBindingPattern(CHECK_OK_CUSTOM(NullStatement));
    3814    13581188 :       if (IsLexicalVariableMode(parsing_result->descriptor.mode)) {
    3815     1797445 :         ValidateLetPattern(CHECK_OK_CUSTOM(NullStatement));
    3816             :       }
    3817             :     }
    3818             : 
    3819             :     Scanner::Location variable_loc = scanner()->location();
    3820             :     bool single_name = impl()->IsIdentifier(pattern);
    3821             : 
    3822    13578908 :     if (single_name) {
    3823     9119901 :       impl()->PushVariableName(impl()->AsIdentifier(pattern));
    3824             :     }
    3825             : 
    3826             :     ExpressionT value = impl()->NullExpression();
    3827             :     int initializer_position = kNoSourcePosition;
    3828             :     int value_beg_position = kNoSourcePosition;
    3829    13578908 :     if (Check(Token::ASSIGN)) {
    3830             :       value_beg_position = peek_position();
    3831             : 
    3832    11054567 :       ExpressionClassifier classifier(this);
    3833    11054567 :       value = ParseAssignmentExpression(var_context != kForStatement,
    3834    22142822 :                                         CHECK_OK_CUSTOM(NullStatement));
    3835    10988710 :       impl()->RewriteNonPattern(CHECK_OK_CUSTOM(NullStatement));
    3836             :       variable_loc.end_pos = scanner()->location().end_pos;
    3837             : 
    3838    10987990 :       if (!parsing_result->first_initializer_loc.IsValid()) {
    3839    10868930 :         parsing_result->first_initializer_loc = variable_loc;
    3840             :       }
    3841             : 
    3842             :       // Don't infer if it is "a = function(){...}();"-like expression.
    3843    10987990 :       if (single_name && fni_ != nullptr) {
    3844    13751675 :         if (!value->IsCall() && !value->IsCallNew()) {
    3845     6515646 :           fni_->Infer();
    3846             :         } else {
    3847      560971 :           fni_->RemoveLastFunction();
    3848             :         }
    3849             :       }
    3850             : 
    3851     7102451 :       impl()->SetFunctionNameFromIdentifierRef(value, pattern);
    3852             : 
    3853             :       // End position of the initializer is after the assignment expression.
    3854             :       initializer_position = scanner()->location().end_pos;
    3855             :     } else {
    3856     2524341 :       if (var_context != kForStatement || !PeekInOrOf()) {
    3857             :         // ES6 'const' and binding patterns require initializers.
    3858     4660504 :         if (parsing_result->descriptor.mode == CONST ||
    3859             :             !impl()->IsIdentifier(pattern)) {
    3860       34256 :           impl()->ReportMessageAt(
    3861             :               Scanner::Location(decl_pos, scanner()->location().end_pos),
    3862             :               MessageTemplate::kDeclarationMissingInitializer,
    3863             :               !impl()->IsIdentifier(pattern) ? "destructuring" : "const");
    3864       20290 :           *ok = false;
    3865       20290 :           return impl()->NullStatement();
    3866             :         }
    3867             :         // 'let x' initializes 'x' to undefined.
    3868     2314507 :         if (parsing_result->descriptor.mode == LET) {
    3869      187508 :           value = factory()->NewUndefinedLiteral(position());
    3870             :         }
    3871             :       }
    3872             : 
    3873             :       // End position of the initializer is after the variable.
    3874             :       initializer_position = position();
    3875             :     }
    3876             : 
    3877             :     typename DeclarationParsingResult::Declaration decl(
    3878             :         pattern, initializer_position, value);
    3879    13492041 :     decl.value_beg_position = value_beg_position;
    3880    13492041 :     if (var_context == kForStatement) {
    3881             :       // Save the declaration for further handling in ParseForStatement.
    3882      860923 :       parsing_result->declarations.push_back(decl);
    3883             :     } else {
    3884             :       // Immediately declare the variable otherwise. This avoids O(N^2)
    3885             :       // behavior (where N is the number of variables in a single
    3886             :       // declaration) in the PatternRewriter having to do with removing
    3887             :       // and adding VariableProxies to the Scope (see bug 4699).
    3888    12631118 :       impl()->DeclareAndInitializeVariables(
    3889             :           init_block, &parsing_result->descriptor, &decl, names,
    3890    12631119 :           CHECK_OK_CUSTOM(NullStatement));
    3891             :     }
    3892             :   } while (Check(Token::COMMA));
    3893             : 
    3894    12937900 :   parsing_result->bindings_loc =
    3895             :       Scanner::Location(bindings_start, scanner()->location().end_pos);
    3896             : 
    3897             :   DCHECK(*ok);
    3898    12937900 :   return init_block;
    3899             : }
    3900             : 
    3901             : template <typename Impl>
    3902             : typename ParserBase<Impl>::StatementT
    3903        3126 : ParserBase<Impl>::ParseFunctionDeclaration(bool* ok) {
    3904        1403 :   Consume(Token::FUNCTION);
    3905             :   int pos = position();
    3906             :   ParseFunctionFlags flags = ParseFunctionFlags::kIsNormal;
    3907        1403 :   if (Check(Token::MUL)) {
    3908         160 :     impl()->ReportMessageAt(
    3909             :         scanner()->location(),
    3910             :         MessageTemplate::kGeneratorInSingleStatementContext);
    3911         320 :     *ok = false;
    3912         320 :     return impl()->NullStatement();
    3913             :   }
    3914        1083 :   return ParseHoistableDeclaration(pos, flags, nullptr, false, ok);
    3915             : }
    3916             : 
    3917             : template <typename Impl>
    3918             : typename ParserBase<Impl>::StatementT
    3919     1377010 : ParserBase<Impl>::ParseHoistableDeclaration(
    3920     1377010 :     ZoneList<const AstRawString*>* names, bool default_export, bool* ok) {
    3921     1377010 :   Expect(Token::FUNCTION, CHECK_OK_CUSTOM(NullStatement));
    3922             :   int pos = position();
    3923             :   ParseFunctionFlags flags = ParseFunctionFlags::kIsNormal;
    3924     1377010 :   if (Check(Token::MUL)) {
    3925             :     flags |= ParseFunctionFlags::kIsGenerator;
    3926             :   }
    3927     1377010 :   return ParseHoistableDeclaration(pos, flags, names, default_export, ok);
    3928             : }
    3929             : 
    3930             : template <typename Impl>
    3931             : typename ParserBase<Impl>::StatementT
    3932     1522813 : ParserBase<Impl>::ParseHoistableDeclaration(
    3933             :     int pos, ParseFunctionFlags flags, ZoneList<const AstRawString*>* names,
    3934     4454796 :     bool default_export, bool* ok) {
    3935             :   // FunctionDeclaration ::
    3936             :   //   'function' Identifier '(' FormalParameters ')' '{' FunctionBody '}'
    3937             :   //   'function' '(' FormalParameters ')' '{' FunctionBody '}'
    3938             :   // GeneratorDeclaration ::
    3939             :   //   'function' '*' Identifier '(' FormalParameters ')' '{' FunctionBody '}'
    3940             :   //   'function' '*' '(' FormalParameters ')' '{' FunctionBody '}'
    3941             :   //
    3942             :   // The anonymous forms are allowed iff [default_export] is true.
    3943             :   //
    3944             :   // 'function' and '*' (if present) have been consumed by the caller.
    3945             : 
    3946             :   bool is_generator = flags & ParseFunctionFlags::kIsGenerator;
    3947             :   const bool is_async = flags & ParseFunctionFlags::kIsAsync;
    3948             :   DCHECK(!is_generator || !is_async);
    3949             : 
    3950     1522813 :   if (allow_harmony_async_iteration() && is_async && Check(Token::MUL)) {
    3951             :     // Async generator
    3952             :     is_generator = true;
    3953             :   }
    3954             : 
    3955             :   IdentifierT name;
    3956             :   FunctionNameValidity name_validity;
    3957             :   IdentifierT variable_name;
    3958     1522940 :   if (default_export && peek() == Token::LPAREN) {
    3959             :     impl()->GetDefaultStrings(&name, &variable_name);
    3960             :     name_validity = kSkipFunctionNameCheck;
    3961             :   } else {
    3962             :     bool is_strict_reserved;
    3963     1522759 :     bool is_await = false;
    3964      240371 :     name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved, &is_await,
    3965     1523807 :                                                CHECK_OK_CUSTOM(NullStatement));
    3966     1520572 :     name_validity = is_strict_reserved ? kFunctionNameIsStrictReserved
    3967             :                                        : kFunctionNameValidityUnknown;
    3968      239323 :     variable_name = name;
    3969             :   }
    3970             : 
    3971     1520626 :   FuncNameInferrer::State fni_state(fni_);
    3972     1281303 :   impl()->PushEnclosingName(name);
    3973             : 
    3974             :   FunctionKind kind = FunctionKindFor(is_generator, is_async);
    3975             : 
    3976             :   FunctionLiteralT function = impl()->ParseFunctionLiteral(
    3977             :       name, scanner()->location(), name_validity, kind, pos,
    3978             :       FunctionLiteral::kDeclaration, language_mode(),
    3979     3100147 :       CHECK_OK_CUSTOM(NullStatement));
    3980             : 
    3981             :   // In ES6, a function behaves as a lexical binding, except in
    3982             :   // a script scope, or the initial scope of eval or another function.
    3983             :   VariableMode mode =
    3984     1372132 :       (!scope()->is_declaration_scope() || scope()->is_module_scope()) ? LET
    3985     2771688 :                                                                        : VAR;
    3986             :   // Async functions don't undergo sloppy mode block scoped hoisting, and don't
    3987             :   // allow duplicates in a block. Both are represented by the
    3988             :   // sloppy_block_function_map. Don't add them to the map for async functions.
    3989             :   // Generators are also supposed to be prohibited; currently doing this behind
    3990             :   // a flag and UseCounting violations to assess web compatibility.
    3991             :   bool is_sloppy_block_function =
    3992             :       is_sloppy(language_mode()) && !scope()->is_declaration_scope() &&
    3993     1411357 :       !is_async && !(allow_harmony_restrictive_generators() && is_generator);
    3994             : 
    3995             :   return impl()->DeclareFunction(variable_name, function, mode, pos,
    3996     1219128 :                                  is_sloppy_block_function, names, ok);
    3997             : }
    3998             : 
    3999             : template <typename Impl>
    4000      113732 : typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseClassDeclaration(
    4001      304265 :     ZoneList<const AstRawString*>* names, bool default_export, bool* ok) {
    4002             :   // ClassDeclaration ::
    4003             :   //   'class' Identifier ('extends' LeftHandExpression)? '{' ClassBody '}'
    4004             :   //   'class' ('extends' LeftHandExpression)? '{' ClassBody '}'
    4005             :   //
    4006             :   // The anonymous form is allowed iff [default_export] is true.
    4007             :   //
    4008             :   // 'class' is expected to be consumed by the caller.
    4009             :   //
    4010             :   // A ClassDeclaration
    4011             :   //
    4012             :   //   class C { ... }
    4013             :   //
    4014             :   // has the same semantics as:
    4015             :   //
    4016             :   //   let C = class C { ... };
    4017             :   //
    4018             :   // so rewrite it as such.
    4019             : 
    4020             :   int class_token_pos = position();
    4021       25898 :   IdentifierT name = impl()->NullIdentifier();
    4022      113732 :   bool is_strict_reserved = false;
    4023             :   IdentifierT variable_name = impl()->NullIdentifier();
    4024      113815 :   if (default_export && (peek() == Token::EXTENDS || peek() == Token::LBRACE)) {
    4025             :     impl()->GetDefaultStrings(&name, &variable_name);
    4026             :   } else {
    4027      113716 :     bool is_await = false;
    4028       25898 :     name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved, &is_await,
    4029      114042 :                                                CHECK_OK_CUSTOM(NullStatement));
    4030             :     variable_name = name;
    4031             :   }
    4032             : 
    4033      113007 :   ExpressionClassifier no_classifier(this);
    4034             :   ExpressionT value =
    4035             :       ParseClassLiteral(name, scanner()->location(), is_strict_reserved,
    4036      235834 :                         class_token_pos, CHECK_OK_CUSTOM(NullStatement));
    4037             :   int end_pos = position();
    4038             :   return impl()->DeclareClass(variable_name, value, names, class_token_pos,
    4039       77526 :                               end_pos, ok);
    4040             : }
    4041             : 
    4042             : // Language extension which is only enabled for source files loaded
    4043             : // through the API's extension mechanism.  A native function
    4044             : // declaration is resolved by looking up the function through a
    4045             : // callback provided by the extension.
    4046             : template <typename Impl>
    4047        1678 : typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseNativeDeclaration(
    4048        1678 :     bool* ok) {
    4049             :   int pos = peek_position();
    4050        1678 :   Expect(Token::FUNCTION, CHECK_OK_CUSTOM(NullStatement));
    4051             :   // Allow "eval" or "arguments" for backward compatibility.
    4052             :   IdentifierT name = ParseIdentifier(kAllowRestrictedIdentifiers,
    4053        1678 :                                      CHECK_OK_CUSTOM(NullStatement));
    4054        1678 :   Expect(Token::LPAREN, CHECK_OK_CUSTOM(NullStatement));
    4055        1678 :   if (peek() != Token::RPAREN) {
    4056           0 :     do {
    4057           0 :       ParseIdentifier(kAllowRestrictedIdentifiers,
    4058           0 :                       CHECK_OK_CUSTOM(NullStatement));
    4059             :     } while (Check(Token::COMMA));
    4060             :   }
    4061        1678 :   Expect(Token::RPAREN, CHECK_OK_CUSTOM(NullStatement));
    4062        1678 :   Expect(Token::SEMICOLON, CHECK_OK_CUSTOM(NullStatement));
    4063        1678 :   return impl()->DeclareNative(name, pos, ok);
    4064             : }
    4065             : 
    4066             : template <typename Impl>
    4067             : typename ParserBase<Impl>::StatementT
    4068      144760 : ParserBase<Impl>::ParseAsyncFunctionDeclaration(
    4069      144780 :     ZoneList<const AstRawString*>* names, bool default_export, bool* ok) {
    4070             :   // AsyncFunctionDeclaration ::
    4071             :   //   async [no LineTerminator here] function BindingIdentifier[Await]
    4072             :   //       ( FormalParameters[Await] ) { AsyncFunctionBody }
    4073             :   DCHECK_EQ(scanner()->current_token(), Token::ASYNC);
    4074             :   int pos = position();
    4075      289520 :   if (scanner()->HasAnyLineTerminatorBeforeNext()) {
    4076          20 :     *ok = false;
    4077          20 :     impl()->ReportUnexpectedToken(scanner()->current_token());
    4078          20 :     return impl()->NullStatement();
    4079             :   }
    4080      144740 :   Expect(Token::FUNCTION, CHECK_OK_CUSTOM(NullStatement));
    4081             :   ParseFunctionFlags flags = ParseFunctionFlags::kIsAsync;
    4082      144720 :   return ParseHoistableDeclaration(pos, flags, names, default_export, ok);
    4083             : }
    4084             : 
    4085             : template <typename Impl>
    4086     3717123 : void ParserBase<Impl>::ParseFunctionBody(
    4087             :     typename ParserBase<Impl>::StatementListT result, IdentifierT function_name,
    4088             :     int pos, const FormalParametersT& parameters, FunctionKind kind,
    4089    10796637 :     FunctionLiteral::FunctionType function_type, bool* ok) {
    4090             :   static const int kFunctionNameAssignmentIndex = 0;
    4091     3717123 :   if (function_type == FunctionLiteral::kNamedExpression) {
    4092             :     DCHECK(!impl()->IsNull(function_name));
    4093             :     // If we have a named function expression, we add a local variable
    4094             :     // declaration to the body of the function with the name of the
    4095             :     // function and let it refer to the function itself (closure).
    4096             :     // Not having parsed the function body, the language mode may still change,
    4097             :     // so we reserve a spot and create the actual const assignment later.
    4098             :     DCHECK_EQ(kFunctionNameAssignmentIndex, result->length());
    4099      134867 :     result->Add(impl()->NullStatement(), zone());
    4100             :   }
    4101             : 
    4102     3717123 :   DeclarationScope* function_scope = scope()->AsDeclarationScope();
    4103             :   DeclarationScope* inner_scope = function_scope;
    4104             :   BlockT inner_block = impl()->NullStatement();
    4105             : 
    4106      485510 :   StatementListT body = result;
    4107     3717124 :   if (!parameters.is_simple) {
    4108       52620 :     inner_scope = NewVarblockScope();
    4109             :     inner_scope->set_start_position(scanner()->location().beg_pos);
    4110       30124 :     inner_block = factory()->NewBlock(8, true);
    4111             :     inner_block->set_scope(inner_scope);
    4112       30124 :     body = inner_block->statements();
    4113             :   }
    4114             : 
    4115             :   {
    4116     3717124 :     BlockState block_state(&scope_, inner_scope);
    4117             : 
    4118     3231614 :     if (IsResumableFunction(kind)) impl()->PrepareGeneratorVariables();
    4119             : 
    4120     3717124 :     if (IsAsyncGeneratorFunction(kind)) {
    4121       18599 :       impl()->ParseAndRewriteAsyncGeneratorFunctionBody(pos, kind, body, ok);
    4122     3666285 :     } else if (IsGeneratorFunction(kind)) {
    4123       21086 :       impl()->ParseAndRewriteGeneratorFunctionBody(pos, kind, body, ok);
    4124     3618866 :     } else if (IsAsyncFunction(kind)) {
    4125       81349 :       ParseAsyncFunctionBody(inner_scope, body, CHECK_OK_VOID);
    4126             :     } else {
    4127     3537517 :       ParseStatementList(body, Token::RBRACE, CHECK_OK_VOID);
    4128             :     }
    4129             : 
    4130     3614421 :     if (IsDerivedConstructor(kind)) {
    4131        5908 :       body->Add(factory()->NewReturnStatement(impl()->ThisExpression(),
    4132             :                                               kNoSourcePosition),
    4133             :                 zone());
    4134             :     }
    4135             :   }
    4136             : 
    4137     3614421 :   Expect(Token::RBRACE, CHECK_OK_VOID);
    4138             :   scope()->set_end_position(scanner()->location().end_pos);
    4139             : 
    4140     3584295 :   if (!parameters.is_simple) {
    4141             :     DCHECK_NOT_NULL(inner_scope);
    4142             :     DCHECK_EQ(function_scope, scope());
    4143             :     DCHECK_EQ(function_scope, inner_scope->outer_scope());
    4144       27927 :     impl()->SetLanguageMode(function_scope, inner_scope->language_mode());
    4145             :     BlockT init_block =
    4146       46263 :         impl()->BuildParameterInitializationBlock(parameters, CHECK_OK_VOID);
    4147             : 
    4148       45425 :     if (is_sloppy(inner_scope->language_mode())) {
    4149       15188 :       impl()->InsertSloppyBlockFunctionVarBindings(inner_scope);
    4150             :     }
    4151             : 
    4152             :     // TODO(littledan): Merge the two rejection blocks into one
    4153       45425 :     if (IsAsyncFunction(kind) && !IsAsyncGeneratorFunction(kind)) {
    4154        1460 :       init_block = impl()->BuildRejectPromiseOnException(init_block);
    4155             :     }
    4156             : 
    4157             :     inner_scope->set_end_position(scanner()->location().end_pos);
    4158       45425 :     if (inner_scope->FinalizeBlockScope() != nullptr) {
    4159        8551 :       impl()->CheckConflictingVarDeclarations(inner_scope, CHECK_OK_VOID);
    4160        8199 :       impl()->InsertShadowingVarBindingInitializers(inner_block);
    4161             :     } else {
    4162             :       inner_block->set_scope(nullptr);
    4163             :     }
    4164             :     inner_scope = nullptr;
    4165             : 
    4166       26999 :     result->Add(init_block, zone());
    4167       26999 :     result->Add(inner_block, zone());
    4168             :   } else {
    4169             :     DCHECK_EQ(inner_scope, function_scope);
    4170     3538032 :     if (is_sloppy(function_scope->language_mode())) {
    4171     1101003 :       impl()->InsertSloppyBlockFunctionVarBindings(function_scope);
    4172             :     }
    4173             :   }
    4174             : 
    4175     3583368 :   if (!IsArrowFunction(kind)) {
    4176             :     // Declare arguments after parsing the function since lexical 'arguments'
    4177             :     // masks the arguments object. Declare arguments before declaring the
    4178             :     // function var since the arguments object masks 'function arguments'.
    4179     3205355 :     function_scope->DeclareArguments(ast_value_factory());
    4180             :   }
    4181             : 
    4182     3170737 :   impl()->CreateFunctionNameAssignment(function_name, pos, function_type,
    4183             :                                        function_scope, result,
    4184             :                                        kFunctionNameAssignmentIndex);
    4185             : }
    4186             : 
    4187             : template <typename Impl>
    4188     5532248 : void ParserBase<Impl>::CheckArityRestrictions(int param_count,
    4189             :                                               FunctionKind function_kind,
    4190             :                                               bool has_rest,
    4191             :                                               int formals_start_pos,
    4192             :                                               int formals_end_pos, bool* ok) {
    4193     5532248 :   if (IsGetterFunction(function_kind)) {
    4194       34642 :     if (param_count != 0) {
    4195         186 :       impl()->ReportMessageAt(
    4196             :           Scanner::Location(formals_start_pos, formals_end_pos),
    4197             :           MessageTemplate::kBadGetterArity);
    4198         226 :       *ok = false;
    4199             :     }
    4200     5497606 :   } else if (IsSetterFunction(function_kind)) {
    4201       27841 :     if (param_count != 1) {
    4202        1065 :       impl()->ReportMessageAt(
    4203             :           Scanner::Location(formals_start_pos, formals_end_pos),
    4204             :           MessageTemplate::kBadSetterArity);
    4205        1405 :       *ok = false;
    4206             :     }
    4207       27841 :     if (has_rest) {
    4208         240 :       impl()->ReportMessageAt(
    4209             :           Scanner::Location(formals_start_pos, formals_end_pos),
    4210             :           MessageTemplate::kBadSetterRestParameter);
    4211         320 :       *ok = false;
    4212             :     }
    4213             :   }
    4214     5532248 : }
    4215             : 
    4216             : template <typename Impl>
    4217     1166649 : bool ParserBase<Impl>::IsNextLetKeyword() {
    4218             :   DCHECK(peek() == Token::LET);
    4219             :   Token::Value next_next = PeekAhead();
    4220     1166649 :   switch (next_next) {
    4221             :     case Token::LBRACE:
    4222             :     case Token::LBRACK:
    4223             :     case Token::IDENTIFIER:
    4224             :     case Token::STATIC:
    4225             :     case Token::LET:  // `let let;` is disallowed by static semantics, but the
    4226             :                       // token must be first interpreted as a keyword in order
    4227             :                       // for those semantics to apply. This ensures that ASI is
    4228             :                       // not honored when a LineTerminator separates the
    4229             :                       // tokens.
    4230             :     case Token::YIELD:
    4231             :     case Token::AWAIT:
    4232             :     case Token::ASYNC:
    4233             :       return true;
    4234             :     case Token::FUTURE_STRICT_RESERVED_WORD:
    4235        3200 :       return is_sloppy(language_mode());
    4236             :     default:
    4237        9989 :       return false;
    4238             :   }
    4239             : }
    4240             : 
    4241             : template <typename Impl>
    4242    97472990 : bool ParserBase<Impl>::IsTrivialExpression() {
    4243             :   Token::Value peek_token = peek();
    4244    97472985 :   if (peek_token == Token::SMI || peek_token == Token::NUMBER ||
    4245             :       peek_token == Token::BIGINT || peek_token == Token::NULL_LITERAL ||
    4246             :       peek_token == Token::TRUE_LITERAL || peek_token == Token::FALSE_LITERAL ||
    4247             :       peek_token == Token::STRING || peek_token == Token::IDENTIFIER ||
    4248             :       peek_token == Token::THIS) {
    4249             :     // PeekAhead() is expensive & may not always be called, so we only call it
    4250             :     // after checking peek().
    4251             :     Token::Value peek_ahead = PeekAhead();
    4252    84761601 :     if (peek_ahead == Token::COMMA || peek_ahead == Token::RPAREN ||
    4253             :         peek_ahead == Token::SEMICOLON || peek_ahead == Token::RBRACK) {
    4254             :       return true;
    4255             :     }
    4256             :   }
    4257             :   return false;
    4258             : }
    4259             : 
    4260             : template <typename Impl>
    4261             : typename ParserBase<Impl>::ExpressionT
    4262      907707 : ParserBase<Impl>::ParseArrowFunctionLiteral(
    4263             :     bool accept_IN, const FormalParametersT& formal_parameters,
    4264     1404615 :     int rewritable_length, bool* ok) {
    4265             :   const RuntimeCallStats::CounterId counters[2][2] = {
    4266             :       {&RuntimeCallStats::ParseBackgroundArrowFunctionLiteral,
    4267             :        &RuntimeCallStats::ParseArrowFunctionLiteral},
    4268             :       {&RuntimeCallStats::PreParseBackgroundArrowFunctionLiteral,
    4269      907707 :        &RuntimeCallStats::PreParseArrowFunctionLiteral}};
    4270             :   RuntimeCallTimerScope runtime_timer(
    4271             :       runtime_call_stats_,
    4272      907707 :       counters[Impl::IsPreParser()][parsing_on_main_thread_]);
    4273             : 
    4274     1815414 :   if (peek() == Token::ARROW && scanner_->HasAnyLineTerminatorBeforeNext()) {
    4275             :     // ASI inserts `;` after arrow parameters if a line terminator is found.
    4276             :     // `=> ...` is never a valid expression, so report as syntax error.
    4277             :     // If next token is not `=>`, it's a syntax error anyways.
    4278         480 :     ReportUnexpectedTokenAt(scanner_->peek_location(), Token::ARROW);
    4279         480 :     *ok = false;
    4280         480 :     return impl()->NullExpression();
    4281             :   }
    4282             : 
    4283      308960 :   StatementListT body = impl()->NullStatementList();
    4284             :   int expected_property_count = -1;
    4285             :   int function_literal_id = GetNextFunctionLiteralId();
    4286             : 
    4287      907227 :   FunctionKind kind = formal_parameters.scope->function_kind();
    4288             :   FunctionLiteral::EagerCompileHint eager_compile_hint =
    4289      598267 :       default_eager_compile_hint_;
    4290      598267 :   bool can_preparse = impl()->parse_lazily() &&
    4291      598267 :                       eager_compile_hint == FunctionLiteral::kShouldLazyCompile;
    4292             :   // TODO(marja): consider lazy-parsing inner arrow functions too. is_this
    4293             :   // handling in Scope::ResolveVariable needs to change.
    4294             :   bool is_lazy_top_level_function =
    4295     1006350 :       can_preparse && impl()->AllowsLazyParsingWithoutUnresolvedVariables();
    4296             :   bool has_braces = true;
    4297      598267 :   ProducedPreParsedScopeData* produced_preparsed_scope_data = nullptr;
    4298             :   {
    4299             :     FunctionState function_state(&function_state_, &scope_,
    4300      907227 :                                  formal_parameters.scope);
    4301             : 
    4302      907227 :     Expect(Token::ARROW, CHECK_OK);
    4303             : 
    4304      907227 :     if (peek() == Token::LBRACE) {
    4305             :       // Multiple statement body
    4306             :       DCHECK_EQ(scope(), formal_parameters.scope);
    4307      284047 :       if (is_lazy_top_level_function) {
    4308             :         // FIXME(marja): Arrow function parameters will be parsed even if the
    4309             :         // body is preparsed; move relevant parts of parameter handling to
    4310             :         // simulate consistent parameter handling.
    4311             : 
    4312             :         // For arrow functions, we don't need to retrieve data about function
    4313             :         // parameters.
    4314       23977 :         int dummy_num_parameters = -1;
    4315             :         DCHECK_NE(kind & FunctionKind::kArrowFunction, 0);
    4316             :         LazyParsingResult result = impl()->SkipFunction(
    4317             :             nullptr, kind, FunctionLiteral::kAnonymousExpression,
    4318             :             formal_parameters.scope, &dummy_num_parameters,
    4319       23977 :             &produced_preparsed_scope_data, false, false, CHECK_OK);
    4320             :         DCHECK_NE(result, kLazyParsingAborted);
    4321             :         DCHECK_NULL(produced_preparsed_scope_data);
    4322             :         USE(result);
    4323       21787 :         formal_parameters.scope->ResetAfterPreparsing(ast_value_factory_,
    4324             :                                                       false);
    4325             : 
    4326             :       } else {
    4327      386464 :         Consume(Token::LBRACE);
    4328      126394 :         body = impl()->NewStatementList(8);
    4329      386464 :         ParseFunctionBody(body, impl()->NullIdentifier(), kNoSourcePosition,
    4330             :                           formal_parameters, kind,
    4331      904942 :                           FunctionLiteral::kAnonymousExpression, CHECK_OK);
    4332      257239 :         expected_property_count = function_state.expected_property_count();
    4333             :       }
    4334             :     } else {
    4335             :       // Single-expression body
    4336             :       has_braces = false;
    4337             :       const bool is_async = IsAsyncFunction(kind);
    4338      182566 :       body = impl()->NewStatementList(1);
    4339             :       impl()->AddParameterInitializationBlock(formal_parameters, body, is_async,
    4340      496786 :                                               CHECK_OK);
    4341      499556 :       ParseSingleExpressionFunctionBody(body, is_async, accept_IN, CHECK_OK);
    4342      312751 :       expected_property_count = function_state.expected_property_count();
    4343             :     }
    4344             : 
    4345     2586253 :     formal_parameters.scope->set_end_position(scanner()->location().end_pos);
    4346             : 
    4347             :     // Arrow function formal parameters are parsed as StrictFormalParameterList,
    4348             :     // which is not the same as "parameters of a strict function"; it only means
    4349             :     // that duplicates are not allowed.  Of course, the arrow function may
    4350             :     // itself be strict as well.
    4351             :     const bool allow_duplicate_parameters = false;
    4352      892287 :     ValidateFormalParameters(language_mode(), allow_duplicate_parameters,
    4353      893197 :                              CHECK_OK);
    4354             : 
    4355             :     // Validate strict mode.
    4356      890419 :     if (is_strict(language_mode())) {
    4357      512328 :       CheckStrictOctalLiteral(formal_parameters.scope->start_position(),
    4358     1024656 :                               scanner()->location().end_pos, CHECK_OK);
    4359             :     }
    4360      890417 :     impl()->CheckConflictingVarDeclarations(formal_parameters.scope, CHECK_OK);
    4361             : 
    4362      590819 :     if (is_lazy_top_level_function) {
    4363      124852 :       FunctionState* parent_state = function_state.outer();
    4364             :       DCHECK_NOT_NULL(parent_state);
    4365             :       DCHECK_GE(parent_state->destructuring_assignments_to_rewrite().length(),
    4366             :                 rewritable_length);
    4367             :       parent_state->RewindDestructuringAssignments(rewritable_length);
    4368             :     }
    4369             : 
    4370             :     impl()->RewriteDestructuringAssignments();
    4371             :   }
    4372             : 
    4373      890419 :   if (FLAG_trace_preparse) {
    4374           0 :     Scope* scope = formal_parameters.scope;
    4375           0 :     PrintF("  [%s]: %i-%i (arrow function)\n",
    4376             :            is_lazy_top_level_function ? "Preparse no-resolution" : "Full parse",
    4377           0 :            scope->start_position(), scope->end_position());
    4378             :   }
    4379             :   FunctionLiteralT function_literal = factory()->NewFunctionLiteral(
    4380             :       impl()->EmptyIdentifierString(), formal_parameters.scope, body,
    4381             :       expected_property_count, formal_parameters.num_parameters(),
    4382             :       formal_parameters.function_length,
    4383             :       FunctionLiteral::kNoDuplicateParameters,
    4384             :       FunctionLiteral::kAnonymousExpression, eager_compile_hint,
    4385             :       formal_parameters.scope->start_position(), has_braces,
    4386     1772456 :       function_literal_id, produced_preparsed_scope_data);
    4387             : 
    4388      590819 :   function_literal->set_function_token_position(
    4389             :       formal_parameters.scope->start_position());
    4390             : 
    4391      590819 :   impl()->AddFunctionForNameInference(function_literal);
    4392             : 
    4393      890419 :   return function_literal;
    4394             : }
    4395             : 
    4396             : template <typename Impl>
    4397      170965 : typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseClassLiteral(
    4398       44505 :     IdentifierT name, Scanner::Location class_name_location,
    4399      311070 :     bool name_is_strict_reserved, int class_token_pos, bool* ok) {
    4400             :   bool is_anonymous = impl()->IsNull(name);
    4401             : 
    4402             :   // All parts of a ClassDeclaration and ClassExpression are strict code.
    4403      170965 :   if (!is_anonymous) {
    4404      130340 :     if (name_is_strict_reserved) {
    4405         720 :       impl()->ReportMessageAt(class_name_location,
    4406             :                               MessageTemplate::kUnexpectedStrictReserved);
    4407        1440 :       *ok = false;
    4408        1440 :       return impl()->NullExpression();
    4409             :     }
    4410      128900 :     if (impl()->IsEvalOrArguments(name)) {
    4411         160 :       impl()->ReportMessageAt(class_name_location,
    4412             :                               MessageTemplate::kStrictEvalArguments);
    4413         320 :       *ok = false;
    4414         320 :       return impl()->NullExpression();
    4415             :     }
    4416             :   }
    4417             : 
    4418             :   Scope* block_scope = NewScope(BLOCK_SCOPE);
    4419      169205 :   BlockState block_state(&scope_, block_scope);
    4420      169205 :   RaiseLanguageMode(LanguageMode::kStrict);
    4421             : 
    4422      169205 :   ClassInfo class_info(this);
    4423      169205 :   class_info.is_anonymous = is_anonymous;
    4424      169205 :   impl()->DeclareClassVariable(name, &class_info, class_token_pos, CHECK_OK);
    4425             : 
    4426             :   scope()->set_start_position(scanner()->location().end_pos);
    4427      169205 :   if (Check(Token::EXTENDS)) {
    4428       28951 :     ExpressionClassifier extends_classifier(this);
    4429       29731 :     class_info.extends = ParseLeftHandSideExpression(CHECK_OK);
    4430       27555 :     impl()->RewriteNonPattern(CHECK_OK);
    4431             :     AccumulateFormalParameterContainmentErrors();
    4432             :   }
    4433             : 
    4434             :   ClassLiteralChecker checker(this);
    4435             : 
    4436      168192 :   Expect(Token::LBRACE, CHECK_OK);
    4437             : 
    4438      209485 :   const bool has_extends = !impl()->IsNull(class_info.extends);
    4439      853083 :   while (peek() != Token::RBRACE) {
    4440      562323 :     if (Check(Token::SEMICOLON)) continue;
    4441      526067 :     FuncNameInferrer::State fni_state(fni_);
    4442      526067 :     bool is_computed_name = false;  // Classes do not care about computed
    4443             :                                     // property names here.
    4444             :     bool is_static;
    4445             :     ClassLiteralProperty::Kind property_kind;
    4446      526067 :     ExpressionClassifier property_classifier(this);
    4447             :     // If we haven't seen the constructor yet, it potentially is the next
    4448             :     // property.
    4449      485697 :     bool is_constructor = !class_info.has_seen_constructor;
    4450             :     ClassLiteralPropertyT property = ParseClassPropertyDefinition(
    4451             :         &checker, has_extends, &is_computed_name,
    4452             :         &class_info.has_seen_constructor, &property_kind, &is_static,
    4453      538447 :         &class_info.has_name_static_property, CHECK_OK);
    4454      500909 :     if (!class_info.has_static_computed_names && is_static &&
    4455             :         is_computed_name) {
    4456        2085 :       class_info.has_static_computed_names = true;
    4457             :     }
    4458      472919 :     is_constructor &= class_info.has_seen_constructor;
    4459      500909 :     impl()->RewriteNonPattern(CHECK_OK);
    4460             :     AccumulateFormalParameterContainmentErrors();
    4461             : 
    4462             :     impl()->DeclareClassProperty(name, property, property_kind, is_static,
    4463      500909 :                                  is_constructor, &class_info, CHECK_OK);
    4464      472919 :     impl()->InferFunctionName();
    4465             :   }
    4466             : 
    4467      141865 :   Expect(Token::RBRACE, CHECK_OK);
    4468             :   int end_pos = scanner()->location().end_pos;
    4469             :   block_scope->set_end_position(end_pos);
    4470             :   return impl()->RewriteClassLiteral(block_scope, name, &class_info,
    4471      111783 :                                      class_token_pos, end_pos, ok);
    4472             : }
    4473             : 
    4474             : template <typename Impl>
    4475      496726 : void ParserBase<Impl>::ParseSingleExpressionFunctionBody(StatementListT body,
    4476             :                                                          bool is_async,
    4477             :                                                          bool accept_IN,
    4478      310703 :                                                          bool* ok) {
    4479      314160 :   if (is_async) impl()->PrepareGeneratorVariables();
    4480             : 
    4481      496726 :   ExpressionClassifier classifier(this);
    4482      674812 :   ExpressionT expression = ParseAssignmentExpression(accept_IN, CHECK_OK_VOID);
    4483      492487 :   impl()->RewriteNonPattern(CHECK_OK_VOID);
    4484             : 
    4485      492487 :   if (is_async) {
    4486        2048 :     BlockT block = factory()->NewBlock(1, true);
    4487        3698 :     impl()->RewriteAsyncFunctionBody(body, block, expression, CHECK_OK_VOID);
    4488             :   } else {
    4489      488789 :     body->Add(BuildReturnStatement(expression, expression->position()), zone());
    4490             :   }
    4491             : }
    4492             : 
    4493             : template <typename Impl>
    4494       81349 : void ParserBase<Impl>::ParseAsyncFunctionBody(Scope* scope, StatementListT body,
    4495       61306 :                                               bool* ok) {
    4496       33187 :   BlockT block = factory()->NewBlock(8, true);
    4497             : 
    4498      114536 :   ParseStatementList(block->statements(), Token::RBRACE, CHECK_OK_VOID);
    4499       26464 :   impl()->RewriteAsyncFunctionBody(
    4500             :       body, block, factory()->NewUndefinedLiteral(kNoSourcePosition),
    4501       61306 :       CHECK_OK_VOID);
    4502             :   scope->set_end_position(scanner()->location().end_pos);
    4503             : }
    4504             : 
    4505             : template <typename Impl>
    4506             : typename ParserBase<Impl>::ExpressionT
    4507       60328 : ParserBase<Impl>::ParseAsyncFunctionLiteral(bool* ok) {
    4508             :   // AsyncFunctionLiteral ::
    4509             :   //   async [no LineTerminator here] function ( FormalParameters[Await] )
    4510             :   //       { AsyncFunctionBody }
    4511             :   //
    4512             :   //   async [no LineTerminator here] function BindingIdentifier[Await]
    4513             :   //       ( FormalParameters[Await] ) { AsyncFunctionBody }
    4514             :   DCHECK_EQ(scanner()->current_token(), Token::ASYNC);
    4515             :   int pos = position();
    4516       32937 :   Expect(Token::FUNCTION, CHECK_OK);
    4517       19964 :   bool is_strict_reserved = false;
    4518        7577 :   IdentifierT name = impl()->NullIdentifier();
    4519             :   FunctionLiteral::FunctionType type = FunctionLiteral::kAnonymousExpression;
    4520             : 
    4521       19964 :   bool is_generator = allow_harmony_async_iteration() && Check(Token::MUL);
    4522             :   const bool kIsAsync = true;
    4523             :   const FunctionKind kind = FunctionKindFor(is_generator, kIsAsync);
    4524             : 
    4525       12387 :   if (impl()->ParsingDynamicFunctionDeclaration()) {
    4526             :     // We don't want dynamic functions to actually declare their name
    4527             :     // "anonymous". We just want that name in the toString().
    4528         662 :     if (stack_overflow()) {
    4529          19 :       *ok = false;
    4530          19 :       return impl()->NullExpression();
    4531             :     }
    4532         643 :     Consume(Token::IDENTIFIER);
    4533             :     DCHECK(scanner()->CurrentMatchesContextual(Token::ANONYMOUS));
    4534       19302 :   } else if (peek_any_identifier()) {
    4535             :     type = FunctionLiteral::kNamedExpression;
    4536        8749 :     bool is_await = false;
    4537        8749 :     name = ParseIdentifierOrStrictReservedWord(kind, &is_strict_reserved,
    4538       17818 :                                                &is_await, CHECK_OK);
    4539             :     // If the function name is "await", ParseIdentifierOrStrictReservedWord
    4540             :     // recognized the error.
    4541             :     DCHECK(!is_await);
    4542             :   }
    4543             :   return impl()->ParseFunctionLiteral(
    4544             :       name, scanner()->location(),
    4545             :       is_strict_reserved ? kFunctionNameIsStrictReserved
    4546             :                          : kFunctionNameValidityUnknown,
    4547       38890 :       kind, pos, type, language_mode(), CHECK_OK);
    4548             : }
    4549             : 
    4550             : template <typename Impl>
    4551       66697 : typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseTemplateLiteral(
    4552      306197 :     ExpressionT tag, int start, bool tagged, bool* ok) {
    4553             :   // A TemplateLiteral is made up of 0 or more TEMPLATE_SPAN tokens (literal
    4554             :   // text followed by a substitution expression), finalized by a single
    4555             :   // TEMPLATE_TAIL.
    4556             :   //
    4557             :   // In terms of draft language, TEMPLATE_SPAN may be either the TemplateHead or
    4558             :   // TemplateMiddle productions, while TEMPLATE_TAIL is either TemplateTail, or
    4559             :   // NoSubstitutionTemplate.
    4560             :   //
    4561             :   // When parsing a TemplateLiteral, we must have scanned either an initial
    4562             :   // TEMPLATE_SPAN, or a TEMPLATE_TAIL.
    4563       84797 :   CHECK(peek() == Token::TEMPLATE_SPAN || peek() == Token::TEMPLATE_TAIL);
    4564             : 
    4565       66697 :   bool forbid_illegal_escapes = !allow_harmony_template_escapes() || !tagged;
    4566             : 
    4567             :   // If we reach a TEMPLATE_TAIL first, we are parsing a NoSubstitutionTemplate.
    4568             :   // In this case we may simply consume the token and build a template with a
    4569             :   // single TEMPLATE_SPAN and no expressions.
    4570       66697 :   if (peek() == Token::TEMPLATE_TAIL) {
    4571       18100 :     Consume(Token::TEMPLATE_TAIL);
    4572             :     int pos = position();
    4573        9462 :     typename Impl::TemplateLiteralState ts = impl()->OpenTemplateLiteral(pos);
    4574       20960 :     bool is_valid = CheckTemplateEscapes(forbid_illegal_escapes, CHECK_OK);
    4575        6309 :     impl()->AddTemplateSpan(&ts, is_valid, true);
    4576        6309 :     return impl()->CloseTemplateLiteral(&ts, start, tag);
    4577             :   }
    4578             : 
    4579       48597 :   Consume(Token::TEMPLATE_SPAN);
    4580             :   int pos = position();
    4581       24971 :   typename Impl::TemplateLiteralState ts = impl()->OpenTemplateLiteral(pos);
    4582       50377 :   bool is_valid = CheckTemplateEscapes(forbid_illegal_escapes, CHECK_OK);
    4583       23231 :   impl()->AddTemplateSpan(&ts, is_valid, false);
    4584             :   Token::Value next;
    4585             : 
    4586             :   // If we open with a TEMPLATE_SPAN, we must scan the subsequent expression,
    4587             :   // and repeat if the following token is a TEMPLATE_SPAN as well (in this
    4588             :   // case, representing a TemplateMiddle).
    4589             : 
    4590       60007 :   do {
    4591             :     next = peek();
    4592       70755 :     if (next == Token::EOS) {
    4593         930 :       impl()->ReportMessageAt(Scanner::Location(start, peek_position()),
    4594             :                               MessageTemplate::kUnterminatedTemplate);
    4595        1490 :       *ok = false;
    4596        1490 :       return impl()->NullExpression();
    4597       69265 :     } else if (next == Token::ILLEGAL) {
    4598         640 :       impl()->ReportMessageAt(
    4599             :           Scanner::Location(position() + 1, peek_position()),
    4600             :           MessageTemplate::kUnexpectedToken, "ILLEGAL", kSyntaxError);
    4601         640 :       *ok = false;
    4602         640 :       return impl()->NullExpression();
    4603             :     }
    4604             : 
    4605             :     int expr_pos = peek_position();
    4606       69395 :     ExpressionT expression = ParseExpressionCoverGrammar(true, CHECK_OK);
    4607       67256 :     impl()->RewriteNonPattern(CHECK_OK);
    4608             :     impl()->AddTemplateExpression(&ts, expression);
    4609             : 
    4610       67256 :     if (peek() != Token::RBRACE) {
    4611         120 :       impl()->ReportMessageAt(Scanner::Location(expr_pos, peek_position()),
    4612             :                               MessageTemplate::kUnterminatedTemplateExpr);
    4613         200 :       *ok = false;
    4614         200 :       return impl()->NullExpression();
    4615             :     }
    4616             : 
    4617             :     // If we didn't die parsing that expression, our next token should be a
    4618             :     // TEMPLATE_SPAN or TEMPLATE_TAIL.
    4619       67056 :     next = scanner()->ScanTemplateContinuation();
    4620             :     Next();
    4621             :     pos = position();
    4622             : 
    4623       67056 :     if (next == Token::EOS) {
    4624           0 :       impl()->ReportMessageAt(Scanner::Location(start, pos),
    4625             :                               MessageTemplate::kUnterminatedTemplate);
    4626           0 :       *ok = false;
    4627           0 :       return impl()->NullExpression();
    4628       67056 :     } else if (next == Token::ILLEGAL) {
    4629           0 :       impl()->ReportMessageAt(
    4630             :           Scanner::Location(position() + 1, peek_position()),
    4631             :           MessageTemplate::kUnexpectedToken, "ILLEGAL", kSyntaxError);
    4632           0 :       *ok = false;
    4633           0 :       return impl()->NullExpression();
    4634             :     }
    4635             : 
    4636       70616 :     bool is_valid = CheckTemplateEscapes(forbid_illegal_escapes, CHECK_OK);
    4637       33017 :     impl()->AddTemplateSpan(&ts, is_valid, next == Token::TEMPLATE_TAIL);
    4638             :   } while (next == Token::TEMPLATE_SPAN);
    4639             : 
    4640             :   DCHECK_EQ(next, Token::TEMPLATE_TAIL);
    4641             :   // Once we've reached a TEMPLATE_TAIL, we can close the TemplateLiteral.
    4642       18183 :   return impl()->CloseTemplateLiteral(&ts, start, tag);
    4643             : }
    4644             : 
    4645             : template <typename Impl>
    4646             : typename ParserBase<Impl>::ExpressionT
    4647             : ParserBase<Impl>::CheckAndRewriteReferenceExpression(
    4648             :     ExpressionT expression, int beg_pos, int end_pos,
    4649             :     MessageTemplate::Template message, bool* ok) {
    4650             :   return CheckAndRewriteReferenceExpression(expression, beg_pos, end_pos,
    4651    11011535 :                                             message, kReferenceError, ok);
    4652             : }
    4653             : 
    4654             : template <typename Impl>
    4655             : typename ParserBase<Impl>::ExpressionT
    4656    11112726 : ParserBase<Impl>::CheckAndRewriteReferenceExpression(
    4657             :     ExpressionT expression, int beg_pos, int end_pos,
    4658             :     MessageTemplate::Template message, ParseErrorType type, bool* ok) {
    4659    18329206 :   if (impl()->IsIdentifier(expression) && is_strict(language_mode()) &&
    4660             :       impl()->IsEvalOrArguments(impl()->AsIdentifier(expression))) {
    4661        1403 :     ReportMessageAt(Scanner::Location(beg_pos, end_pos),
    4662        1403 :                     MessageTemplate::kStrictEvalArguments, kSyntaxError);
    4663        4159 :     *ok = false;
    4664        4159 :     return impl()->NullExpression();
    4665             :   }
    4666    11108567 :   if (expression->IsValidReferenceExpression()) {
    4667     4571895 :     return expression;
    4668             :   }
    4669       22151 :   if (expression->IsCall() && !expression->AsCall()->is_tagged_template()) {
    4670             :     // If it is a call, make it a runtime error for legacy web compatibility.
    4671             :     // Bug: https://bugs.chromium.org/p/v8/issues/detail?id=4480
    4672             :     // Rewrite `expr' to `expr[throw ReferenceError]'.
    4673        2289 :     impl()->CountUsage(
    4674             :         is_strict(language_mode())
    4675             :             ? v8::Isolate::kAssigmentExpressionLHSIsCallInStrict
    4676             :             : v8::Isolate::kAssigmentExpressionLHSIsCallInSloppy);
    4677             :     ExpressionT error = impl()->NewThrowReferenceError(message, beg_pos);
    4678        2470 :     return factory()->NewProperty(expression, error, beg_pos);
    4679             :   }
    4680        6509 :   ReportMessageAt(Scanner::Location(beg_pos, end_pos), message, type);
    4681       15104 :   *ok = false;
    4682       15104 :   return impl()->NullExpression();
    4683             : }
    4684             : 
    4685             : template <typename Impl>
    4686   110204929 : bool ParserBase<Impl>::IsValidReferenceExpression(ExpressionT expression) {
    4687   193485047 :   return IsAssignableIdentifier(expression) || expression->IsProperty();
    4688             : }
    4689             : 
    4690             : template <typename Impl>
    4691    14328557 : void ParserBase<Impl>::CheckDestructuringElement(ExpressionT expression,
    4692    11250850 :                                                  int begin, int end) {
    4693    42451949 :   if (!IsValidPattern(expression) && !expression->IsAssignment() &&
    4694    13984082 :       !IsValidReferenceExpression(expression)) {
    4695    11250850 :     classifier()->RecordAssignmentPatternError(
    4696             :         Scanner::Location(begin, end),
    4697             :         MessageTemplate::kInvalidDestructuringTarget);
    4698             :   }
    4699    14328558 : }
    4700             : 
    4701             : template <typename Impl>
    4702     1199666 : typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseV8Intrinsic(
    4703     1099279 :     bool* ok) {
    4704             :   // CallRuntime ::
    4705             :   //   '%' Identifier Arguments
    4706             : 
    4707             :   int pos = peek_position();
    4708     1199666 :   Expect(Token::MOD, CHECK_OK);
    4709             :   // Allow "eval" or "arguments" for backward compatibility.
    4710     1199666 :   IdentifierT name = ParseIdentifier(kAllowRestrictedIdentifiers, CHECK_OK);
    4711             :   Scanner::Location spread_pos;
    4712     1199666 :   ExpressionClassifier classifier(this);
    4713     1199666 :   ExpressionListT args = ParseArguments(&spread_pos, CHECK_OK);
    4714             : 
    4715             :   DCHECK(!spread_pos.IsValid());
    4716             : 
    4717     1099279 :   return impl()->NewV8Intrinsic(name, args, pos, ok);
    4718             : }
    4719             : 
    4720             : template <typename Impl>
    4721         975 : typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseDoExpression(
    4722         622 :     bool* ok) {
    4723             :   // AssignmentExpression ::
    4724             :   //     do '{' StatementList '}'
    4725             : 
    4726             :   int pos = peek_position();
    4727         975 :   Expect(Token::DO, CHECK_OK);
    4728         975 :   BlockT block = ParseBlock(nullptr, CHECK_OK);
    4729         612 :   return impl()->RewriteDoExpression(block, pos, ok);
    4730             : }
    4731             : 
    4732             : // Redefinition of CHECK_OK for parsing statements.
    4733             : #undef CHECK_OK
    4734             : #define CHECK_OK CHECK_OK_CUSTOM(NullStatement)
    4735             : 
    4736             : template <typename Impl>
    4737             : typename ParserBase<Impl>::LazyParsingResult
    4738     8028178 : ParserBase<Impl>::ParseStatementList(StatementListT body, int end_token,
    4739    53045991 :                                      bool may_abort, bool* ok) {
    4740             :   // StatementList ::
    4741             :   //   (StatementListItem)* <end_token>
    4742             : 
    4743             :   // Allocate a target stack to use for this set of source
    4744             :   // elements. This way, all scripts and functions get their own
    4745             :   // target stack thus avoiding illegal breaks and continues across
    4746             :   // functions.
    4747             :   typename Types::TargetScope target_scope(this);
    4748             :   int count_statements = 0;
    4749             : 
    4750             :   DCHECK(!impl()->IsNull(body));
    4751             :   bool directive_prologue = true;  // Parsing directive prologue.
    4752             : 
    4753    47859381 :   while (peek() != end_token) {
    4754    41825505 :     if (directive_prologue && peek() != Token::STRING) {
    4755             :       directive_prologue = false;
    4756             :     }
    4757             : 
    4758             :     bool starts_with_identifier = peek() == Token::IDENTIFIER;
    4759             :     Scanner::Location token_loc = scanner()->peek_location();
    4760             :     StatementT stat =
    4761    33128113 :         ParseStatementListItem(CHECK_OK_CUSTOM(Return, kLazyParsingComplete));
    4762             : 
    4763    63623198 :     if (impl()->IsNull(stat) || stat->IsEmptyStatement()) {
    4764             :       directive_prologue = false;  // End of directive prologue.
    4765     1283809 :       continue;
    4766             :     }
    4767             : 
    4768    30527791 :     if (directive_prologue) {
    4769             :       // The length of the token is used to distinguish between strings literals
    4770             :       // that evaluate equal to directives but contain either escape sequences
    4771             :       // (e.g., "use \x73trict") or line continuations (e.g., "use \(newline)
    4772             :       // strict").
    4773     3211224 :       if (impl()->IsUseStrictDirective(stat) &&
    4774             :           token_loc.end_pos - token_loc.beg_pos == sizeof("use strict") + 1) {
    4775             :         // Directive "use strict" (ES5 14.1).
    4776      439283 :         RaiseLanguageMode(LanguageMode::kStrict);
    4777      439283 :         if (!scope()->HasSimpleParameters()) {
    4778             :           // TC39 deemed "use strict" directives to be an error when occurring
    4779             :           // in the body of a function with non-simple parameter list, on
    4780             :           // 29/7/2015. https://goo.gl/ueA7Ln
    4781        6330 :           impl()->ReportMessageAt(
    4782             :               token_loc, MessageTemplate::kIllegalLanguageModeDirective,
    4783             :               "use strict");
    4784        8527 :           *ok = false;
    4785        8527 :           return kLazyParsingComplete;
    4786             :         }
    4787     2538208 :       } else if (impl()->IsUseAsmDirective(stat) &&
    4788             :                  token_loc.end_pos - token_loc.beg_pos ==
    4789             :                      sizeof("use asm") + 1) {
    4790             :         // Directive "use asm".
    4791        5506 :         impl()->SetAsmModule();
    4792     2527196 :       } else if (impl()->IsStringLiteral(stat)) {
    4793             :         // Possibly an unknown directive.
    4794             :         // Should not change mode, but will increment usage counters
    4795             :         // as appropriate. Ditto usages below.
    4796     1259679 :         RaiseLanguageMode(LanguageMode::kSloppy);
    4797             :       } else {
    4798             :         // End of the directive prologue.
    4799             :         directive_prologue = false;
    4800        5946 :         RaiseLanguageMode(LanguageMode::kSloppy);
    4801             :       }
    4802             :     } else {
    4803    28817377 :       RaiseLanguageMode(LanguageMode::kSloppy);
    4804             :     }
    4805             : 
    4806             :     // If we're allowed to abort, we will do so when we see a "long and
    4807             :     // trivial" function. Our current definition of "long and trivial" is:
    4808             :     // - over kLazyParseTrialLimit statements
    4809             :     // - all starting with an identifier (i.e., no if, for, while, etc.)
    4810    30519264 :     if (may_abort) {
    4811      711761 :       if (!starts_with_identifier) {
    4812             :         may_abort = false;
    4813      249284 :       } else if (++count_statements > kLazyParseTrialLimit) {
    4814             :         return kLazyParsingAborted;
    4815             :       }
    4816             :     }
    4817             : 
    4818    20141142 :     body->Add(stat, zone());
    4819             :   }
    4820             :   return kLazyParsingComplete;
    4821             : }
    4822             : 
    4823             : template <typename Impl>
    4824    42044067 : typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseStatementListItem(
    4825      144595 :     bool* ok) {
    4826             :   // ECMA 262 6th Edition
    4827             :   // StatementListItem[Yield, Return] :
    4828             :   //   Statement[?Yield, ?Return]
    4829             :   //   Declaration[?Yield]
    4830             :   //
    4831             :   // Declaration[Yield] :
    4832             :   //   HoistableDeclaration[?Yield]
    4833             :   //   ClassDeclaration[?Yield]
    4834             :   //   LexicalDeclaration[In, ?Yield]
    4835             :   //
    4836             :   // HoistableDeclaration[Yield, Default] :
    4837             :   //   FunctionDeclaration[?Yield, ?Default]
    4838             :   //   GeneratorDeclaration[?Yield, ?Default]
    4839             :   //
    4840             :   // LexicalDeclaration[In, Yield] :
    4841             :   //   LetOrConst BindingList[?In, ?Yield] ;
    4842             : 
    4843    42044079 :   switch (peek()) {
    4844             :     case Token::FUNCTION:
    4845     1376640 :       return ParseHoistableDeclaration(nullptr, false, ok);
    4846             :     case Token::CLASS:
    4847      113655 :       Consume(Token::CLASS);
    4848      113655 :       return ParseClassDeclaration(nullptr, false, ok);
    4849             :     case Token::VAR:
    4850             :     case Token::CONST:
    4851    11256429 :       return ParseVariableStatement(kStatementListItem, nullptr, ok);
    4852             :     case Token::LET:
    4853      989236 :       if (IsNextLetKeyword()) {
    4854      980035 :         return ParseVariableStatement(kStatementListItem, nullptr, ok);
    4855             :       }
    4856             :       break;
    4857             :     case Token::ASYNC:
    4858      289771 :       if (PeekAhead() == Token::FUNCTION &&
    4859             :           !scanner()->HasAnyLineTerminatorAfterNext()) {
    4860      144595 :         Consume(Token::ASYNC);
    4861      144595 :         return ParseAsyncFunctionDeclaration(nullptr, false, ok);
    4862             :       }
    4863             :     /* falls through */
    4864             :     default:
    4865             :       break;
    4866             :   }
    4867    28172725 :   return ParseStatement(nullptr, kAllowLabelledFunctionStatement, ok);
    4868             : }
    4869             : 
    4870             : template <typename Impl>
    4871    34352376 : typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseStatement(
    4872             :     ZoneList<const AstRawString*>* labels,
    4873     2005375 :     AllowLabelledFunctionStatement allow_function, bool* ok) {
    4874             :   // Statement ::
    4875             :   //   Block
    4876             :   //   VariableStatement
    4877             :   //   EmptyStatement
    4878             :   //   ExpressionStatement
    4879             :   //   IfStatement
    4880             :   //   IterationStatement
    4881             :   //   ContinueStatement
    4882             :   //   BreakStatement
    4883             :   //   ReturnStatement
    4884             :   //   WithStatement
    4885             :   //   LabelledStatement
    4886             :   //   SwitchStatement
    4887             :   //   ThrowStatement
    4888             :   //   TryStatement
    4889             :   //   DebuggerStatement
    4890             : 
    4891             :   // Note: Since labels can only be used by 'break' and 'continue'
    4892             :   // statements, which themselves are only valid within blocks,
    4893             :   // iterations or 'switch' statements (i.e., BreakableStatements),
    4894             :   // labels can be simply ignored in all other cases; except for
    4895             :   // trivial labeled break statements 'label: break label' which is
    4896             :   // parsed into an empty statement.
    4897    34352394 :   switch (peek()) {
    4898             :     case Token::LBRACE:
    4899     4374018 :       return ParseBlock(labels, ok);
    4900             :     case Token::SEMICOLON:
    4901             :       Next();
    4902      417188 :       return factory()->NewEmptyStatement(kNoSourcePosition);
    4903             :     case Token::IF:
    4904     4116249 :       return ParseIfStatement(labels, ok);
    4905             :     case Token::DO:
    4906       21666 :       return ParseDoWhileStatement(labels, ok);
    4907             :     case Token::WHILE:
    4908       83077 :       return ParseWhileStatement(labels, ok);
    4909             :     case Token::FOR:
    4910     2122991 :       if (V8_UNLIKELY(allow_harmony_async_iteration() && is_async_function() &&
    4911             :                       PeekAhead() == Token::AWAIT)) {
    4912      125314 :         return ParseForAwaitStatement(labels, ok);
    4913             :       }
    4914      939691 :       return ParseForStatement(labels, ok);
    4915             :     case Token::CONTINUE:
    4916      101619 :       return ParseContinueStatement(ok);
    4917             :     case Token::BREAK:
    4918      217464 :       return ParseBreakStatement(labels, ok);
    4919             :     case Token::RETURN:
    4920     4842174 :       return ParseReturnStatement(ok);
    4921             :     case Token::THROW:
    4922      270023 :       return ParseThrowStatement(ok);
    4923             :     case Token::TRY: {
    4924             :       // It is somewhat complicated to have labels on try-statements.
    4925             :       // When breaking out of a try-finally statement, one must take
    4926             :       // great care not to treat it as a fall-through. It is much easier
    4927             :       // just to wrap the entire try-statement in a statement block and
    4928             :       // put the labels there.
    4929      350750 :       if (labels == nullptr) return ParseTryStatement(ok);
    4930          73 :       BlockT result = factory()->NewBlock(1, false, labels);
    4931             :       typename Types::Target target(this, result);
    4932          73 :       StatementT statement = ParseTryStatement(CHECK_OK);
    4933          73 :       result->statements()->Add(statement, zone());
    4934          73 :       return result;
    4935             :     }
    4936             :     case Token::WITH:
    4937       99141 :       return ParseWithStatement(labels, ok);
    4938             :     case Token::SWITCH:
    4939      125364 :       return ParseSwitchStatement(labels, ok);
    4940             :     case Token::FUNCTION:
    4941             :       // FunctionDeclaration only allowed as a StatementListItem, not in
    4942             :       // an arbitrary Statement position. Exceptions such as
    4943             :       // ES#sec-functiondeclarations-in-ifstatement-statement-clauses
    4944             :       // are handled by calling ParseScopedStatement rather than
    4945             :       // ParseStatement directly.
    4946       12813 :       impl()->ReportMessageAt(scanner()->peek_location(),
    4947             :                               is_strict(language_mode())
    4948             :                                   ? MessageTemplate::kStrictFunction
    4949             :                                   : MessageTemplate::kSloppyFunction);
    4950        8456 :       *ok = false;
    4951        8456 :       return impl()->NullStatement();
    4952             :     case Token::DEBUGGER:
    4953      132872 :       return ParseDebuggerStatement(ok);
    4954             :     case Token::VAR:
    4955         439 :       return ParseVariableStatement(kStatement, nullptr, ok);
    4956             :     case Token::ASYNC:
    4957        3722 :       if (!scanner()->HasAnyLineTerminatorAfterNext() &&
    4958             :           PeekAhead() == Token::FUNCTION) {
    4959         640 :         impl()->ReportMessageAt(
    4960             :             scanner()->peek_location(),
    4961             :             MessageTemplate::kAsyncFunctionInSingleStatementContext);
    4962        1280 :         *ok = false;
    4963        1280 :         return impl()->NullStatement();
    4964             :       }
    4965             :     // Falls through
    4966             :     default:
    4967    18227319 :       return ParseExpressionOrLabelledStatement(labels, allow_function, ok);
    4968             :   }
    4969             : }
    4970             : 
    4971             : template <typename Impl>
    4972     5067068 : typename ParserBase<Impl>::BlockT ParserBase<Impl>::ParseBlock(
    4973    24312810 :     ZoneList<const AstRawString*>* labels, bool* ok) {
    4974             :   // Block ::
    4975             :   //   '{' StatementList '}'
    4976             : 
    4977             :   // Construct block expecting 16 statements.
    4978     2481620 :   BlockT body = factory()->NewBlock(16, false, labels);
    4979             : 
    4980             :   // Parse the statements and collect escaping labels.
    4981     5067313 :   Expect(Token::LBRACE, CHECK_OK_CUSTOM(NullStatement));
    4982             :   {
    4983    10133028 :     BlockState block_state(zone(), &scope_);
    4984             :     scope()->set_start_position(scanner()->location().beg_pos);
    4985             :     typename Types::Target target(this, body);
    4986             : 
    4987    13599249 :     while (peek() != Token::RBRACE) {
    4988     8576703 :       StatementT stat = ParseStatementListItem(CHECK_OK_CUSTOM(NullStatement));
    4989    17065474 :       if (!impl()->IsNull(stat) && !stat->IsEmptyStatement()) {
    4990     4110689 :         body->statements()->Add(stat, zone());
    4991             :       }
    4992             :     }
    4993             : 
    4994     5034547 :     Expect(Token::RBRACE, CHECK_OK_CUSTOM(NullStatement));
    4995             :     int end_pos = scanner()->location().end_pos;
    4996             :     scope()->set_end_position(end_pos);
    4997             :     impl()->RecordBlockSourceRange(body, end_pos);
    4998     5034547 :     body->set_scope(scope()->FinalizeBlockScope());
    4999             :   }
    5000     5034547 :   return body;
    5001             : }
    5002             : 
    5003             : template <typename Impl>
    5004     4956348 : typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseScopedStatement(
    5005        3516 :     ZoneList<const AstRawString*>* labels, bool* ok) {
    5006     7431292 :   if (is_strict(language_mode()) || peek() != Token::FUNCTION) {
    5007     2300175 :     return ParseStatement(labels, ok);
    5008             :   } else {
    5009             :     // Make a block around the statement for a lexical binding
    5010             :     // is introduced by a FunctionDeclaration.
    5011        1796 :     BlockState block_state(zone(), &scope_);
    5012             :     scope()->set_start_position(scanner()->location().beg_pos);
    5013         459 :     BlockT block = factory()->NewBlock(1, false);
    5014        1005 :     StatementT body = ParseFunctionDeclaration(CHECK_OK);
    5015         352 :     block->statements()->Add(body, zone());
    5016             :     scope()->set_end_position(scanner()->location().end_pos);
    5017         684 :     block->set_scope(scope()->FinalizeBlockScope());
    5018         684 :     return block;
    5019             :   }
    5020             : }
    5021             : 
    5022             : template <typename Impl>
    5023    12254456 : typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseVariableStatement(
    5024             :     VariableDeclarationContext var_context,
    5025             :     ZoneList<const AstRawString*>* names, bool* ok) {
    5026             :   // VariableStatement ::
    5027             :   //   VariableDeclarations ';'
    5028             : 
    5029             :   // The scope of a var declared variable anywhere inside a function
    5030             :   // is the entire function (ECMA-262, 3rd, 10.1.3, and 12.2). Thus we can
    5031             :   // transform a source-level var declaration into a (Function) Scope
    5032             :   // declaration, and rewrite the source-level initialization into an assignment
    5033             :   // statement. We use a block to collect multiple assignments.
    5034             :   //
    5035             :   // We mark the block as initializer block because we don't want the
    5036             :   // rewriter to add a '.result' assignment to such a block (to get compliant
    5037             :   // behavior for code such as print(eval('var x = 7')), and for cosmetic
    5038             :   // reasons when pretty-printing. Also, unless an assignment (initialization)
    5039             :   // is inside an initializer block, it is ignored.
    5040             : 
    5041             :   DeclarationParsingResult parsing_result;
    5042             :   StatementT result =
    5043    12310799 :       ParseVariableDeclarations(var_context, &parsing_result, names, CHECK_OK);
    5044    12098354 :   ExpectSemicolon(CHECK_OK);
    5045    12093888 :   return result;
    5046             : }
    5047             : 
    5048             : template <typename Impl>
    5049      132872 : typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseDebuggerStatement(
    5050       46510 :     bool* ok) {
    5051             :   // In ECMA-262 'debugger' is defined as a reserved keyword. In some browser
    5052             :   // contexts this is used as a statement which invokes the debugger as i a
    5053             :   // break point is present.
    5054             :   // DebuggerStatement ::
    5055             :   //   'debugger' ';'
    5056             : 
    5057             :   int pos = peek_position();
    5058      132872 :   Expect(Token::DEBUGGER, CHECK_OK);
    5059      132883 :   ExpectSemicolon(CHECK_OK);
    5060       92998 :   return factory()->NewDebuggerStatement(pos);
    5061             : }
    5062             : 
    5063             : template <typename Impl>
    5064             : typename ParserBase<Impl>::StatementT
    5065    18227318 : ParserBase<Impl>::ParseExpressionOrLabelledStatement(
    5066             :     ZoneList<const AstRawString*>* labels,
    5067    11314907 :     AllowLabelledFunctionStatement allow_function, bool* ok) {
    5068             :   // ExpressionStatement | LabelledStatement ::
    5069             :   //   Expression ';'
    5070             :   //   Identifier ':' Statement
    5071             :   //
    5072             :   // ExpressionStatement[Yield] :
    5073             :   //   [lookahead notin {{, function, class, let [}] Expression[In, ?Yield] ;
    5074             : 
    5075             :   int pos = peek_position();
    5076             : 
    5077    18227318 :   switch (peek()) {
    5078             :     case Token::FUNCTION:
    5079             :     case Token::LBRACE:
    5080           0 :       UNREACHABLE();  // Always handled by the callers.
    5081             :     case Token::CLASS:
    5082         308 :       ReportUnexpectedToken(Next());
    5083         308 :       *ok = false;
    5084         308 :       return impl()->NullStatement();
    5085             :     case Token::LET: {
    5086             :       Token::Value next_next = PeekAhead();
    5087             :       // "let" followed by either "[", "{" or an identifier means a lexical
    5088             :       // declaration, which should not appear here.
    5089             :       // However, ASI may insert a line break before an identifier or a brace.
    5090       10417 :       if (next_next != Token::LBRACK &&
    5091             :           ((next_next != Token::LBRACE && next_next != Token::IDENTIFIER) ||
    5092         548 :            scanner_->HasAnyLineTerminatorAfterNext())) {
    5093             :         break;
    5094             :       }
    5095         100 :       impl()->ReportMessageAt(scanner()->peek_location(),
    5096             :                               MessageTemplate::kUnexpectedLexicalDeclaration);
    5097         308 :       *ok = false;
    5098         308 :       return impl()->NullStatement();
    5099             :     }
    5100             :     default:
    5101             :       break;
    5102             :   }
    5103             : 
    5104    18226702 :   bool starts_with_identifier = peek_any_identifier();
    5105    18340852 :   ExpressionT expr = ParseExpression(true, CHECK_OK);
    5106    18019693 :   if (peek() == Token::COLON && starts_with_identifier &&
    5107             :       impl()->IsIdentifier(expr)) {
    5108             :     // The whole expression was a single identifier, and not, e.g.,
    5109             :     // something starting with an identifier or a parenthesized identifier.
    5110       18095 :     labels = impl()->DeclareLabel(labels, impl()->AsIdentifierExpression(expr),
    5111       35213 :                                   CHECK_OK);
    5112       35213 :     Consume(Token::COLON);
    5113             :     // ES#sec-labelled-function-declarations Labelled Function Declarations
    5114       39896 :     if (peek() == Token::FUNCTION && is_sloppy(language_mode()) &&
    5115             :         allow_function == kAllowLabelledFunctionStatement) {
    5116         505 :       return ParseFunctionDeclaration(ok);
    5117             :     }
    5118       34708 :     return ParseStatement(labels, allow_function, ok);
    5119             :   }
    5120             : 
    5121             :   // If we have an extension, we allow a native function declaration.
    5122             :   // A native function declaration starts with "native function" with
    5123             :   // no line-terminator between the two words.
    5124    17957025 :   if (extension_ != nullptr && peek() == Token::FUNCTION &&
    5125        1688 :       !scanner()->HasAnyLineTerminatorBeforeNext() && impl()->IsNative(expr) &&
    5126             :       !scanner()->literal_contains_escapes()) {
    5127        1678 :     return ParseNativeDeclaration(ok);
    5128             :   }
    5129             : 
    5130             :   // Parsed expression statement, followed by semicolon.
    5131    17949531 :   ExpectSemicolon(CHECK_OK);
    5132    17941498 :   if (labels != nullptr) {
    5133             :     // TODO(adamk): Also measure in the PreParser by passing something
    5134             :     // non-null as |labels|.
    5135           0 :     impl()->CountUsage(v8::Isolate::kLabeledExpressionStatement);
    5136             :   }
    5137    22318930 :   return factory()->NewExpressionStatement(expr, pos);
    5138             : }
    5139             : 
    5140             : template <typename Impl>
    5141     4116249 : typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseIfStatement(
    5142     6776840 :     ZoneList<const AstRawString*>* labels, bool* ok) {
    5143             :   // IfStatement ::
    5144             :   //   'if' '(' Expression ')' Statement ('else' Statement)?
    5145             : 
    5146             :   int pos = peek_position();
    5147     4116249 :   Expect(Token::IF, CHECK_OK);
    5148     4116358 :   Expect(Token::LPAREN, CHECK_OK);
    5149     4116932 :   ExpressionT condition = ParseExpression(true, CHECK_OK);
    5150     4114257 :   Expect(Token::RPAREN, CHECK_OK);
    5151             : 
    5152             :   SourceRange then_range, else_range;
    5153             :   StatementT then_statement = impl()->NullStatement();
    5154             :   {
    5155             :     SourceRangeScope range_scope(scanner(), &then_range);
    5156     4117090 :     then_statement = ParseScopedStatement(labels, CHECK_OK);
    5157             :   }
    5158             : 
    5159             :   StatementT else_statement = impl()->NullStatement();
    5160     4107799 :   if (Check(Token::ELSE)) {
    5161             :     SourceRangeScope range_scope(scanner(), &else_range);
    5162      844664 :     else_statement = ParseScopedStatement(labels, CHECK_OK);
    5163             :   } else {
    5164     1335038 :     else_statement = factory()->NewEmptyStatement(kNoSourcePosition);
    5165             :   }
    5166             :   StatementT stmt =
    5167     1815125 :       factory()->NewIfStatement(condition, then_statement, else_statement, pos);
    5168             :   impl()->RecordIfStatementSourceRange(stmt, then_range, else_range);
    5169     4104327 :   return stmt;
    5170             : }
    5171             : 
    5172             : template <typename Impl>
    5173      101619 : typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseContinueStatement(
    5174      138805 :     bool* ok) {
    5175             :   // ContinueStatement ::
    5176             :   //   'continue' Identifier? ';'
    5177             : 
    5178             :   int pos = peek_position();
    5179      101619 :   Expect(Token::CONTINUE, CHECK_OK);
    5180             :   IdentifierT label = impl()->NullIdentifier();
    5181             :   Token::Value tok = peek();
    5182      203238 :   if (!scanner()->HasAnyLineTerminatorBeforeNext() && tok != Token::SEMICOLON &&
    5183             :       tok != Token::RBRACE && tok != Token::EOS) {
    5184             :     // ECMA allows "eval" or "arguments" as labels even in strict mode.
    5185        3120 :     label = ParseIdentifier(kAllowRestrictedIdentifiers, CHECK_OK);
    5186             :   }
    5187             :   typename Types::IterationStatement target =
    5188      101587 :       impl()->LookupContinueTarget(label, CHECK_OK);
    5189      101587 :   if (impl()->IsNull(target)) {
    5190             :     // Illegal continue statement.
    5191             :     MessageTemplate::Template message = MessageTemplate::kIllegalContinue;
    5192             :     typename Types::BreakableStatement breakable_target =
    5193         205 :         impl()->LookupBreakTarget(label, CHECK_OK);
    5194         205 :     if (impl()->IsNull(label)) {
    5195             :       message = MessageTemplate::kNoIterationStatement;
    5196         101 :     } else if (impl()->IsNull(breakable_target)) {
    5197             :       message = MessageTemplate::kUnknownLabel;
    5198             :     }
    5199         205 :     ReportMessage(message, label);
    5200         205 :     *ok = false;
    5201         205 :     return impl()->NullStatement();
    5202             :   }
    5203      101393 :   ExpectSemicolon(CHECK_OK);
    5204       36958 :   StatementT stmt = factory()->NewContinueStatement(target, pos);
    5205       36958 :   impl()->RecordJumpStatementSourceRange(stmt, scanner_->location().end_pos);
    5206      101369 :   return stmt;
    5207             : }
    5208             : 
    5209             : template <typename Impl>
    5210      217464 : typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseBreakStatement(
    5211      285055 :     ZoneList<const AstRawString*>* labels, bool* ok) {
    5212             :   // BreakStatement ::
    5213             :   //   'break' Identifier? ';'
    5214             : 
    5215             :   int pos = peek_position();
    5216      217464 :   Expect(Token::BREAK, CHECK_OK);
    5217             :   IdentifierT label = impl()->NullIdentifier();
    5218             :   Token::Value tok = peek();
    5219      434928 :   if (!scanner()->HasAnyLineTerminatorBeforeNext() && tok != Token::SEMICOLON &&
    5220             :       tok != Token::RBRACE && tok != Token::EOS) {
    5221             :     // ECMA allows "eval" or "arguments" as labels even in strict mode.
    5222       23584 :     label = ParseIdentifier(kAllowRestrictedIdentifiers, CHECK_OK);
    5223             :   }
    5224             :   // Parse labeled break statements that target themselves into
    5225             :   // empty statements, e.g. 'l1: l2: l3: break l2;'
    5226       77834 :   if (!impl()->IsNull(label) && impl()->ContainsLabel(labels, label)) {
    5227         104 :     ExpectSemicolon(CHECK_OK);
    5228         108 :     return factory()->NewEmptyStatement(pos);
    5229             :   }
    5230             :   typename Types::BreakableStatement target =
    5231      217328 :       impl()->LookupBreakTarget(label, CHECK_OK);
    5232      217328 :   if (impl()->IsNull(target)) {
    5233             :     // Illegal break statement.
    5234             :     MessageTemplate::Template message = MessageTemplate::kIllegalBreak;
    5235         113 :     if (!impl()->IsNull(label)) {
    5236             :       message = MessageTemplate::kUnknownLabel;
    5237             :     }
    5238         113 :     ReportMessage(message, label);
    5239         113 :     *ok = false;
    5240         113 :     return impl()->NullStatement();
    5241             :   }
    5242      217217 :   ExpectSemicolon(CHECK_OK);
    5243       67351 :   StatementT stmt = factory()->NewBreakStatement(target, pos);
    5244       67351 :   impl()->RecordJumpStatementSourceRange(stmt, scanner_->location().end_pos);
    5245      217211 :   return stmt;
    5246             : }
    5247             : 
    5248             : template <typename Impl>
    5249     4842173 : typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseReturnStatement(
    5250     9684242 :     bool* ok) {
    5251             :   // ReturnStatement ::
    5252             :   //   'return' [no line terminator] Expression? ';'
    5253             : 
    5254             :   // Consume the return token. It is necessary to do that before
    5255             :   // reporting any errors on it, because of the way errors are
    5256             :   // reported (underlining).
    5257     4842173 :   Expect(Token::RETURN, CHECK_OK);
    5258             :   Scanner::Location loc = scanner()->location();
    5259             : 
    5260     4842174 :   switch (GetDeclarationScope()->scope_type()) {
    5261             :     case SCRIPT_SCOPE:
    5262             :     case EVAL_SCOPE:
    5263             :     case MODULE_SCOPE:
    5264          20 :       impl()->ReportMessageAt(loc, MessageTemplate::kIllegalReturn);
    5265         107 :       *ok = false;
    5266         107 :       return impl()->NullStatement();
    5267             :     default:
    5268             :       break;
    5269             :   }
    5270             : 
    5271             :   Token::Value tok = peek();
    5272             :   ExpressionT return_value = impl()->NullExpression();
    5273     9684136 :   if (scanner()->HasAnyLineTerminatorBeforeNext() || tok == Token::SEMICOLON ||
    5274             :       tok == Token::RBRACE || tok == Token::EOS) {
    5275      547512 :     if (IsDerivedConstructor(function_state_->kind())) {
    5276             :       return_value = impl()->ThisExpression(loc.beg_pos);
    5277             :     }
    5278             :   } else {
    5279     4569848 :     return_value = ParseExpression(true, CHECK_OK);
    5280             :   }
    5281     4839139 :   ExpectSemicolon(CHECK_OK);
    5282     2644912 :   return_value = impl()->RewriteReturn(return_value, loc.beg_pos);
    5283     2644911 :   int continuation_pos = scanner_->location().end_pos;
    5284             :   StatementT stmt =
    5285     4839140 :       BuildReturnStatement(return_value, loc.beg_pos, continuation_pos);
    5286     2644911 :   impl()->RecordJumpStatementSourceRange(stmt, scanner_->location().end_pos);
    5287     4839140 :   return stmt;
    5288             : }
    5289             : 
    5290             : template <typename Impl>
    5291       99141 : typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseWithStatement(
    5292      233618 :     ZoneList<const AstRawString*>* labels, bool* ok) {
    5293             :   // WithStatement ::
    5294             :   //   'with' '(' Expression ')' Statement
    5295             : 
    5296       99141 :   Expect(Token::WITH, CHECK_OK);
    5297             :   int pos = position();
    5298             : 
    5299       99141 :   if (is_strict(language_mode())) {
    5300         692 :     ReportMessage(MessageTemplate::kStrictWith);
    5301         692 :     *ok = false;
    5302         692 :     return impl()->NullStatement();
    5303             :   }
    5304             : 
    5305       98458 :   Expect(Token::LPAREN, CHECK_OK);
    5306       98431 :   ExpressionT expr = ParseExpression(true, CHECK_OK);
    5307       98211 :   Expect(Token::RPAREN, CHECK_OK);
    5308             : 
    5309             :   Scope* with_scope = NewScope(WITH_SCOPE);
    5310             :   StatementT body = impl()->NullStatement();
    5311             :   {
    5312       98211 :     BlockState block_state(&scope_, with_scope);
    5313             :     with_scope->set_start_position(scanner()->peek_location().beg_pos);
    5314       98395 :     body = ParseStatement(labels, CHECK_OK);
    5315             :     with_scope->set_end_position(scanner()->location().end_pos);
    5316             :   }
    5317       73676 :   return factory()->NewWithStatement(with_scope, expr, body, pos);
    5318             : }
    5319             : 
    5320             : template <typename Impl>
    5321       21666 : typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseDoWhileStatement(
    5322       28493 :     ZoneList<const AstRawString*>* labels, bool* ok) {
    5323             :   // DoStatement ::
    5324             :   //   'do' Statement 'while' '(' Expression ')' ';'
    5325             : 
    5326        6827 :   auto loop = factory()->NewDoWhileStatement(labels, peek_position());
    5327             :   typename Types::Target target(this, loop);
    5328             : 
    5329             :   SourceRange body_range;
    5330             :   StatementT body = impl()->NullStatement();
    5331             : 
    5332       21666 :   Expect(Token::DO, CHECK_OK);
    5333             :   {
    5334             :     SourceRangeScope range_scope(scanner(), &body_range);
    5335       23618 :     body = ParseStatement(nullptr, CHECK_OK);
    5336             :   }
    5337       18711 :   Expect(Token::WHILE, CHECK_OK);
    5338       18384 :   Expect(Token::LPAREN, CHECK_OK);
    5339             : 
    5340       18387 :   ExpressionT cond = ParseExpression(true, CHECK_OK);
    5341       18336 :   Expect(Token::RPAREN, CHECK_OK);
    5342             : 
    5343             :   // Allow do-statements to be terminated with and without
    5344             :   // semi-colons. This allows code such as 'do;while(0)return' to
    5345             :   // parse, which would not be the case if we had used the
    5346             :   // ExpectSemicolon() functionality here.
    5347       18309 :   Check(Token::SEMICOLON);
    5348             : 
    5349             :   loop->Initialize(cond, body);
    5350             :   impl()->RecordIterationStatementSourceRange(loop, body_range);
    5351             : 
    5352       18309 :   return loop;
    5353             : }
    5354             : 
    5355             : template <typename Impl>
    5356       83077 : typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseWhileStatement(
    5357      146149 :     ZoneList<const AstRawString*>* labels, bool* ok) {
    5358             :   // WhileStatement ::
    5359             :   //   'while' '(' Expression ')' Statement
    5360             : 
    5361       63108 :   auto loop = factory()->NewWhileStatement(labels, peek_position());
    5362             :   typename Types::Target target(this, loop);
    5363             : 
    5364             :   SourceRange body_range;
    5365             :   StatementT body = impl()->NullStatement();
    5366             : 
    5367       83077 :   Expect(Token::WHILE, CHECK_OK);
    5368       83095 :   Expect(Token::LPAREN, CHECK_OK);
    5369       83041 :   ExpressionT cond = ParseExpression(true, CHECK_OK);
    5370       83041 :   Expect(Token::RPAREN, CHECK_OK);
    5371             :   {
    5372             :     SourceRangeScope range_scope(scanner(), &body_range);
    5373       84991 :     body = ParseStatement(nullptr, CHECK_OK);
    5374             :   }
    5375             : 
    5376             :   loop->Initialize(cond, body);
    5377             :   impl()->RecordIterationStatementSourceRange(loop, body_range);
    5378             : 
    5379       79968 :   return loop;
    5380             : }
    5381             : 
    5382             : template <typename Impl>
    5383      270023 : typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseThrowStatement(
    5384      270023 :     bool* ok) {
    5385             :   // ThrowStatement ::
    5386             :   //   'throw' Expression ';'
    5387             : 
    5388      270023 :   Expect(Token::THROW, CHECK_OK);
    5389             :   int pos = position();
    5390      540046 :   if (scanner()->HasAnyLineTerminatorBeforeNext()) {
    5391         177 :     ReportMessage(MessageTemplate::kNewlineAfterThrow);
    5392         177 :     *ok = false;
    5393         177 :     return impl()->NullStatement();
    5394             :   }
    5395      269891 :   ExpressionT exception = ParseExpression(true, CHECK_OK);
    5396      269758 :   ExpectSemicolon(CHECK_OK);
    5397             : 
    5398             :   StatementT stmt = impl()->NewThrowStatement(exception, pos);
    5399      138724 :   impl()->RecordThrowSourceRange(stmt, scanner_->location().end_pos);
    5400             : 
    5401      269752 :   return stmt;
    5402             : }
    5403             : 
    5404             : template <typename Impl>
    5405      125364 : typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseSwitchStatement(
    5406     1974095 :     ZoneList<const AstRawString*>* labels, bool* ok) {
    5407             :   // SwitchStatement ::
    5408             :   //   'switch' '(' Expression ')' '{' CaseClause* '}'
    5409             :   // CaseClause ::
    5410             :   //   'case' Expression ':' StatementList
    5411             :   //   'default' ':' StatementList
    5412             : 
    5413             :   int switch_pos = peek_position();
    5414             : 
    5415      125364 :   Expect(Token::SWITCH, CHECK_OK);
    5416      125373 :   Expect(Token::LPAREN, CHECK_OK);
    5417      125404 :   ExpressionT tag = ParseExpression(true, CHECK_OK);
    5418      125160 :   Expect(Token::RPAREN, CHECK_OK);
    5419             : 
    5420             :   auto switch_statement =
    5421       20224 :       factory()->NewSwitchStatement(labels, tag, switch_pos);
    5422             : 
    5423             :   {
    5424      250320 :     BlockState cases_block_state(zone(), &scope_);
    5425             :     scope()->set_start_position(switch_pos);
    5426             :     scope()->SetNonlinear();
    5427             :     typename Types::Target target(this, switch_statement);
    5428             : 
    5429             :     bool default_seen = false;
    5430      125178 :     Expect(Token::LBRACE, CHECK_OK);
    5431     1099829 :     while (peek() != Token::RBRACE) {
    5432             :       // An empty label indicates the default case.
    5433             :       ExpressionT label = impl()->NullExpression();
    5434             :       SourceRange clause_range;
    5435             :       SourceRangeScope range_scope(scanner(), &clause_range);
    5436      975613 :       if (Check(Token::CASE)) {
    5437      869703 :         label = ParseExpression(true, CHECK_OK);
    5438             :       } else {
    5439      106223 :         Expect(Token::DEFAULT, CHECK_OK);
    5440      105311 :         if (default_seen) {
    5441          18 :           ReportMessage(MessageTemplate::kMultipleDefaultsInSwitch);
    5442          18 :           *ok = false;
    5443          18 :           return impl()->NullStatement();
    5444             :         }
    5445             :         default_seen = true;
    5446             :       }
    5447      974938 :       Expect(Token::COLON, CHECK_OK);
    5448             :       StatementListT statements = impl()->NewStatementList(5);
    5449     5084922 :       while (peek() != Token::CASE && peek() != Token::DEFAULT &&
    5450             :              peek() != Token::RBRACE) {
    5451      927674 :         StatementT stat = ParseStatementListItem(CHECK_OK);
    5452      139845 :         statements->Add(stat, zone());
    5453             :       }
    5454      218722 :       auto clause = factory()->NewCaseClause(label, statements);
    5455      974705 :       impl()->RecordCaseClauseSourceRange(clause, range_scope.Finalize());
    5456      109361 :       switch_statement->cases()->Add(clause, zone());
    5457             :     }
    5458      124216 :     Expect(Token::RBRACE, CHECK_OK);
    5459             : 
    5460             :     int end_position = scanner()->location().end_pos;
    5461             :     scope()->set_end_position(end_position);
    5462             :     impl()->RecordSwitchStatementSourceRange(switch_statement, end_position);
    5463      124216 :     Scope* switch_scope = scope()->FinalizeBlockScope();
    5464      124216 :     if (switch_scope != nullptr) {
    5465         920 :       return impl()->RewriteSwitchStatement(switch_statement, switch_scope);
    5466             :     }
    5467      104171 :     return switch_statement;
    5468             :   }
    5469             : }
    5470             : 
    5471             : template <typename Impl>
    5472      350750 : typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseTryStatement(
    5473     2712365 :     bool* ok) {
    5474             :   // TryStatement ::
    5475             :   //   'try' Block Catch
    5476             :   //   'try' Block Finally
    5477             :   //   'try' Block Catch Finally
    5478             :   //
    5479             :   // Catch ::
    5480             :   //   'catch' '(' Identifier ')' Block
    5481             :   //
    5482             :   // Finally ::
    5483             :   //   'finally' Block
    5484             : 
    5485      350750 :   Expect(Token::TRY, CHECK_OK);
    5486             :   int pos = position();
    5487             : 
    5488      350929 :   BlockT try_block = ParseBlock(nullptr, CHECK_OK);
    5489             : 
    5490      257239 :   CatchInfo catch_info(this);
    5491             : 
    5492      387567 :   if (peek() != Token::CATCH && peek() != Token::FINALLY) {
    5493         246 :     ReportMessage(MessageTemplate::kNoCatchOrFinally);
    5494         246 :     *ok = false;
    5495         246 :     return impl()->NullStatement();
    5496             :   }
    5497             : 
    5498             :   SourceRange catch_range, finally_range;
    5499             : 
    5500             :   BlockT catch_block = impl()->NullStatement();
    5501             :   {
    5502             :     SourceRangeScope catch_range_scope(scanner(), &catch_range);
    5503      350052 :     if (Check(Token::CATCH)) {
    5504      313058 :       Expect(Token::LPAREN, CHECK_OK);
    5505      312971 :       catch_info.scope = NewScope(CATCH_SCOPE);
    5506             :       catch_info.scope->set_start_position(scanner()->location().beg_pos);
    5507             : 
    5508             :       {
    5509      312971 :         BlockState catch_block_state(&scope_, catch_info.scope);
    5510             : 
    5511       86650 :         catch_block = factory()->NewBlock(16, false);
    5512             : 
    5513             :         // Create a block scope to hold any lexical declarations created
    5514             :         // as part of destructuring the catch parameter.
    5515             :         {
    5516      312971 :           BlockState catch_variable_block_state(zone(), &scope_);
    5517             :           scope()->set_start_position(scanner()->location().beg_pos);
    5518             :           typename Types::Target target(this, catch_block);
    5519             : 
    5520             :           // This does not simply call ParsePrimaryExpression to avoid
    5521             :           // ExpressionFromIdentifier from being called in the first
    5522             :           // branch, which would introduce an unresolved symbol and mess
    5523             :           // with arrow function names.
    5524      312971 :           if (peek_any_identifier()) {
    5525      298666 :             catch_info.name =
    5526      378624 :                 ParseIdentifier(kDontAllowRestrictedIdentifiers, CHECK_OK);
    5527             :           } else {
    5528       14305 :             ExpressionClassifier pattern_classifier(this);
    5529       16546 :             catch_info.pattern = ParsePrimaryExpression(CHECK_OK);
    5530       11569 :             ValidateBindingPattern(CHECK_OK);
    5531             :           }
    5532             : 
    5533      304623 :           Expect(Token::RPAREN, CHECK_OK);
    5534      302643 :           impl()->RewriteCatchPattern(&catch_info, CHECK_OK);
    5535       81707 :           if (!impl()->IsNull(catch_info.init_block)) {
    5536        3701 :             catch_block->statements()->Add(catch_info.init_block, zone());
    5537             :           }
    5538             : 
    5539      302681 :           catch_info.inner_block = ParseBlock(nullptr, CHECK_OK);
    5540       81424 :           catch_block->statements()->Add(catch_info.inner_block, zone());
    5541      302322 :           impl()->ValidateCatchBlock(catch_info, CHECK_OK);
    5542             :           scope()->set_end_position(scanner()->location().end_pos);
    5543      301980 :           catch_block->set_scope(scope()->FinalizeBlockScope());
    5544             :         }
    5545             :       }
    5546             : 
    5547      301980 :       catch_info.scope->set_end_position(scanner()->location().end_pos);
    5548             :     }
    5549             :   }
    5550             : 
    5551             :   BlockT finally_block = impl()->NullStatement();
    5552             :   DCHECK(peek() == Token::FINALLY || !impl()->IsNull(catch_block));
    5553             :   {
    5554             :     SourceRangeScope range_scope(scanner(), &finally_range);
    5555      339003 :     if (Check(Token::FINALLY)) {
    5556       38720 :       finally_block = ParseBlock(nullptr, CHECK_OK);
    5557             :     }
    5558             :   }
    5559             : 
    5560             :   return impl()->RewriteTryStatement(try_block, catch_block, catch_range,
    5561             :                                      finally_block, finally_range, catch_info,
    5562       87296 :                                      pos);
    5563             : }
    5564             : 
    5565             : template <typename Impl>
    5566      939691 : typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseForStatement(
    5567     2446743 :     ZoneList<const AstRawString*>* labels, bool* ok) {
    5568             :   int stmt_pos = peek_position();
    5569      939691 :   ForInfo for_info(this);
    5570             : 
    5571      939691 :   Expect(Token::FOR, CHECK_OK);
    5572      939700 :   Expect(Token::LPAREN, CHECK_OK);
    5573             : 
    5574     1841254 :   if (peek() == Token::CONST || (peek() == Token::LET && IsNextLetKeyword())) {
    5575             :     // The initializer contains lexical declarations,
    5576             :     // so create an in-between scope.
    5577      361658 :     BlockState for_state(zone(), &scope_);
    5578             :     scope()->set_start_position(scanner()->location().beg_pos);
    5579             : 
    5580             :     // Also record whether inner functions or evals are found inside
    5581             :     // this loop, as this information is used to simplify the desugaring
    5582             :     // if none are found.
    5583             :     typename FunctionState::FunctionOrEvalRecordingScope recording_scope(
    5584      180829 :         function_state_);
    5585             : 
    5586             :     // Create an inner block scope which will be the parent scope of scopes
    5587             :     // possibly created by ParseVariableDeclarations.
    5588             :     Scope* inner_block_scope = NewScope(BLOCK_SCOPE);
    5589             :     {
    5590             :       BlockState inner_state(&scope_, inner_block_scope);
    5591      180829 :       ParseVariableDeclarations(kForStatement, &for_info.parsing_result,
    5592      184688 :                                 nullptr, CHECK_OK);
    5593             :     }
    5594             :     DCHECK(IsLexicalVariableMode(for_info.parsing_result.descriptor.mode));
    5595      174513 :     for_info.position = scanner()->location().beg_pos;
    5596             : 
    5597      174513 :     if (CheckInOrOf(&for_info.mode)) {
    5598             :       scope()->set_is_hidden();
    5599             :       return ParseForEachStatementWithDeclarations(stmt_pos, &for_info, labels,
    5600       84050 :                                                    inner_block_scope, ok);
    5601             :     }
    5602             : 
    5603       90472 :     Expect(Token::SEMICOLON, CHECK_OK);
    5604             : 
    5605             :     StatementT init = impl()->BuildInitializationBlock(
    5606       90445 :         &for_info.parsing_result, &for_info.bound_names, CHECK_OK);
    5607             : 
    5608       90445 :     Scope* finalized = inner_block_scope->FinalizeBlockScope();
    5609             :     // No variable declarations will have been created in inner_block_scope.
    5610             :     DCHECK_NULL(finalized);
    5611             :     USE(finalized);
    5612             :     return ParseStandardForLoopWithLexicalDeclarations(stmt_pos, init,
    5613       90445 :                                                        &for_info, labels, ok);
    5614             :   }
    5615             : 
    5616             :   StatementT init = impl()->NullStatement();
    5617      758844 :   if (peek() == Token::VAR) {
    5618      593905 :     ParseVariableDeclarations(kForStatement, &for_info.parsing_result, nullptr,
    5619      594402 :                               CHECK_OK);
    5620             :     DCHECK_EQ(for_info.parsing_result.descriptor.mode, VAR);
    5621      592953 :     for_info.position = scanner()->location().beg_pos;
    5622             : 
    5623      592953 :     if (CheckInOrOf(&for_info.mode)) {
    5624             :       return ParseForEachStatementWithDeclarations(stmt_pos, &for_info, labels,
    5625       52317 :                                                    nullptr, ok);
    5626             :     }
    5627             : 
    5628      365060 :     init = impl()->BuildInitializationBlock(&for_info.parsing_result, nullptr,
    5629      540636 :                                             CHECK_OK);
    5630      164939 :   } else if (peek() != Token::SEMICOLON) {
    5631             :     // The initializer does not contain declarations.
    5632             :     int lhs_beg_pos = peek_position();
    5633      147876 :     ExpressionClassifier classifier(this);
    5634      148732 :     ExpressionT expression = ParseExpressionCoverGrammar(false, CHECK_OK);
    5635             :     int lhs_end_pos = scanner()->location().end_pos;
    5636             : 
    5637      146002 :     bool is_for_each = CheckInOrOf(&for_info.mode);
    5638       57114 :     bool is_destructuring = is_for_each && (expression->IsArrayLiteral() ||
    5639      314705 :                                             expression->IsObjectLiteral());
    5640             : 
    5641      146002 :     if (is_destructuring) {
    5642       24257 :       ValidateAssignmentPattern(CHECK_OK);
    5643             :     } else {
    5644      122325 :       impl()->RewriteNonPattern(CHECK_OK);
    5645             :     }
    5646             : 
    5647      144842 :     if (is_for_each) {
    5648             :       return ParseForEachStatementWithoutDeclarations(stmt_pos, expression,
    5649             :                                                       lhs_beg_pos, lhs_end_pos,
    5650      114473 :                                                       &for_info, labels, ok);
    5651             :     }
    5652             :     // Initializer is just an expression.
    5653       17115 :     init = factory()->NewExpressionStatement(expression, lhs_beg_pos);
    5654             :   }
    5655             : 
    5656      588582 :   Expect(Token::SEMICOLON, CHECK_OK);
    5657             : 
    5658             :   // Standard 'for' loop, we have parsed the initializer at this point.
    5659      587093 :   ExpressionT cond = impl()->NullExpression();
    5660      587093 :   StatementT next = impl()->NullStatement();
    5661      587093 :   StatementT body = impl()->NullStatement();
    5662             :   ForStatementT loop =
    5663      588498 :       ParseStandardForLoop(stmt_pos, labels, &cond, &next, &body, CHECK_OK);
    5664      392923 :   loop->Initialize(init, cond, next, body);
    5665      584175 :   return loop;
    5666             : }
    5667             : 
    5668             : template <typename Impl>
    5669             : typename ParserBase<Impl>::StatementT
    5670      136367 : ParserBase<Impl>::ParseForEachStatementWithDeclarations(
    5671             :     int stmt_pos, ForInfo* for_info, ZoneList<const AstRawString*>* labels,
    5672      494552 :     Scope* inner_block_scope, bool* ok) {
    5673             :   // Just one declaration followed by in/of.
    5674      272734 :   if (for_info->parsing_result.declarations.size() != 1) {
    5675        4905 :     impl()->ReportMessageAt(for_info->parsing_result.bindings_loc,
    5676             :                             MessageTemplate::kForInOfLoopMultiBindings,
    5677             :                             ForEachStatement::VisitModeString(for_info->mode));
    5678        3006 :     *ok = false;
    5679        3006 :     return impl()->NullStatement();
    5680             :   }
    5681      139581 :   if (for_info->parsing_result.first_initializer_loc.IsValid() &&
    5682             :       (is_strict(language_mode()) ||
    5683             :        for_info->mode == ForEachStatement::ITERATE ||
    5684        1438 :        IsLexicalVariableMode(for_info->parsing_result.descriptor.mode) ||
    5685         212 :        !impl()->IsIdentifier(
    5686             :            for_info->parsing_result.declarations[0].pattern))) {
    5687        5912 :     impl()->ReportMessageAt(for_info->parsing_result.first_initializer_loc,
    5688             :                             MessageTemplate::kForInOfLoopInitializer,
    5689             :                             ForEachStatement::VisitModeString(for_info->mode));
    5690        3546 :     *ok = false;
    5691        3546 :     return impl()->NullStatement();
    5692             :   }
    5693             : 
    5694             :   // Reset the declaration_kind to ensure proper processing during declaration.
    5695      129815 :   for_info->parsing_result.descriptor.declaration_kind =
    5696             :       DeclarationDescriptor::FOR_EACH;
    5697             : 
    5698       80308 :   BlockT init_block = impl()->RewriteForVarInLegacy(*for_info);
    5699             : 
    5700       80308 :   auto loop = factory()->NewForEachStatement(for_info->mode, labels, stmt_pos);
    5701             :   typename Types::Target target(this, loop);
    5702             : 
    5703             :   ExpressionT enumerable = impl()->NullExpression();
    5704      129815 :   if (for_info->mode == ForEachStatement::ITERATE) {
    5705       88876 :     ExpressionClassifier classifier(this);
    5706       88912 :     enumerable = ParseAssignmentExpression(true, CHECK_OK);
    5707       89050 :     impl()->RewriteNonPattern(CHECK_OK);
    5708             :   } else {
    5709       40939 :     enumerable = ParseExpression(true, CHECK_OK);
    5710             :   }
    5711             : 
    5712      129665 :   Expect(Token::RPAREN, CHECK_OK);
    5713             : 
    5714             :   Scope* for_scope = nullptr;
    5715      129023 :   if (inner_block_scope != nullptr) {
    5716             :     for_scope = inner_block_scope->outer_scope();
    5717             :     DCHECK(for_scope == scope());
    5718             :     inner_block_scope->set_start_position(scanner()->location().beg_pos);
    5719             :   }
    5720             : 
    5721       80008 :   ExpressionT each_variable = impl()->NullExpression();
    5722       80008 :   BlockT body_block = impl()->NullStatement();
    5723             :   {
    5724             :     BlockState block_state(
    5725      129023 :         &scope_, inner_block_scope != nullptr ? inner_block_scope : scope_);
    5726             : 
    5727             :     SourceRange body_range;
    5728             :     SourceRangeScope range_scope(scanner(), &body_range);
    5729             : 
    5730      129983 :     StatementT body = ParseStatement(nullptr, CHECK_OK);
    5731      127103 :     impl()->RecordIterationStatementSourceRange(loop, range_scope.Finalize());
    5732             : 
    5733       79048 :     impl()->DesugarBindingInForEachStatement(for_info, &body_block,
    5734      127103 :                                              &each_variable, CHECK_OK);
    5735       78931 :     body_block->statements()->Add(body, zone());
    5736             : 
    5737      126986 :     if (inner_block_scope != nullptr) {
    5738             :       inner_block_scope->set_end_position(scanner()->location().end_pos);
    5739       79175 :       body_block->set_scope(inner_block_scope->FinalizeBlockScope());
    5740             :     }
    5741             :   }
    5742             : 
    5743             :   StatementT final_loop = impl()->InitializeForEachStatement(
    5744       78931 :       loop, each_variable, enumerable, body_block);
    5745             : 
    5746       78931 :   init_block = impl()->CreateForEachStatementTDZ(init_block, *for_info, ok);
    5747             : 
    5748      126986 :   if (for_scope != nullptr) {
    5749             :     for_scope->set_end_position(scanner()->location().end_pos);
    5750       79175 :     for_scope = for_scope->FinalizeBlockScope();
    5751             :   }
    5752             : 
    5753             :   // Parsed for-in loop w/ variable declarations.
    5754      126986 :   if (!impl()->IsNull(init_block)) {
    5755       49073 :     init_block->statements()->Add(final_loop, zone());
    5756             :     init_block->set_scope(for_scope);
    5757       76455 :     return init_block;
    5758             :   }
    5759             : 
    5760             :   DCHECK_NULL(for_scope);
    5761       50531 :   return final_loop;
    5762             : }
    5763             : 
    5764             : template <typename Impl>
    5765             : typename ParserBase<Impl>::StatementT
    5766      114473 : ParserBase<Impl>::ParseForEachStatementWithoutDeclarations(
    5767             :     int stmt_pos, ExpressionT expression, int lhs_beg_pos, int lhs_end_pos,
    5768       97057 :     ForInfo* for_info, ZoneList<const AstRawString*>* labels, bool* ok) {
    5769             :   // Initializer is reference followed by in/of.
    5770      167263 :   if (!expression->IsArrayLiteral() && !expression->IsObjectLiteral()) {
    5771       91896 :     expression = impl()->CheckAndRewriteReferenceExpression(
    5772             :         expression, lhs_beg_pos, lhs_end_pos, MessageTemplate::kInvalidLhsInFor,
    5773       92761 :         kSyntaxError, CHECK_OK);
    5774             :   }
    5775             : 
    5776       57424 :   auto loop = factory()->NewForEachStatement(for_info->mode, labels, stmt_pos);
    5777             :   typename Types::Target target(this, loop);
    5778             : 
    5779             :   ExpressionT enumerable = impl()->NullExpression();
    5780      113113 :   if (for_info->mode == ForEachStatement::ITERATE) {
    5781       55210 :     ExpressionClassifier classifier(this);
    5782       59188 :     enumerable = ParseAssignmentExpression(true, CHECK_OK);
    5783       47342 :     impl()->RewriteNonPattern(CHECK_OK);
    5784             :   } else {
    5785       61823 :     enumerable = ParseExpression(true, CHECK_OK);
    5786             :   }
    5787             : 
    5788       97283 :   Expect(Token::RPAREN, CHECK_OK);
    5789             : 
    5790             :   StatementT body = impl()->NullStatement();
    5791             :   {
    5792             :     SourceRange body_range;
    5793             :     SourceRangeScope range_scope(scanner(), &body_range);
    5794             : 
    5795       98077 :     body = ParseStatement(nullptr, CHECK_OK);
    5796       94997 :     impl()->RecordIterationStatementSourceRange(loop, range_scope.Finalize());
    5797             :   }
    5798       48384 :   return impl()->InitializeForEachStatement(loop, expression, enumerable, body);
    5799             : }
    5800             : 
    5801             : template <typename Impl>
    5802             : typename ParserBase<Impl>::StatementT
    5803       90445 : ParserBase<Impl>::ParseStandardForLoopWithLexicalDeclarations(
    5804             :     int stmt_pos, StatementT init, ForInfo* for_info,
    5805      421170 :     ZoneList<const AstRawString*>* labels, bool* ok) {
    5806             :   // The condition and the next statement of the for loop must be parsed
    5807             :   // in a new scope.
    5808             :   Scope* inner_scope = NewScope(BLOCK_SCOPE);
    5809             :   ForStatementT loop = impl()->NullStatement();
    5810       90445 :   ExpressionT cond = impl()->NullExpression();
    5811       90445 :   StatementT next = impl()->NullStatement();
    5812       90445 :   StatementT body = impl()->NullStatement();
    5813             :   {
    5814       90445 :     BlockState block_state(&scope_, inner_scope);
    5815             :     scope()->set_start_position(scanner()->location().beg_pos);
    5816       90445 :     loop =
    5817       90445 :         ParseStandardForLoop(stmt_pos, labels, &cond, &next, &body, CHECK_OK);
    5818             :     scope()->set_end_position(scanner()->location().end_pos);
    5819             :   }
    5820             : 
    5821             :   scope()->set_end_position(scanner()->location().end_pos);
    5822       90445 :   if (for_info->bound_names.length() > 0 &&
    5823             :       function_state_->contains_function_or_eval()) {
    5824             :     scope()->set_is_hidden();
    5825             :     return impl()->DesugarLexicalBindingsInForStatement(
    5826       17590 :         loop, init, cond, next, body, inner_scope, *for_info, ok);
    5827             :   } else {
    5828       72855 :     inner_scope = inner_scope->FinalizeBlockScope();
    5829             :     DCHECK_NULL(inner_scope);
    5830             :     USE(inner_scope);
    5831             :   }
    5832             : 
    5833       72855 :   Scope* for_scope = scope()->FinalizeBlockScope();
    5834       72855 :   if (for_scope != nullptr) {
    5835             :     // Rewrite a for statement of the form
    5836             :     //   for (const x = i; c; n) b
    5837             :     //
    5838             :     // into
    5839             :     //
    5840             :     //   {
    5841             :     //     const x = i;
    5842             :     //     for (; c; n) b
    5843             :     //   }
    5844             :     //
    5845             :     DCHECK(!impl()->IsNull(init));
    5846       29695 :     BlockT block = factory()->NewBlock(2, false);
    5847       29695 :     block->statements()->Add(init, zone());
    5848       29695 :     block->statements()->Add(loop, zone());
    5849             :     block->set_scope(for_scope);
    5850       29695 :     loop->Initialize(impl()->NullStatement(), cond, next, body);
    5851       71525 :     return block;
    5852             :   }
    5853             : 
    5854           0 :   loop->Initialize(init, cond, next, body);
    5855        1330 :   return loop;
    5856             : }
    5857             : 
    5858             : template <typename Impl>
    5859      677538 : typename ParserBase<Impl>::ForStatementT ParserBase<Impl>::ParseStandardForLoop(
    5860             :     int stmt_pos, ZoneList<const AstRawString*>* labels, ExpressionT* cond,
    5861      677430 :     StatementT* next, StatementT* body, bool* ok) {
    5862      441522 :   ForStatementT loop = factory()->NewForStatement(labels, stmt_pos);
    5863             :   typename Types::Target target(this, loop);
    5864             : 
    5865      677538 :   if (peek() != Token::SEMICOLON) {
    5866      663379 :     *cond = ParseExpression(true, CHECK_OK);
    5867             :   }
    5868      677502 :   Expect(Token::SEMICOLON, CHECK_OK);
    5869             : 
    5870      677448 :   if (peek() != Token::RPAREN) {
    5871      621323 :     ExpressionT exp = ParseExpression(true, CHECK_OK);
    5872     1012443 :     *next = factory()->NewExpressionStatement(exp, exp->position());
    5873             :   }
    5874      677430 :   Expect(Token::RPAREN, CHECK_OK);
    5875             : 
    5876             :   SourceRange body_range;
    5877             :   {
    5878             :     SourceRangeScope range_scope(scanner(), &body_range);
    5879      678781 :     *body = ParseStatement(nullptr, CHECK_OK);
    5880             :   }
    5881             :   impl()->RecordIterationStatementSourceRange(loop, body_range);
    5882             : 
    5883      674620 :   return loop;
    5884             : }
    5885             : 
    5886             : template <typename Impl>
    5887             : void ParserBase<Impl>::MarkLoopVariableAsAssigned(
    5888    21216734 :     Scope* scope, Variable* var,
    5889             :     typename DeclarationDescriptor::Kind declaration_kind) {
    5890    21216734 :   if (!IsLexicalVariableMode(var->mode()) &&
    5891             :       (!scope->is_function_scope() ||
    5892             :        declaration_kind == DeclarationDescriptor::FOR_EACH)) {
    5893             :     var->set_maybe_assigned();
    5894             :   }
    5895             : }
    5896             : 
    5897             : template <typename Impl>
    5898      125314 : typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseForAwaitStatement(
    5899     1073761 :     ZoneList<const AstRawString*>* labels, bool* ok) {
    5900             :   // for await '(' ForDeclaration of AssignmentExpression ')'
    5901             :   DCHECK(is_async_function());
    5902             :   DCHECK(allow_harmony_async_iteration());
    5903             : 
    5904             :   int stmt_pos = peek_position();
    5905             : 
    5906      125314 :   ForInfo for_info(this);
    5907      125314 :   for_info.mode = ForEachStatement::ITERATE;
    5908             : 
    5909             :   // Create an in-between scope for let-bound iteration variables.
    5910      250628 :   BlockState for_state(zone(), &scope_);
    5911      125314 :   Expect(Token::FOR, CHECK_OK);
    5912      125314 :   Expect(Token::AWAIT, CHECK_OK);
    5913      125314 :   Expect(Token::LPAREN, CHECK_OK);
    5914             :   scope()->set_start_position(scanner()->location().beg_pos);
    5915             :   scope()->set_is_hidden();
    5916             : 
    5917       31505 :   auto loop = factory()->NewForOfStatement(labels, stmt_pos);
    5918             :   typename Types::Target target(this, loop);
    5919             : 
    5920       31505 :   ExpressionT each_variable = impl()->NullExpression();
    5921             : 
    5922             :   bool has_declarations = false;
    5923             :   Scope* inner_block_scope = NewScope(BLOCK_SCOPE);
    5924             : 
    5925      332821 :   if (peek() == Token::VAR || peek() == Token::CONST ||
    5926       33568 :       (peek() == Token::LET && IsNextLetKeyword())) {
    5927             :     // The initializer contains declarations
    5928             :     // 'for' 'await' '(' ForDeclaration 'of' AssignmentExpression ')'
    5929             :     //     Statement
    5930             :     // 'for' 'await' '(' 'var' ForBinding 'of' AssignmentExpression ')'
    5931             :     //     Statement
    5932             :     has_declarations = true;
    5933             : 
    5934             :     {
    5935             :       BlockState inner_state(&scope_, inner_block_scope);
    5936       88595 :       ParseVariableDeclarations(kForStatement, &for_info.parsing_result,
    5937       99875 :                                 nullptr, CHECK_OK);
    5938             :     }
    5939       73555 :     for_info.position = scanner()->location().beg_pos;
    5940             : 
    5941             :     // Only a single declaration is allowed in for-await-of loops
    5942      147110 :     if (for_info.parsing_result.declarations.size() != 1) {
    5943         480 :       impl()->ReportMessageAt(for_info.parsing_result.bindings_loc,
    5944             :                               MessageTemplate::kForInOfLoopMultiBindings,
    5945             :                               "for-await-of");
    5946         640 :       *ok = false;
    5947         640 :       return impl()->NullStatement();
    5948             :     }
    5949             : 
    5950             :     // for-await-of's declarations do not permit initializers.
    5951       72915 :     if (for_info.parsing_result.first_initializer_loc.IsValid()) {
    5952       11040 :       impl()->ReportMessageAt(for_info.parsing_result.first_initializer_loc,
    5953             :                               MessageTemplate::kForInOfLoopInitializer,
    5954             :                               "for-await-of");
    5955       14720 :       *ok = false;
    5956       14720 :       return impl()->NullStatement();
    5957             :     }
    5958             :   } else {
    5959             :     // The initializer does not contain declarations.
    5960             :     // 'for' 'await' '(' LeftHandSideExpression 'of' AssignmentExpression ')'
    5961             :     //     Statement
    5962             :     int lhs_beg_pos = peek_position();
    5963             :     BlockState inner_state(&scope_, inner_block_scope);
    5964       36719 :     ExpressionClassifier classifier(this);
    5965       37199 :     ExpressionT lhs = each_variable = ParseLeftHandSideExpression(CHECK_OK);
    5966             :     int lhs_end_pos = scanner()->location().end_pos;
    5967             : 
    5968       43784 :     if (lhs->IsArrayLiteral() || lhs->IsObjectLiteral()) {
    5969       27264 :       ValidateAssignmentPattern(CHECK_OK);
    5970             :     } else {
    5971        9295 :       impl()->RewriteNonPattern(CHECK_OK);
    5972        9295 :       each_variable = impl()->CheckAndRewriteReferenceExpression(
    5973             :           lhs, lhs_beg_pos, lhs_end_pos, MessageTemplate::kInvalidLhsInFor,
    5974       13135 :           kSyntaxError, CHECK_OK);
    5975             :     }
    5976             :   }
    5977             : 
    5978       92594 :   ExpectContextualKeyword(Token::OF, CHECK_OK);
    5979             :   int each_keyword_pos = scanner()->location().beg_pos;
    5980             : 
    5981             :   const bool kAllowIn = true;
    5982             :   ExpressionT iterable = impl()->NullExpression();
    5983             : 
    5984             :   {
    5985       83074 :     ExpressionClassifier classifier(this);
    5986       83074 :     iterable = ParseAssignmentExpression(kAllowIn, CHECK_OK);
    5987       83074 :     impl()->RewriteNonPattern(CHECK_OK);
    5988             :   }
    5989             : 
    5990       83074 :   Expect(Token::RPAREN, CHECK_OK);
    5991             : 
    5992       20945 :   StatementT body = impl()->NullStatement();
    5993             :   {
    5994             :     BlockState block_state(&scope_, inner_block_scope);
    5995             :     scope()->set_start_position(scanner()->location().beg_pos);
    5996             : 
    5997             :     SourceRange body_range;
    5998             :     SourceRangeScope range_scope(scanner(), &body_range);
    5999             : 
    6000       83314 :     body = ParseStatement(nullptr, CHECK_OK);
    6001             :     scope()->set_end_position(scanner()->location().end_pos);
    6002       82754 :     impl()->RecordIterationStatementSourceRange(loop, range_scope.Finalize());
    6003             : 
    6004       82754 :     if (has_declarations) {
    6005       14701 :       BlockT body_block = impl()->NullStatement();
    6006       14701 :       impl()->DesugarBindingInForEachStatement(&for_info, &body_block,
    6007       58195 :                                                &each_variable, CHECK_OK);
    6008       14701 :       body_block->statements()->Add(body, zone());
    6009       58195 :       body_block->set_scope(scope()->FinalizeBlockScope());
    6010       14701 :       body = body_block;
    6011             :     } else {
    6012       24559 :       Scope* block_scope = scope()->FinalizeBlockScope();
    6013             :       DCHECK_NULL(block_scope);
    6014             :       USE(block_scope);
    6015             :     }
    6016             :   }
    6017             :   const bool finalize = true;
    6018             :   StatementT final_loop = impl()->InitializeForOfStatement(
    6019             :       loop, each_variable, iterable, body, finalize, IteratorType::kAsync,
    6020       20865 :       each_keyword_pos);
    6021             : 
    6022       82754 :   if (!has_declarations) {
    6023       24559 :     Scope* for_scope = scope()->FinalizeBlockScope();
    6024             :     DCHECK_NULL(for_scope);
    6025             :     USE(for_scope);
    6026       24559 :     return final_loop;
    6027             :   }
    6028             : 
    6029             :   BlockT init_block =
    6030       14701 :       impl()->CreateForEachStatementTDZ(impl()->NullStatement(), for_info, ok);
    6031             : 
    6032             :   scope()->set_end_position(scanner()->location().end_pos);
    6033       58195 :   Scope* for_scope = scope()->FinalizeBlockScope();
    6034             :   // Parsed for-in loop w/ variable declarations.
    6035       58195 :   if (!impl()->IsNull(init_block)) {
    6036       11710 :     init_block->statements()->Add(final_loop, zone());
    6037             :     init_block->set_scope(for_scope);
    6038       23413 :     return init_block;
    6039             :   }
    6040             :   DCHECK_NULL(for_scope);
    6041       34782 :   return final_loop;
    6042             : }
    6043             : 
    6044             : template <typename Impl>
    6045     5228867 : void ParserBase<Impl>::ObjectLiteralChecker::CheckDuplicateProto(
    6046        2820 :     Token::Value property) {
    6047     5228867 :   if (property == Token::SMI || property == Token::NUMBER) return;
    6048             : 
    6049     2978118 :   if (IsProto()) {
    6050       71899 :     if (has_seen_proto_) {
    6051        2820 :       this->parser()->classifier()->RecordExpressionError(
    6052             :           this->scanner()->location(), MessageTemplate::kDuplicateProto);
    6053        2820 :       return;
    6054             :     }
    6055       69079 :     has_seen_proto_ = true;
    6056             :   }
    6057             : }
    6058             : 
    6059             : template <typename Impl>
    6060      499968 : void ParserBase<Impl>::ClassLiteralChecker::CheckClassMethodName(
    6061             :     Token::Value property, PropertyKind type, bool is_generator, bool is_async,
    6062        2188 :     bool is_static, bool* ok) {
    6063             :   DCHECK(type == PropertyKind::kMethodProperty ||
    6064             :          type == PropertyKind::kAccessorProperty);
    6065             : 
    6066      499968 :   if (property == Token::SMI || property == Token::NUMBER) return;
    6067             : 
    6068      499553 :   if (is_static) {
    6069       20629 :     if (IsPrototype()) {
    6070        1094 :       this->parser()->ReportMessage(MessageTemplate::kStaticPrototype);
    6071        1094 :       *ok = false;
    6072        1094 :       return;
    6073             :     }
    6074      478924 :   } else if (IsConstructor()) {
    6075       43997 :     if (is_generator || is_async || type == PropertyKind::kAccessorProperty) {
    6076             :       MessageTemplate::Template msg =
    6077             :           is_generator ? MessageTemplate::kConstructorIsGenerator
    6078             :                        : is_async ? MessageTemplate::kConstructorIsAsync
    6079         996 :                                   : MessageTemplate::kConstructorIsAccessor;
    6080         996 :       this->parser()->ReportMessage(msg);
    6081         996 :       *ok = false;
    6082         996 :       return;
    6083             :     }
    6084       43001 :     if (has_seen_constructor_) {
    6085          98 :       this->parser()->ReportMessage(MessageTemplate::kDuplicateConstructor);
    6086          98 :       *ok = false;
    6087          98 :       return;
    6088             :     }
    6089       42903 :     has_seen_constructor_ = true;
    6090       42903 :     return;
    6091             :   }
    6092             : }
    6093             : 
    6094             : #undef CHECK_OK
    6095             : #undef CHECK_OK_CUSTOM
    6096             : #undef CHECK_OK_VOID
    6097             : 
    6098             : }  // namespace internal
    6099             : }  // namespace v8
    6100             : 
    6101             : #endif  // V8_PARSING_PARSER_BASE_H

Generated by: LCOV version 1.10