LCOV - code coverage report
Current view: top level - src/parsing - parser.h (source / functions) Hit Total Coverage
Test: app.info Lines: 164 164 100.0 %
Date: 2017-10-20 Functions: 7 7 100.0 %

          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_H_
       6             : #define V8_PARSING_PARSER_H_
       7             : 
       8             : #include <cstddef>
       9             : 
      10             : #include "src/ast/ast-source-ranges.h"
      11             : #include "src/ast/ast.h"
      12             : #include "src/ast/scopes.h"
      13             : #include "src/base/compiler-specific.h"
      14             : #include "src/globals.h"
      15             : #include "src/parsing/parser-base.h"
      16             : #include "src/parsing/parsing.h"
      17             : #include "src/parsing/preparse-data-format.h"
      18             : #include "src/parsing/preparse-data.h"
      19             : #include "src/parsing/preparser.h"
      20             : #include "src/pending-compilation-error-handler.h"
      21             : #include "src/utils.h"
      22             : 
      23             : namespace v8 {
      24             : 
      25             : class ScriptCompiler;
      26             : 
      27             : namespace internal {
      28             : 
      29             : class ConsumedPreParsedScopeData;
      30             : class ParseInfo;
      31             : class ScriptData;
      32             : class ParserTarget;
      33             : class ParserTargetScope;
      34             : class PreParsedScopeData;
      35             : 
      36             : class FunctionEntry BASE_EMBEDDED {
      37             :  public:
      38             :   enum {
      39             :     kStartPositionIndex,
      40             :     kEndPositionIndex,
      41             :     kNumParametersIndex,
      42             :     kFlagsIndex,
      43             :     kNumInnerFunctionsIndex,
      44             :     kSize
      45             :   };
      46             : 
      47             :   explicit FunctionEntry(Vector<unsigned> backing)
      48             :     : backing_(backing) { }
      49             : 
      50             :   FunctionEntry() : backing_() { }
      51             : 
      52             :   class LanguageModeField : public BitField<LanguageMode, 0, 1> {};
      53             :   class UsesSuperPropertyField
      54             :       : public BitField<bool, LanguageModeField::kNext, 1> {};
      55             : 
      56             :   static uint32_t EncodeFlags(LanguageMode language_mode,
      57             :                               bool uses_super_property) {
      58             :     return LanguageModeField::encode(language_mode) |
      59         170 :            UsesSuperPropertyField::encode(uses_super_property);
      60             :   }
      61             : 
      62             :   int start_pos() const { return backing_[kStartPositionIndex]; }
      63         405 :   int end_pos() const { return backing_[kEndPositionIndex]; }
      64         100 :   int num_parameters() const { return backing_[kNumParametersIndex]; }
      65             :   LanguageMode language_mode() const {
      66         100 :     return LanguageModeField::decode(backing_[kFlagsIndex]);
      67             :   }
      68             :   bool uses_super_property() const {
      69         100 :     return UsesSuperPropertyField::decode(backing_[kFlagsIndex]);
      70             :   }
      71         100 :   int num_inner_functions() const { return backing_[kNumInnerFunctionsIndex]; }
      72             : 
      73         115 :   bool is_valid() const { return !backing_.is_empty(); }
      74             : 
      75             :  private:
      76             :   Vector<unsigned> backing_;
      77             : };
      78             : 
      79             : 
      80             : // Wrapper around ScriptData to provide parser-specific functionality.
      81             : class ParseData {
      82             :  public:
      83          95 :   static ParseData* FromCachedData(ScriptData* cached_data) {
      84          95 :     ParseData* pd = new ParseData(cached_data);
      85          95 :     if (pd->IsSane()) return pd;
      86             :     cached_data->Reject();
      87           5 :     delete pd;
      88           5 :     return nullptr;
      89             :   }
      90             : 
      91             :   void Initialize();
      92             :   FunctionEntry GetFunctionEntry(int start);
      93             :   int FunctionCount();
      94             : 
      95             :   unsigned* Data() {  // Writable data as unsigned int array.
      96         345 :     return reinterpret_cast<unsigned*>(const_cast<byte*>(script_data_->data()));
      97             :   }
      98             : 
      99             :   void Reject() { script_data_->Reject(); }
     100             : 
     101             :   bool rejected() const { return script_data_->rejected(); }
     102             : 
     103             :  private:
     104          95 :   explicit ParseData(ScriptData* script_data) : script_data_(script_data) {}
     105             : 
     106             :   bool IsSane();
     107             :   unsigned Magic();
     108             :   unsigned Version();
     109             :   int FunctionsSize();
     110             :   int Length() const {
     111             :     // Script data length is already checked to be a multiple of unsigned size.
     112         270 :     return script_data_->length() / sizeof(unsigned);
     113             :   }
     114             : 
     115             :   ScriptData* script_data_;
     116             :   int function_index_;
     117             : 
     118             :   DISALLOW_COPY_AND_ASSIGN(ParseData);
     119             : };
     120             : 
     121             : // ----------------------------------------------------------------------------
     122             : // JAVASCRIPT PARSING
     123             : 
     124             : class Parser;
     125             : 
     126             : 
     127             : struct ParserFormalParameters : FormalParametersBase {
     128             :   struct Parameter : public ZoneObject {
     129     5239474 :     Parameter(const AstRawString* name, Expression* pattern,
     130             :               Expression* initializer, int position,
     131             :               int initializer_end_position, bool is_rest)
     132             :         : name(name),
     133             :           pattern(pattern),
     134             :           initializer(initializer),
     135             :           position(position),
     136             :           initializer_end_position(initializer_end_position),
     137     5239474 :           is_rest(is_rest) {}
     138             :     const AstRawString* name;
     139             :     Expression* pattern;
     140             :     Expression* initializer;
     141             :     int position;
     142             :     int initializer_end_position;
     143             :     bool is_rest;
     144             :     Parameter* next_parameter = nullptr;
     145       51122 :     bool is_simple() const {
     146      102244 :       return pattern->IsVariableProxy() && initializer == nullptr && !is_rest;
     147             :     }
     148             : 
     149             :     Parameter** next() { return &next_parameter; }
     150             :     Parameter* const* next() const { return &next_parameter; }
     151             :   };
     152             : 
     153             :   explicit ParserFormalParameters(DeclarationScope* scope)
     154             :       : FormalParametersBase(scope) {}
     155             :   ThreadedList<Parameter> params;
     156             : };
     157             : 
     158             : template <>
     159             : struct ParserTypes<Parser> {
     160             :   typedef ParserBase<Parser> Base;
     161             :   typedef Parser Impl;
     162             : 
     163             :   // Return types for traversing functions.
     164             :   typedef const AstRawString* Identifier;
     165             :   typedef v8::internal::Expression* Expression;
     166             :   typedef v8::internal::FunctionLiteral* FunctionLiteral;
     167             :   typedef ObjectLiteral::Property* ObjectLiteralProperty;
     168             :   typedef ClassLiteral::Property* ClassLiteralProperty;
     169             :   typedef v8::internal::Suspend* Suspend;
     170             :   typedef ZoneList<v8::internal::Expression*>* ExpressionList;
     171             :   typedef ZoneList<ObjectLiteral::Property*>* ObjectPropertyList;
     172             :   typedef ZoneList<ClassLiteral::Property*>* ClassPropertyList;
     173             :   typedef ParserFormalParameters FormalParameters;
     174             :   typedef v8::internal::Statement* Statement;
     175             :   typedef ZoneList<v8::internal::Statement*>* StatementList;
     176             :   typedef v8::internal::Block* Block;
     177             :   typedef v8::internal::BreakableStatement* BreakableStatement;
     178             :   typedef v8::internal::ForStatement* ForStatement;
     179             :   typedef v8::internal::IterationStatement* IterationStatement;
     180             : 
     181             :   // For constructing objects returned by the traversing functions.
     182             :   typedef AstNodeFactory Factory;
     183             : 
     184             :   typedef ParserTarget Target;
     185             :   typedef ParserTargetScope TargetScope;
     186             : };
     187             : 
     188             : class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
     189             :  public:
     190             :   explicit Parser(ParseInfo* info);
     191     4696018 :   ~Parser() {
     192     2348009 :     delete reusable_preparser_;
     193     2348009 :     reusable_preparser_ = nullptr;
     194     2348009 :     delete cached_parse_data_;
     195     2348009 :     cached_parse_data_ = nullptr;
     196     2348009 :   }
     197             : 
     198             :   static bool IsPreParser() { return false; }
     199             : 
     200             :   void ParseOnBackground(ParseInfo* info);
     201             : 
     202             :   // Deserialize the scope chain prior to parsing in which the script is going
     203             :   // to be executed. If the script is a top-level script, or the scope chain
     204             :   // consists of only a native context, maybe_outer_scope_info should be an
     205             :   // empty handle.
     206             :   //
     207             :   // This only deserializes the scope chain, but doesn't connect the scopes to
     208             :   // their corresponding scope infos. Therefore, looking up variables in the
     209             :   // deserialized scopes is not possible.
     210             :   void DeserializeScopeChain(ParseInfo* info,
     211             :                              MaybeHandle<ScopeInfo> maybe_outer_scope_info);
     212             : 
     213             :   // Handle errors detected during parsing
     214             :   void ReportErrors(Isolate* isolate, Handle<Script> script);
     215             :   // Move statistics to Isolate
     216             :   void UpdateStatistics(Isolate* isolate, Handle<Script> script);
     217             :   void HandleSourceURLComments(Isolate* isolate, Handle<Script> script);
     218             : 
     219             :  private:
     220             :   friend class ParserBase<Parser>;
     221             :   friend class v8::internal::ExpressionClassifier<ParserTypes<Parser>>;
     222             :   friend bool v8::internal::parsing::ParseProgram(ParseInfo*, Isolate*);
     223             :   friend bool v8::internal::parsing::ParseFunction(
     224             :       ParseInfo*, Handle<SharedFunctionInfo> shared_info, Isolate*);
     225             : 
     226             :   bool AllowsLazyParsingWithoutUnresolvedVariables() const {
     227             :     return scope()->AllowsLazyParsingWithoutUnresolvedVariables(
     228     5642385 :         original_scope_);
     229             :   }
     230             : 
     231             :   bool parse_lazily() const { return mode_ == PARSE_LAZILY; }
     232             :   enum Mode { PARSE_LAZILY, PARSE_EAGERLY };
     233             : 
     234             :   class ParsingModeScope BASE_EMBEDDED {
     235             :    public:
     236             :     ParsingModeScope(Parser* parser, Mode mode)
     237     5333930 :         : parser_(parser), old_mode_(parser->mode_) {
     238     5333930 :       parser_->mode_ = mode;
     239             :     }
     240     5333928 :     ~ParsingModeScope() { parser_->mode_ = old_mode_; }
     241             : 
     242             :    private:
     243             :     Parser* parser_;
     244             :     Mode old_mode_;
     245             :   };
     246             : 
     247             :   // Runtime encoding of different completion modes.
     248             :   enum CompletionKind {
     249             :     kNormalCompletion,
     250             :     kThrowCompletion,
     251             :     kAbruptCompletion
     252             :   };
     253             : 
     254        4946 :   Variable* NewTemporary(const AstRawString* name) {
     255      891153 :     return scope()->NewTemporary(name);
     256             :   }
     257             : 
     258             :   void PrepareGeneratorVariables();
     259             : 
     260             :   // Returns nullptr if parsing failed.
     261             :   FunctionLiteral* ParseProgram(Isolate* isolate, ParseInfo* info);
     262             : 
     263             :   FunctionLiteral* ParseFunction(Isolate* isolate, ParseInfo* info,
     264             :                                  Handle<SharedFunctionInfo> shared_info);
     265             :   FunctionLiteral* DoParseFunction(ParseInfo* info,
     266             :                                    const AstRawString* raw_name);
     267             : 
     268             :   // Called by ParseProgram after setting up the scanner.
     269             :   FunctionLiteral* DoParseProgram(ParseInfo* info);
     270             : 
     271             :   void SetCachedData(ParseInfo* info);
     272             : 
     273             :   void StitchAst(ParseInfo* top_level_parse_info, Isolate* isolate);
     274             : 
     275             :   ScriptCompiler::CompileOptions compile_options() const {
     276             :     return compile_options_;
     277             :   }
     278             :   bool consume_cached_parse_data() const {
     279             :     return compile_options_ == ScriptCompiler::kConsumeParserCache;
     280             :   }
     281             :   bool produce_cached_parse_data() const {
     282             :     return compile_options_ == ScriptCompiler::kProduceParserCache;
     283             :   }
     284             : 
     285     4417812 :   PreParser* reusable_preparser() {
     286     4417812 :     if (reusable_preparser_ == nullptr) {
     287             :       reusable_preparser_ =
     288     3588440 :           new PreParser(zone(), &scanner_, stack_limit_, ast_value_factory(),
     289             :                         &pending_error_handler_, runtime_call_stats_,
     290      717688 :                         parsing_on_main_thread_);
     291             : #define SET_ALLOW(name) reusable_preparser_->set_allow_##name(allow_##name());
     292             :       SET_ALLOW(natives);
     293      358844 :       SET_ALLOW(harmony_do_expressions);
     294      358844 :       SET_ALLOW(harmony_function_sent);
     295      358844 :       SET_ALLOW(harmony_class_fields);
     296      358844 :       SET_ALLOW(harmony_object_rest_spread);
     297      358844 :       SET_ALLOW(harmony_dynamic_import);
     298      358844 :       SET_ALLOW(harmony_import_meta);
     299      358844 :       SET_ALLOW(harmony_async_iteration);
     300      358844 :       SET_ALLOW(harmony_template_escapes);
     301      358844 :       SET_ALLOW(harmony_restrictive_generators);
     302             :       SET_ALLOW(harmony_bigint);
     303             : #undef SET_ALLOW
     304             :     }
     305     4417812 :     return reusable_preparser_;
     306             :   }
     307             : 
     308             :   void ParseModuleItemList(ZoneList<Statement*>* body, bool* ok);
     309             :   Statement* ParseModuleItem(bool* ok);
     310             :   const AstRawString* ParseModuleSpecifier(bool* ok);
     311             :   void ParseImportDeclaration(bool* ok);
     312             :   Statement* ParseExportDeclaration(bool* ok);
     313             :   Statement* ParseExportDefault(bool* ok);
     314             :   void ParseExportClause(ZoneList<const AstRawString*>* export_names,
     315             :                          ZoneList<Scanner::Location>* export_locations,
     316             :                          ZoneList<const AstRawString*>* local_names,
     317             :                          Scanner::Location* reserved_loc, bool* ok);
     318             :   struct NamedImport : public ZoneObject {
     319             :     const AstRawString* import_name;
     320             :     const AstRawString* local_name;
     321             :     const Scanner::Location location;
     322             :     NamedImport(const AstRawString* import_name, const AstRawString* local_name,
     323             :                 Scanner::Location location)
     324             :         : import_name(import_name),
     325             :           local_name(local_name),
     326        1134 :           location(location) {}
     327             :   };
     328             :   ZoneList<const NamedImport*>* ParseNamedImports(int pos, bool* ok);
     329             :   Block* BuildInitializationBlock(DeclarationParsingResult* parsing_result,
     330             :                                   ZoneList<const AstRawString*>* names,
     331             :                                   bool* ok);
     332             :   ZoneList<const AstRawString*>* DeclareLabel(
     333             :       ZoneList<const AstRawString*>* labels, VariableProxy* expr, bool* ok);
     334             :   bool ContainsLabel(ZoneList<const AstRawString*>* labels,
     335             :                      const AstRawString* label);
     336             :   Expression* RewriteReturn(Expression* return_value, int pos);
     337             :   Statement* RewriteSwitchStatement(SwitchStatement* switch_statement,
     338             :                                     Scope* scope);
     339             :   void RewriteCatchPattern(CatchInfo* catch_info, bool* ok);
     340             :   void ValidateCatchBlock(const CatchInfo& catch_info, bool* ok);
     341             :   Statement* RewriteTryStatement(Block* try_block, Block* catch_block,
     342             :                                  const SourceRange& catch_range,
     343             :                                  Block* finally_block,
     344             :                                  const SourceRange& finally_range,
     345             :                                  const CatchInfo& catch_info, int pos);
     346             :   void ParseAndRewriteGeneratorFunctionBody(int pos, FunctionKind kind,
     347             :                                             ZoneList<Statement*>* body,
     348             :                                             bool* ok);
     349             :   void ParseAndRewriteAsyncGeneratorFunctionBody(int pos, FunctionKind kind,
     350             :                                                  ZoneList<Statement*>* body,
     351             :                                                  bool* ok);
     352             :   void CreateFunctionNameAssignment(const AstRawString* function_name, int pos,
     353             :                                     FunctionLiteral::FunctionType function_type,
     354             :                                     DeclarationScope* function_scope,
     355             :                                     ZoneList<Statement*>* result, int index);
     356             : 
     357             :   Statement* DeclareFunction(const AstRawString* variable_name,
     358             :                              FunctionLiteral* function, VariableMode mode,
     359             :                              int pos, bool is_sloppy_block_function,
     360             :                              ZoneList<const AstRawString*>* names, bool* ok);
     361             :   V8_INLINE Statement* DeclareClass(const AstRawString* variable_name,
     362             :                                     Expression* value,
     363             :                                     ZoneList<const AstRawString*>* names,
     364             :                                     int class_token_pos, int end_pos, bool* ok);
     365             :   V8_INLINE void DeclareClassVariable(const AstRawString* name,
     366             :                                       ClassInfo* class_info,
     367             :                                       int class_token_pos, bool* ok);
     368             :   V8_INLINE void DeclareClassProperty(const AstRawString* class_name,
     369             :                                       ClassLiteralProperty* property,
     370             :                                       ClassLiteralProperty::Kind kind,
     371             :                                       bool is_static, bool is_constructor,
     372             :                                       ClassInfo* class_info, bool* ok);
     373             :   V8_INLINE Expression* RewriteClassLiteral(Scope* block_scope,
     374             :                                             const AstRawString* name,
     375             :                                             ClassInfo* class_info, int pos,
     376             :                                             int end_pos, bool* ok);
     377             :   V8_INLINE Statement* DeclareNative(const AstRawString* name, int pos,
     378             :                                      bool* ok);
     379             : 
     380             :   V8_INLINE Block* IgnoreCompletion(Statement* statement);
     381             : 
     382             :   V8_INLINE Scope* NewHiddenCatchScope();
     383             : 
     384             :   // PatternRewriter and associated methods defined in pattern-rewriter.cc.
     385             :   friend class PatternRewriter;
     386             :   void DeclareAndInitializeVariables(
     387             :       Block* block, const DeclarationDescriptor* declaration_descriptor,
     388             :       const DeclarationParsingResult::Declaration* declaration,
     389             :       ZoneList<const AstRawString*>* names, bool* ok);
     390             :   void RewriteDestructuringAssignment(RewritableExpression* expr);
     391             :   Expression* RewriteDestructuringAssignment(Assignment* assignment);
     392             : 
     393             :   // [if (IteratorType == kAsync)]
     394             :   //     !%_IsJSReceiver(result = Await(iterator.next()) &&
     395             :   //         %ThrowIteratorResultNotAnObject(result)
     396             :   // [else]
     397             :   //     !%_IsJSReceiver(result = iterator.next()) &&
     398             :   //         %ThrowIteratorResultNotAnObject(result)
     399             :   // [endif]
     400             :   Expression* BuildIteratorNextResult(Expression* iterator, Variable* result,
     401             :                                       IteratorType type, int pos);
     402             : 
     403             :   // Initialize the components of a for-in / for-of statement.
     404             :   Statement* InitializeForEachStatement(ForEachStatement* stmt,
     405             :                                         Expression* each, Expression* subject,
     406             :                                         Statement* body);
     407             :   Statement* InitializeForOfStatement(ForOfStatement* stmt, Expression* each,
     408             :                                       Expression* iterable, Statement* body,
     409             :                                       bool finalize, IteratorType type,
     410             :                                       int next_result_pos = kNoSourcePosition);
     411             : 
     412             :   Block* RewriteForVarInLegacy(const ForInfo& for_info);
     413             :   void DesugarBindingInForEachStatement(ForInfo* for_info, Block** body_block,
     414             :                                         Expression** each_variable, bool* ok);
     415             :   Block* CreateForEachStatementTDZ(Block* init_block, const ForInfo& for_info,
     416             :                                    bool* ok);
     417             : 
     418             :   Statement* DesugarLexicalBindingsInForStatement(
     419             :       ForStatement* loop, Statement* init, Expression* cond, Statement* next,
     420             :       Statement* body, Scope* inner_scope, const ForInfo& for_info, bool* ok);
     421             : 
     422             :   Expression* RewriteDoExpression(Block* body, int pos, bool* ok);
     423             : 
     424             :   FunctionLiteral* ParseFunctionLiteral(
     425             :       const AstRawString* name, Scanner::Location function_name_location,
     426             :       FunctionNameValidity function_name_validity, FunctionKind kind,
     427             :       int function_token_position, FunctionLiteral::FunctionType type,
     428             :       LanguageMode language_mode, bool* ok);
     429             : 
     430             :   // Check if the scope has conflicting var/let declarations from different
     431             :   // scopes. This covers for example
     432             :   //
     433             :   // function f() { { { var x; } let x; } }
     434             :   // function g() { { var x; let x; } }
     435             :   //
     436             :   // The var declarations are hoisted to the function scope, but originate from
     437             :   // a scope where the name has also been let bound or the var declaration is
     438             :   // hoisted over such a scope.
     439             :   void CheckConflictingVarDeclarations(Scope* scope, bool* ok);
     440             : 
     441             :   // Insert initializer statements for var-bindings shadowing parameter bindings
     442             :   // from a non-simple parameter list.
     443             :   void InsertShadowingVarBindingInitializers(Block* block);
     444             : 
     445             :   // Implement sloppy block-scoped functions, ES2015 Annex B 3.3
     446             :   void InsertSloppyBlockFunctionVarBindings(DeclarationScope* scope);
     447             : 
     448             :   VariableProxy* NewUnresolved(const AstRawString* name, int begin_pos,
     449             :                                VariableKind kind = NORMAL_VARIABLE);
     450             :   VariableProxy* NewUnresolved(const AstRawString* name);
     451             :   Variable* Declare(Declaration* declaration,
     452             :                     DeclarationDescriptor::Kind declaration_kind,
     453             :                     VariableMode mode, InitializationFlag init, bool* ok,
     454             :                     Scope* declaration_scope = nullptr,
     455             :                     int var_end_pos = kNoSourcePosition);
     456             :   Declaration* DeclareVariable(const AstRawString* name, VariableMode mode,
     457             :                                int pos, bool* ok);
     458             :   Declaration* DeclareVariable(const AstRawString* name, VariableMode mode,
     459             :                                InitializationFlag init, int pos, bool* ok);
     460             : 
     461             :   bool TargetStackContainsLabel(const AstRawString* label);
     462             :   BreakableStatement* LookupBreakTarget(const AstRawString* label, bool* ok);
     463             :   IterationStatement* LookupContinueTarget(const AstRawString* label, bool* ok);
     464             : 
     465             :   Statement* BuildAssertIsCoercible(Variable* var, ObjectLiteral* pattern);
     466             : 
     467             :   // Factory methods.
     468             :   FunctionLiteral* DefaultConstructor(const AstRawString* name, bool call_super,
     469             :                                       int pos, int end_pos);
     470             : 
     471             :   // Skip over a lazy function, either using cached data if we have it, or
     472             :   // by parsing the function with PreParser. Consumes the ending }.
     473             :   // If may_abort == true, the (pre-)parser may decide to abort skipping
     474             :   // in order to force the function to be eagerly parsed, after all.
     475             :   LazyParsingResult SkipFunction(
     476             :       const AstRawString* function_name, FunctionKind kind,
     477             :       FunctionLiteral::FunctionType function_type,
     478             :       DeclarationScope* function_scope, int* num_parameters,
     479             :       ProducedPreParsedScopeData** produced_preparsed_scope_data,
     480             :       bool is_inner_function, bool may_abort, bool* ok);
     481             : 
     482             :   Block* BuildParameterInitializationBlock(
     483             :       const ParserFormalParameters& parameters, bool* ok);
     484             :   Block* BuildRejectPromiseOnException(Block* block);
     485             : 
     486             :   ZoneList<Statement*>* ParseFunction(
     487             :       const AstRawString* function_name, int pos, FunctionKind kind,
     488             :       FunctionLiteral::FunctionType function_type,
     489             :       DeclarationScope* function_scope, int* num_parameters,
     490             :       int* function_length, bool* has_duplicate_parameters,
     491             :       int* expected_property_count, bool* ok);
     492             : 
     493             :   void ThrowPendingError(Isolate* isolate, Handle<Script> script);
     494             : 
     495             :   class TemplateLiteral : public ZoneObject {
     496             :    public:
     497       34433 :     TemplateLiteral(Zone* zone, int pos)
     498       34433 :         : cooked_(8, zone), raw_(8, zone), expressions_(8, zone), pos_(pos) {}
     499             : 
     500             :     const ZoneList<Literal*>* cooked() const { return &cooked_; }
     501             :     const ZoneList<Literal*>* raw() const { return &raw_; }
     502             :     const ZoneList<Expression*>* expressions() const { return &expressions_; }
     503             :     int position() const { return pos_; }
     504             : 
     505             :     void AddTemplateSpan(Literal* cooked, Literal* raw, int end, Zone* zone) {
     506             :       DCHECK_NOT_NULL(cooked);
     507             :       DCHECK_NOT_NULL(raw);
     508       62557 :       cooked_.Add(cooked, zone);
     509       62557 :       raw_.Add(raw, zone);
     510             :     }
     511             : 
     512             :     void AddExpression(Expression* expression, Zone* zone) {
     513             :       DCHECK_NOT_NULL(expression);
     514       36586 :       expressions_.Add(expression, zone);
     515             :     }
     516             : 
     517             :    private:
     518             :     ZoneList<Literal*> cooked_;
     519             :     ZoneList<Literal*> raw_;
     520             :     ZoneList<Expression*> expressions_;
     521             :     int pos_;
     522             :   };
     523             : 
     524             :   typedef TemplateLiteral* TemplateLiteralState;
     525             : 
     526             :   TemplateLiteralState OpenTemplateLiteral(int pos);
     527             :   // "should_cook" means that the span can be "cooked": in tagged template
     528             :   // literals, both the raw and "cooked" representations are available to user
     529             :   // code ("cooked" meaning that escape sequences are converted to their
     530             :   // interpreted values). With the --harmony-template-escapes flag, invalid
     531             :   // escape sequences cause the cooked span to be represented by undefined,
     532             :   // instead of being a syntax error.
     533             :   // "tail" indicates that this span is the last in the literal.
     534             :   void AddTemplateSpan(TemplateLiteralState* state, bool should_cook,
     535             :                        bool tail);
     536             :   void AddTemplateExpression(TemplateLiteralState* state,
     537             :                              Expression* expression);
     538             :   Expression* CloseTemplateLiteral(TemplateLiteralState* state, int start,
     539             :                                    Expression* tag);
     540             :   int32_t ComputeTemplateLiteralHash(const TemplateLiteral* lit);
     541             : 
     542             :   ZoneList<Expression*>* PrepareSpreadArguments(ZoneList<Expression*>* list);
     543             :   Expression* SpreadCall(Expression* function, ZoneList<Expression*>* args,
     544             :                          int pos, Call::PossiblyEval is_possibly_eval);
     545             :   Expression* SpreadCallNew(Expression* function, ZoneList<Expression*>* args,
     546             :                             int pos);
     547             :   Expression* RewriteSuperCall(Expression* call_expression);
     548             : 
     549             :   void SetLanguageMode(Scope* scope, LanguageMode mode);
     550             :   void SetAsmModule();
     551             : 
     552             :   // Rewrite all DestructuringAssignments in the current FunctionState.
     553             :   V8_INLINE void RewriteDestructuringAssignments();
     554             : 
     555             :   V8_INLINE Expression* RewriteExponentiation(Expression* left,
     556             :                                               Expression* right, int pos);
     557             :   V8_INLINE Expression* RewriteAssignExponentiation(Expression* left,
     558             :                                                     Expression* right, int pos);
     559             : 
     560             :   friend class NonPatternRewriter;
     561             :   V8_INLINE Expression* RewriteSpreads(ArrayLiteral* lit);
     562             : 
     563             :   // Rewrite expressions that are not used as patterns
     564             :   V8_INLINE void RewriteNonPattern(bool* ok);
     565             : 
     566             :   V8_INLINE void QueueDestructuringAssignmentForRewriting(
     567             :       Expression* assignment);
     568             :   V8_INLINE void QueueNonPatternForRewriting(Expression* expr, bool* ok);
     569             : 
     570             :   friend class InitializerRewriter;
     571             :   void RewriteParameterInitializer(Expression* expr);
     572             : 
     573             :   Expression* BuildInitialYield(int pos, FunctionKind kind);
     574             :   Assignment* BuildCreateJSGeneratorObject(int pos, FunctionKind kind);
     575             :   Expression* BuildResolvePromise(Expression* value, int pos);
     576             :   Expression* BuildRejectPromise(Expression* value, int pos);
     577             :   Variable* PromiseVariable();
     578             :   Variable* AsyncGeneratorAwaitVariable();
     579             : 
     580             :   // Generic AST generator for throwing errors from compiled code.
     581             :   Expression* NewThrowError(Runtime::FunctionId function_id,
     582             :                             MessageTemplate::Template message,
     583             :                             const AstRawString* arg, int pos);
     584             : 
     585             :   void FinalizeIteratorUse(Variable* completion, Expression* condition,
     586             :                            Variable* iter, Block* iterator_use, Block* result,
     587             :                            IteratorType type);
     588             : 
     589             :   Statement* FinalizeForOfStatement(ForOfStatement* loop, Variable* completion,
     590             :                                     IteratorType type, int pos);
     591             :   void BuildIteratorClose(ZoneList<Statement*>* statements, Variable* iterator,
     592             :                           Variable* input, Variable* output, IteratorType type);
     593             :   void BuildIteratorCloseForCompletion(ZoneList<Statement*>* statements,
     594             :                                        Variable* iterator,
     595             :                                        Expression* completion,
     596             :                                        IteratorType type);
     597             :   Statement* CheckCallable(Variable* var, Expression* error, int pos);
     598             : 
     599             :   V8_INLINE void RewriteAsyncFunctionBody(ZoneList<Statement*>* body,
     600             :                                           Block* block,
     601             :                                           Expression* return_value, bool* ok);
     602             : 
     603             :   void AddArrowFunctionFormalParameters(ParserFormalParameters* parameters,
     604             :                                         Expression* params, int end_pos,
     605             :                                         bool* ok);
     606             :   void SetFunctionName(Expression* value, const AstRawString* name,
     607             :                        const AstRawString* prefix = nullptr);
     608             : 
     609             :   // Helper functions for recursive descent.
     610             :   V8_INLINE bool IsEval(const AstRawString* identifier) const {
     611    55164963 :     return identifier == ast_value_factory()->eval_string();
     612             :   }
     613             : 
     614             :   V8_INLINE bool IsArguments(const AstRawString* identifier) const {
     615    52044267 :     return identifier == ast_value_factory()->arguments_string();
     616             :   }
     617             : 
     618             :   V8_INLINE bool IsEvalOrArguments(const AstRawString* identifier) const {
     619   104233914 :     return IsEval(identifier) || IsArguments(identifier);
     620             :   }
     621             : 
     622             :   // Returns true if the expression is of type "this.foo".
     623             :   V8_INLINE static bool IsThisProperty(Expression* expression) {
     624             :     DCHECK_NOT_NULL(expression);
     625     6693786 :     Property* property = expression->AsProperty();
     626    16184154 :     return property != nullptr && property->obj()->IsVariableProxy() &&
     627     5574554 :            property->obj()->AsVariableProxy()->is_this();
     628             :   }
     629             : 
     630             :   // This returns true if the expression is an indentifier (wrapped
     631             :   // inside a variable proxy).  We exclude the case of 'this', which
     632             :   // has been converted to a variable proxy.
     633             :   V8_INLINE static bool IsIdentifier(Expression* expression) {
     634             :     DCHECK_NOT_NULL(expression);
     635   131551087 :     VariableProxy* operand = expression->AsVariableProxy();
     636   176343890 :     return operand != nullptr && !operand->is_this() &&
     637    42849246 :            !operand->is_new_target();
     638             :   }
     639             : 
     640             :   V8_INLINE static const AstRawString* AsIdentifier(Expression* expression) {
     641             :     DCHECK(IsIdentifier(expression));
     642    19349510 :     return expression->AsVariableProxy()->raw_name();
     643             :   }
     644             : 
     645             :   V8_INLINE VariableProxy* AsIdentifierExpression(Expression* expression) {
     646       18095 :     return expression->AsVariableProxy();
     647             :   }
     648             : 
     649             :   V8_INLINE bool IsConstructor(const AstRawString* identifier) const {
     650      446002 :     return identifier == ast_value_factory()->constructor_string();
     651             :   }
     652             : 
     653             :   V8_INLINE bool IsName(const AstRawString* identifier) const {
     654       14907 :     return identifier == ast_value_factory()->name_string();
     655             :   }
     656             : 
     657             :   V8_INLINE static bool IsBoilerplateProperty(
     658             :       ObjectLiteral::Property* property) {
     659     3757418 :     return !property->IsPrototype();
     660             :   }
     661             : 
     662             :   V8_INLINE bool IsNative(Expression* expr) const {
     663             :     DCHECK_NOT_NULL(expr);
     664        5049 :     return expr->IsVariableProxy() &&
     665        1683 :            expr->AsVariableProxy()->raw_name() ==
     666        1683 :                ast_value_factory()->native_string();
     667             :   }
     668             : 
     669             :   V8_INLINE static bool IsArrayIndex(const AstRawString* string,
     670             :                                      uint32_t* index) {
     671     1742601 :     return string->AsArrayIndex(index);
     672             :   }
     673             : 
     674             :   V8_INLINE bool IsUseStrictDirective(Statement* statement) const {
     675     1500810 :     return IsStringLiteral(statement, ast_value_factory()->use_strict_string());
     676             :   }
     677             : 
     678             :   V8_INLINE bool IsUseAsmDirective(Statement* statement) const {
     679     1267077 :     return IsStringLiteral(statement, ast_value_factory()->use_asm_string());
     680             :   }
     681             : 
     682             :   // Returns true if the statement is an expression statement containing
     683             :   // a single string literal.  If a second argument is given, the literal
     684             :   // is also compared with it and the result is true only if they are equal.
     685             :   V8_INLINE bool IsStringLiteral(Statement* statement,
     686             :                                  const AstRawString* arg = nullptr) const {
     687     8058916 :     ExpressionStatement* e_stat = statement->AsExpressionStatement();
     688     4029458 :     if (e_stat == nullptr) return false;
     689    10798193 :     Literal* literal = e_stat->expression()->AsLiteral();
     690     8041750 :     if (literal == nullptr || !literal->raw_value()->IsString()) return false;
     691     5512886 :     return arg == nullptr || literal->raw_value()->AsString() == arg;
     692             :   }
     693             : 
     694             :   V8_INLINE void GetDefaultStrings(
     695             :       const AstRawString** default_string,
     696             :       const AstRawString** star_default_star_string) {
     697          70 :     *default_string = ast_value_factory()->default_string();
     698          70 :     *star_default_star_string = ast_value_factory()->star_default_star_string();
     699             :   }
     700             : 
     701             :   // Functions for encapsulating the differences between parsing and preparsing;
     702             :   // operations interleaved with the recursive descent.
     703             :   V8_INLINE void PushLiteralName(const AstRawString* id) {
     704             :     DCHECK_NOT_NULL(fni_);
     705    14768606 :     fni_->PushLiteralName(id);
     706             :   }
     707             : 
     708             :   V8_INLINE void PushVariableName(const AstRawString* id) {
     709             :     DCHECK_NOT_NULL(fni_);
     710     9119901 :     fni_->PushVariableName(id);
     711             :   }
     712             : 
     713             :   V8_INLINE void PushPropertyName(Expression* expression) {
     714             :     DCHECK_NOT_NULL(fni_);
     715     2672514 :     if (expression->IsPropertyName()) {
     716       41408 :       fni_->PushLiteralName(expression->AsLiteral()->AsRawPropertyName());
     717             :     } else {
     718     2651810 :       fni_->PushLiteralName(ast_value_factory()->anonymous_function_string());
     719             :     }
     720             :   }
     721             : 
     722             :   V8_INLINE void PushEnclosingName(const AstRawString* name) {
     723             :     DCHECK_NOT_NULL(fni_);
     724     1281303 :     fni_->PushEnclosingName(name);
     725             :   }
     726             : 
     727             :   V8_INLINE void AddFunctionForNameInference(FunctionLiteral* func_to_infer) {
     728             :     DCHECK_NOT_NULL(fni_);
     729      702602 :     fni_->AddFunction(func_to_infer);
     730             :   }
     731             : 
     732             :   V8_INLINE void InferFunctionName() {
     733             :     DCHECK_NOT_NULL(fni_);
     734      472919 :     fni_->Infer();
     735             :   }
     736             : 
     737             :   // If we assign a function literal to a property we pretenure the
     738             :   // literal so it can be added as a constant function property.
     739             :   V8_INLINE static void CheckAssigningFunctionLiteralToProperty(
     740             :       Expression* left, Expression* right) {
     741             :     DCHECK_NOT_NULL(left);
     742     9824132 :     if (left->IsProperty() && right->IsFunctionLiteral()) {
     743     2464498 :       right->AsFunctionLiteral()->set_pretenure();
     744             :     }
     745             :   }
     746             : 
     747             :   // Determine if the expression is a variable proxy and mark it as being used
     748             :   // in an assignment or with a increment/decrement operator.
     749             :   V8_INLINE static void MarkExpressionAsAssigned(Expression* expression) {
     750             :     DCHECK_NOT_NULL(expression);
     751    13198394 :     if (expression->IsVariableProxy()) {
     752     2601983 :       expression->AsVariableProxy()->set_is_assigned();
     753             :     }
     754             :   }
     755             : 
     756             :   // Returns true if we have a binary expression between two numeric
     757             :   // literals. In that case, *x will be changed to an expression which is the
     758             :   // computed value.
     759             :   bool ShortcutNumericLiteralBinaryExpression(Expression** x, Expression* y,
     760             :                                               Token::Value op, int pos);
     761             : 
     762             :   // Rewrites the following types of unary expressions:
     763             :   // not <literal> -> true / false
     764             :   // + <numeric literal> -> <numeric literal>
     765             :   // - <numeric literal> -> <numeric literal with value negated>
     766             :   // ! <literal> -> true / false
     767             :   // The following rewriting rules enable the collection of type feedback
     768             :   // without any special stub and the multiplication is removed later in
     769             :   // Crankshaft's canonicalization pass.
     770             :   // + foo -> foo * 1
     771             :   // - foo -> foo * (-1)
     772             :   // ~ foo -> foo ^(~0)
     773             :   Expression* BuildUnaryExpression(Expression* expression, Token::Value op,
     774             :                                    int pos);
     775             : 
     776             :   // Generate AST node that throws a ReferenceError with the given type.
     777             :   V8_INLINE Expression* NewThrowReferenceError(
     778             :       MessageTemplate::Template message, int pos) {
     779             :     return NewThrowError(Runtime::kNewReferenceError, message,
     780        1235 :                          ast_value_factory()->empty_string(), pos);
     781             :   }
     782             : 
     783             :   // Generate AST node that throws a SyntaxError with the given
     784             :   // type. The first argument may be null (in the handle sense) in
     785             :   // which case no arguments are passed to the constructor.
     786             :   V8_INLINE Expression* NewThrowSyntaxError(MessageTemplate::Template message,
     787             :                                             const AstRawString* arg, int pos) {
     788             :     return NewThrowError(Runtime::kNewSyntaxError, message, arg, pos);
     789             :   }
     790             : 
     791             :   // Generate AST node that throws a TypeError with the given
     792             :   // type. Both arguments must be non-null (in the handle sense).
     793             :   V8_INLINE Expression* NewThrowTypeError(MessageTemplate::Template message,
     794             :                                           const AstRawString* arg, int pos) {
     795      267775 :     return NewThrowError(Runtime::kNewTypeError, message, arg, pos);
     796             :   }
     797             : 
     798             :   // Reporting errors.
     799             :   V8_INLINE void ReportMessageAt(Scanner::Location source_location,
     800             :                                  MessageTemplate::Template message,
     801             :                                  const char* arg = nullptr,
     802             :                                  ParseErrorType error_type = kSyntaxError) {
     803      200078 :     if (stack_overflow()) {
     804             :       // Suppress the error message (syntax error or such) in the presence of a
     805             :       // stack overflow. The isolate allows only one pending exception at at
     806             :       // time
     807             :       // and we want to report the stack overflow later.
     808             :       return;
     809             :     }
     810             :     pending_error_handler_.ReportMessageAt(source_location.beg_pos,
     811             :                                            source_location.end_pos, message,
     812      195771 :                                            arg, error_type);
     813             :   }
     814             : 
     815             :   V8_INLINE void ReportMessageAt(Scanner::Location source_location,
     816             :                                  MessageTemplate::Template message,
     817             :                                  const AstRawString* arg,
     818             :                                  ParseErrorType error_type = kSyntaxError) {
     819       76217 :     if (stack_overflow()) {
     820             :       // Suppress the error message (syntax error or such) in the presence of a
     821             :       // stack overflow. The isolate allows only one pending exception at at
     822             :       // time
     823             :       // and we want to report the stack overflow later.
     824             :       return;
     825             :     }
     826             :     pending_error_handler_.ReportMessageAt(source_location.beg_pos,
     827             :                                            source_location.end_pos, message,
     828       76217 :                                            arg, error_type);
     829             :   }
     830             : 
     831             :   // "null" return type creators.
     832             :   V8_INLINE static std::nullptr_t NullIdentifier() { return nullptr; }
     833             :   V8_INLINE static std::nullptr_t NullExpression() { return nullptr; }
     834             :   V8_INLINE static std::nullptr_t NullLiteralProperty() { return nullptr; }
     835             :   V8_INLINE static ZoneList<Expression*>* NullExpressionList() {
     836             :     return nullptr;
     837             :   }
     838             :   V8_INLINE static ZoneList<Statement*>* NullStatementList() { return nullptr; }
     839             :   V8_INLINE static std::nullptr_t NullStatement() { return nullptr; }
     840             : 
     841             :   template <typename T>
     842             :   V8_INLINE static bool IsNull(T subject) {
     843      126460 :     return subject == nullptr;
     844             :   }
     845             : 
     846             :   // Non-null empty string.
     847             :   V8_INLINE const AstRawString* EmptyIdentifierString() const {
     848      597699 :     return ast_value_factory()->empty_string();
     849             :   }
     850             : 
     851             :   // Producing data during the recursive descent.
     852             :   V8_INLINE const AstRawString* GetSymbol() const {
     853    63600392 :     const AstRawString* result = scanner()->CurrentSymbol(ast_value_factory());
     854             :     DCHECK_NOT_NULL(result);
     855             :     return result;
     856             :   }
     857             : 
     858             :   V8_INLINE const AstRawString* GetNextSymbol() const {
     859       62607 :     return scanner()->NextSymbol(ast_value_factory());
     860             :   }
     861             : 
     862             :   V8_INLINE const AstRawString* GetNumberAsSymbol() const {
     863     1581447 :     double double_value = scanner()->DoubleValue();
     864             :     char array[100];
     865     1581447 :     const char* string = DoubleToCString(double_value, ArrayVector(array));
     866     1581447 :     return ast_value_factory()->GetOneByteString(string);
     867             :   }
     868             : 
     869             :   V8_INLINE Expression* ThisExpression(int pos = kNoSourcePosition) {
     870             :     return NewUnresolved(ast_value_factory()->this_string(), pos,
     871     2726709 :                          THIS_VARIABLE);
     872             :   }
     873             : 
     874             :   Expression* NewSuperPropertyReference(int pos);
     875             :   Expression* NewSuperCallReference(int pos);
     876             :   Expression* NewTargetExpression(int pos);
     877             :   Expression* FunctionSentExpression(int pos);
     878             :   Expression* ImportMetaExpression(int pos);
     879             : 
     880             :   Literal* ExpressionFromLiteral(Token::Value token, int pos);
     881             : 
     882             :   V8_INLINE Expression* ExpressionFromIdentifier(
     883             :       const AstRawString* name, int start_position,
     884             :       InferName infer = InferName::kYes) {
     885             :     if (infer == InferName::kYes) {
     886    41686009 :       fni_->PushVariableName(name);
     887             :     }
     888    41686577 :     return NewUnresolved(name, start_position);
     889             :   }
     890             : 
     891             :   V8_INLINE Expression* ExpressionFromString(int pos) {
     892             :     const AstRawString* symbol = GetSymbol();
     893     5523576 :     fni_->PushLiteralName(symbol);
     894     5523576 :     return factory()->NewStringLiteral(symbol, pos);
     895             :   }
     896             : 
     897             :   V8_INLINE ZoneList<Expression*>* NewExpressionList(int size) const {
     898     7977929 :     return new (zone()) ZoneList<Expression*>(size, zone());
     899             :   }
     900             :   V8_INLINE ZoneList<ObjectLiteral::Property*>* NewObjectPropertyList(
     901             :       int size) const {
     902      794895 :     return new (zone()) ZoneList<ObjectLiteral::Property*>(size, zone());
     903             :   }
     904             :   V8_INLINE ZoneList<ClassLiteral::Property*>* NewClassPropertyList(
     905             :       int size) const {
     906      125580 :     return new (zone()) ZoneList<ClassLiteral::Property*>(size, zone());
     907             :   }
     908             :   V8_INLINE ZoneList<Statement*>* NewStatementList(int size) const {
     909      690676 :     return new (zone()) ZoneList<Statement*>(size, zone());
     910             :   }
     911             : 
     912             :   V8_INLINE Expression* NewV8Intrinsic(const AstRawString* name,
     913             :                                        ZoneList<Expression*>* args, int pos,
     914             :                                        bool* ok);
     915             : 
     916             :   V8_INLINE Statement* NewThrowStatement(Expression* exception, int pos) {
     917             :     return factory()->NewExpressionStatement(
     918      138724 :         factory()->NewThrow(exception, pos), pos);
     919             :   }
     920             : 
     921             :   V8_INLINE void AddParameterInitializationBlock(
     922             :       const ParserFormalParameters& parameters, ZoneList<Statement*>* body,
     923             :       bool is_async, bool* ok) {
     924      314220 :     if (parameters.is_simple) return;
     925        2102 :     auto* init_block = BuildParameterInitializationBlock(parameters, ok);
     926        2102 :     if (!*ok) return;
     927        2042 :     if (is_async) {
     928         140 :       init_block = BuildRejectPromiseOnException(init_block);
     929             :     }
     930        2042 :     body->Add(init_block, zone());
     931             :   }
     932             : 
     933             :   V8_INLINE void AddFormalParameter(ParserFormalParameters* parameters,
     934             :                                     Expression* pattern,
     935             :                                     Expression* initializer,
     936             :                                     int initializer_end_position,
     937             :                                     bool is_rest) {
     938     5239476 :     parameters->UpdateArityAndFunctionLength(initializer != nullptr, is_rest);
     939     5461876 :     bool has_simple_name = pattern->IsVariableProxy() && initializer == nullptr;
     940             :     const AstRawString* name = has_simple_name
     941             :                                    ? pattern->AsVariableProxy()->raw_name()
     942    10443955 :                                    : ast_value_factory()->empty_string();
     943     5239476 :     auto parameter = new (parameters->scope->zone())
     944             :         ParserFormalParameters::Parameter(name, pattern, initializer,
     945     5239474 :                                           scanner()->location().beg_pos,
     946    10478951 :                                           initializer_end_position, is_rest);
     947             : 
     948     5239474 :     parameters->params.Add(parameter);
     949             :   }
     950             : 
     951             :   V8_INLINE void DeclareFormalParameters(
     952             :       DeclarationScope* scope,
     953             :       const ThreadedList<ParserFormalParameters::Parameter>& parameters,
     954             :       bool is_simple, bool* has_duplicate = nullptr) {
     955     3301379 :     if (!is_simple) scope->SetHasNonSimpleParameters();
     956     7877304 :     for (auto parameter : parameters) {
     957     4575927 :       bool is_optional = parameter->initializer != nullptr;
     958             :       // If the parameter list is simple, declare the parameters normally with
     959             :       // their names. If the parameter list is not simple, declare a temporary
     960             :       // for each parameter - the corresponding named variable is declared by
     961             :       // BuildParamerterInitializationBlock.
     962             :       scope->DeclareParameter(
     963       61784 :           is_simple ? parameter->name : ast_value_factory()->empty_string(),
     964             :           is_simple ? VAR : TEMPORARY, is_optional, parameter->is_rest,
     965     4637711 :           has_duplicate, ast_value_factory(), parameter->position);
     966             :     }
     967             :   }
     968             : 
     969             :   void DeclareArrowFunctionFormalParameters(ParserFormalParameters* parameters,
     970             :                                             Expression* params,
     971             :                                             const Scanner::Location& params_loc,
     972             :                                             Scanner::Location* duplicate_loc,
     973             :                                             bool* ok);
     974             : 
     975             :   Expression* ExpressionListToExpression(ZoneList<Expression*>* args);
     976             : 
     977             :   void SetFunctionNameFromPropertyName(LiteralProperty* property,
     978             :                                        const AstRawString* name,
     979             :                                        const AstRawString* prefix = nullptr);
     980             :   void SetFunctionNameFromPropertyName(ObjectLiteralProperty* property,
     981             :                                        const AstRawString* name,
     982             :                                        const AstRawString* prefix = nullptr);
     983             : 
     984             :   void SetFunctionNameFromIdentifierRef(Expression* value,
     985             :                                         Expression* identifier);
     986             : 
     987             :   V8_INLINE ZoneList<typename ExpressionClassifier::Error>*
     988             :   GetReportedErrorList() const {
     989   128017255 :     return function_state_->GetReportedErrorList();
     990             :   }
     991             : 
     992             :   V8_INLINE ZoneList<Expression*>* GetNonPatternList() const {
     993   128017236 :     return function_state_->non_patterns_to_rewrite();
     994             :   }
     995             : 
     996             :   V8_INLINE void CountUsage(v8::Isolate::UseCounterFeature feature) {
     997        1873 :     ++use_counts_[feature];
     998             :   }
     999             : 
    1000             :   // Returns true iff we're parsing the first function literal during
    1001             :   // CreateDynamicFunction().
    1002             :   V8_INLINE bool ParsingDynamicFunctionDeclaration() const {
    1003             :     return parameters_end_pos_ != kNoSourcePosition;
    1004             :   }
    1005             : 
    1006             :   V8_INLINE void RecordBlockSourceRange(Block* node,
    1007             :                                         int32_t continuation_position) {
    1008     2461345 :     if (source_range_map_ == nullptr) return;
    1009             :     source_range_map_->Insert(
    1010         612 :         node, new (zone()) BlockSourceRanges(continuation_position));
    1011             :   }
    1012             : 
    1013             :   V8_INLINE void RecordCaseClauseSourceRange(CaseClause* node,
    1014             :                                              const SourceRange& body_range) {
    1015      109361 :     if (source_range_map_ == nullptr) return;
    1016             :     source_range_map_->Insert(node,
    1017          36 :                               new (zone()) CaseClauseSourceRanges(body_range));
    1018             :   }
    1019             : 
    1020             :   V8_INLINE void RecordConditionalSourceRange(Expression* node,
    1021             :                                               const SourceRange& then_range,
    1022             :                                               const SourceRange& else_range) {
    1023      113136 :     if (source_range_map_ == nullptr) return;
    1024             :     source_range_map_->Insert(
    1025             :         node->AsConditional(),
    1026         176 :         new (zone()) ConditionalSourceRanges(then_range, else_range));
    1027             :   }
    1028             : 
    1029             :   V8_INLINE void RecordJumpStatementSourceRange(Statement* node,
    1030             :                                                 int32_t continuation_position) {
    1031     2749220 :     if (source_range_map_ == nullptr) return;
    1032             :     source_range_map_->Insert(
    1033             :         static_cast<JumpStatement*>(node),
    1034         615 :         new (zone()) JumpStatementSourceRanges(continuation_position));
    1035             :   }
    1036             : 
    1037             :   V8_INLINE void RecordIfStatementSourceRange(Statement* node,
    1038             :                                               const SourceRange& then_range,
    1039             :                                               const SourceRange& else_range) {
    1040     1815125 :     if (source_range_map_ == nullptr) return;
    1041             :     source_range_map_->Insert(
    1042             :         node->AsIfStatement(),
    1043         854 :         new (zone()) IfStatementSourceRanges(then_range, else_range));
    1044             :   }
    1045             : 
    1046             :   V8_INLINE void RecordIterationStatementSourceRange(
    1047             :       IterationStatement* node, const SourceRange& body_range) {
    1048      655855 :     if (source_range_map_ == nullptr) return;
    1049             :     source_range_map_->Insert(
    1050         330 :         node, new (zone()) IterationStatementSourceRanges(body_range));
    1051             :   }
    1052             : 
    1053             :   V8_INLINE void RecordSuspendSourceRange(Expression* node,
    1054             :                                           int32_t continuation_position) {
    1055       35427 :     if (source_range_map_ == nullptr) return;
    1056             :     source_range_map_->Insert(static_cast<Suspend*>(node),
    1057             :                               new (zone())
    1058         174 :                                   SuspendSourceRanges(continuation_position));
    1059             :   }
    1060             : 
    1061             :   V8_INLINE void RecordSwitchStatementSourceRange(
    1062             :       Statement* node, int32_t continuation_position) {
    1063       19690 :     if (source_range_map_ == nullptr) return;
    1064             :     source_range_map_->Insert(
    1065             :         node->AsSwitchStatement(),
    1066          36 :         new (zone()) SwitchStatementSourceRanges(continuation_position));
    1067             :   }
    1068             : 
    1069             :   V8_INLINE void RecordThrowSourceRange(Statement* node,
    1070             :                                         int32_t continuation_position) {
    1071      138724 :     if (source_range_map_ == nullptr) return;
    1072          42 :     ExpressionStatement* expr_stmt = static_cast<ExpressionStatement*>(node);
    1073          42 :     Throw* throw_expr = expr_stmt->expression()->AsThrow();
    1074             :     source_range_map_->Insert(
    1075          42 :         throw_expr, new (zone()) ThrowSourceRanges(continuation_position));
    1076             :   }
    1077             : 
    1078             :   V8_INLINE void RecordTryCatchStatementSourceRange(
    1079             :       TryCatchStatement* node, const SourceRange& body_range) {
    1080       81082 :     if (source_range_map_ == nullptr) return;
    1081             :     source_range_map_->Insert(
    1082          78 :         node, new (zone()) TryCatchStatementSourceRanges(body_range));
    1083             :   }
    1084             : 
    1085             :   V8_INLINE void RecordTryFinallyStatementSourceRange(
    1086             :       TryFinallyStatement* node, const SourceRange& body_range) {
    1087        6918 :     if (source_range_map_ == nullptr) return;
    1088             :     source_range_map_->Insert(
    1089          42 :         node, new (zone()) TryFinallyStatementSourceRanges(body_range));
    1090             :   }
    1091             : 
    1092             :   // Parser's private field members.
    1093             :   friend class DiscardableZoneScope;  // Uses reusable_preparser_.
    1094             :   // FIXME(marja): Make reusable_preparser_ always use its own temp Zone (call
    1095             :   // DeleteAll after each function), so this won't be needed.
    1096             : 
    1097             :   Scanner scanner_;
    1098             :   PreParser* reusable_preparser_;
    1099             :   Mode mode_;
    1100             : 
    1101             :   SourceRangeMap* source_range_map_ = nullptr;
    1102             : 
    1103             :   friend class ParserTarget;
    1104             :   friend class ParserTargetScope;
    1105             :   ParserTarget* target_stack_;  // for break, continue statements
    1106             : 
    1107             :   ScriptCompiler::CompileOptions compile_options_;
    1108             :   ParseData* cached_parse_data_;
    1109             : 
    1110             :   PendingCompilationErrorHandler pending_error_handler_;
    1111             : 
    1112             :   // Other information which will be stored in Parser and moved to Isolate after
    1113             :   // parsing.
    1114             :   int use_counts_[v8::Isolate::kUseCounterFeatureCount];
    1115             :   int total_preparse_skipped_;
    1116             :   bool allow_lazy_;
    1117             :   bool temp_zoned_;
    1118             :   ParserLogger* log_;
    1119             :   ConsumedPreParsedScopeData* consumed_preparsed_scope_data_;
    1120             : 
    1121             :   // If not kNoSourcePosition, indicates that the first function literal
    1122             :   // encountered is a dynamic function, see CreateDynamicFunction(). This field
    1123             :   // indicates the correct position of the ')' that closes the parameter list.
    1124             :   // After that ')' is encountered, this field is reset to kNoSourcePosition.
    1125             :   int parameters_end_pos_;
    1126             : };
    1127             : 
    1128             : // ----------------------------------------------------------------------------
    1129             : // Target is a support class to facilitate manipulation of the
    1130             : // Parser's target_stack_ (the stack of potential 'break' and
    1131             : // 'continue' statement targets). Upon construction, a new target is
    1132             : // added; it is removed upon destruction.
    1133             : 
    1134             : class ParserTarget BASE_EMBEDDED {
    1135             :  public:
    1136             :   ParserTarget(ParserBase<Parser>* parser, BreakableStatement* statement)
    1137             :       : variable_(&parser->impl()->target_stack_),
    1138             :         statement_(statement),
    1139     3268951 :         previous_(parser->impl()->target_stack_) {
    1140     3268951 :     parser->impl()->target_stack_ = this;
    1141             :   }
    1142             : 
    1143     3268952 :   ~ParserTarget() { *variable_ = previous_; }
    1144             : 
    1145             :   ParserTarget* previous() { return previous_; }
    1146             :   BreakableStatement* statement() { return statement_; }
    1147             : 
    1148             :  private:
    1149             :   ParserTarget** variable_;
    1150             :   BreakableStatement* statement_;
    1151             :   ParserTarget* previous_;
    1152             : };
    1153             : 
    1154             : class ParserTargetScope BASE_EMBEDDED {
    1155             :  public:
    1156             :   explicit ParserTargetScope(ParserBase<Parser>* parser)
    1157             :       : variable_(&parser->impl()->target_stack_),
    1158     4883622 :         previous_(parser->impl()->target_stack_) {
    1159     4883622 :     parser->impl()->target_stack_ = nullptr;
    1160             :   }
    1161             : 
    1162     4883623 :   ~ParserTargetScope() { *variable_ = previous_; }
    1163             : 
    1164             :  private:
    1165             :   ParserTarget** variable_;
    1166             :   ParserTarget* previous_;
    1167             : };
    1168             : 
    1169             : }  // namespace internal
    1170             : }  // namespace v8
    1171             : 
    1172             : #endif  // V8_PARSING_PARSER_H_

Generated by: LCOV version 1.10