LCOV - code coverage report
Current view: top level - src/parsing - preparser.h (source / functions) Hit Total Coverage
Test: app.info Lines: 245 246 99.6 %
Date: 2019-01-20 Functions: 46 46 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_PREPARSER_H_
       6             : #define V8_PARSING_PREPARSER_H_
       7             : 
       8             : #include "src/ast/ast.h"
       9             : #include "src/ast/scopes.h"
      10             : #include "src/parsing/parser-base.h"
      11             : #include "src/parsing/preparser-logger.h"
      12             : #include "src/pending-compilation-error-handler.h"
      13             : 
      14             : namespace v8 {
      15             : namespace internal {
      16             : 
      17             : // Whereas the Parser generates AST during the recursive descent,
      18             : // the PreParser doesn't create a tree. Instead, it passes around minimal
      19             : // data objects (PreParserExpression, PreParserIdentifier etc.) which contain
      20             : // just enough data for the upper layer functions. PreParserFactory is
      21             : // responsible for creating these dummy objects. It provides a similar kind of
      22             : // interface as AstNodeFactory, so ParserBase doesn't need to care which one is
      23             : // used.
      24             : 
      25             : class PreparseDataBuilder;
      26             : 
      27             : class PreParserIdentifier {
      28             :  public:
      29     8908203 :   PreParserIdentifier() : type_(kUnknownIdentifier) {}
      30      595220 :   static PreParserIdentifier Default() {
      31      595220 :     return PreParserIdentifier(kUnknownIdentifier);
      32             :   }
      33     2939656 :   static PreParserIdentifier Null() {
      34     2939656 :     return PreParserIdentifier(kNullIdentifier);
      35             :   }
      36             :   static PreParserIdentifier Eval() {
      37             :     return PreParserIdentifier(kEvalIdentifier);
      38             :   }
      39             :   static PreParserIdentifier Arguments() {
      40             :     return PreParserIdentifier(kArgumentsIdentifier);
      41             :   }
      42             :   static PreParserIdentifier Constructor() {
      43             :     return PreParserIdentifier(kConstructorIdentifier);
      44             :   }
      45             :   static PreParserIdentifier Await() {
      46             :     return PreParserIdentifier(kAwaitIdentifier);
      47             :   }
      48             :   static PreParserIdentifier Let() {
      49             :     return PreParserIdentifier(kLetIdentifier);
      50             :   }
      51             :   static PreParserIdentifier Async() {
      52             :     return PreParserIdentifier(kAsyncIdentifier);
      53             :   }
      54             :   static PreParserIdentifier Name() {
      55             :     return PreParserIdentifier(kNameIdentifier);
      56             :   }
      57             :   static PreParserIdentifier PrivateName() {
      58             :     return PreParserIdentifier(kPrivateNameIdentifier);
      59             :   }
      60      547851 :   bool IsNull() const { return type_ == kNullIdentifier; }
      61     3514508 :   bool IsEval() const { return type_ == kEvalIdentifier; }
      62             :   bool IsAsync() const { return type_ == kAsyncIdentifier; }
      63    38442601 :   bool IsArguments() const { return type_ == kArgumentsIdentifier; }
      64     9650710 :   bool IsEvalOrArguments() const {
      65             :     STATIC_ASSERT(kEvalIdentifier + 1 == kArgumentsIdentifier);
      66    19301420 :     return IsInRange(type_, kEvalIdentifier, kArgumentsIdentifier);
      67             :   }
      68       35150 :   bool IsConstructor() const { return type_ == kConstructorIdentifier; }
      69             :   bool IsAwait() const { return type_ == kAwaitIdentifier; }
      70     1997439 :   bool IsLet() const { return type_ == kLetIdentifier; }
      71       43949 :   bool IsName() const { return type_ == kNameIdentifier; }
      72             :   bool IsPrivateName() const { return type_ == kPrivateNameIdentifier; }
      73             : 
      74             :  private:
      75             :   enum Type : uint8_t {
      76             :     kNullIdentifier,
      77             :     kUnknownIdentifier,
      78             :     kEvalIdentifier,
      79             :     kArgumentsIdentifier,
      80             :     kConstructorIdentifier,
      81             :     kAwaitIdentifier,
      82             :     kLetIdentifier,
      83             :     kAsyncIdentifier,
      84             :     kNameIdentifier,
      85             :     kPrivateNameIdentifier
      86             :   };
      87             : 
      88             :   explicit PreParserIdentifier(Type type) : string_(nullptr), type_(type) {}
      89             :   const AstRawString* string_;
      90             : 
      91             :   Type type_;
      92             :   friend class PreParserExpression;
      93             :   friend class PreParser;
      94             :   friend class PreParserFactory;
      95             : };
      96             : 
      97             : class PreParserExpression {
      98             :  public:
      99             :   using VariableZoneThreadedListType =
     100             :       ZoneThreadedList<VariableProxy, VariableProxy::PreParserNext>;
     101             : 
     102    53427583 :   PreParserExpression()
     103    53427583 :       : code_(TypeField::encode(kNull)), variables_(nullptr) {}
     104             : 
     105    18734231 :   static PreParserExpression Null() { return PreParserExpression(); }
     106      607248 :   static PreParserExpression Failure() {
     107      607248 :     return PreParserExpression(TypeField::encode(kFailure));
     108             :   }
     109             : 
     110    12682178 :   static PreParserExpression Default(
     111             :       VariableZoneThreadedListType* variables = nullptr) {
     112    12682178 :     return PreParserExpression(TypeField::encode(kExpression), variables);
     113             :   }
     114             : 
     115             :   static PreParserExpression Spread(const PreParserExpression& expression) {
     116             :     return PreParserExpression(TypeField::encode(kSpreadExpression),
     117             :                                expression.variables_);
     118             :   }
     119             : 
     120    38600143 :   static PreParserExpression FromIdentifier(const PreParserIdentifier& id,
     121             :                                             VariableProxy* variable,
     122             :                                             Zone* zone) {
     123             :     PreParserExpression expression(TypeField::encode(kIdentifierExpression) |
     124    77200286 :                                    IdentifierTypeField::encode(id.type_));
     125    38600143 :     expression.AddVariable(variable, zone);
     126    38598906 :     return expression;
     127             :   }
     128             : 
     129             :   static PreParserExpression BinaryOperation(const PreParserExpression& left,
     130             :                                              Token::Value op,
     131             :                                              const PreParserExpression& right,
     132             :                                              Zone* zone) {
     133             :     return PreParserExpression(TypeField::encode(kExpression));
     134             :   }
     135             : 
     136             :   static PreParserExpression Assignment(
     137             :       VariableZoneThreadedListType* variables) {
     138             :     return PreParserExpression(TypeField::encode(kExpression) |
     139             :                                    ExpressionTypeField::encode(kAssignment),
     140             :                                variables);
     141             :   }
     142             : 
     143        4056 :   static PreParserExpression NewTargetExpression() {
     144        4056 :     return PreParserExpression::Default();
     145             :   }
     146             : 
     147             :   static PreParserExpression ObjectLiteral(
     148             :       VariableZoneThreadedListType* variables) {
     149             :     return PreParserExpression(TypeField::encode(kObjectLiteralExpression),
     150             :                                variables);
     151             :   }
     152             : 
     153             :   static PreParserExpression ArrayLiteral(
     154             :       VariableZoneThreadedListType* variables) {
     155             :     return PreParserExpression(TypeField::encode(kArrayLiteralExpression),
     156             :                                variables);
     157             :   }
     158             : 
     159     5500930 :   static PreParserExpression StringLiteral() {
     160     5500930 :     return PreParserExpression(TypeField::encode(kStringLiteralExpression));
     161             :   }
     162             : 
     163     3033884 :   static PreParserExpression This() {
     164             :     return PreParserExpression(TypeField::encode(kExpression) |
     165     3033884 :                                ExpressionTypeField::encode(kThisExpression));
     166             :   }
     167             : 
     168             :   static PreParserExpression ThisPropertyWithPrivateFieldKey() {
     169             :     return PreParserExpression(TypeField::encode(kExpression) |
     170             :                                ExpressionTypeField::encode(
     171             :                                    kThisPropertyExpressionWithPrivateFieldKey));
     172             :   }
     173             : 
     174             :   static PreParserExpression ThisProperty() {
     175             :     return PreParserExpression(
     176             :         TypeField::encode(kExpression) |
     177             :         ExpressionTypeField::encode(kThisPropertyExpression));
     178             :   }
     179             : 
     180             :   static PreParserExpression Property() {
     181             :     return PreParserExpression(
     182             :         TypeField::encode(kExpression) |
     183             :         ExpressionTypeField::encode(kPropertyExpression));
     184             :   }
     185             : 
     186             :   static PreParserExpression PropertyWithPrivateFieldKey() {
     187             :     return PreParserExpression(
     188             :         TypeField::encode(kExpression) |
     189             :         ExpressionTypeField::encode(kPropertyExpressionWithPrivateFieldKey));
     190             :   }
     191             : 
     192             :   static PreParserExpression Call() {
     193             :     return PreParserExpression(TypeField::encode(kExpression) |
     194             :                                ExpressionTypeField::encode(kCallExpression));
     195             :   }
     196             : 
     197             :   static PreParserExpression CallEval() {
     198             :     return PreParserExpression(
     199             :         TypeField::encode(kExpression) |
     200             :         ExpressionTypeField::encode(kCallEvalExpression));
     201             :   }
     202             : 
     203             :   static PreParserExpression CallTaggedTemplate() {
     204             :     return PreParserExpression(
     205             :         TypeField::encode(kExpression) |
     206             :         ExpressionTypeField::encode(kCallTaggedTemplateExpression));
     207             :   }
     208             : 
     209             :   bool is_tagged_template() const {
     210             :     DCHECK(IsCall());
     211             :     return ExpressionTypeField::decode(code_) == kCallTaggedTemplateExpression;
     212             :   }
     213             : 
     214        3060 :   static PreParserExpression SuperCallReference() {
     215             :     return PreParserExpression(
     216             :         TypeField::encode(kExpression) |
     217        3060 :         ExpressionTypeField::encode(kSuperCallReference));
     218             :   }
     219             : 
     220    17211344 :   bool IsNull() const { return TypeField::decode(code_) == kNull; }
     221             :   bool IsFailureExpression() const {
     222             :     return TypeField::decode(code_) == kFailure;
     223             :   }
     224             : 
     225    59971455 :   bool IsIdentifier() const {
     226   119942910 :     return TypeField::decode(code_) == kIdentifierExpression;
     227             :   }
     228             : 
     229    12555604 :   PreParserIdentifier AsIdentifier() const {
     230             :     DCHECK(IsIdentifier());
     231    25111208 :     return PreParserIdentifier(IdentifierTypeField::decode(code_));
     232             :   }
     233             : 
     234             :   bool IsAssignment() const {
     235    37743047 :     return TypeField::decode(code_) == kExpression &&
     236             :            ExpressionTypeField::decode(code_) == kAssignment;
     237             :   }
     238             : 
     239             :   bool IsObjectLiteral() const {
     240             :     return TypeField::decode(code_) == kObjectLiteralExpression;
     241             :   }
     242             : 
     243             :   bool IsArrayLiteral() const {
     244             :     return TypeField::decode(code_) == kArrayLiteralExpression;
     245             :   }
     246             : 
     247             :   bool IsPattern() const {
     248             :     STATIC_ASSERT(kObjectLiteralExpression + 1 == kArrayLiteralExpression);
     249             :     return IsInRange(TypeField::decode(code_), kObjectLiteralExpression,
     250             :                      kArrayLiteralExpression);
     251             :   }
     252             : 
     253             :   bool IsStringLiteral() const {
     254             :     return TypeField::decode(code_) == kStringLiteralExpression;
     255             :   }
     256             : 
     257             :   bool IsThis() const {
     258    15291706 :     return TypeField::decode(code_) == kExpression &&
     259             :            ExpressionTypeField::decode(code_) == kThisExpression;
     260             :   }
     261             : 
     262     5572539 :   bool IsThisProperty() const {
     263    15317329 :     return TypeField::decode(code_) == kExpression &&
     264     1823606 :            (ExpressionTypeField::decode(code_) == kThisPropertyExpression ||
     265             :             ExpressionTypeField::decode(code_) ==
     266     5572539 :                 kThisPropertyExpressionWithPrivateFieldKey);
     267             :   }
     268             : 
     269             :   bool IsProperty() const {
     270    12574705 :     return TypeField::decode(code_) == kExpression &&
     271     4005411 :            (ExpressionTypeField::decode(code_) == kPropertyExpression ||
     272     1640853 :             ExpressionTypeField::decode(code_) == kThisPropertyExpression ||
     273             :             ExpressionTypeField::decode(code_) ==
     274     1640807 :                 kPropertyExpressionWithPrivateFieldKey ||
     275             :             ExpressionTypeField::decode(code_) ==
     276             :                 kThisPropertyExpressionWithPrivateFieldKey);
     277             :   }
     278             : 
     279       10501 :   bool IsPropertyWithPrivateFieldKey() const {
     280       29432 :     return TypeField::decode(code_) == kExpression &&
     281             :            (ExpressionTypeField::decode(code_) ==
     282        7230 :                 kPropertyExpressionWithPrivateFieldKey ||
     283             :             ExpressionTypeField::decode(code_) ==
     284       10501 :                 kThisPropertyExpressionWithPrivateFieldKey);
     285             :   }
     286             : 
     287             :   bool IsCall() const {
     288       23234 :     return TypeField::decode(code_) == kExpression &&
     289        8486 :            (ExpressionTypeField::decode(code_) == kCallExpression ||
     290        8486 :             ExpressionTypeField::decode(code_) == kCallEvalExpression ||
     291             :             ExpressionTypeField::decode(code_) ==
     292             :                 kCallTaggedTemplateExpression);
     293             :   }
     294             :   PreParserExpression* AsCall() {
     295        1052 :     if (IsCall()) return this;
     296             :     return nullptr;
     297             :   }
     298             : 
     299             :   bool IsSuperCallReference() const {
     300             :     return TypeField::decode(code_) == kExpression &&
     301             :            ExpressionTypeField::decode(code_) == kSuperCallReference;
     302             :   }
     303             : 
     304             :   bool IsValidReferenceExpression() const {
     305             :     return IsIdentifier() || IsProperty();
     306             :   }
     307             : 
     308             :   // At the moment PreParser doesn't track these expression types.
     309             :   bool IsFunctionLiteral() const { return false; }
     310             :   bool IsCallNew() const { return false; }
     311             : 
     312             :   bool IsSpread() const {
     313             :     return TypeField::decode(code_) == kSpreadExpression;
     314             :   }
     315             : 
     316             :   bool is_parenthesized() const { return IsParenthesizedField::decode(code_); }
     317             : 
     318             :   void mark_parenthesized() {
     319             :     code_ = IsParenthesizedField::update(code_, true);
     320             :   }
     321             : 
     322     4928513 :   void clear_parenthesized() {
     323     9857026 :     code_ = IsParenthesizedField::update(code_, false);
     324     4928513 :   }
     325             : 
     326             :   PreParserExpression AsFunctionLiteral() { return *this; }
     327             : 
     328             :   // Dummy implementation for making expression->somefunc() work in both Parser
     329             :   // and PreParser.
     330             :   PreParserExpression* operator->() { return this; }
     331             : 
     332             :   // More dummy implementations of things PreParser doesn't need to track:
     333             :   void SetShouldEagerCompile() {}
     334             :   void mark_as_iife() {}
     335             : 
     336             :   int position() const { return kNoSourcePosition; }
     337             :   void set_function_token_position(int position) {}
     338             :   void set_scope(Scope* scope) {}
     339             :   void set_suspend_count(int suspend_count) {}
     340             : 
     341             :  private:
     342             :   enum Type {
     343             :     kNull,
     344             :     kFailure,
     345             :     kExpression,
     346             :     kIdentifierExpression,
     347             :     kStringLiteralExpression,
     348             :     kSpreadExpression,
     349             :     kObjectLiteralExpression,
     350             :     kArrayLiteralExpression
     351             :   };
     352             : 
     353             :   enum ExpressionType {
     354             :     kThisExpression,
     355             :     kThisPropertyExpression,
     356             :     kThisPropertyExpressionWithPrivateFieldKey,
     357             :     kPropertyExpression,
     358             :     kPropertyExpressionWithPrivateFieldKey,
     359             :     kCallExpression,
     360             :     kCallEvalExpression,
     361             :     kCallTaggedTemplateExpression,
     362             :     kSuperCallReference,
     363             :     kAssignment
     364             :   };
     365             : 
     366             :   explicit PreParserExpression(
     367             :       uint32_t expression_code,
     368             :       VariableZoneThreadedListType* variables = nullptr)
     369    38600143 :       : code_(expression_code), variables_(variables) {}
     370             : 
     371    38599541 :   void AddVariable(VariableProxy* variable, Zone* zone) {
     372    38599541 :     if (variable == nullptr) {
     373    38597935 :       return;
     374             :     }
     375    38600525 :     if (variables_ == nullptr) {
     376    38598353 :       variables_ = new (zone) VariableZoneThreadedListType();
     377             :     }
     378    38598919 :     variables_->Add(variable);
     379             :   }
     380             : 
     381             :   // The first three bits are for the Type.
     382             :   typedef BitField<Type, 0, 3> TypeField;
     383             : 
     384             :   // The high order bit applies only to nodes which would inherit from the
     385             :   // Expression ASTNode --- This is by necessity, due to the fact that
     386             :   // Expression nodes may be represented as multiple Types, not exclusively
     387             :   // through kExpression.
     388             :   // TODO(caitp, adamk): clean up PreParserExpression bitfields.
     389             :   typedef BitField<bool, TypeField::kNext, 1> IsParenthesizedField;
     390             : 
     391             :   // The rest of the bits are interpreted depending on the value
     392             :   // of the Type field, so they can share the storage.
     393             :   typedef BitField<ExpressionType, IsParenthesizedField::kNext, 4>
     394             :       ExpressionTypeField;
     395             :   typedef BitField<PreParserIdentifier::Type, IsParenthesizedField::kNext, 8>
     396             :       IdentifierTypeField;
     397             :   typedef BitField<bool, IsParenthesizedField::kNext, 1>
     398             :       HasCoverInitializedNameField;
     399             : 
     400             :   uint32_t code_;
     401             :   // If the PreParser is used in the variable tracking mode, PreParserExpression
     402             :   // accumulates variables in that expression.
     403             :   VariableZoneThreadedListType* variables_;
     404             : 
     405             :   friend class PreParser;
     406             :   friend class PreParserFactory;
     407             :   friend class PreParserExpressionList;
     408             : };
     409             : 
     410             : class PreParserStatement;
     411             : class PreParserStatementList {
     412             :  public:
     413             :   PreParserStatementList() : PreParserStatementList(false) {}
     414             :   PreParserStatementList* operator->() { return this; }
     415             :   void Add(const PreParserStatement& element, Zone* zone) {}
     416             :   static PreParserStatementList Null() { return PreParserStatementList(true); }
     417             :   bool IsNull() const { return is_null_; }
     418             : 
     419             :  private:
     420             :   explicit PreParserStatementList(bool is_null) : is_null_(is_null) {}
     421             :   bool is_null_;
     422             : };
     423             : 
     424             : class PreParserScopedStatementList {
     425             :  public:
     426             :   explicit PreParserScopedStatementList(std::vector<void*>* buffer) {}
     427             :   void Rewind() {}
     428             :   void MergeInto(const PreParserScopedStatementList* other) {}
     429             :   void Add(const PreParserStatement& element) {}
     430             :   int length() { return 0; }
     431             : };
     432             : 
     433             : // The pre-parser doesn't need to build lists of expressions, identifiers, or
     434             : // the like. If the PreParser is used in variable tracking mode, it needs to
     435             : // build lists of variables though.
     436             : class PreParserExpressionList {
     437             :   using VariableZoneThreadedListType =
     438             :       ZoneThreadedList<VariableProxy, VariableProxy::PreParserNext>;
     439             : 
     440             :  public:
     441             :   explicit PreParserExpressionList(std::vector<void*>* buffer)
     442    27837943 :       : length_(0), variables_(nullptr) {}
     443             : 
     444             :   int length() const { return length_; }
     445             : 
     446             :   void Add(const PreParserExpression& expression) {
     447    35273578 :     if (expression.variables_ != nullptr) {
     448    10680553 :       if (variables_ == nullptr) {
     449     8178503 :         variables_ = expression.variables_;
     450             :       } else {
     451             :         variables_->Append(std::move(*expression.variables_));
     452             :       }
     453             :     }
     454    32509270 :     ++length_;
     455             :   }
     456             : 
     457             :  private:
     458             :   int length_;
     459             :   VariableZoneThreadedListType* variables_;
     460             : 
     461             :   friend class PreParser;
     462             :   friend class PreParserFactory;
     463             : };
     464             : 
     465             : class PreParserStatement {
     466             :  public:
     467     5441949 :   static PreParserStatement Default() {
     468     5441949 :     return PreParserStatement(kUnknownStatement);
     469             :   }
     470             : 
     471     6899034 :   static PreParserStatement Null() {
     472     6899034 :     return PreParserStatement(kNullStatement);
     473             :   }
     474             : 
     475             :   static PreParserStatement Empty() {
     476             :     return PreParserStatement(kEmptyStatement);
     477             :   }
     478             : 
     479      236322 :   static PreParserStatement Jump() {
     480      236322 :     return PreParserStatement(kJumpStatement);
     481             :   }
     482             : 
     483             :   void InitializeStatements(const PreParserScopedStatementList& statements,
     484             :                             Zone* zone) {}
     485             : 
     486             :   // Creates expression statement from expression.
     487             :   // Preserves being an unparenthesized string literal, possibly
     488             :   // "use strict".
     489             :   static PreParserStatement ExpressionStatement(
     490             :       const PreParserExpression& expression) {
     491     9554400 :     if (expression.IsStringLiteral()) {
     492             :       return PreParserStatement(kStringLiteralExpressionStatement);
     493             :     }
     494             :     return Default();
     495             :   }
     496             : 
     497      206859 :   bool IsStringLiteral() { return code_ == kStringLiteralExpressionStatement; }
     498             : 
     499             :   bool IsJumpStatement() {
     500             :     return code_ == kJumpStatement;
     501             :   }
     502             : 
     503    20334662 :   bool IsNull() { return code_ == kNullStatement; }
     504             : 
     505    13765386 :   bool IsEmptyStatement() {
     506             :     DCHECK(!IsNull());
     507    19417431 :     return code_ == kEmptyStatement;
     508             :   }
     509             : 
     510             :   // Dummy implementation for making statement->somefunc() work in both Parser
     511             :   // and PreParser.
     512    13765389 :   PreParserStatement* operator->() { return this; }
     513             : 
     514             :   PreParserStatementList statements() { return PreParserStatementList(); }
     515             :   PreParserStatementList cases() { return PreParserStatementList(); }
     516             : 
     517             :   void set_scope(Scope* scope) {}
     518             :   void Initialize(const PreParserExpression& cond, PreParserStatement body,
     519             :                   const SourceRange& body_range = {}) {}
     520             :   void Initialize(PreParserStatement init, const PreParserExpression& cond,
     521             :                   PreParserStatement next, PreParserStatement body,
     522             :                   const SourceRange& body_range = {}) {}
     523             :   void Initialize(PreParserExpression each, const PreParserExpression& subject,
     524             :                   PreParserStatement body, const SourceRange& body_range = {}) {
     525             :   }
     526             : 
     527             :  protected:
     528             :   enum Type {
     529             :     kNullStatement,
     530             :     kEmptyStatement,
     531             :     kUnknownStatement,
     532             :     kJumpStatement,
     533             :     kStringLiteralExpressionStatement,
     534             :   };
     535             : 
     536             :   explicit PreParserStatement(Type code) : code_(code) {}
     537             : 
     538             :  private:
     539             :   Type code_;
     540             : };
     541             : 
     542             : // A PreParserBlock extends statement with a place to store the scope.
     543             : // The scope is dropped as the block is returned as a statement.
     544             : class PreParserBlock : public PreParserStatement {
     545             :  public:
     546      277840 :   void set_scope(Scope* scope) { scope_ = scope; }
     547      277842 :   Scope* scope() const { return scope_; }
     548       91706 :   static PreParserBlock Default() {
     549       91706 :     return PreParserBlock(PreParserStatement::kUnknownStatement);
     550             :   }
     551      904441 :   static PreParserBlock Null() {
     552      904441 :     return PreParserBlock(PreParserStatement::kNullStatement);
     553             :   }
     554             :   // Dummy implementation for making block->somefunc() work in both Parser and
     555             :   // PreParser.
     556      555682 :   PreParserBlock* operator->() { return this; }
     557             : 
     558             :  private:
     559             :   explicit PreParserBlock(PreParserStatement::Type type)
     560             :       : PreParserStatement(type), scope_(nullptr) {}
     561             :   Scope* scope_;
     562             : };
     563             : 
     564             : class PreParserFactory {
     565             :  public:
     566             :   explicit PreParserFactory(AstValueFactory* ast_value_factory, Zone* zone)
     567      910367 :       : ast_node_factory_(ast_value_factory, zone), zone_(zone) {}
     568             : 
     569     3051663 :   AstNodeFactory* ast_node_factory() { return &ast_node_factory_; }
     570             : 
     571             :   PreParserExpression NewStringLiteral(const PreParserIdentifier& identifier,
     572             :                                        int pos) {
     573             :     return PreParserExpression::Default();
     574             :   }
     575             :   PreParserExpression NewNumberLiteral(double number,
     576             :                                        int pos) {
     577             :     return PreParserExpression::Default();
     578             :   }
     579             :   PreParserExpression NewUndefinedLiteral(int pos) {
     580             :     return PreParserExpression::Default();
     581             :   }
     582             :   PreParserExpression NewTheHoleLiteral() {
     583             :     return PreParserExpression::Default();
     584             :   }
     585             :   PreParserExpression NewRegExpLiteral(const PreParserIdentifier& js_pattern,
     586             :                                        int js_flags, int pos) {
     587             :     return PreParserExpression::Default();
     588             :   }
     589             :   PreParserExpression NewArrayLiteral(const PreParserExpressionList& values,
     590             :                                       int first_spread_index, int pos) {
     591             :     return PreParserExpression::ArrayLiteral(values.variables_);
     592             :   }
     593             :   PreParserExpression NewClassLiteralProperty(const PreParserExpression& key,
     594             :                                               const PreParserExpression& value,
     595             :                                               ClassLiteralProperty::Kind kind,
     596             :                                               bool is_static,
     597             :                                               bool is_computed_name,
     598             :                                               bool is_private) {
     599             :     return PreParserExpression::Default();
     600             :   }
     601             :   PreParserExpression NewObjectLiteralProperty(const PreParserExpression& key,
     602             :                                                const PreParserExpression& value,
     603             :                                                ObjectLiteralProperty::Kind kind,
     604             :                                                bool is_computed_name) {
     605             :     return PreParserExpression::Default(value.variables_);
     606             :   }
     607             :   PreParserExpression NewObjectLiteralProperty(const PreParserExpression& key,
     608             :                                                const PreParserExpression& value,
     609             :                                                bool is_computed_name) {
     610             :     return PreParserExpression::Default(value.variables_);
     611             :   }
     612             :   PreParserExpression NewObjectLiteral(
     613             :       const PreParserExpressionList& properties, int boilerplate_properties,
     614             :       int pos, bool has_rest_property) {
     615             :     return PreParserExpression::ObjectLiteral(properties.variables_);
     616             :   }
     617             :   PreParserExpression NewVariableProxy(void* variable) {
     618             :     return PreParserExpression::Default();
     619             :   }
     620             : 
     621    22517322 :   PreParserExpression NewProperty(const PreParserExpression& obj,
     622    11258661 :                                   const PreParserExpression& key, int pos) {
     623    13173037 :     if (key.IsIdentifier() && key.AsIdentifier().IsPrivateName()) {
     624        3249 :       if (obj.IsThis()) {
     625             :         return PreParserExpression::ThisPropertyWithPrivateFieldKey();
     626             :       }
     627             :       return PreParserExpression::PropertyWithPrivateFieldKey();
     628             :     }
     629             : 
     630    11255412 :     if (obj.IsThis()) {
     631             :       return PreParserExpression::ThisProperty();
     632             :     }
     633             :     return PreParserExpression::Property();
     634             :   }
     635             :   PreParserExpression NewUnaryOperation(Token::Value op,
     636             :                                         const PreParserExpression& expression,
     637             :                                         int pos) {
     638             :     return PreParserExpression::Default();
     639             :   }
     640             :   PreParserExpression NewBinaryOperation(Token::Value op,
     641             :                                          const PreParserExpression& left,
     642             :                                          const PreParserExpression& right,
     643             :                                          int pos) {
     644             :     return PreParserExpression::BinaryOperation(left, op, right, zone_);
     645             :   }
     646             :   PreParserExpression NewCompareOperation(Token::Value op,
     647             :                                           const PreParserExpression& left,
     648             :                                           const PreParserExpression& right,
     649             :                                           int pos) {
     650             :     return PreParserExpression::Default();
     651             :   }
     652             :   PreParserExpression NewAssignment(Token::Value op,
     653             :                                     const PreParserExpression& left,
     654             :                                     const PreParserExpression& right, int pos) {
     655             :     // Identifiers need to be tracked since this might be a parameter with a
     656             :     // default value inside an arrow function parameter list.
     657             :     return PreParserExpression::Assignment(left.variables_);
     658             :   }
     659             :   PreParserExpression NewYield(const PreParserExpression& expression, int pos,
     660             :                                Suspend::OnAbruptResume on_abrupt_resume) {
     661             :     return PreParserExpression::Default();
     662             :   }
     663             :   PreParserExpression NewAwait(const PreParserExpression& expression, int pos) {
     664             :     return PreParserExpression::Default();
     665             :   }
     666             :   PreParserExpression NewYieldStar(const PreParserExpression& iterable,
     667             :                                    int pos) {
     668             :     return PreParserExpression::Default();
     669             :   }
     670             :   PreParserExpression NewConditional(const PreParserExpression& condition,
     671             :                                      const PreParserExpression& then_expression,
     672             :                                      const PreParserExpression& else_expression,
     673             :                                      int pos) {
     674             :     return PreParserExpression::Default();
     675             :   }
     676      569571 :   PreParserExpression NewCountOperation(Token::Value op, bool is_prefix,
     677             :                                         const PreParserExpression& expression,
     678             :                                         int pos) {
     679      569571 :     return PreParserExpression::Default();
     680             :   }
     681        5291 :   PreParserExpression NewCall(
     682             :       PreParserExpression expression, const PreParserExpressionList& arguments,
     683             :       int pos, Call::PossiblyEval possibly_eval = Call::NOT_EVAL) {
     684     6416252 :     if (possibly_eval == Call::IS_POSSIBLY_EVAL) {
     685             :       DCHECK(expression.IsIdentifier() && expression.AsIdentifier().IsEval());
     686             :       return PreParserExpression::CallEval();
     687             :     }
     688             :     return PreParserExpression::Call();
     689             :   }
     690             :   PreParserExpression NewTaggedTemplate(
     691             :       PreParserExpression expression, const PreParserExpressionList& arguments,
     692             :       int pos) {
     693             :     return PreParserExpression::CallTaggedTemplate();
     694             :   }
     695         140 :   PreParserExpression NewCallNew(const PreParserExpression& expression,
     696             :                                  const PreParserExpressionList& arguments,
     697             :                                  int pos) {
     698         140 :     return PreParserExpression::Default();
     699             :   }
     700             :   PreParserStatement NewReturnStatement(
     701             :       const PreParserExpression& expression, int pos,
     702             :       int continuation_pos = kNoSourcePosition) {
     703             :     return PreParserStatement::Jump();
     704             :   }
     705             :   PreParserStatement NewAsyncReturnStatement(
     706             :       const PreParserExpression& expression, int pos,
     707             :       int continuation_pos = kNoSourcePosition) {
     708             :     return PreParserStatement::Jump();
     709             :   }
     710             :   PreParserExpression NewFunctionLiteral(
     711             :       const PreParserIdentifier& name, Scope* scope,
     712             :       const PreParserScopedStatementList& body, int expected_property_count,
     713             :       int parameter_count, int function_length,
     714             :       FunctionLiteral::ParameterFlag has_duplicate_parameters,
     715             :       FunctionLiteral::FunctionType function_type,
     716             :       FunctionLiteral::EagerCompileHint eager_compile_hint, int position,
     717             :       bool has_braces, int function_literal_id,
     718             :       ProducedPreparseData* produced_preparse_data = nullptr) {
     719             :     DCHECK_NULL(produced_preparse_data);
     720             :     return PreParserExpression::Default();
     721             :   }
     722             : 
     723       27671 :   PreParserExpression NewSpread(const PreParserExpression& expression, int pos,
     724             :                                 int expr_pos) {
     725             :     return PreParserExpression::Spread(expression);
     726             :   }
     727             : 
     728             :   PreParserExpression NewEmptyParentheses(int pos) {
     729             :     PreParserExpression result = PreParserExpression::Default();
     730             :     result.mark_parenthesized();
     731             :     return result;
     732             :   }
     733             : 
     734             :   PreParserStatement EmptyStatement() { return PreParserStatement::Default(); }
     735             : 
     736             :   PreParserBlock NewBlock(int capacity, bool ignore_completion_value) {
     737             :     return PreParserBlock::Default();
     738             :   }
     739             : 
     740             :   PreParserBlock NewBlock(bool ignore_completion_value,
     741             :                           ZonePtrList<const AstRawString>* labels) {
     742             :     return PreParserBlock::Default();
     743             :   }
     744             : 
     745      277836 :   PreParserBlock NewBlock(bool ignore_completion_value,
     746             :                           const PreParserScopedStatementList& list) {
     747      277836 :     return PreParserBlock::Default();
     748             :   }
     749             : 
     750             :   PreParserStatement NewDebuggerStatement(int pos) {
     751             :     return PreParserStatement::Default();
     752             :   }
     753             : 
     754             :   PreParserStatement NewExpressionStatement(const PreParserExpression& expr,
     755             :                                             int pos) {
     756             :     return PreParserStatement::ExpressionStatement(expr);
     757             :   }
     758             : 
     759             :   PreParserStatement NewIfStatement(const PreParserExpression& condition,
     760             :                                     PreParserStatement then_statement,
     761             :                                     PreParserStatement else_statement, int pos,
     762             :                                     SourceRange then_range = {},
     763             :                                     SourceRange else_range = {}) {
     764             :     // This must return a jump statement iff both clauses are jump statements.
     765     2629824 :     return else_statement.IsJumpStatement() ? then_statement : else_statement;
     766             :   }
     767             : 
     768             :   PreParserStatement NewBreakStatement(
     769             :       PreParserStatement target, int pos,
     770             :       int continuation_pos = kNoSourcePosition) {
     771             :     return PreParserStatement::Jump();
     772             :   }
     773             : 
     774             :   PreParserStatement NewContinueStatement(
     775             :       PreParserStatement target, int pos,
     776             :       int continuation_pos = kNoSourcePosition) {
     777             :     return PreParserStatement::Jump();
     778             :   }
     779             : 
     780             :   PreParserStatement NewWithStatement(Scope* scope,
     781             :                                       const PreParserExpression& expression,
     782             :                                       PreParserStatement statement, int pos) {
     783             :     return PreParserStatement::Default();
     784             :   }
     785             : 
     786             :   PreParserStatement NewDoWhileStatement(
     787             :       ZonePtrList<const AstRawString>* labels,
     788             :       ZonePtrList<const AstRawString>* own_labels, int pos) {
     789             :     return PreParserStatement::Default();
     790             :   }
     791             : 
     792             :   PreParserStatement NewWhileStatement(
     793             :       ZonePtrList<const AstRawString>* labels,
     794             :       ZonePtrList<const AstRawString>* own_labels, int pos) {
     795             :     return PreParserStatement::Default();
     796             :   }
     797             : 
     798             :   PreParserStatement NewSwitchStatement(ZonePtrList<const AstRawString>* labels,
     799             :                                         const PreParserExpression& tag,
     800             :                                         int pos) {
     801             :     return PreParserStatement::Default();
     802             :   }
     803             : 
     804             :   PreParserStatement NewCaseClause(
     805             :       const PreParserExpression& label,
     806             :       const PreParserScopedStatementList& statements) {
     807             :     return PreParserStatement::Default();
     808             :   }
     809             : 
     810             :   PreParserStatement NewForStatement(
     811             :       ZonePtrList<const AstRawString>* labels,
     812             :       ZonePtrList<const AstRawString>* own_labels, int pos) {
     813             :     return PreParserStatement::Default();
     814             :   }
     815             : 
     816             :   PreParserStatement NewForEachStatement(
     817             :       ForEachStatement::VisitMode visit_mode,
     818             :       ZonePtrList<const AstRawString>* labels,
     819             :       ZonePtrList<const AstRawString>* own_labels, int pos) {
     820             :     return PreParserStatement::Default();
     821             :   }
     822             : 
     823             :   PreParserStatement NewForOfStatement(
     824             :       ZonePtrList<const AstRawString>* labels,
     825             :       ZonePtrList<const AstRawString>* own_labels, int pos, IteratorType type) {
     826             :     return PreParserStatement::Default();
     827             :   }
     828             : 
     829             :   PreParserExpression NewCallRuntime(
     830             :       Runtime::FunctionId id, ZoneChunkList<PreParserExpression>* arguments,
     831             :       int pos) {
     832             :     return PreParserExpression::Default();
     833             :   }
     834             : 
     835             :   PreParserExpression NewImportCallExpression(const PreParserExpression& args,
     836             :                                               int pos) {
     837             :     return PreParserExpression::Default();
     838             :   }
     839             : 
     840             :  private:
     841             :   // For creating VariableProxy objects to track unresolved variables.
     842             :   AstNodeFactory ast_node_factory_;
     843             :   Zone* zone_;
     844             : };
     845             : 
     846             : class PreParser;
     847             : 
     848             : class PreParserFormalParameters : public FormalParametersBase {
     849             :  public:
     850             :   explicit PreParserFormalParameters(DeclarationScope* scope)
     851     3322336 :       : FormalParametersBase(scope) {}
     852             : 
     853        8621 :   void set_has_duplicate() { has_duplicate_ = true; }
     854             :   bool has_duplicate() { return has_duplicate_; }
     855             :   void ValidateDuplicate(PreParser* preparser) const;
     856             : 
     857             :   void set_strict_parameter_error(const Scanner::Location& loc,
     858             :                                   MessageTemplate message) {
     859      462386 :     strict_parameter_error_ = loc.IsValid();
     860             :   }
     861             :   void ValidateStrictMode(PreParser* preparser) const;
     862             : 
     863             :  private:
     864             :   bool has_duplicate_ = false;
     865             :   bool strict_parameter_error_ = false;
     866             : };
     867             : 
     868             : class PreParserTarget {
     869             :  public:
     870             :   PreParserTarget(ParserBase<PreParser>* preparser,
     871             :                   PreParserStatement statement) {}
     872             : };
     873             : 
     874             : class PreParserTargetScope {
     875             :  public:
     876             :   explicit PreParserTargetScope(ParserBase<PreParser>* preparser) {}
     877             : };
     878             : 
     879             : class PreParserFuncNameInferrer {
     880             :  public:
     881             :   explicit PreParserFuncNameInferrer(AstValueFactory* avf) {}
     882             :   void RemoveAsyncKeywordFromEnd() const {}
     883             :   void Infer() const {}
     884             :   void RemoveLastFunction() const {}
     885             : 
     886             :   class State {
     887             :    public:
     888             :     explicit State(PreParserFuncNameInferrer* fni) {}
     889             : 
     890             :    private:
     891             :     DISALLOW_COPY_AND_ASSIGN(State);
     892             :   };
     893             : 
     894             :  private:
     895             :   DISALLOW_COPY_AND_ASSIGN(PreParserFuncNameInferrer);
     896             : };
     897             : 
     898             : class PreParserSourceRange {
     899             :  public:
     900             :   PreParserSourceRange() {}
     901             :   PreParserSourceRange(int start, int end) {}
     902             :   static PreParserSourceRange Empty() { return PreParserSourceRange(); }
     903             :   static PreParserSourceRange OpenEnded(int32_t start) { return Empty(); }
     904             :   static const PreParserSourceRange& ContinuationOf(
     905             :       const PreParserSourceRange& that, int end) {
     906             :     return that;
     907             :   }
     908             : };
     909             : 
     910             : class PreParserSourceRangeScope {
     911             :  public:
     912             :   PreParserSourceRangeScope(Scanner* scanner, PreParserSourceRange* range) {}
     913             :   const PreParserSourceRange& Finalize() const { return range_; }
     914             : 
     915             :  private:
     916             :   PreParserSourceRange range_;
     917             : 
     918             :   DISALLOW_IMPLICIT_CONSTRUCTORS(PreParserSourceRangeScope);
     919             : };
     920             : 
     921             : class PreParserPropertyList {};
     922             : 
     923             : template <>
     924             : struct ParserTypes<PreParser> {
     925             :   typedef ParserBase<PreParser> Base;
     926             :   typedef PreParser Impl;
     927             : 
     928             :   // Return types for traversing functions.
     929             :   typedef PreParserExpression ClassLiteralProperty;
     930             :   typedef PreParserExpression Expression;
     931             :   typedef PreParserExpression FunctionLiteral;
     932             :   typedef PreParserExpression ObjectLiteralProperty;
     933             :   typedef PreParserExpression Suspend;
     934             :   typedef PreParserExpressionList ExpressionList;
     935             :   typedef PreParserExpressionList ObjectPropertyList;
     936             :   typedef PreParserFormalParameters FormalParameters;
     937             :   typedef PreParserIdentifier Identifier;
     938             :   typedef PreParserPropertyList ClassPropertyList;
     939             :   typedef PreParserScopedStatementList StatementList;
     940             :   typedef PreParserBlock Block;
     941             :   typedef PreParserStatement BreakableStatement;
     942             :   typedef PreParserStatement ForStatement;
     943             :   typedef PreParserStatement IterationStatement;
     944             :   typedef PreParserStatement Statement;
     945             : 
     946             :   // For constructing objects returned by the traversing functions.
     947             :   typedef PreParserFactory Factory;
     948             : 
     949             :   // Other implementation-specific tasks.
     950             :   typedef PreParserFuncNameInferrer FuncNameInferrer;
     951             :   typedef PreParserSourceRange SourceRange;
     952             :   typedef PreParserSourceRangeScope SourceRangeScope;
     953             :   typedef PreParserTarget Target;
     954             :   typedef PreParserTargetScope TargetScope;
     955             : };
     956             : 
     957             : 
     958             : // Preparsing checks a JavaScript program and emits preparse-data that helps
     959             : // a later parsing to be faster.
     960             : // See preparse-data-format.h for the data format.
     961             : 
     962             : // The PreParser checks that the syntax follows the grammar for JavaScript,
     963             : // and collects some information about the program along the way.
     964             : // The grammar check is only performed in order to understand the program
     965             : // sufficiently to deduce some information about it, that can be used
     966             : // to speed up later parsing. Finding errors is not the goal of pre-parsing,
     967             : // rather it is to speed up properly written and correct programs.
     968             : // That means that contextual checks (like a label being declared where
     969             : // it is used) are generally omitted.
     970      910535 : class PreParser : public ParserBase<PreParser> {
     971             :   friend class ParserBase<PreParser>;
     972             : 
     973             :  public:
     974             :   typedef PreParserIdentifier Identifier;
     975             :   typedef PreParserExpression Expression;
     976             :   typedef PreParserStatement Statement;
     977             : 
     978             :   enum PreParseResult {
     979             :     kPreParseStackOverflow,
     980             :     kPreParseNotIdentifiableError,
     981             :     kPreParseSuccess
     982             :   };
     983             : 
     984             :   PreParser(Zone* zone, Scanner* scanner, uintptr_t stack_limit,
     985             :             AstValueFactory* ast_value_factory,
     986             :             PendingCompilationErrorHandler* pending_error_handler,
     987             :             RuntimeCallStats* runtime_call_stats, Logger* logger,
     988             :             int script_id = -1, bool parsing_module = false,
     989             :             bool parsing_on_main_thread = true)
     990             :       : ParserBase<PreParser>(zone, scanner, stack_limit, nullptr,
     991             :                               ast_value_factory, pending_error_handler,
     992             :                               runtime_call_stats, logger, script_id,
     993             :                               parsing_module, parsing_on_main_thread),
     994             :         use_counts_(nullptr),
     995     1821038 :         preparse_data_builder_(nullptr) {}
     996             : 
     997             :   static bool IsPreParser() { return true; }
     998             : 
     999             :   PreParserLogger* logger() { return &log_; }
    1000             : 
    1001             :   // Pre-parse the program from the character stream; returns true on
    1002             :   // success (even if parsing failed, the pre-parse data successfully
    1003             :   // captured the syntax error), and false if a stack-overflow happened
    1004             :   // during parsing.
    1005             :   PreParseResult PreParseProgram();
    1006             : 
    1007             :   // Parses a single function literal, from the opening parentheses before
    1008             :   // parameters to the closing brace after the body.
    1009             :   // Returns a FunctionEntry describing the body of the function in enough
    1010             :   // detail that it can be lazily compiled.
    1011             :   // The scanner is expected to have matched the "function" or "function*"
    1012             :   // keyword and parameters, and have consumed the initial '{'.
    1013             :   // At return, unless an error occurred, the scanner is positioned before the
    1014             :   // the final '}'.
    1015             :   PreParseResult PreParseFunction(
    1016             :       const AstRawString* function_name, FunctionKind kind,
    1017             :       FunctionLiteral::FunctionType function_type,
    1018             :       DeclarationScope* function_scope, int* use_counts,
    1019             :       ProducedPreparseData** produced_preparser_scope_data, int script_id);
    1020             : 
    1021             :   PreparseDataBuilder* preparse_data_builder() const {
    1022             :     return preparse_data_builder_;
    1023             :   }
    1024             : 
    1025             :   void set_preparse_data_builder(PreparseDataBuilder* preparse_data_builder) {
    1026     5134514 :     preparse_data_builder_ = preparse_data_builder;
    1027             :   }
    1028             : 
    1029             :  private:
    1030             :   friend class i::ExpressionScope<ParserTypes<PreParser>>;
    1031             :   friend class PreParserFormalParameters;
    1032             :   // These types form an algebra over syntactic categories that is just
    1033             :   // rich enough to let us recognize and propagate the constructs that
    1034             :   // are either being counted in the preparser data, or is important
    1035             :   // to throw the correct syntax error exceptions.
    1036             : 
    1037             :   // All ParseXXX functions take as the last argument an *ok parameter
    1038             :   // which is set to false if parsing failed; it is unchanged otherwise.
    1039             :   // By making the 'exception handling' explicit, we are forced to check
    1040             :   // for failure at the call sites.
    1041             : 
    1042             :   // Indicates that we won't switch from the preparser to the preparser; we'll
    1043             :   // just stay where we are.
    1044             :   bool AllowsLazyParsingWithoutUnresolvedVariables() const { return false; }
    1045             :   bool parse_lazily() const { return false; }
    1046             : 
    1047     1570371 :   PendingCompilationErrorHandler* pending_error_handler() {
    1048     1570371 :     return pending_error_handler_;
    1049             :   }
    1050             : 
    1051             :   V8_INLINE bool SkipFunction(const AstRawString* name, FunctionKind kind,
    1052             :                               FunctionLiteral::FunctionType function_type,
    1053             :                               DeclarationScope* function_scope,
    1054             :                               int* num_parameters,
    1055             :                               ProducedPreparseData** produced_preparse_data) {
    1056             :     UNREACHABLE();
    1057             :   }
    1058             : 
    1059             :   Expression ParseFunctionLiteral(
    1060             :       Identifier name, Scanner::Location function_name_location,
    1061             :       FunctionNameValidity function_name_validity, FunctionKind kind,
    1062             :       int function_token_pos, FunctionLiteral::FunctionType function_type,
    1063             :       LanguageMode language_mode,
    1064             :       ZonePtrList<const AstRawString>* arguments_for_wrapped_function);
    1065             : 
    1066             :   PreParserExpression InitializeObjectLiteral(PreParserExpression literal) {
    1067             :     return literal;
    1068             :   }
    1069             : 
    1070             :   void ParseStatementListAndLogFunction(PreParserFormalParameters* formals);
    1071             : 
    1072             :   struct TemplateLiteralState {};
    1073             : 
    1074             :   V8_INLINE TemplateLiteralState OpenTemplateLiteral(int pos) {
    1075             :     return TemplateLiteralState();
    1076             :   }
    1077             :   V8_INLINE void AddTemplateExpression(TemplateLiteralState* state,
    1078             :                                        const PreParserExpression& expression) {}
    1079             :   V8_INLINE void AddTemplateSpan(TemplateLiteralState* state, bool should_cook,
    1080             :                                  bool tail) {}
    1081             :   V8_INLINE PreParserExpression CloseTemplateLiteral(
    1082             :       TemplateLiteralState* state, int start, const PreParserExpression& tag) {
    1083       31398 :     return PreParserExpression::Default();
    1084             :   }
    1085             :   V8_INLINE bool IsPropertyWithPrivateFieldKey(
    1086             :       const PreParserExpression& expression) {
    1087       10501 :     return expression.IsPropertyWithPrivateFieldKey();
    1088             :   }
    1089             :   V8_INLINE void CheckConflictingVarDeclarations(Scope* scope) {}
    1090             : 
    1091             :   V8_INLINE void SetLanguageMode(Scope* scope, LanguageMode mode) {
    1092      512887 :     scope->SetLanguageMode(mode);
    1093             :   }
    1094             :   V8_INLINE void SetAsmModule() {}
    1095             : 
    1096             :   V8_INLINE PreParserExpression SpreadCall(const PreParserExpression& function,
    1097             :                                            const PreParserExpressionList& args,
    1098             :                                            int pos,
    1099             :                                            Call::PossiblyEval possibly_eval);
    1100             :   V8_INLINE PreParserExpression
    1101             :   SpreadCallNew(const PreParserExpression& function,
    1102             :                 const PreParserExpressionList& args, int pos);
    1103             : 
    1104             :   V8_INLINE void PrepareGeneratorVariables() {}
    1105             :   V8_INLINE void RewriteAsyncFunctionBody(
    1106             :       const PreParserScopedStatementList* body, PreParserStatement block,
    1107             :       const PreParserExpression& return_value) {}
    1108             : 
    1109             :   void InitializeVariables(
    1110             :       PreParserScopedStatementList* statements,
    1111             :       const DeclarationDescriptor* declaration_descriptor,
    1112             :       const DeclarationParsingResult::Declaration* declaration,
    1113             :       ZonePtrList<const AstRawString>* names);
    1114             : 
    1115             :   V8_INLINE void DeclareLabel(ZonePtrList<const AstRawString>** labels,
    1116             :                               ZonePtrList<const AstRawString>** own_labels,
    1117             :                               const PreParserExpression& expr) {
    1118             :     DCHECK(!parsing_module_ || !expr.AsIdentifier().IsAwait());
    1119             :     DCHECK(IsIdentifier(expr));
    1120             :   }
    1121             : 
    1122             :   // TODO(nikolaos): The preparser currently does not keep track of labels.
    1123             :   V8_INLINE bool ContainsLabel(ZonePtrList<const AstRawString>* labels,
    1124             :                                const PreParserIdentifier& label) {
    1125             :     return false;
    1126             :   }
    1127             : 
    1128             :   V8_INLINE PreParserExpression
    1129             :   RewriteReturn(const PreParserExpression& return_value, int pos) {
    1130             :     return return_value;
    1131             :   }
    1132             :   V8_INLINE PreParserStatement
    1133             :   RewriteSwitchStatement(PreParserStatement switch_statement, Scope* scope) {
    1134        1370 :     return PreParserStatement::Default();
    1135             :   }
    1136             : 
    1137             :   V8_INLINE PreParserBlock RewriteCatchPattern(CatchInfo* catch_info) {
    1138        2266 :     if (catch_info->pattern.variables_ != nullptr) {
    1139        6529 :       for (auto variable : *catch_info->pattern.variables_) {
    1140        4433 :         scope()->DeclareVariableName(variable->raw_name(), VariableMode::kLet);
    1141             :       }
    1142             :     }
    1143        2266 :     return PreParserBlock::Default();
    1144             :   }
    1145             : 
    1146             :   V8_INLINE void ReportVarRedeclarationIn(const AstRawString* name,
    1147             :                                           Scope* scope) {
    1148             :     ReportUnidentifiableError();
    1149             :   }
    1150             : 
    1151             :   V8_INLINE PreParserStatement RewriteTryStatement(
    1152             :       PreParserStatement try_block, PreParserStatement catch_block,
    1153             :       const SourceRange& catch_range, PreParserStatement finally_block,
    1154             :       const SourceRange& finally_range, const CatchInfo& catch_info, int pos) {
    1155      311772 :     return PreParserStatement::Default();
    1156             :   }
    1157             : 
    1158             :   V8_INLINE void GetUnexpectedTokenMessage(Token::Value token,
    1159             :                                            MessageTemplate* message,
    1160             :                                            Scanner::Location* location,
    1161             :                                            const char** arg) {}
    1162             :   V8_INLINE void ParseAndRewriteGeneratorFunctionBody(
    1163             :       int pos, FunctionKind kind, PreParserScopedStatementList* body) {
    1164       30699 :     ParseStatementList(body, Token::RBRACE);
    1165             :   }
    1166             :   V8_INLINE void ParseAndRewriteAsyncGeneratorFunctionBody(
    1167             :       int pos, FunctionKind kind, PreParserScopedStatementList* body) {
    1168       36677 :     ParseStatementList(body, Token::RBRACE);
    1169             :   }
    1170             :   V8_INLINE void DeclareFunctionNameVar(
    1171             :       const AstRawString* function_name,
    1172             :       FunctionLiteral::FunctionType function_type,
    1173             :       DeclarationScope* function_scope) {
    1174     4055585 :     if (function_type == FunctionLiteral::kNamedExpression &&
    1175      850386 :         function_scope->LookupLocal(function_name) == nullptr) {
    1176             :       DCHECK_EQ(function_scope, scope());
    1177      848554 :       function_scope->DeclareFunctionVar(function_name);
    1178             :     }
    1179             :   }
    1180             : 
    1181             :   V8_INLINE void DeclareFunctionNameVar(
    1182             :       const PreParserIdentifier& function_name,
    1183             :       FunctionLiteral::FunctionType function_type,
    1184             :       DeclarationScope* function_scope) {
    1185             :     DeclareFunctionNameVar(function_name.string_, function_type,
    1186             :                            function_scope);
    1187             :   }
    1188             : 
    1189             :   bool IdentifierEquals(const PreParserIdentifier& identifier,
    1190             :                         const AstRawString* other);
    1191             : 
    1192             :   // TODO(nikolaos): The preparser currently does not keep track of labels
    1193             :   // and targets.
    1194             :   V8_INLINE PreParserStatement
    1195             :   LookupBreakTarget(const PreParserIdentifier& label) {
    1196      151980 :     return PreParserStatement::Default();
    1197             :   }
    1198             :   V8_INLINE PreParserStatement
    1199             :   LookupContinueTarget(const PreParserIdentifier& label) {
    1200       41152 :     return PreParserStatement::Default();
    1201             :   }
    1202             : 
    1203             :   V8_INLINE PreParserStatement
    1204             :   DeclareFunction(const PreParserIdentifier& variable_name,
    1205             :                   const PreParserExpression& function, VariableMode mode,
    1206             :                   int beg_pos, int end_pos, bool is_sloppy_block_function,
    1207             :                   ZonePtrList<const AstRawString>* names) {
    1208             :     DCHECK_NULL(names);
    1209      231219 :     if (variable_name.string_ != nullptr) {
    1210      231588 :       scope()->DeclareVariableName(variable_name.string_, mode);
    1211      229141 :       if (is_sloppy_block_function) {
    1212             :         GetDeclarationScope()->DeclareSloppyBlockFunction(variable_name.string_,
    1213        4900 :                                                           scope());
    1214             :       }
    1215             :     }
    1216      231222 :     return Statement::Default();
    1217             :   }
    1218             : 
    1219             :   V8_INLINE PreParserStatement DeclareClass(
    1220             :       const PreParserIdentifier& variable_name,
    1221             :       const PreParserExpression& value, ZonePtrList<const AstRawString>* names,
    1222             :       int class_token_pos, int end_pos) {
    1223             :     // Preparser shouldn't be used in contexts where we need to track the names.
    1224             :     DCHECK_NULL(names);
    1225       68683 :     if (variable_name.string_ != nullptr) {
    1226       68177 :       scope()->DeclareVariableName(variable_name.string_, VariableMode::kLet);
    1227             :     }
    1228       68683 :     return PreParserStatement::Default();
    1229             :   }
    1230             :   V8_INLINE void DeclareClassVariable(const PreParserIdentifier& name,
    1231             :                                       ClassInfo* class_info,
    1232             :                                       int class_token_pos) {
    1233      126980 :     if (name.string_ != nullptr) {
    1234       68901 :       scope()->DeclareVariableName(name.string_, VariableMode::kConst);
    1235             :     }
    1236             :   }
    1237             :   V8_INLINE void DeclareClassProperty(const PreParserIdentifier& class_name,
    1238             :                                       const PreParserExpression& property,
    1239             :                                       bool is_constructor,
    1240             :                                       ClassInfo* class_info) {}
    1241             : 
    1242             :   V8_INLINE void DeclareClassField(const PreParserExpression& property,
    1243             :                                    const PreParserIdentifier& property_name,
    1244             :                                    bool is_static, bool is_computed_name,
    1245             :                                    bool is_private, ClassInfo* class_info) {
    1246             :     DCHECK_IMPLIES(is_computed_name, !is_private);
    1247       29592 :     if (is_computed_name) {
    1248             :       scope()->DeclareVariableName(
    1249             :           ClassFieldVariableName(ast_value_factory(),
    1250             :                                  class_info->computed_field_count),
    1251        4714 :           VariableMode::kConst);
    1252       24878 :     } else if (is_private && property_name.string_ != nullptr) {
    1253        9275 :       if (scope()->DeclareVariableName(property_name.string_,
    1254        9275 :                                        VariableMode::kConst) == nullptr) {
    1255             :         ReportUnidentifiableError();
    1256             :       }
    1257             :     }
    1258             :   }
    1259             : 
    1260             :   V8_INLINE PreParserExpression
    1261             :   RewriteClassLiteral(Scope* scope, const PreParserIdentifier& name,
    1262             :                       ClassInfo* class_info, int pos, int end_pos) {
    1263       53960 :     bool has_default_constructor = !class_info->has_seen_constructor;
    1264             :     // Account for the default constructor.
    1265       53960 :     if (has_default_constructor) {
    1266             :       // Creating and disposing of a FunctionState makes tracking of
    1267             :       // next_function_is_likely_called match what Parser does. TODO(marja):
    1268             :       // Make the lazy function + next_function_is_likely_called + default ctor
    1269             :       // logic less surprising. Default ctors shouldn't affect the laziness of
    1270             :       // functions.
    1271       52975 :       bool has_extends = class_info->extends.IsNull();
    1272             :       FunctionKind kind = has_extends ? FunctionKind::kDefaultDerivedConstructor
    1273       52975 :                                       : FunctionKind::kDefaultBaseConstructor;
    1274       52975 :       DeclarationScope* function_scope = NewFunctionScope(kind);
    1275             :       SetLanguageMode(function_scope, LanguageMode::kStrict);
    1276       52975 :       function_scope->set_start_position(pos);
    1277       52975 :       function_scope->set_end_position(pos);
    1278       52975 :       FunctionState function_state(&function_state_, &scope_, function_scope);
    1279       52975 :       GetNextFunctionLiteralId();
    1280             :     }
    1281       53960 :     if (class_info->has_static_class_fields) {
    1282        7875 :       GetNextFunctionLiteralId();
    1283             :     }
    1284       53960 :     if (class_info->has_instance_members) {
    1285       17597 :       GetNextFunctionLiteralId();
    1286             :     }
    1287       53960 :     return PreParserExpression::Default();
    1288             :   }
    1289             : 
    1290             :   V8_INLINE PreParserStatement DeclareNative(const PreParserIdentifier& name,
    1291             :                                              int pos) {
    1292             :     return PreParserStatement::Default();
    1293             :   }
    1294             : 
    1295             :   V8_INLINE void QueueDestructuringAssignmentForRewriting(
    1296             :       PreParserExpression assignment) {}
    1297             : 
    1298             :   // Helper functions for recursive descent.
    1299             :   V8_INLINE bool IsEval(const PreParserIdentifier& identifier) const {
    1300     3514495 :     return identifier.IsEval();
    1301             :   }
    1302             : 
    1303             :   V8_INLINE bool IsAsync(const PreParserIdentifier& identifier) const {
    1304             :     return identifier.IsAsync();
    1305             :   }
    1306             : 
    1307             :   V8_INLINE bool IsArguments(const PreParserIdentifier& identifier) const {
    1308    38449916 :     return identifier.IsArguments();
    1309             :   }
    1310             : 
    1311             :   V8_INLINE bool IsEvalOrArguments(
    1312     7777545 :       const PreParserIdentifier& identifier) const {
    1313     9651085 :     return identifier.IsEvalOrArguments();
    1314             :   }
    1315             : 
    1316             :   V8_INLINE bool IsAwait(const PreParserIdentifier& identifier) const {
    1317             :     return identifier.IsAwait();
    1318             :   }
    1319             : 
    1320             :   V8_INLINE bool IsLet(const PreParserIdentifier& identifier) const {
    1321     1997440 :     return identifier.IsLet();
    1322             :   }
    1323             : 
    1324             :   // Returns true if the expression is of type "this.foo".
    1325             :   V8_INLINE static bool IsThisProperty(const PreParserExpression& expression) {
    1326     5572577 :     return expression.IsThisProperty();
    1327             :   }
    1328             : 
    1329     6277626 :   V8_INLINE static bool IsIdentifier(const PreParserExpression& expression) {
    1330    60000041 :     return expression.IsIdentifier();
    1331             :   }
    1332             : 
    1333             :   V8_INLINE static PreParserIdentifier AsIdentifier(
    1334             :       const PreParserExpression& expression) {
    1335    12557127 :     return expression.AsIdentifier();
    1336             :   }
    1337             : 
    1338             :   V8_INLINE static PreParserExpression AsIdentifierExpression(
    1339             :       const PreParserExpression& expression) {
    1340             :     return expression;
    1341             :   }
    1342             : 
    1343       35150 :   V8_INLINE bool IsConstructor(const PreParserIdentifier& identifier) const {
    1344       35150 :     return identifier.IsConstructor();
    1345             :   }
    1346             : 
    1347       43949 :   V8_INLINE bool IsName(const PreParserIdentifier& identifier) const {
    1348       43949 :     return identifier.IsName();
    1349             :   }
    1350             : 
    1351             :   V8_INLINE static bool IsBoilerplateProperty(
    1352             :       const PreParserExpression& property) {
    1353             :     // PreParser doesn't count boilerplate properties.
    1354             :     return false;
    1355             :   }
    1356             : 
    1357             :   V8_INLINE bool IsNative(const PreParserExpression& expr) const {
    1358             :     // Preparsing is disabled for extensions (because the extension
    1359             :     // details aren't passed to lazily compiled functions), so we
    1360             :     // don't accept "native function" in the preparser and there is
    1361             :     // no need to keep track of "native".
    1362             :     return false;
    1363             :   }
    1364             : 
    1365             :   V8_INLINE static bool IsArrayIndex(const PreParserIdentifier& string,
    1366             :                                      uint32_t* index) {
    1367             :     return false;
    1368             :   }
    1369             : 
    1370             :   V8_INLINE bool IsStringLiteral(PreParserStatement statement) const {
    1371      206858 :     return statement.IsStringLiteral();
    1372             :   }
    1373             : 
    1374             :   V8_INLINE static void GetDefaultStrings(
    1375             :       PreParserIdentifier* default_string,
    1376             :       PreParserIdentifier* star_default_star_string) {}
    1377             : 
    1378             :   // Functions for encapsulating the differences between parsing and preparsing;
    1379             :   // operations interleaved with the recursive descent.
    1380             :   V8_INLINE static void PushLiteralName(const PreParserIdentifier& id) {}
    1381             :   V8_INLINE static void PushVariableName(const PreParserIdentifier& id) {}
    1382             :   V8_INLINE void PushPropertyName(const PreParserExpression& expression) {}
    1383             :   V8_INLINE void PushEnclosingName(const PreParserIdentifier& name) {}
    1384             :   V8_INLINE static void AddFunctionForNameInference(
    1385             :       const PreParserExpression& expression) {}
    1386             :   V8_INLINE static void InferFunctionName() {}
    1387             : 
    1388             :   V8_INLINE static void CheckAssigningFunctionLiteralToProperty(
    1389             :       const PreParserExpression& left, const PreParserExpression& right) {}
    1390             : 
    1391             :   V8_INLINE bool ShortcutNumericLiteralBinaryExpression(
    1392             :       PreParserExpression* x, const PreParserExpression& y, Token::Value op,
    1393             :       int pos) {
    1394             :     return false;
    1395             :   }
    1396             : 
    1397             :   V8_INLINE NaryOperation* CollapseNaryExpression(PreParserExpression* x,
    1398             :                                                   PreParserExpression y,
    1399             :                                                   Token::Value op, int pos,
    1400             :                                                   const SourceRange& range) {
    1401     4928371 :     x->clear_parenthesized();
    1402             :     return nullptr;
    1403             :   }
    1404             : 
    1405             :   V8_INLINE PreParserExpression BuildUnaryExpression(
    1406             :       const PreParserExpression& expression, Token::Value op, int pos) {
    1407     1189716 :     return PreParserExpression::Default();
    1408             :   }
    1409             : 
    1410             :   V8_INLINE PreParserStatement
    1411             :   BuildInitializationBlock(DeclarationParsingResult* parsing_result,
    1412             :                            ZonePtrList<const AstRawString>* names) {
    1413     9464475 :     for (auto declaration : parsing_result->declarations) {
    1414             :       InitializeVariables(nullptr, &(parsing_result->descriptor), &declaration,
    1415     4828530 :                           names);
    1416             :     }
    1417     4635901 :     return PreParserStatement::Default();
    1418             :   }
    1419             : 
    1420             :   V8_INLINE PreParserBlock RewriteForVarInLegacy(const ForInfo& for_info) {
    1421       69615 :     return PreParserBlock::Null();
    1422             :   }
    1423             : 
    1424             :   V8_INLINE void DesugarBindingInForEachStatement(
    1425             :       ForInfo* for_info, PreParserStatement* body_block,
    1426             :       PreParserExpression* each_variable) {
    1427             :     DCHECK_EQ(1, for_info->parsing_result.declarations.size());
    1428             :     bool is_for_var_of =
    1429      215889 :         for_info->mode == ForEachStatement::ITERATE &&
    1430      102702 :         for_info->parsing_result.descriptor.mode == VariableMode::kVar;
    1431             :     bool collect_names =
    1432      113187 :         IsLexicalVariableMode(for_info->parsing_result.descriptor.mode) ||
    1433             :         is_for_var_of;
    1434             : 
    1435             :     InitializeVariables(nullptr, &for_info->parsing_result.descriptor,
    1436      113184 :                         &for_info->parsing_result.declarations[0],
    1437      226371 :                         collect_names ? &for_info->bound_names : nullptr);
    1438             :   }
    1439             : 
    1440             :   V8_INLINE PreParserBlock CreateForEachStatementTDZ(PreParserBlock init_block,
    1441             :                                                      const ForInfo& for_info) {
    1442      113186 :     if (IsLexicalVariableMode(for_info.parsing_result.descriptor.mode)) {
    1443      181640 :       for (auto name : for_info.bound_names) {
    1444       92812 :         scope()->DeclareVariableName(name, VariableMode::kLet);
    1445             :       }
    1446       88828 :       return PreParserBlock::Default();
    1447             :     }
    1448             :     return init_block;
    1449             :   }
    1450             : 
    1451             :   V8_INLINE StatementT DesugarLexicalBindingsInForStatement(
    1452             :       PreParserStatement loop, PreParserStatement init,
    1453             :       const PreParserExpression& cond, PreParserStatement next,
    1454             :       PreParserStatement body, Scope* inner_scope, const ForInfo& for_info) {
    1455             :     // See Parser::DesugarLexicalBindingsInForStatement.
    1456         700 :     for (auto name : for_info.bound_names) {
    1457             :       inner_scope->DeclareVariableName(name,
    1458         365 :                                        for_info.parsing_result.descriptor.mode);
    1459             :     }
    1460             :     return loop;
    1461             :   }
    1462             : 
    1463             :   PreParserBlock BuildParameterInitializationBlock(
    1464             :       const PreParserFormalParameters& parameters);
    1465             : 
    1466             :   V8_INLINE PreParserBlock
    1467             :   BuildRejectPromiseOnException(PreParserStatement init_block) {
    1468         612 :     return PreParserBlock::Default();
    1469             :   }
    1470             : 
    1471             :   V8_INLINE void InsertSloppyBlockFunctionVarBindings(DeclarationScope* scope) {
    1472      423276 :     scope->HoistSloppyBlockFunctions(nullptr);
    1473             :   }
    1474             : 
    1475             :   V8_INLINE void InsertShadowingVarBindingInitializers(
    1476             :       PreParserStatement block) {}
    1477             : 
    1478             :   V8_INLINE PreParserExpression NewThrowReferenceError(MessageTemplate message,
    1479             :                                                        int pos) {
    1480        1052 :     return PreParserExpression::Default();
    1481             :   }
    1482             : 
    1483             :   V8_INLINE PreParserExpression NewThrowSyntaxError(
    1484             :       MessageTemplate message, const PreParserIdentifier& arg, int pos) {
    1485             :     return PreParserExpression::Default();
    1486             :   }
    1487             : 
    1488             :   V8_INLINE PreParserExpression NewThrowTypeError(
    1489             :       MessageTemplate message, const PreParserIdentifier& arg, int pos) {
    1490             :     return PreParserExpression::Default();
    1491             :   }
    1492             : 
    1493             :   // Reporting errors.
    1494      199589 :   void ReportMessageAt(Scanner::Location source_location,
    1495             :                        MessageTemplate message, const char* arg = nullptr,
    1496      199589 :                        ParseErrorType error_type = kSyntaxError) {
    1497             :     pending_error_handler()->ReportMessageAt(source_location.beg_pos,
    1498             :                                              source_location.end_pos, message,
    1499      399178 :                                              arg, error_type);
    1500      199589 :     scanner()->set_parser_error();
    1501      199589 :   }
    1502             : 
    1503     1570371 :   V8_INLINE void ReportUnidentifiableError() {
    1504     1570371 :     pending_error_handler()->set_unidentifiable_error();
    1505     1570371 :     scanner()->set_parser_error();
    1506             :   }
    1507             : 
    1508             :   V8_INLINE void ReportMessageAt(Scanner::Location source_location,
    1509             :                                  MessageTemplate message,
    1510             :                                  const PreParserIdentifier& arg,
    1511             :                                  ParseErrorType error_type = kSyntaxError) {
    1512           0 :     UNREACHABLE();
    1513             :   }
    1514             : 
    1515             :   // "null" return type creators.
    1516             :   V8_INLINE static PreParserIdentifier NullIdentifier() {
    1517     2939645 :     return PreParserIdentifier::Null();
    1518             :   }
    1519             :   V8_INLINE static PreParserExpression NullExpression() {
    1520    18663226 :     return PreParserExpression::Null();
    1521             :   }
    1522             :   V8_INLINE static PreParserExpression FailureExpression() {
    1523      607248 :     return PreParserExpression::Failure();
    1524             :   }
    1525             :   V8_INLINE static PreParserExpression NullLiteralProperty() {
    1526       75899 :     return PreParserExpression::Null();
    1527             :   }
    1528             :   V8_INLINE static PreParserStatementList NullStatementList() {
    1529             :     return PreParserStatementList::Null();
    1530             :   }
    1531             :   V8_INLINE static PreParserStatement NullStatement() {
    1532     6899725 :     return PreParserStatement::Null();
    1533             :   }
    1534      834854 :   V8_INLINE static PreParserBlock NullBlock() { return PreParserBlock::Null(); }
    1535             : 
    1536             :   template <typename T>
    1537             :   V8_INLINE static bool IsNull(T subject) {
    1538    25698861 :     return subject.IsNull();
    1539             :   }
    1540             : 
    1541             :   V8_INLINE PreParserIdentifier EmptyIdentifierString() const {
    1542      560744 :     return PreParserIdentifier::Default();
    1543             :   }
    1544             : 
    1545             :   // Producing data during the recursive descent.
    1546             :   PreParserIdentifier GetSymbol() const;
    1547             : 
    1548             :   V8_INLINE PreParserIdentifier GetNextSymbol() const {
    1549       30953 :     return PreParserIdentifier::Default();
    1550             :   }
    1551             : 
    1552             :   V8_INLINE PreParserIdentifier GetNumberAsSymbol() const {
    1553        3527 :     return PreParserIdentifier::Default();
    1554             :   }
    1555             : 
    1556             :   V8_INLINE PreParserExpression ThisExpression(int pos = kNoSourcePosition) {
    1557             :     scope()->NewUnresolved(factory()->ast_node_factory(),
    1558             :                            ast_value_factory()->this_string(), pos,
    1559     3034009 :                            THIS_VARIABLE);
    1560     3033890 :     return PreParserExpression::This();
    1561             :   }
    1562             : 
    1563             :   V8_INLINE PreParserExpression NewSuperPropertyReference(int pos) {
    1564             :     scope()->NewUnresolved(factory()->ast_node_factory(),
    1565             :                            ast_value_factory()->this_function_string(), pos,
    1566        4236 :                            NORMAL_VARIABLE);
    1567             :     scope()->NewUnresolved(factory()->ast_node_factory(),
    1568             :                            ast_value_factory()->this_string(), pos,
    1569        4236 :                            THIS_VARIABLE);
    1570        4236 :     return PreParserExpression::Default();
    1571             :   }
    1572             : 
    1573             :   V8_INLINE PreParserExpression NewSuperCallReference(int pos) {
    1574             :     scope()->NewUnresolved(factory()->ast_node_factory(),
    1575             :                            ast_value_factory()->this_function_string(), pos,
    1576        3059 :                            NORMAL_VARIABLE);
    1577             :     scope()->NewUnresolved(factory()->ast_node_factory(),
    1578             :                            ast_value_factory()->new_target_string(), pos,
    1579        3059 :                            NORMAL_VARIABLE);
    1580             :     scope()->NewUnresolved(factory()->ast_node_factory(),
    1581             :                            ast_value_factory()->this_string(), pos,
    1582        3059 :                            THIS_VARIABLE);
    1583        3060 :     return PreParserExpression::SuperCallReference();
    1584             :   }
    1585             : 
    1586             :   V8_INLINE PreParserExpression NewTargetExpression(int pos) {
    1587        4056 :     return PreParserExpression::NewTargetExpression();
    1588             :   }
    1589             : 
    1590             :   V8_INLINE PreParserExpression ImportMetaExpression(int pos) {
    1591        7925 :     return PreParserExpression::Default();
    1592             :   }
    1593             : 
    1594             :   V8_INLINE PreParserExpression ExpressionFromLiteral(Token::Value token,
    1595             :                                                       int pos) {
    1596    16745455 :     if (token != Token::STRING) return PreParserExpression::Default();
    1597     5500940 :     return PreParserExpression::StringLiteral();
    1598             :   }
    1599             : 
    1600             :   PreParserExpression ExpressionFromIdentifier(
    1601             :       const PreParserIdentifier& name, int start_position,
    1602             :       InferName infer = InferName::kYes);
    1603             : 
    1604             :   V8_INLINE Variable* DeclareCatchVariableName(
    1605             :       Scope* scope, const PreParserIdentifier& identifier) {
    1606      275545 :     return scope->DeclareCatchVariableName(identifier.string_);
    1607             :   }
    1608             : 
    1609             :   V8_INLINE PreParserPropertyList NewClassPropertyList(int size) const {
    1610             :     return PreParserPropertyList();
    1611             :   }
    1612             : 
    1613             :   V8_INLINE PreParserStatementList NewStatementList(int size) const {
    1614             :     return PreParserStatementList();
    1615             :   }
    1616             : 
    1617             :   V8_INLINE PreParserExpression
    1618             :   NewV8Intrinsic(const PreParserIdentifier& name,
    1619             :                  const PreParserExpressionList& arguments, int pos) {
    1620       73480 :     return PreParserExpression::Default();
    1621             :   }
    1622             : 
    1623             :   V8_INLINE PreParserStatement
    1624             :   NewThrowStatement(const PreParserExpression& exception, int pos) {
    1625      236322 :     return PreParserStatement::Jump();
    1626             :   }
    1627             : 
    1628             :   V8_INLINE void AddFormalParameter(PreParserFormalParameters* parameters,
    1629             :                                     PreParserExpression& pattern,
    1630             :                                     const PreParserExpression& initializer,
    1631             :                                     int initializer_end_position,
    1632             :                                     bool is_rest) {
    1633     3739230 :     DeclarationScope* scope = parameters->scope;
    1634     3739230 :     scope->RecordParameter(is_rest);
    1635     3739093 :     if (pattern.variables_) {
    1636     7412440 :       for (VariableProxy* param : *pattern.variables_) {
    1637     3713962 :         const AstRawString* name = param->raw_name();
    1638     3713945 :         if (scope->LookupLocal(name)) parameters->set_has_duplicate();
    1639     3713842 :         scope->DeclareParameterName(name);
    1640             :       }
    1641             :     }
    1642     3739138 :     parameters->UpdateArityAndFunctionLength(!initializer.IsNull(), is_rest);
    1643             :   }
    1644             : 
    1645             :   V8_INLINE void DeclareFormalParameters(
    1646             :       const PreParserFormalParameters* parameters) {
    1647     2837207 :     if (!parameters->is_simple) parameters->scope->SetHasNonSimpleParameters();
    1648             :   }
    1649             : 
    1650             :   V8_INLINE void DeclareArrowFunctionFormalParameters(
    1651             :       PreParserFormalParameters* parameters, const PreParserExpression& params,
    1652             :       const Scanner::Location& params_loc) {
    1653      456021 :     if (params.variables_ != nullptr) {
    1654             :       DeclarationScope* scope = parameters->scope;
    1655      624613 :       for (auto param : *params.variables_) {
    1656      329086 :         const AstRawString* name = param->raw_name();
    1657      329085 :         if (scope->LookupLocal(name)) parameters->set_has_duplicate();
    1658      329087 :         scope->DeclareParameterName(name);
    1659             :       }
    1660             :     }
    1661             :   }
    1662             : 
    1663             :   V8_INLINE PreParserExpression
    1664             :   ExpressionListToExpression(const PreParserExpressionList& args) {
    1665       76436 :     return PreParserExpression::Default(args.variables_);
    1666             :   }
    1667             : 
    1668             :   V8_INLINE void SetFunctionNameFromPropertyName(
    1669             :       const PreParserExpression& property, const PreParserIdentifier& name,
    1670             :       const AstRawString* prefix = nullptr) {}
    1671             :   V8_INLINE void SetFunctionNameFromIdentifierRef(
    1672             :       const PreParserExpression& value, const PreParserExpression& identifier) {
    1673             :   }
    1674             : 
    1675             :   V8_INLINE void CountUsage(v8::Isolate::UseCounterFeature feature) {
    1676        1052 :     if (use_counts_ != nullptr) ++use_counts_[feature];
    1677             :   }
    1678             : 
    1679             :   V8_INLINE bool ParsingDynamicFunctionDeclaration() const { return false; }
    1680             : 
    1681             : // Generate empty functions here as the preparser does not collect source
    1682             : // ranges for block coverage.
    1683             : #define DEFINE_RECORD_SOURCE_RANGE(Name) \
    1684             :   template <typename... Ts>              \
    1685             :   V8_INLINE void Record##Name##SourceRange(Ts... args) {}
    1686             :   AST_SOURCE_RANGE_LIST(DEFINE_RECORD_SOURCE_RANGE)
    1687             : #undef DEFINE_RECORD_SOURCE_RANGE
    1688             : 
    1689             :   // Preparser's private field members.
    1690             : 
    1691             :   int* use_counts_;
    1692             :   PreParserLogger log_;
    1693             : 
    1694             :   PreparseDataBuilder* preparse_data_builder_;
    1695             : };
    1696             : 
    1697             : PreParserExpression PreParser::SpreadCall(const PreParserExpression& function,
    1698             :                                           const PreParserExpressionList& args,
    1699             :                                           int pos,
    1700             :                                           Call::PossiblyEval possibly_eval) {
    1701        5290 :   return factory()->NewCall(function, args, pos, possibly_eval);
    1702             : }
    1703             : 
    1704             : PreParserExpression PreParser::SpreadCallNew(
    1705             :     const PreParserExpression& function, const PreParserExpressionList& args,
    1706             :     int pos) {
    1707         140 :   return factory()->NewCallNew(function, args, pos);
    1708             : }
    1709             : 
    1710             : }  // namespace internal
    1711             : }  // namespace v8
    1712             : 
    1713             : #endif  // V8_PARSING_PREPARSER_H_

Generated by: LCOV version 1.10