v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
parser.h
Go to the documentation of this file.
1// Copyright 2012 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_PARSING_PARSER_H_
6#define V8_PARSING_PARSER_H_
7
8#include <cstddef>
9
12#include "src/ast/ast.h"
13#include "src/ast/scopes.h"
18#include "src/common/globals.h"
22#include "src/parsing/parsing.h"
25
26namespace v8 {
27
28class ScriptCompiler;
29
30namespace internal {
31
32class ConsumedPreparseData;
33class ParseInfo;
34class ParserTarget;
35class ParserTargetScope;
36class PendingCompilationErrorHandler;
37class PreparseData;
38
39// ----------------------------------------------------------------------------
40// JAVASCRIPT PARSING
41
42class Parser;
43
44
46 struct Parameter : public ZoneObject {
53
55
58 return initializer_and_is_rest.GetPointer();
59 }
62 inline bool is_rest() const { return initializer_and_is_rest.GetPayload(); }
63
65 bool is_simple() const {
66 return pattern->IsVariableProxy() && initializer() == nullptr &&
67 !is_rest();
68 }
69
70 const AstRawString* name() const {
72 return pattern->AsVariableProxy()->raw_name();
73 }
74
75 Parameter** next() { return &next_parameter; }
76 Parameter* const* next() const { return &next_parameter; }
77 };
78
80 MessageTemplate message) {
81 strict_error_loc = loc;
82 strict_error_message = message;
83 }
84
85 bool has_duplicate() const { return duplicate_loc.IsValid(); }
86 void ValidateDuplicate(Parser* parser) const;
87 void ValidateStrictMode(Parser* parser) const;
88
91
95 MessageTemplate strict_error_message = MessageTemplate::kNone;
96};
97
98template <>
101 using Impl = Parser;
102
103 // Return types for traversing functions.
115 using Identifier = const AstRawString*;
122
123 // For constructing objects returned by the traversing functions.
125
126 // Other implementation-specific functions.
130};
131
132class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
133 public:
134 Parser(LocalIsolate* local_isolate, ParseInfo* info);
136 delete reusable_preparser_;
137 reusable_preparser_ = nullptr;
138 }
139
140 static bool IsPreParser() { return false; }
141
142 // Sets the literal on |info| if parsing succeeded.
143 void ParseOnBackground(LocalIsolate* isolate, ParseInfo* info,
144 DirectHandle<Script> script, int start_position,
145 int end_position, int function_literal_id);
146
147 // Initializes an empty scope chain for top-level scripts, or scopes which
148 // consist of only the native context.
149 void InitializeEmptyScopeChain(ParseInfo* info);
150
151 // Deserialize the scope chain prior to parsing in which the script is going
152 // to be executed. If the script is a top-level script, or the scope chain
153 // consists of only a native context, maybe_outer_scope_info should be an
154 // empty handle.
155 //
156 // This only deserializes the scope chain, but doesn't connect the scopes to
157 // their corresponding scope infos. Therefore, looking up variables in the
158 // deserialized scopes is not possible.
159 template <typename IsolateT>
160 void DeserializeScopeChain(
161 IsolateT* isolate, ParseInfo* info,
162 MaybeDirectHandle<ScopeInfo> maybe_outer_scope_info,
164 Scope::DeserializationMode::kScopesOnly);
165
166 // Move statistics to Isolate
167 void UpdateStatistics(Isolate* isolate, DirectHandle<Script> script);
168 void UpdateStatistics(
171 int* preparse_skipped);
172 template <typename IsolateT>
173 void HandleSourceURLComments(IsolateT* isolate, DirectHandle<Script> script);
174
175 private:
176 friend class ParserBase<Parser>;
184 MaybeDirectHandle<ScopeInfo> maybe_outer_scope_info, Isolate*,
189
191 return !MaybeParsingArrowhead() &&
192 scope()->AllowsLazyParsingWithoutUnresolvedVariables(
193 original_scope_);
194 }
195
196 bool parse_lazily() const { return mode_ == PARSE_LAZILY; }
197 enum Mode { PARSE_LAZILY, PARSE_EAGERLY };
198
200 public:
202 : parser_(parser), old_mode_(parser->mode_) {
203 parser_->mode_ = mode;
204 }
205 ~ParsingModeScope() { parser_->mode_ = old_mode_; }
206
207 private:
210 };
211
212 // Runtime encoding of different completion modes.
218
220 return scope()->NewTemporary(name);
221 }
222
223 void PrepareGeneratorVariables();
224
225 // Sets the literal on |info| if parsing succeeded.
226 void ParseProgram(Isolate* isolate, DirectHandle<Script> script,
227 ParseInfo* info,
228 MaybeDirectHandle<ScopeInfo> maybe_outer_scope_info);
229
230 // Sets the literal on |info| if parsing succeeded.
231 void ParseFunction(Isolate* isolate, ParseInfo* info,
233
234 template <typename IsolateT>
235 void PostProcessParseResult(IsolateT* isolate, ParseInfo* info,
237
238 FunctionLiteral* DoParseFunction(Isolate* isolate, ParseInfo* info,
239 int start_position, int end_position,
240 int function_literal_id,
241 const AstRawString* raw_name);
242
243 FunctionLiteral* ParseClassForMemberInitialization(
244 FunctionKind initializer_kind, int initializer_pos, int initializer_id,
245 int initializer_end_pos, const AstRawString* class_name);
246
247 // Called by ParseProgram after setting up the scanner.
248 FunctionLiteral* DoParseProgram(Isolate* isolate, ParseInfo* info);
249
250 // Parse with the script as if the source is implicitly wrapped in a function.
251 // We manually construct the AST and scopes for a top-level function and the
252 // function wrapper.
253 void ParseWrapped(Isolate* isolate, ParseInfo* info,
255 Zone* zone);
256
257 void ParseREPLProgram(ParseInfo* info, ScopedPtrList<Statement>* body,
258 DeclarationScope* scope);
259 Expression* WrapREPLResult(Expression* value);
260
261 ZonePtrList<const AstRawString>* PrepareWrappedArguments(Isolate* isolate,
262 ParseInfo* info,
263 Zone* zone);
264
266 if (reusable_preparser_ == nullptr) {
267 reusable_preparser_ = new PreParser(
268 &preparser_zone_, &scanner_, stack_limit_, ast_value_factory(),
269 pending_error_handler(), runtime_call_stats_, v8_file_logger_,
270 flags(), parsing_on_main_thread_);
271 reusable_preparser_->set_allow_eval_cache(allow_eval_cache());
272 preparse_data_buffer_.reserve(128);
273 }
274 return reusable_preparser_;
275 }
276
277 void ParseModuleItemList(ScopedPtrList<Statement>* body);
278 Statement* ParseModuleItem();
279 const AstRawString* ParseModuleSpecifier();
280 void ParseImportDeclaration();
281 Statement* ParseExportDeclaration();
282 Statement* ParseExportDefault();
283 void ParseExportStar();
289 ZoneChunkList<ExportClauseData>* ParseExportClause(
290 Scanner::Location* reserved_loc,
291 Scanner::Location* string_literal_local_name_loc);
292 struct NamedImport : public ZoneObject {
296 NamedImport(const AstRawString* import_name, const AstRawString* local_name,
297 Scanner::Location location)
298 : import_name(import_name),
299 local_name(local_name),
300 location(location) {}
301 };
302 const AstRawString* ParseExportSpecifierName();
303 ZonePtrList<const NamedImport>* ParseNamedImports(int pos);
304
305 ImportAttributes* ParseImportWithOrAssertClause();
306 Statement* BuildInitializationBlock(DeclarationParsingResult* parsing_result);
307 Statement* RewriteSwitchStatement(SwitchStatement* switch_statement,
308 Scope* scope);
309 Block* RewriteCatchPattern(CatchInfo* catch_info);
310 void ReportVarRedeclarationIn(const AstRawString* name, Scope* scope);
311 Statement* RewriteTryStatement(Block* try_block, Block* catch_block,
312 const SourceRange& catch_range,
313 Block* finally_block,
314 const SourceRange& finally_range,
315 const CatchInfo& catch_info, int pos);
316 void ParseGeneratorFunctionBody(int pos, FunctionKind kind,
318 void ParseAsyncGeneratorFunctionBody(int pos, FunctionKind kind,
320 void DeclareFunctionNameVar(const AstRawString* function_name,
321 FunctionSyntaxKind function_syntax_kind,
322 DeclarationScope* function_scope);
323
324 Statement* DeclareFunction(const AstRawString* variable_name,
325 FunctionLiteral* function, VariableMode mode,
326 VariableKind kind, int beg_pos, int end_pos,
328 VariableProxy* CreateSyntheticContextVariableProxy(ClassScope* scope,
329 ClassInfo* class_info,
330 const AstRawString* name,
331 bool is_static);
332 VariableProxy* CreatePrivateNameVariable(ClassScope* scope, VariableMode mode,
333 IsStaticFlag is_static_flag,
334 const AstRawString* name);
335 FunctionLiteral* CreateInitializerFunction(const AstRawString* class_name,
336 DeclarationScope* scope,
337 int function_literal_id,
338 Statement* initializer_stmt);
339
341 const AstRawString* other) {
342 return identifier == other;
343 }
344
345 Statement* DeclareClass(const AstRawString* variable_name, Expression* value,
347 int class_token_pos, int end_pos);
348 void DeclareClassVariable(ClassScope* scope, const AstRawString* name,
349 ClassInfo* class_info, int class_token_pos);
350 void DeclareClassBrandVariable(ClassScope* scope, ClassInfo* class_info,
351 int class_token_pos);
352 void AddInstanceFieldOrStaticElement(ClassLiteralProperty* property,
353 ClassInfo* class_info, bool is_static);
354 void DeclarePrivateClassMember(ClassScope* scope,
355 const AstRawString* property_name,
356 ClassLiteralProperty* property,
358 bool is_static, ClassInfo* class_info);
359 void DeclarePublicClassMethod(const AstRawString* class_name,
360 ClassLiteralProperty* property,
361 bool is_constructor, ClassInfo* class_info);
362 void DeclarePublicClassField(ClassScope* scope,
363 ClassLiteralProperty* property, bool is_static,
364 bool is_computed_name, ClassInfo* class_info);
365 void DeclareClassProperty(ClassScope* scope, const AstRawString* class_name,
366 ClassLiteralProperty* property, bool is_constructor,
367 ClassInfo* class_info);
369 const AstRawString* property_name, bool is_static,
370 bool is_computed_name, bool is_private,
371 ClassInfo* class_info);
372 void AddClassStaticBlock(Block* block, ClassInfo* class_info);
373 FunctionLiteral* CreateStaticElementsInitializer(const AstRawString* name,
374 ClassInfo* class_info);
375 FunctionLiteral* CreateInstanceMembersInitializer(const AstRawString* name,
376 ClassInfo* class_info);
377 Expression* RewriteClassLiteral(ClassScope* block_scope,
378 const AstRawString* name,
379 ClassInfo* class_info, int pos);
380 Statement* DeclareNative(const AstRawString* name, int pos);
381
382 Block* IgnoreCompletion(Statement* statement);
383
385 return scope()->GetDeclarationScope()->has_checked_syntax();
386 }
387
388 void InitializeVariables(
390 const DeclarationParsingResult::Declaration* declaration);
391
392 Block* RewriteForVarInLegacy(const ForInfo& for_info);
393 void DesugarBindingInForEachStatement(ForInfo* for_info, Block** body_block,
394 Expression** each_variable);
395 Block* CreateForEachStatementTDZ(Block* init_block, const ForInfo& for_info);
396
397 Statement* DesugarLexicalBindingsInForStatement(
398 ForStatement* loop, Statement* init, Expression* cond, Statement* next,
399 Statement* body, Scope* inner_scope, const ForInfo& for_info);
400
401 FunctionLiteral* ParseFunctionLiteral(
402 const AstRawString* name, Scanner::Location function_name_location,
403 FunctionNameValidity function_name_validity, FunctionKind kind,
404 int function_token_position, FunctionSyntaxKind type,
405 LanguageMode language_mode,
406 ZonePtrList<const AstRawString>* arguments_for_wrapped_function);
407
409 object_literal->CalculateEmitStore(main_zone());
410 return object_literal;
411 }
412
413 // Insert initializer statements for var-bindings shadowing parameter bindings
414 // from a non-simple parameter list.
415 void InsertShadowingVarBindingInitializers(Block* block);
416
417 // Implement sloppy block-scoped functions, ES2015 Annex B 3.3
418 void InsertSloppyBlockFunctionVarBindings(DeclarationScope* scope);
419
420 void DeclareUnboundVariable(const AstRawString* name, VariableMode mode,
421 InitializationFlag init, int pos);
423 VariableProxy* DeclareBoundVariable(const AstRawString* name,
424 VariableMode mode, int pos);
425 void DeclareAndBindVariable(VariableProxy* proxy, VariableKind kind,
426 VariableMode mode, Scope* declaration_scope,
427 bool* was_added, int initializer_position);
429 Variable* DeclareVariable(const AstRawString* name, VariableKind kind,
431 Scope* declaration_scope, bool* was_added,
432 int begin, int end = kNoSourcePosition);
433 void Declare(Declaration* declaration, const AstRawString* name,
435 Scope* declaration_scope, bool* was_added, int var_begin_pos,
436 int var_end_pos = kNoSourcePosition);
437
438 // Factory methods.
439 FunctionLiteral* DefaultConstructor(const AstRawString* name, bool call_super,
440 int pos);
441
442 FunctionLiteral* MakeAutoAccessorGetter(VariableProxy* name_proxy,
443 const AstRawString* name,
444 bool is_static, int pos);
445
446 FunctionLiteral* MakeAutoAccessorSetter(VariableProxy* name_proxy,
447 const AstRawString* name,
448 bool is_static, int pos);
449
450 AutoAccessorInfo* NewAutoAccessorInfo(ClassScope* scope,
451 ClassInfo* class_info,
452 const AstRawString* name,
453 bool is_static, int pos);
454 ClassLiteralProperty* NewClassLiteralPropertyWithAccessorInfo(
455 ClassScope* scope, ClassInfo* class_info, const AstRawString* name,
456 Expression* key, Expression* value, bool is_static, bool is_computed_name,
457 bool is_private, int pos);
458
459 // Skip over a lazy function, either using cached data if we have it, or
460 // by parsing the function with PreParser. Consumes the ending }.
461 // In case the preparser detects an error it cannot identify, it resets the
462 // scanner- and preparser state to the initial one, before PreParsing the
463 // function.
464 // SkipFunction returns true if it correctly parsed the function, including
465 // cases where we detect an error. It returns false, if we needed to stop
466 // parsing or could not identify an error correctly, meaning the caller needs
467 // to fully reparse. In this case it resets the scanner and preparser state.
468 bool SkipFunction(const AstRawString* function_name, FunctionKind kind,
469 FunctionSyntaxKind function_syntax_kind,
470 DeclarationScope* function_scope, int* num_parameters,
471 int* function_length,
472 ProducedPreparseData** produced_preparsed_scope_data);
473
474 Block* BuildParameterInitializationBlock(
475 const ParserFormalParameters& parameters);
476
477 void ParseFunction(
478 ScopedPtrList<Statement>* body, const AstRawString* function_name,
479 int pos, FunctionKind kind, FunctionSyntaxKind function_syntax_kind,
480 DeclarationScope* function_scope, int* num_parameters,
481 int* function_length, bool* has_duplicate_parameters,
482 int* expected_property_count, int* suspend_count,
483 ZonePtrList<const AstRawString>* arguments_for_wrapped_function);
484
486
488 public:
490 : cooked_(8, zone), raw_(8, zone), expressions_(8, zone), pos_(pos) {}
491
492 const ZonePtrList<const AstRawString>* cooked() const { return &cooked_; }
493 const ZonePtrList<const AstRawString>* raw() const { return &raw_; }
494 const ZonePtrList<Expression>* expressions() const { return &expressions_; }
495 int position() const { return pos_; }
496
497 void AddTemplateSpan(const AstRawString* cooked, const AstRawString* raw,
498 int end, Zone* zone) {
499 DCHECK_NOT_NULL(raw);
500 cooked_.Add(cooked, zone);
501 raw_.Add(raw, zone);
502 }
503
504 void AddExpression(Expression* expression, Zone* zone) {
505 expressions_.Add(expression, zone);
506 }
507
508 private:
512 int pos_;
513 };
514
516
517 TemplateLiteralState OpenTemplateLiteral(int pos);
518 // "should_cook" means that the span can be "cooked": in tagged template
519 // literals, both the raw and "cooked" representations are available to user
520 // code ("cooked" meaning that escape sequences are converted to their
521 // interpreted values). Invalid escape sequences cause the cooked span
522 // to be represented by undefined, instead of being a syntax error.
523 // "tail" indicates that this span is the last in the literal.
524 void AddTemplateSpan(TemplateLiteralState* state, bool should_cook,
525 bool tail);
526 void AddTemplateExpression(TemplateLiteralState* state,
527 Expression* expression);
528 Expression* CloseTemplateLiteral(TemplateLiteralState* state, int start,
529 Expression* tag);
530
532
533 void SetLanguageMode(Scope* scope, LanguageMode mode);
534#if V8_ENABLE_WEBASSEMBLY
535 void SetAsmModule();
536#endif // V8_ENABLE_WEBASSEMBLY
537
539
540 Expression* BuildInitialYield(int pos, FunctionKind kind);
542
543 // Generic AST generator for throwing errors from compiled code.
544 Expression* NewThrowError(Runtime::FunctionId function_id,
545 MessageTemplate message, const AstRawString* arg,
546 int pos);
547
548 void AddArrowFunctionFormalParameters(ParserFormalParameters* parameters,
549 Expression* params, int end_pos);
550 void SetFunctionName(Expression* value, const AstRawString* name,
551 const AstRawString* prefix = nullptr);
552
553 // Helper functions for recursive descent.
555 return identifier == ast_value_factory()->eval_string();
556 }
557
559 return identifier == ast_value_factory()->async_string();
560 }
561
563 return identifier == ast_value_factory()->arguments_string();
564 }
565
567 return IsEval(identifier) || IsArguments(identifier);
568 }
569
570 // Returns true if the expression is of type "this.foo".
571 V8_INLINE static bool IsThisProperty(Expression* expression) {
572 DCHECK_NOT_NULL(expression);
573 Property* property = expression->AsProperty();
574 return property != nullptr && property->obj()->IsThisExpression();
575 }
576
577 // Returns true if the expression is of type "obj.#foo" or "obj?.#foo".
578 V8_INLINE static bool IsPrivateReference(Expression* expression) {
579 DCHECK_NOT_NULL(expression);
580 Property* property = expression->AsProperty();
581 if (expression->IsOptionalChain()) {
582 Expression* expr_inner = expression->AsOptionalChain()->expression();
583 property = expr_inner->AsProperty();
584 }
585 return property != nullptr && property->IsPrivateReference();
586 }
587
588 // This returns true if the expression is an identifier (wrapped
589 // inside a variable proxy). We exclude the case of 'this', which
590 // has been converted to a variable proxy.
591 V8_INLINE static bool IsIdentifier(Expression* expression) {
592 VariableProxy* operand = expression->AsVariableProxy();
593 return operand != nullptr && !operand->is_new_target();
594 }
595
596 V8_INLINE static const AstRawString* AsIdentifier(Expression* expression) {
597 DCHECK(IsIdentifier(expression));
598 return expression->AsVariableProxy()->raw_name();
599 }
600
602 return expression->AsVariableProxy();
603 }
604
606 return identifier == ast_value_factory()->constructor_string();
607 }
608
610 ObjectLiteral::Property* property) {
611 return !property->IsPrototype();
612 }
613
614 V8_INLINE v8::Extension* extension() const { return info_->extension(); }
615
616 V8_INLINE bool ParsingExtension() const { return extension() != nullptr; }
617
618 V8_INLINE bool IsNative(Expression* expr) const {
619 DCHECK_NOT_NULL(expr);
620 return expr->IsVariableProxy() &&
621 expr->AsVariableProxy()->raw_name() ==
622 ast_value_factory()->native_string();
623 }
624
625 V8_INLINE static bool IsArrayIndex(const AstRawString* string,
626 uint32_t* index) {
627 return string->AsArrayIndex(index);
628 }
629
630 // Returns true if the statement is an expression statement containing
631 // a single string literal. If a second argument is given, the literal
632 // is also compared with it and the result is true only if they are equal.
634 const AstRawString* arg = nullptr) const {
635 ExpressionStatement* e_stat = statement->AsExpressionStatement();
636 if (e_stat == nullptr) return false;
637 Literal* literal = e_stat->expression()->AsLiteral();
638 if (literal == nullptr || !literal->IsRawString()) return false;
639 return arg == nullptr || literal->AsRawString() == arg;
640 }
641
642 V8_INLINE void GetDefaultStrings(const AstRawString** default_string,
643 const AstRawString** dot_default_string) {
644 *default_string = ast_value_factory()->default_string();
645 *dot_default_string = ast_value_factory()->dot_default_string();
646 }
647
648 // Functions for encapsulating the differences between parsing and preparsing;
649 // operations interleaved with the recursive descent.
651 fni_.PushLiteralName(id);
652 }
653
655 fni_.PushVariableName(id);
656 }
657
659 if (expression->IsPropertyName()) {
660 fni_.PushLiteralName(expression->AsLiteral()->AsRawPropertyName());
661 } else {
662 fni_.PushLiteralName(ast_value_factory()->computed_string());
663 }
664 }
665
667 fni_.PushEnclosingName(name);
668 }
669
671 fni_.AddFunction(func_to_infer);
672 }
673
674 V8_INLINE void InferFunctionName() { fni_.Infer(); }
675
676 // If we assign a function literal to a property we pretenure the
677 // literal so it can be added as a constant function property.
679 Expression* left, Expression* right) {
680 DCHECK_NOT_NULL(left);
681 if (left->IsProperty() && right->IsFunctionLiteral()) {
682 right->AsFunctionLiteral()->set_pretenure();
683 }
684 }
685
686 // Returns true if we have a binary expression between two literals. In that
687 // case, *x will be changed to an expression which is the computed value.
688 bool ShortcutLiteralBinaryExpression(Expression** x, Expression* y,
689 Token::Value op, int pos);
690
691 bool CollapseConditionalChain(Expression** x, Expression* cond,
692 Expression* then_expression,
693 Expression* else_expression, int pos,
694 const SourceRange& then_range);
695
696 void AppendConditionalChainElse(Expression** x,
697 const SourceRange& else_range);
698
699 // Returns true if we have a binary operation between a binary/n-ary
700 // expression (with the same operation) and a value, which can be collapsed
701 // into a single n-ary expression. In that case, *x will be changed to an
702 // n-ary expression.
703 bool CollapseNaryExpression(Expression** x, Expression* y, Token::Value op,
704 int pos, const SourceRange& range);
705
706 // Returns a UnaryExpression or, in one of the following cases, a Literal.
707 // ! <literal> -> true / false
708 // + <Number literal> -> <Number literal>
709 // - <Number literal> -> <Number literal with value negated>
710 // ~ <literal> -> true / false
711 Expression* BuildUnaryExpression(Expression* expression, Token::Value op,
712 int pos);
713
714 // Generate AST node that throws a ReferenceError with the given type.
716 int pos) {
717 return NewThrowError(Runtime::kNewReferenceError, message,
718 ast_value_factory()->empty_string(), pos);
719 }
720
721 // Dummy implementation. The parser should never have a unidentifiable
722 // error.
724
726 return arg;
727 }
728
730 const PreParserIdentifier& arg) {
731 // This method definition is only needed due to an MSVC oddity that
732 // instantiates the method despite it being unused. See crbug.com/v8/12266 .
733 UNREACHABLE();
734 }
735
739
740 void ReportUnexpectedTokenAt(
741 Scanner::Location location, Token::Value token,
742 MessageTemplate message = MessageTemplate::kUnexpectedToken);
743
744 // "null" return type creators.
745 V8_INLINE static std::nullptr_t NullIdentifier() { return nullptr; }
746 V8_INLINE static std::nullptr_t NullExpression() { return nullptr; }
747 V8_INLINE static std::nullptr_t NullLiteralProperty() { return nullptr; }
749 return nullptr;
750 }
752 return nullptr;
753 }
754 V8_INLINE static std::nullptr_t NullStatement() { return nullptr; }
755 V8_INLINE static std::nullptr_t NullBlock() { return nullptr; }
756 Expression* FailureExpression() { return factory()->FailureExpression(); }
757
758 template <typename T>
759 V8_INLINE static bool IsNull(T subject) {
760 return subject == nullptr;
761 }
762
764 return subject->AsIterationStatement() != nullptr;
765 }
766
767 // Non-null empty string.
769 return ast_value_factory()->empty_string();
770 }
771 V8_INLINE bool IsEmptyIdentifier(const AstRawString* subject) const {
772 DCHECK_NOT_NULL(subject);
773 return subject->IsEmpty();
774 }
775
776 // Producing data during the recursive descent.
778 const AstRawString* result = scanner()->CurrentSymbol(ast_value_factory());
780 return result;
781 }
782
783 V8_INLINE const AstRawString* GetIdentifier() const { return GetSymbol(); }
784
786 return scanner()->NextSymbol(ast_value_factory());
787 }
788
790 double double_value = scanner()->DoubleValue();
791 char array[100];
792 std::string_view string =
793 DoubleToStringView(double_value, base::ArrayVector(array));
794 return ast_value_factory()->GetOneByteString(
795 base::OneByteVector(string.data(), string.length()));
796 }
797
798 const AstRawString* GetBigIntAsSymbol();
799
801 UseThis();
802 return factory()->ThisExpression();
803 }
804
806 UseThis();
807 return factory()->NewThisExpression(pos);
808 }
809
810 Expression* NewSuperPropertyReference(int pos);
811 SuperCallReference* NewSuperCallReference(int pos);
812 Expression* NewTargetExpression(int pos);
813 Expression* ImportMetaExpression(int pos);
814
815 Expression* ExpressionFromLiteral(Token::Value token, int pos);
816
818 PrivateNameScopeIterator* private_name_scope, const AstRawString* name,
819 int start_position) {
820 VariableProxy* proxy = factory()->ast_node_factory()->NewVariableProxy(
821 name, NORMAL_VARIABLE, start_position);
822 private_name_scope->AddUnresolvedPrivateName(proxy);
823 return proxy;
824 }
825
827 const AstRawString* name, int start_position,
828 InferName infer = InferName::kYes) {
829 if (infer == InferName::kYes) {
830 fni_.PushVariableName(name);
831 }
832 return expression_scope()->NewVariable(name, start_position);
833 }
834
836 int start_position) {
837 expression_scope()->Declare(name, start_position);
838 }
839
841 const AstRawString* name) {
842 return scope->DeclareCatchVariableName(name);
843 }
844
853
854 Expression* NewV8Intrinsic(const AstRawString* name,
856
857 Expression* NewV8RuntimeFunctionForFuzzing(
858 const Runtime::Function* function, const ScopedPtrList<Expression>& args,
859 int pos);
860
862 return factory()->NewExpressionStatement(
863 factory()->NewThrow(exception, pos), pos);
864 }
865
868 Expression* initializer,
869 int initializer_end_position,
870 bool is_rest) {
871 parameters->UpdateArityAndFunctionLength(initializer != nullptr, is_rest);
872 auto parameter =
874 pattern, initializer, scanner()->location().beg_pos,
875 initializer_end_position, is_rest);
876
877 parameters->params.Add(parameter);
878 }
879
881 bool is_simple = parameters->is_simple;
882 DeclarationScope* scope = parameters->scope;
883 if (!is_simple) scope->MakeParametersNonSimple();
884 for (auto parameter : parameters->params) {
885 bool is_optional = parameter->initializer() != nullptr;
886 // If the parameter list is simple, declare the parameters normally with
887 // their names. If the parameter list is not simple, declare a temporary
888 // for each parameter - the corresponding named variable is declared by
889 // BuildParameterInitializationBlock.
890 scope->DeclareParameter(
891 is_simple ? parameter->name() : ast_value_factory()->empty_string(),
892 is_simple ? VariableMode::kVar : VariableMode::kTemporary,
893 is_optional, parameter->is_rest(), ast_value_factory(),
894 parameter->position);
895 }
896 }
897
898 void ReindexArrowFunctionFormalParameters(ParserFormalParameters* parameters);
899 void ReindexComputedMemberName(Expression* computed_name);
900 void DeclareArrowFunctionFormalParameters(
901 ParserFormalParameters* parameters, Expression* params,
902 const Scanner::Location& params_loc);
903
904 Expression* ExpressionListToExpression(const ScopedPtrList<Expression>& args);
905
906 void SetFunctionNameFromPropertyName(LiteralProperty* property,
907 const AstRawString* name,
908 const AstRawString* prefix = nullptr);
909 void SetFunctionNameFromPropertyName(ObjectLiteralProperty* property,
910 const AstRawString* name,
911 const AstRawString* prefix = nullptr);
912
913 void SetFunctionNameFromIdentifierRef(Expression* value,
915
917 ++use_counts_[feature];
918 }
919
920 // Returns true iff we're parsing the first function literal during
921 // CreateDynamicFunction().
923 return parameters_end_pos_ != kNoSourcePosition;
924 }
925
927 BinaryOperation* binary_op, NaryOperation* nary_op) {
928 if (source_range_map_ == nullptr) return;
929 DCHECK_NULL(source_range_map_->Find(nary_op));
930
932 static_cast<BinaryOperationSourceRanges*>(
933 source_range_map_->Find(binary_op));
934 if (ranges == nullptr) return;
935
936 SourceRange range = ranges->GetRange(SourceRangeKind::kRight);
937 source_range_map_->Insert(
938 nary_op, zone()->New<NaryOperationSourceRanges>(zone(), range));
939 }
940
942 const SourceRange& range) {
943 if (source_range_map_ == nullptr) return;
945 static_cast<NaryOperationSourceRanges*>(source_range_map_->Find(node));
946 if (ranges == nullptr) return;
947
948 ranges->AddRange(range);
949 DCHECK_EQ(node->subsequent_length(), ranges->RangeCount());
950 }
951
953 int32_t continuation_position) {
954 if (source_range_map_ == nullptr) return;
955 source_range_map_->Insert(
956 node, zone()->New<BlockSourceRanges>(continuation_position));
957 }
958
960 const SourceRange& body_range) {
961 if (source_range_map_ == nullptr) return;
962 source_range_map_->Insert(node,
963 zone()->New<CaseClauseSourceRanges>(body_range));
964 }
965
967 const SourceRange& range) {
968 if (source_range_map_ == nullptr) return;
970 static_cast<ConditionalChainSourceRanges*>(
971 source_range_map_->Find(node));
972 if (ranges == nullptr) {
973 source_range_map_->Insert(
974 node, zone()->New<ConditionalChainSourceRanges>(zone()));
975 }
976 ranges = static_cast<ConditionalChainSourceRanges*>(
977 source_range_map_->Find(node));
978 if (ranges == nullptr) return;
979 ranges->AddThenRanges(range);
980 DCHECK_EQ(node->conditional_chain_length(), ranges->RangeCount());
981 }
982
984 ConditionalChain* node, const SourceRange& range) {
985 if (source_range_map_ == nullptr) return;
987 static_cast<ConditionalChainSourceRanges*>(
988 source_range_map_->Find(node));
989 if (ranges == nullptr) return;
990 ranges->AddElseRange(range);
991 }
992
994 const SourceRange& then_range,
995 const SourceRange& else_range) {
996 if (source_range_map_ == nullptr) return;
997 source_range_map_->Insert(
998 node->AsConditional(),
999 zone()->New<ConditionalSourceRanges>(then_range, else_range));
1000 }
1001
1003 if (source_range_map_ == nullptr) return;
1004 source_range_map_->Insert(node, zone()->New<FunctionLiteralSourceRanges>());
1005 }
1006
1008 Expression* node, const SourceRange& right_range) {
1009 if (source_range_map_ == nullptr) return;
1010 source_range_map_->Insert(
1011 node->AsBinaryOperation(),
1012 zone()->New<BinaryOperationSourceRanges>(right_range));
1013 }
1014
1016 int32_t continuation_position) {
1017 if (source_range_map_ == nullptr) return;
1018 source_range_map_->Insert(
1019 static_cast<JumpStatement*>(node),
1020 zone()->New<JumpStatementSourceRanges>(continuation_position));
1021 }
1022
1024 const SourceRange& then_range,
1025 const SourceRange& else_range) {
1026 if (source_range_map_ == nullptr) return;
1027 source_range_map_->Insert(
1028 node->AsIfStatement(),
1029 zone()->New<IfStatementSourceRanges>(then_range, else_range));
1030 }
1031
1033 IterationStatement* node, const SourceRange& body_range) {
1034 if (source_range_map_ == nullptr) return;
1035 source_range_map_->Insert(
1036 node, zone()->New<IterationStatementSourceRanges>(body_range));
1037 }
1038
1039 // Used to record source ranges of expressions associated with optional chain:
1041 const SourceRange& right_range) {
1042 if (source_range_map_ == nullptr) return;
1043 source_range_map_->Insert(node,
1044 zone()->New<ExpressionSourceRanges>(right_range));
1045 }
1046
1048 int32_t continuation_position) {
1049 if (source_range_map_ == nullptr) return;
1050 source_range_map_->Insert(
1051 static_cast<Suspend*>(node),
1052 zone()->New<SuspendSourceRanges>(continuation_position));
1053 }
1054
1056 Statement* node, int32_t continuation_position) {
1057 if (source_range_map_ == nullptr) return;
1058 source_range_map_->Insert(
1059 node->AsSwitchStatement(),
1060 zone()->New<SwitchStatementSourceRanges>(continuation_position));
1061 }
1062
1064 int32_t continuation_position) {
1065 if (source_range_map_ == nullptr) return;
1066 ExpressionStatement* expr_stmt = static_cast<ExpressionStatement*>(node);
1067 Throw* throw_expr = expr_stmt->expression()->AsThrow();
1068 source_range_map_->Insert(
1069 throw_expr, zone()->New<ThrowSourceRanges>(continuation_position));
1070 }
1071
1073 TryCatchStatement* node, const SourceRange& body_range) {
1074 if (source_range_map_ == nullptr) return;
1075 source_range_map_->Insert(
1076 node, zone()->New<TryCatchStatementSourceRanges>(body_range));
1077 }
1078
1080 TryFinallyStatement* node, const SourceRange& body_range) {
1081 if (source_range_map_ == nullptr) return;
1082 source_range_map_->Insert(
1083 node, zone()->New<TryFinallyStatementSourceRanges>(body_range));
1084 }
1085
1087 FunctionLiteral::EagerCompileHint current_compile_hint, int position) {
1088 if (current_compile_hint == FunctionLiteral::kShouldLazyCompile) {
1089 v8::CompileHintCallback callback = info_->compile_hint_callback();
1090 if (callback != nullptr &&
1091 callback(position, info_->compile_hint_callback_data())) {
1092 return FunctionLiteral::kShouldEagerCompile;
1093 }
1094 }
1095 return current_compile_hint;
1096 }
1097
1098 // Generate the next internal variable name for binding an exported namespace
1099 // object (used to implement the "export * as" syntax).
1100 const AstRawString* NextInternalNamespaceExportName();
1101
1102 ParseInfo* info() const { return info_; }
1103
1104 std::vector<uint8_t>* preparse_data_buffer() {
1105 return &preparse_data_buffer_;
1106 }
1107
1108 // Parser's private field members.
1109 friend class PreParserZoneScope; // Uses reusable_preparser().
1110 friend class PreparseDataBuilder; // Uses preparse_data_buffer()
1111
1118
1120
1121 SourceRangeMap* source_range_map_ = nullptr;
1122
1123 friend class ParserTargetScope;
1124
1126
1127 // For NextInternalNamespaceExportName().
1128 int number_of_named_namespace_exports_ = 0;
1129
1130 // Other information which will be stored in Parser and moved to Isolate after
1131 // parsing.
1137 std::vector<uint8_t> preparse_data_buffer_;
1138
1139 // If not kNoSourcePosition, indicates that the first function literal
1140 // encountered is a dynamic function, see CreateDynamicFunction(). This field
1141 // indicates the correct position of the ')' that closes the parameter list.
1142 // After that ')' is encountered, this field is reset to kNoSourcePosition.
1144};
1145
1146} // namespace internal
1147} // namespace v8
1148
1149#endif // V8_PARSING_PARSER_H_
int pos_
union v8::internal::@341::BuiltinMetadata::KindSpecificData data
Builtins::Kind kind
Definition builtins.cc:40
SourcePosition pos
@ kUseCounterFeatureCount
Definition v8-isolate.h:641
IterationStatement * AsIterationStatement()
Definition ast.cc:49
void AddElseRange(const SourceRange &else_range)
void AddThenRanges(const SourceRange &range)
Variable * DeclareParameter(const AstRawString *name, VariableMode mode, bool is_optional, bool is_rest, AstValueFactory *ast_value_factory, int position)
Definition scopes.cc:1012
Expression * expression() const
Definition ast.h:604
void AddRange(const SourceRange &range)
void CalculateEmitStore(Zone *zone)
Definition ast.cc:338
ParsingModeScope(Parser *parser, Mode mode)
Definition parser.h:201
TemplateLiteral(Zone *zone, int pos)
Definition parser.h:489
void AddExpression(Expression *expression, Zone *zone)
Definition parser.h:504
ZonePtrList< Expression > expressions_
Definition parser.h:511
const ZonePtrList< Expression > * expressions() const
Definition parser.h:494
ZonePtrList< const AstRawString > raw_
Definition parser.h:510
const ZonePtrList< const AstRawString > * raw() const
Definition parser.h:493
const ZonePtrList< const AstRawString > * cooked() const
Definition parser.h:492
void AddTemplateSpan(const AstRawString *cooked, const AstRawString *raw, int end, Zone *zone)
Definition parser.h:497
ZonePtrList< const AstRawString > cooked_
Definition parser.h:509
Expression * RewriteSpreads(ArrayLiteral *lit)
bool AllowsLazyParsingWithoutUnresolvedVariables() const
Definition parser.h:190
V8_INLINE void AddFunctionForNameInference(FunctionLiteral *func_to_infer)
Definition parser.h:670
V8_INLINE Expression * NewThrowReferenceError(MessageTemplate message, int pos)
Definition parser.h:715
class ThisExpression * ThisExpression()
Definition parser.h:800
V8_INLINE bool IsConstructor(const AstRawString *identifier) const
Definition parser.h:605
V8_INLINE bool IsStringLiteral(Statement *statement, const AstRawString *arg=nullptr) const
Definition parser.h:633
Expression * RewriteSuperCall(Expression *call_expression)
ParseInfo * info() const
Definition parser.h:1102
static V8_INLINE void CheckAssigningFunctionLiteralToProperty(Expression *left, Expression *right)
Definition parser.h:678
std::vector< uint8_t > preparse_data_buffer_
Definition parser.h:1137
V8_INLINE bool IsArguments(const AstRawString *identifier) const
Definition parser.h:562
V8_INLINE ZonePtrList< ClassLiteral::StaticElement > * NewClassStaticElementList(int size) const
Definition parser.h:849
static V8_INLINE bool IsArrayIndex(const AstRawString *string, uint32_t *index)
Definition parser.h:625
V8_INLINE void PushPropertyName(Expression *expression)
Definition parser.h:658
static V8_INLINE const AstRawString * AsIdentifier(Expression *expression)
Definition parser.h:596
class ThisExpression * NewThisExpression(int pos)
Definition parser.h:805
V8_INLINE void ReportUnidentifiableError()
Definition parser.h:723
V8_INLINE void RecordTryFinallyStatementSourceRange(TryFinallyStatement *node, const SourceRange &body_range)
Definition parser.h:1079
bool IdentifierEquals(const AstRawString *identifier, const AstRawString *other)
Definition parser.h:340
static V8_INLINE ZonePtrList< Expression > * NullExpressionList()
Definition parser.h:748
V8_INLINE void DeclareIdentifier(const AstRawString *name, int start_position)
Definition parser.h:835
static V8_INLINE bool IsIdentifier(Expression *expression)
Definition parser.h:591
static V8_INLINE bool IsNull(T subject)
Definition parser.h:759
V8_INLINE VariableProxy * ExpressionFromPrivateName(PrivateNameScopeIterator *private_name_scope, const AstRawString *name, int start_position)
Definition parser.h:817
V8_INLINE void InferFunctionName()
Definition parser.h:674
ObjectLiteral * InitializeObjectLiteral(ObjectLiteral *object_literal)
Definition parser.h:408
V8_INLINE bool IsEmptyIdentifier(const AstRawString *subject) const
Definition parser.h:771
V8_INLINE void CountUsage(v8::Isolate::UseCounterFeature feature)
Definition parser.h:916
static V8_INLINE std::nullptr_t NullLiteralProperty()
Definition parser.h:747
V8_INLINE void GetDefaultStrings(const AstRawString **default_string, const AstRawString **dot_default_string)
Definition parser.h:642
V8_INLINE const AstRawString * GetSymbol() const
Definition parser.h:777
V8_INLINE void RecordBlockSourceRange(Block *node, int32_t continuation_position)
Definition parser.h:952
static V8_INLINE bool IsPrivateReference(Expression *expression)
Definition parser.h:578
void DeclareClassField(ClassScope *scope, ClassLiteralProperty *property, const AstRawString *property_name, bool is_static, bool is_computed_name, bool is_private, ClassInfo *class_info)
V8_INLINE Statement * NewThrowStatement(Expression *exception, int pos)
Definition parser.h:861
ScriptCompiler::CompileOptions compile_options_
Definition parser.h:1125
V8_INLINE void RecordConditionalSourceRange(Expression *node, const SourceRange &then_range, const SourceRange &else_range)
Definition parser.h:993
V8_INLINE void RecordJumpStatementSourceRange(Statement *node, int32_t continuation_position)
Definition parser.h:1015
static V8_INLINE std::nullptr_t NullStatement()
Definition parser.h:754
static V8_INLINE bool IsBoilerplateProperty(ObjectLiteral::Property *property)
Definition parser.h:609
Assignment * BuildCreateJSGeneratorObject(int pos, FunctionKind kind)
LocalIsolate * local_isolate_
Definition parser.h:1112
V8_INLINE void PushVariableName(const AstRawString *id)
Definition parser.h:654
V8_INLINE v8::Extension * extension() const
Definition parser.h:614
Variable * NewTemporary(const AstRawString *name)
Definition parser.h:219
MaybeHandle< FixedArray > maybe_wrapped_arguments_
Definition parser.h:1119
V8_INLINE bool ParsingDynamicFunctionDeclaration() const
Definition parser.h:922
V8_INLINE bool IsAsync(const AstRawString *identifier) const
Definition parser.h:558
ConsumedPreparseData * consumed_preparse_data_
Definition parser.h:1136
V8_INLINE void RecordExpressionSourceRange(Expression *node, const SourceRange &right_range)
Definition parser.h:1040
const AstRawString * GetRawNameFromIdentifier(const AstRawString *arg)
Definition parser.h:725
static bool IsPreParser()
Definition parser.h:140
bool HasCheckedSyntax()
Definition parser.h:384
V8_INLINE void RecordIfStatementSourceRange(Statement *node, const SourceRange &then_range, const SourceRange &else_range)
Definition parser.h:1023
void ThrowPendingError(Isolate *isolate, Handle< Script > script)
V8_INLINE void AppendConditionalChainElseSourceRange(ConditionalChain *node, const SourceRange &range)
Definition parser.h:983
V8_INLINE void PushLiteralName(const AstRawString *id)
Definition parser.h:650
V8_INLINE void AppendNaryOperationSourceRange(NaryOperation *node, const SourceRange &range)
Definition parser.h:941
V8_INLINE void RecordIterationStatementSourceRange(IterationStatement *node, const SourceRange &body_range)
Definition parser.h:1032
V8_INLINE bool IsNative(Expression *expr) const
Definition parser.h:618
void DeclareClassBrandVariable(ClassScope *scope, ClassInfo *class_info, int class_token_pos)
V8_INLINE void DeclareFormalParameters(ParserFormalParameters *parameters)
Definition parser.h:880
Expression * FailureExpression()
Definition parser.h:756
V8_INLINE bool ParsingExtension() const
Definition parser.h:616
V8_INLINE VariableProxy * ExpressionFromIdentifier(const AstRawString *name, int start_position, InferName infer=InferName::kYes)
Definition parser.h:826
V8_INLINE const AstRawString * GetIdentifier() const
Definition parser.h:783
V8_INLINE void RecordCaseClauseSourceRange(CaseClause *node, const SourceRange &body_range)
Definition parser.h:959
V8_INLINE void AppendConditionalChainSourceRange(ConditionalChain *node, const SourceRange &range)
Definition parser.h:966
V8_INLINE void AddFormalParameter(ParserFormalParameters *parameters, Expression *pattern, Expression *initializer, int initializer_end_position, bool is_rest)
Definition parser.h:866
V8_INLINE void RecordBinaryOperationSourceRange(Expression *node, const SourceRange &right_range)
Definition parser.h:1007
void DeclareClassProperty(ClassScope *scope, const AstRawString *class_name, ClassLiteralProperty *property, bool is_constructor, ClassInfo *class_info)
static V8_INLINE bool IsIterationStatement(Statement *subject)
Definition parser.h:763
IterationStatement * AsIterationStatement(BreakableStatement *s)
Definition parser.h:736
static V8_INLINE bool IsThisProperty(Expression *expression)
Definition parser.h:571
static V8_INLINE std::nullptr_t NullExpression()
Definition parser.h:746
std::vector< uint8_t > * preparse_data_buffer()
Definition parser.h:1104
static V8_INLINE ZonePtrList< Statement > * NullStatementList()
Definition parser.h:751
V8_INLINE Variable * DeclareCatchVariableName(Scope *scope, const AstRawString *name)
Definition parser.h:840
V8_INLINE const AstRawString * EmptyIdentifierString() const
Definition parser.h:768
static V8_INLINE std::nullptr_t NullIdentifier()
Definition parser.h:745
const AstRawString * PreParserIdentifierToAstRawString(const PreParserIdentifier &arg)
Definition parser.h:729
V8_INLINE const AstRawString * GetNumberAsSymbol() const
Definition parser.h:789
V8_INLINE VariableProxy * AsIdentifierExpression(Expression *expression)
Definition parser.h:601
V8_INLINE void RecordFunctionLiteralSourceRange(FunctionLiteral *node)
Definition parser.h:1002
V8_INLINE void RecordSuspendSourceRange(Expression *node, int32_t continuation_position)
Definition parser.h:1047
V8_INLINE bool IsEvalOrArguments(const AstRawString *identifier) const
Definition parser.h:566
bool parse_lazily() const
Definition parser.h:196
V8_INLINE const AstRawString * GetNextSymbol() const
Definition parser.h:785
V8_INLINE ZonePtrList< ClassLiteral::Property > * NewClassPropertyList(int size) const
Definition parser.h:845
V8_INLINE void RecordTryCatchStatementSourceRange(TryCatchStatement *node, const SourceRange &body_range)
Definition parser.h:1072
V8_INLINE FunctionLiteral::EagerCompileHint GetEmbedderCompileHint(FunctionLiteral::EagerCompileHint current_compile_hint, int position)
Definition parser.h:1086
static V8_INLINE std::nullptr_t NullBlock()
Definition parser.h:755
V8_INLINE void PushEnclosingName(const AstRawString *name)
Definition parser.h:666
V8_INLINE void RecordSwitchStatementSourceRange(Statement *node, int32_t continuation_position)
Definition parser.h:1055
PreParser * reusable_preparser()
Definition parser.h:265
V8_INLINE bool IsEval(const AstRawString *identifier) const
Definition parser.h:554
ParseInfo * info_
Definition parser.h:1113
PreParser * reusable_preparser_
Definition parser.h:1116
V8_INLINE void RecordThrowSourceRange(Statement *node, int32_t continuation_position)
Definition parser.h:1063
V8_INLINE void ConvertBinaryToNaryOperationSourceRange(BinaryOperation *binary_op, NaryOperation *nary_op)
Definition parser.h:926
void AddUnresolvedPrivateName(VariableProxy *proxy)
Definition scopes.cc:3234
Expression * obj() const
Definition ast.h:1679
bool IsPrivateReference() const
Definition ast.h:1683
Variable * DeclareCatchVariableName(const AstRawString *name)
Definition scopes.cc:1213
Zone * zone() const
Definition scopes.h:179
bool is_new_target() const
Definition ast.h:1547
T * New(Args &&... args)
Definition zone.h:114
RecordWriteMode const mode_
int start
int end
base::Vector< const DirectHandle< Object > > args
Definition execution.cc:74
too high values may cause the compiler to set high thresholds for inlining to as much as possible avoid inlined allocation of objects that cannot escape trace load stores from virtual maglev objects use TurboFan fast string builder analyze liveness of environment slots and zap dead values trace TurboFan load elimination emit data about basic block usage in builtins to this enable builtin reordering when run mksnapshot flag for emit warnings when applying builtin profile data verify register allocation in TurboFan randomly schedule instructions to stress dependency tracking enable store store elimination in TurboFan rewrite far to near simulate GC compiler thread race related to allow float parameters to be passed in simulator mode JS Wasm Run additional turbo_optimize_inlined_js_wasm_wrappers enable experimental feedback collection in generic lowering enable Turboshaft s WasmLoadElimination enable Turboshaft s low level load elimination for JS enable Turboshaft s escape analysis for string concatenation use enable Turbolev features that we want to ship in the not too far future trace individual Turboshaft reduction steps trace intermediate Turboshaft reduction steps invocation count threshold for early optimization Enables optimizations which favor memory size over execution speed Enables sampling allocation profiler with X as a sample interval min size of a semi the new space consists of two semi spaces max size of the Collect garbage after Collect garbage after keeps maps alive for< n > old space garbage collections print one detailed trace line in allocation gc speed threshold for starting incremental marking via a task in percent of available threshold for starting incremental marking immediately in percent of available Use a single schedule for determining a marking schedule between JS and C objects schedules the minor GC task with kUserVisible priority max worker number of concurrent for NumberOfWorkerThreads start background threads that allocate memory concurrent_array_buffer_sweeping use parallel threads to clear weak refs in the atomic pause trace progress of the incremental marking trace object counts and memory usage report a tick only when allocated zone memory changes by this amount TracingFlags::gc_stats TracingFlags::gc_stats track native contexts that are expected to be garbage collected verify heap pointers before and after GC memory reducer runs GC with ReduceMemoryFootprint flag Maximum number of memory reducer GCs scheduled Old gen GC speed is computed directly from gc tracer counters Perform compaction on full GCs based on V8 s default heuristics Perform compaction on every full GC Perform code space compaction when finalizing a full GC with stack Stress GC compaction to flush out bugs with moving objects flush of baseline code when it has not been executed recently Use time base code flushing instead of age Use a progress bar to scan large objects in increments when incremental marking is active force incremental marking for small heaps and run it more often force marking at random points between and force scavenge at random points between and reclaim otherwise unreachable unmodified wrapper objects when possible less compaction in non memory reducing mode use high priority threads for concurrent Marking Test mode only flag It allows an unit test to select evacuation candidates use incremental marking for CppHeap cppheap_concurrent_marking c value for membalancer A special constant to balance between memory and space tradeoff The smaller the more memory it uses enable use of SSE4 instructions if available enable use of AVX VNNI instructions if available enable use of POPCNT instruction if available force all emitted branches to be in long mode(MIPS/PPC only)") DEFINE_BOOL(partial_constant_pool
other heap size flags(e.g. initial_heap_size) take precedence") DEFINE_SIZE_T( max_shared_heap_size
std::string extension
TNode< Object > callback
std::string pattern
Node * node
ZoneVector< RpoNumber > & result
int y
int x
FunctionLiteral * literal
Definition liveedit.cc:294
int position
Definition liveedit.cc:290
bool ParseFunction(ParseInfo *info, DirectHandle< SharedFunctionInfo > shared_info, Isolate *isolate, ReportStatisticsMode mode)
Definition parsing.cc:67
bool ParseProgram(ParseInfo *info, DirectHandle< Script > script, MaybeDirectHandle< ScopeInfo > maybe_outer_scope_info, Isolate *isolate, ReportStatisticsMode mode)
Definition parsing.cc:39
constexpr int kNoSourcePosition
Definition globals.h:850
std::string_view DoubleToStringView(double v, base::Vector< char > buffer)
bool(*)(int, void *) CompileHintCallback
OptimizedCompilationInfo * info_
Definition pipeline.cc:305
RegExpParserImpl< CharT > *const parser_
const uintptr_t stack_limit_
#define NON_EXPORTED_BASE(code)
#define UNREACHABLE()
Definition logging.h:67
#define DCHECK_NULL(val)
Definition logging.h:491
#define DCHECK_NOT_NULL(val)
Definition logging.h:492
#define DCHECK(condition)
Definition logging.h:482
#define DCHECK_EQ(v1, v2)
Definition logging.h:485
#define V8_EXPORT_PRIVATE
Definition macros.h:460
void UpdateArityAndFunctionLength(bool is_optional, bool is_rest)
Definition parser-base.h:69
const AstRawString * name() const
Definition parser.h:70
Parameter(Expression *pattern, Expression *initializer, int position, int initializer_end_position, bool is_rest)
Definition parser.h:47
base::PointerWithPayload< Expression, bool, 1 > initializer_and_is_rest
Definition parser.h:54
void ValidateStrictMode(Parser *parser) const
Definition parser.cc:2516
base::ThreadedList< Parameter > params
Definition parser.h:92
MessageTemplate strict_error_message
Definition parser.h:95
ParserFormalParameters(DeclarationScope *scope)
Definition parser.h:89
Scanner::Location strict_error_loc
Definition parser.h:94
void set_strict_parameter_error(const Scanner::Location &loc, MessageTemplate message)
Definition parser.h:79
Scanner::Location duplicate_loc
Definition parser.h:93
void ValidateDuplicate(Parser *parser) const
Definition parser.cc:2511
const AstRawString * local_name
Definition parser.h:286
const AstRawString * export_name
Definition parser.h:285
NamedImport(const AstRawString *import_name, const AstRawString *local_name, Scanner::Location location)
Definition parser.h:296
const AstRawString * local_name
Definition parser.h:294
const AstRawString * import_name
Definition parser.h:293
const Scanner::Location location
Definition parser.h:295
static Location invalid()
Definition scanner.h:270
Symbol identifier
Symbol declaration
Symbol statement
#define V8_INLINE
Definition v8config.h:500
#define V8_WARN_UNUSED_RESULT
Definition v8config.h:671
#define V8_NODISCARD
Definition v8config.h:693
std::unique_ptr< ValueMirror > key