diff options
author | Myles Borins <mylesborins@google.com> | 2019-09-24 11:56:38 -0400 |
---|---|---|
committer | Myles Borins <myles.borins@gmail.com> | 2019-10-07 03:19:23 -0400 |
commit | f7f6c928c1c9c136b7926f892b8a2fda11d8b4b2 (patch) | |
tree | f5edbccb3ffda2573d70a6e291e7157f290e0ae0 /deps/v8/src/parsing/parser.cc | |
parent | ffd22e81983056d09c064c59343a0e488236272d (diff) | |
download | android-node-v8-f7f6c928c1c9c136b7926f892b8a2fda11d8b4b2.tar.gz android-node-v8-f7f6c928c1c9c136b7926f892b8a2fda11d8b4b2.tar.bz2 android-node-v8-f7f6c928c1c9c136b7926f892b8a2fda11d8b4b2.zip |
deps: update V8 to 7.8.279.9
PR-URL: https://github.com/nodejs/node/pull/29694
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Diffstat (limited to 'deps/v8/src/parsing/parser.cc')
-rw-r--r-- | deps/v8/src/parsing/parser.cc | 115 |
1 files changed, 51 insertions, 64 deletions
diff --git a/deps/v8/src/parsing/parser.cc b/deps/v8/src/parsing/parser.cc index 2a860da3d0..e1bebc71f0 100644 --- a/deps/v8/src/parsing/parser.cc +++ b/deps/v8/src/parsing/parser.cc @@ -78,8 +78,8 @@ FunctionLiteral* Parser::DefaultConstructor(const AstRawString* name, FunctionLiteral* function_literal = factory()->NewFunctionLiteral( name, function_scope, body, expected_property_count, parameter_count, parameter_count, FunctionLiteral::kNoDuplicateParameters, - FunctionLiteral::kAnonymousExpression, default_eager_compile_hint(), pos, - true, GetNextFunctionLiteralId()); + FunctionSyntaxKind::kAnonymousExpression, default_eager_compile_hint(), + pos, true, GetNextFunctionLiteralId()); return function_literal; } @@ -424,7 +424,8 @@ Parser::Parser(ParseInfo* info) set_allow_natives(info->allow_natives_syntax()); set_allow_harmony_dynamic_import(info->allow_harmony_dynamic_import()); set_allow_harmony_import_meta(info->allow_harmony_import_meta()); - set_allow_harmony_numeric_separator(info->allow_harmony_numeric_separator()); + set_allow_harmony_nullish(info->allow_harmony_nullish()); + set_allow_harmony_optional_chaining(info->allow_harmony_optional_chaining()); set_allow_harmony_private_methods(info->allow_harmony_private_methods()); for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount; ++feature) { @@ -676,7 +677,7 @@ void Parser::ParseWrapped(Isolate* isolate, ParseInfo* info, FunctionLiteral* function_literal = ParseFunctionLiteral( function_name, location, kSkipFunctionNameCheck, kNormalFunction, - kNoSourcePosition, FunctionLiteral::kWrapped, LanguageMode::kSloppy, + kNoSourcePosition, FunctionSyntaxKind::kWrapped, LanguageMode::kSloppy, arguments_for_wrapped_function); Statement* return_statement = factory()->NewReturnStatement( @@ -728,20 +729,6 @@ FunctionLiteral* Parser::ParseFunction(Isolate* isolate, ParseInfo* info, return result; } -static FunctionLiteral::FunctionType ComputeFunctionType(ParseInfo* info) { - if (info->is_wrapped_as_function()) { - return FunctionLiteral::kWrapped; - } else if (info->is_declaration()) { - return FunctionLiteral::kDeclaration; - } else if (info->is_named_expression()) { - return FunctionLiteral::kNamedExpression; - } else if (IsConciseMethod(info->function_kind()) || - IsAccessorFunction(info->function_kind())) { - return FunctionLiteral::kAccessorOrMethod; - } - return FunctionLiteral::kAnonymousExpression; -} - FunctionLiteral* Parser::DoParseFunction(Isolate* isolate, ParseInfo* info, const AstRawString* raw_name) { DCHECK_EQ(parsing_on_main_thread_, isolate != nullptr); @@ -770,8 +757,10 @@ FunctionLiteral* Parser::DoParseFunction(Isolate* isolate, ParseInfo* info, BlockState block_state(&scope_, outer); DCHECK(is_sloppy(outer->language_mode()) || is_strict(info->language_mode())); - FunctionLiteral::FunctionType function_type = ComputeFunctionType(info); FunctionKind kind = info->function_kind(); + DCHECK_IMPLIES( + IsConciseMethod(kind) || IsAccessorFunction(kind), + info->function_syntax_kind() == FunctionSyntaxKind::kAccessorOrMethod); if (IsArrowFunction(kind)) { if (IsAsyncFunction(kind)) { @@ -857,8 +846,8 @@ FunctionLiteral* Parser::DoParseFunction(Isolate* isolate, ParseInfo* info, : nullptr; result = ParseFunctionLiteral( raw_name, Scanner::Location::invalid(), kSkipFunctionNameCheck, kind, - kNoSourcePosition, function_type, info->language_mode(), - arguments_for_wrapped_function); + kNoSourcePosition, info->function_syntax_kind(), + info->language_mode(), arguments_for_wrapped_function); } if (has_error()) return nullptr; @@ -1377,11 +1366,12 @@ VariableProxy* Parser::DeclareBoundVariable(const AstRawString* name, } void Parser::DeclareAndBindVariable(VariableProxy* proxy, VariableKind kind, - VariableMode mode, InitializationFlag init, - Scope* scope, bool* was_added, int begin, - int end) { - Variable* var = DeclareVariable(proxy->raw_name(), kind, mode, init, scope, - was_added, begin, end); + VariableMode mode, Scope* scope, + bool* was_added, int initializer_position) { + Variable* var = DeclareVariable( + proxy->raw_name(), kind, mode, Variable::DefaultInitializationFlag(mode), + scope, was_added, proxy->position(), kNoSourcePosition); + var->set_initializer_position(initializer_position); proxy->BindTo(var); } @@ -1791,9 +1781,9 @@ void Parser::ParseAndRewriteAsyncGeneratorFunctionBody( } void Parser::DeclareFunctionNameVar(const AstRawString* function_name, - FunctionLiteral::FunctionType function_type, + FunctionSyntaxKind function_syntax_kind, DeclarationScope* function_scope) { - if (function_type == FunctionLiteral::kNamedExpression && + if (function_syntax_kind == FunctionSyntaxKind::kNamedExpression && function_scope->LookupLocal(function_name) == nullptr) { DCHECK_EQ(function_scope, scope()); function_scope->DeclareFunctionVar(function_name); @@ -2238,7 +2228,7 @@ void Parser::PrepareGeneratorVariables() { FunctionLiteral* Parser::ParseFunctionLiteral( const AstRawString* function_name, Scanner::Location function_name_location, FunctionNameValidity function_name_validity, FunctionKind kind, - int function_token_pos, FunctionLiteral::FunctionType function_type, + int function_token_pos, FunctionSyntaxKind function_syntax_kind, LanguageMode language_mode, ZonePtrList<const AstRawString>* arguments_for_wrapped_function) { // Function :: @@ -2250,7 +2240,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral( // Setter :: // '(' PropertySetParameterList ')' '{' FunctionBody '}' - bool is_wrapped = function_type == FunctionLiteral::kWrapped; + bool is_wrapped = function_syntax_kind == FunctionSyntaxKind::kWrapped; DCHECK_EQ(is_wrapped, arguments_for_wrapped_function != nullptr); int pos = function_token_pos == kNoSourcePosition ? peek_position() @@ -2385,15 +2375,15 @@ FunctionLiteral* Parser::ParseFunctionLiteral( // try to lazy parse in the first place, we'll have to parse eagerly. bool did_preparse_successfully = should_preparse && - SkipFunction(function_name, kind, function_type, scope, &num_parameters, - &function_length, &produced_preparse_data); + SkipFunction(function_name, kind, function_syntax_kind, scope, + &num_parameters, &function_length, &produced_preparse_data); if (!did_preparse_successfully) { // If skipping aborted, it rewound the scanner until before the LPAREN. // Consume it in that case. if (should_preparse) Consume(Token::LPAREN); should_post_parallel_task = false; - ParseFunction(&body, function_name, pos, kind, function_type, scope, + ParseFunction(&body, function_name, pos, kind, function_syntax_kind, scope, &num_parameters, &function_length, &has_duplicate_parameters, &expected_property_count, &suspend_count, arguments_for_wrapped_function); @@ -2439,8 +2429,9 @@ FunctionLiteral* Parser::ParseFunctionLiteral( // Note that the FunctionLiteral needs to be created in the main Zone again. FunctionLiteral* function_literal = factory()->NewFunctionLiteral( function_name, scope, body, expected_property_count, num_parameters, - function_length, duplicate_parameters, function_type, eager_compile_hint, - pos, true, function_literal_id, produced_preparse_data); + function_length, duplicate_parameters, function_syntax_kind, + eager_compile_hint, pos, true, function_literal_id, + produced_preparse_data); function_literal->set_function_token_position(function_token_pos); function_literal->set_suspend_count(suspend_count); @@ -2458,7 +2449,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral( } bool Parser::SkipFunction(const AstRawString* function_name, FunctionKind kind, - FunctionLiteral::FunctionType function_type, + FunctionSyntaxKind function_syntax_kind, DeclarationScope* function_scope, int* num_parameters, int* function_length, ProducedPreparseData** produced_preparse_data) { @@ -2513,7 +2504,7 @@ bool Parser::SkipFunction(const AstRawString* function_name, FunctionKind kind, TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.PreParse"); PreParser::PreParseResult result = reusable_preparser()->PreParseFunction( - function_name, kind, function_type, function_scope, use_counts_, + function_name, kind, function_syntax_kind, function_scope, use_counts_, produced_preparse_data, this->script_id()); if (result == PreParser::kPreParseStackOverflow) { @@ -2555,7 +2546,7 @@ bool Parser::SkipFunction(const AstRawString* function_name, FunctionKind kind, closest_class_scope->MigrateUnresolvedPrivateNameTail( factory(), unresolved_private_tail); } - function_scope->AnalyzePartially(this, factory()); + function_scope->AnalyzePartially(this, factory(), MaybeParsingArrowhead()); } return true; @@ -2583,12 +2574,11 @@ Block* Parser::BuildParameterInitializationBlock( initial_value, kNoSourcePosition); } - Scope* param_scope = scope(); + DeclarationScope* param_scope = scope()->AsDeclarationScope(); ScopedPtrList<Statement>* param_init_statements = &init_statements; base::Optional<ScopedPtrList<Statement>> non_simple_param_init_statements; - if (!parameter->is_simple() && - scope()->AsDeclarationScope()->calls_sloppy_eval()) { + if (!parameter->is_simple() && param_scope->sloppy_eval_can_extend_vars()) { param_scope = NewVarblockScope(); param_scope->set_start_position(parameter->pattern->position()); param_scope->set_end_position(parameter->initializer_end_position); @@ -2613,7 +2603,7 @@ Block* Parser::BuildParameterInitializationBlock( factory()->NewBlock(true, *non_simple_param_init_statements); non_simple_param_init_statements.reset(); param_block->set_scope(param_scope); - param_scope = param_scope->FinalizeBlockScope(); + param_scope = param_scope->FinalizeBlockScope()->AsDeclarationScope(); init_statements.Add(param_block); } ++index; @@ -2678,7 +2668,7 @@ Expression* Parser::BuildInitialYield(int pos, FunctionKind kind) { void Parser::ParseFunction( ScopedPtrList<Statement>* body, const AstRawString* function_name, int pos, - FunctionKind kind, FunctionLiteral::FunctionType function_type, + FunctionKind kind, FunctionSyntaxKind function_syntax_kind, DeclarationScope* function_scope, int* num_parameters, int* function_length, bool* has_duplicate_parameters, int* expected_property_count, int* suspend_count, @@ -2687,7 +2677,7 @@ void Parser::ParseFunction( FunctionState function_state(&function_state_, &scope_, function_scope); - bool is_wrapped = function_type == FunctionLiteral::kWrapped; + bool is_wrapped = function_syntax_kind == FunctionSyntaxKind::kWrapped; int expected_parameters_end_pos = parameters_end_pos_; if (expected_parameters_end_pos != kNoSourcePosition) { @@ -2749,8 +2739,8 @@ void Parser::ParseFunction( *function_length = formals.function_length; AcceptINScope scope(this, true); - ParseFunctionBody(body, function_name, pos, formals, kind, function_type, - FunctionBodyType::kBlock); + ParseFunctionBody(body, function_name, pos, formals, kind, + function_syntax_kind, FunctionBodyType::kBlock); *has_duplicate_parameters = formals.has_duplicate(); @@ -2781,15 +2771,15 @@ Variable* Parser::CreateSyntheticContextVariable(const AstRawString* name) { return proxy->var(); } -Variable* Parser::CreatePrivateNameVariable( - ClassScope* scope, RequiresBrandCheckFlag requires_brand_check, - const AstRawString* name) { +Variable* Parser::CreatePrivateNameVariable(ClassScope* scope, + VariableMode mode, + const AstRawString* name) { DCHECK_NOT_NULL(name); int begin = position(); int end = end_position(); bool was_added = false; - Variable* var = - scope->DeclarePrivateName(name, requires_brand_check, &was_added); + DCHECK(IsConstVariableMode(mode)); + Variable* var = scope->DeclarePrivateName(name, mode, &was_added); if (!was_added) { Scanner::Location loc(begin, end); ReportMessageAt(loc, MessageTemplate::kVarRedeclaration, var->raw_name()); @@ -2824,14 +2814,8 @@ void Parser::DeclarePrivateClassMember(ClassScope* scope, ClassLiteralProperty* property, ClassLiteralProperty::Kind kind, bool is_static, ClassInfo* class_info) { - DCHECK_IMPLIES(kind == ClassLiteralProperty::Kind::METHOD, + DCHECK_IMPLIES(kind != ClassLiteralProperty::Kind::FIELD, allow_harmony_private_methods()); - // TODO(joyee): We do not support private accessors yet (which allow - // declaring the same private name twice). Make them noops. - if (kind != ClassLiteralProperty::Kind::FIELD && - kind != ClassLiteralProperty::Kind::METHOD) { - return; - } if (kind == ClassLiteralProperty::Kind::FIELD) { if (is_static) { @@ -2842,7 +2826,7 @@ void Parser::DeclarePrivateClassMember(ClassScope* scope, } Variable* private_name_var = - CreatePrivateNameVariable(scope, RequiresBrandCheck(kind), property_name); + CreatePrivateNameVariable(scope, GetVariableMode(kind), property_name); int pos = property->value()->position(); if (pos == kNoSourcePosition) { pos = property->key()->position(); @@ -2886,7 +2870,7 @@ FunctionLiteral* Parser::CreateInitializerFunction( FunctionLiteral* result = factory()->NewFunctionLiteral( ast_value_factory()->GetOneByteString(name), scope, statements, 0, 0, 0, FunctionLiteral::kNoDuplicateParameters, - FunctionLiteral::kAnonymousExpression, + FunctionSyntaxKind::kAccessorOrMethod, FunctionLiteral::kShouldEagerCompile, scope->start_position(), false, GetNextFunctionLiteralId()); @@ -3168,10 +3152,12 @@ ArrayLiteral* Parser::ArrayLiteralFromListWithSpread( Expression* Parser::SpreadCall(Expression* function, const ScopedPtrList<Expression>& args_list, - int pos, Call::PossiblyEval is_possibly_eval) { + int pos, Call::PossiblyEval is_possibly_eval, + bool optional_chain) { // Handle this case in BytecodeGenerator. if (OnlyLastArgIsSpread(args_list) || function->IsSuperCallReference()) { - return factory()->NewCall(function, args_list, pos); + return factory()->NewCall(function, args_list, pos, Call::NOT_EVAL, + optional_chain); } ScopedPtrList<Expression> args(pointer_buffer()); @@ -3186,8 +3172,9 @@ Expression* Parser::SpreadCall(Expression* function, VariableProxy* obj = factory()->NewVariableProxy(temp); Assignment* assign_obj = factory()->NewAssignment( Token::ASSIGN, obj, function->AsProperty()->obj(), kNoSourcePosition); - function = factory()->NewProperty( - assign_obj, function->AsProperty()->key(), kNoSourcePosition); + function = + factory()->NewProperty(assign_obj, function->AsProperty()->key(), + kNoSourcePosition, optional_chain); args.Add(function); obj = factory()->NewVariableProxy(temp); args.Add(obj); |