From 9087056060a71f2b274295ad6cbe1a5c8068bc98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Mon, 9 Sep 2024 18:20:23 +0200 Subject: [PATCH] deps: patch V8 to 12.8.374.31 Refs: https://github.com/v8/v8/compare/12.8.374.22...12.8.374.31 PR-URL: https://github.com/nodejs/node/pull/54682 Reviewed-By: Antoine du Hamel Reviewed-By: Rafael Gonzaga Reviewed-By: Jiawen Geng Reviewed-By: James M Snell --- deps/v8/include/v8-version.h | 2 +- .../ast/ast-function-literal-id-reindexer.cc | 7 - .../ast/ast-function-literal-id-reindexer.h | 1 - deps/v8/src/ast/ast.h | 43 ++- deps/v8/src/ast/scopes.cc | 117 +------ deps/v8/src/ast/scopes.h | 22 +- deps/v8/src/builtins/builtins-function.cc | 9 +- deps/v8/src/codegen/background-merge-task.h | 2 +- deps/v8/src/codegen/compiler.cc | 303 ++++++------------ deps/v8/src/codegen/compiler.h | 5 +- deps/v8/src/common/globals.h | 2 +- deps/v8/src/d8/d8.cc | 56 ++-- deps/v8/src/debug/debug-evaluate.cc | 8 +- deps/v8/src/debug/debug.cc | 9 +- deps/v8/src/debug/liveedit.cc | 11 +- deps/v8/src/diagnostics/objects-debug.cc | 9 +- deps/v8/src/diagnostics/objects-printer.cc | 2 +- deps/v8/src/execution/isolate.cc | 36 ++- deps/v8/src/flags/flag-definitions.h | 5 - deps/v8/src/heap/factory-base.cc | 3 +- deps/v8/src/heap/factory.cc | 3 +- deps/v8/src/heap/incremental-marking.cc | 62 ++++ deps/v8/src/heap/incremental-marking.h | 1 + deps/v8/src/heap/object-stats.cc | 5 +- deps/v8/src/heap/object-stats.h | 2 +- deps/v8/src/heap/scavenger.cc | 1 + deps/v8/src/init/bootstrapper.cc | 2 +- deps/v8/src/interpreter/bytecode-generator.cc | 2 +- deps/v8/src/interpreter/interpreter.cc | 2 +- deps/v8/src/maglev/maglev-graph-builder.cc | 13 +- deps/v8/src/maglev/maglev-graph-builder.h | 2 +- deps/v8/src/objects/module.cc | 2 +- deps/v8/src/objects/objects.cc | 7 +- deps/v8/src/objects/scope-info.cc | 16 +- deps/v8/src/objects/scope-info.h | 2 - deps/v8/src/objects/script-inl.h | 17 +- deps/v8/src/objects/script.h | 8 +- deps/v8/src/objects/script.tq | 2 +- .../v8/src/objects/shared-function-info-inl.h | 13 +- deps/v8/src/objects/shared-function-info.cc | 28 +- deps/v8/src/objects/shared-function-info.h | 4 +- deps/v8/src/objects/source-text-module.cc | 7 +- deps/v8/src/parsing/parse-info.cc | 2 +- deps/v8/src/parsing/parse-info.h | 8 +- deps/v8/src/parsing/parser-base.h | 73 +++-- deps/v8/src/parsing/parser.cc | 47 +-- deps/v8/src/parsing/preparser-logger.h | 10 +- deps/v8/src/parsing/preparser.cc | 9 +- deps/v8/src/parsing/preparser.h | 7 +- .../src/profiler/heap-snapshot-generator.cc | 5 +- deps/v8/src/runtime/runtime-compiler.cc | 18 +- deps/v8/src/runtime/runtime-wasm.cc | 2 + .../compactible-external-entity-table.h | 2 +- deps/v8/src/sandbox/external-pointer-table.cc | 45 ++- deps/v8/src/sandbox/external-pointer-table.h | 4 + deps/v8/src/snapshot/code-serializer.cc | 5 +- deps/v8/src/wasm/canonical-types.cc | 26 +- deps/v8/src/wasm/graph-builder-interface.cc | 10 +- deps/v8/src/wasm/value-type.h | 1 + deps/v8/test/cctest/heap/test-heap.cc | 2 +- deps/v8/test/cctest/test-debug.cc | 2 +- deps/v8/test/cctest/test-serialize.cc | 27 +- deps/v8/test/cctest/wasm/wasm-run-utils.cc | 3 +- .../modules-async-error-parent-entry.mjs} | 4 +- .../mjsunit/harmony/modules-import-16.mjs | 6 +- ...odules-skip-async-error-parent-dynamic.mjs | 0 ...odules-skip-async-error-parent-static1.mjs | 6 + ...dules-skip-async-error-parent-static2.mjs} | 10 +- .../modules-skip-async-error-parent.mjs | 10 + .../test/mjsunit/maglev/regress-362784006.js | 19 ++ .../test/mjsunit/maglev/regress-363983041.js | 14 + deps/v8/test/mjsunit/regress-352414652.js | 13 - deps/v8/test/mjsunit/regress-352739458.js | 13 - deps/v8/test/mjsunit/regress-353561476.js | 40 --- .../test/mjsunit/regress-4530868594868224.js | 22 -- .../mjsunit/regress/wasm/regress-361862737.js | 31 ++ .../test/mjsunit/test-scopeinfo-reuse-eval.js | 15 - .../unittests/api/deserialize-unittest.cc | 20 +- .../unittests/heap/local-factory-unittest.cc | 7 +- .../CallLookupSlot.golden | 2 +- .../bytecode_expectations/Eval.golden | 2 +- .../bytecode_expectations/ForOfLoop.golden | 2 +- .../bytecode_expectations/LookupSlot.golden | 10 +- .../StandardForLoop.golden | 2 +- .../test/unittests/parser/parsing-unittest.cc | 36 ++- deps/v8/test/unittests/test-helpers.cc | 2 +- 86 files changed, 673 insertions(+), 774 deletions(-) rename deps/v8/test/mjsunit/{regress-352402518.js => harmony/modules-async-error-parent-entry.mjs} (71%) create mode 100644 deps/v8/test/mjsunit/harmony/modules-skip-async-error-parent-dynamic.mjs create mode 100644 deps/v8/test/mjsunit/harmony/modules-skip-async-error-parent-static1.mjs rename deps/v8/test/mjsunit/{regress-class-initializer-eval.js => harmony/modules-skip-async-error-parent-static2.mjs} (57%) create mode 100644 deps/v8/test/mjsunit/harmony/modules-skip-async-error-parent.mjs create mode 100644 deps/v8/test/mjsunit/maglev/regress-362784006.js create mode 100644 deps/v8/test/mjsunit/maglev/regress-363983041.js delete mode 100644 deps/v8/test/mjsunit/regress-352414652.js delete mode 100644 deps/v8/test/mjsunit/regress-352739458.js delete mode 100644 deps/v8/test/mjsunit/regress-353561476.js delete mode 100644 deps/v8/test/mjsunit/regress-4530868594868224.js create mode 100644 deps/v8/test/mjsunit/regress/wasm/regress-361862737.js delete mode 100644 deps/v8/test/mjsunit/test-scopeinfo-reuse-eval.js diff --git a/deps/v8/include/v8-version.h b/deps/v8/include/v8-version.h index e8ca1b5b46fa72..4904bcb6615a45 100644 --- a/deps/v8/include/v8-version.h +++ b/deps/v8/include/v8-version.h @@ -11,7 +11,7 @@ #define V8_MAJOR_VERSION 12 #define V8_MINOR_VERSION 8 #define V8_BUILD_NUMBER 374 -#define V8_PATCH_LEVEL 22 +#define V8_PATCH_LEVEL 31 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) diff --git a/deps/v8/src/ast/ast-function-literal-id-reindexer.cc b/deps/v8/src/ast/ast-function-literal-id-reindexer.cc index c0892994528850..7c5030d090c7ea 100644 --- a/deps/v8/src/ast/ast-function-literal-id-reindexer.cc +++ b/deps/v8/src/ast/ast-function-literal-id-reindexer.cc @@ -31,13 +31,6 @@ void AstFunctionLiteralIdReindexer::VisitFunctionLiteral(FunctionLiteral* lit) { lit->set_function_literal_id(lit->function_literal_id() + delta_); } -void AstFunctionLiteralIdReindexer::VisitCall(Call* expr) { - AstTraversalVisitor::VisitCall(expr); - if (expr->is_possibly_eval()) { - expr->adjust_eval_scope_info_index(delta_); - } -} - void AstFunctionLiteralIdReindexer::VisitClassLiteral(ClassLiteral* expr) { // Manually visit the class literal so that we can change the property walk. // This should be kept in-sync with AstTraversalVisitor::VisitClassLiteral. diff --git a/deps/v8/src/ast/ast-function-literal-id-reindexer.h b/deps/v8/src/ast/ast-function-literal-id-reindexer.h index f7a41e0a9a5314..21eaeafd20273f 100644 --- a/deps/v8/src/ast/ast-function-literal-id-reindexer.h +++ b/deps/v8/src/ast/ast-function-literal-id-reindexer.h @@ -30,7 +30,6 @@ class AstFunctionLiteralIdReindexer final // AstTraversalVisitor implementation. void VisitFunctionLiteral(FunctionLiteral* lit); void VisitClassLiteral(ClassLiteral* lit); - void VisitCall(Call* lit); private: int delta_; diff --git a/deps/v8/src/ast/ast.h b/deps/v8/src/ast/ast.h index 53976fed46997b..5c1004c99a05c3 100644 --- a/deps/v8/src/ast/ast.h +++ b/deps/v8/src/ast/ast.h @@ -1731,7 +1731,7 @@ class CallBase : public Expression { class Call final : public CallBase { public: bool is_possibly_eval() const { - return EvalScopeInfoIndexField::decode(bit_field_) > 0; + return IsPossiblyEvalField::decode(bit_field_); } bool is_tagged_template() const { @@ -1742,15 +1742,6 @@ class Call final : public CallBase { return IsOptionalChainLinkField::decode(bit_field_); } - uint32_t eval_scope_info_index() const { - return EvalScopeInfoIndexField::decode(bit_field_); - } - - void adjust_eval_scope_info_index(int delta) { - bit_field_ = EvalScopeInfoIndexField::update( - bit_field_, eval_scope_info_index() + delta); - } - enum CallType { GLOBAL_CALL, WITH_CALL, @@ -1766,6 +1757,11 @@ class Call final : public CallBase { OTHER_CALL, }; + enum PossiblyEval { + IS_POSSIBLY_EVAL, + NOT_EVAL, + }; + // Helpers to determine how to handle the call. CallType GetCallType() const; @@ -1777,26 +1773,26 @@ class Call final : public CallBase { Call(Zone* zone, Expression* expression, const ScopedPtrList& arguments, int pos, bool has_spread, - int eval_scope_info_index, bool optional_chain) + PossiblyEval possibly_eval, bool optional_chain) : CallBase(zone, kCall, expression, arguments, pos, has_spread) { - bit_field_ |= IsTaggedTemplateField::encode(false) | - IsOptionalChainLinkField::encode(optional_chain) | - EvalScopeInfoIndexField::encode(eval_scope_info_index); - DCHECK_EQ(eval_scope_info_index > 0, is_possibly_eval()); + bit_field_ |= + IsPossiblyEvalField::encode(possibly_eval == IS_POSSIBLY_EVAL) | + IsTaggedTemplateField::encode(false) | + IsOptionalChainLinkField::encode(optional_chain); } Call(Zone* zone, Expression* expression, const ScopedPtrList& arguments, int pos, TaggedTemplateTag tag) : CallBase(zone, kCall, expression, arguments, pos, false) { - bit_field_ |= IsTaggedTemplateField::encode(true) | - IsOptionalChainLinkField::encode(false) | - EvalScopeInfoIndexField::encode(0); + bit_field_ |= IsPossiblyEvalField::encode(false) | + IsTaggedTemplateField::encode(true) | + IsOptionalChainLinkField::encode(false); } - using IsTaggedTemplateField = CallBase::NextBitField; + using IsPossiblyEvalField = CallBase::NextBitField; + using IsTaggedTemplateField = IsPossiblyEvalField::Next; using IsOptionalChainLinkField = IsTaggedTemplateField::Next; - using EvalScopeInfoIndexField = IsOptionalChainLinkField::Next; }; class CallNew final : public CallBase { @@ -3188,11 +3184,12 @@ class AstNodeFactory final { Call* NewCall(Expression* expression, const ScopedPtrList& arguments, int pos, - bool has_spread, int eval_scope_info_index = 0, + bool has_spread, + Call::PossiblyEval possibly_eval = Call::NOT_EVAL, bool optional_chain = false) { - DCHECK_IMPLIES(eval_scope_info_index > 0, !optional_chain); + DCHECK_IMPLIES(possibly_eval == Call::IS_POSSIBLY_EVAL, !optional_chain); return zone_->New(zone_, expression, arguments, pos, has_spread, - eval_scope_info_index, optional_chain); + possibly_eval, optional_chain); } SuperCallForwardArgs* NewSuperCallForwardArgs(SuperCallReference* expression, diff --git a/deps/v8/src/ast/scopes.cc b/deps/v8/src/ast/scopes.cc index e2b2405aaae8fb..109ce824b57f51 100644 --- a/deps/v8/src/ast/scopes.cc +++ b/deps/v8/src/ast/scopes.cc @@ -2607,23 +2607,6 @@ void ModuleScope::AllocateModuleVariables() { } } -// Needs to be kept in sync with ScopeInfo::UniqueIdInScript. -int Scope::UniqueIdInScript() const { - // Script scopes start "before" the script to avoid clashing with a scope that - // starts on character 0. - if (is_script_scope() || scope_type() == EVAL_SCOPE || - scope_type() == MODULE_SCOPE) { - return -1; - } - if (is_declaration_scope()) { - // Default constructors have the same start position as their parent class - // scope. Use the next char position to distinguish this scope. - return start_position() + - IsDefaultConstructor(AsDeclarationScope()->function_kind()); - } - return start_position(); -} - void Scope::AllocateVariablesRecursively() { this->ForEach([](Scope* scope) -> Iteration { DCHECK(!scope->already_resolved_); @@ -2675,63 +2658,33 @@ void Scope::AllocateVariablesRecursively() { } template -void Scope::AllocateScopeInfosRecursively( - IsolateT* isolate, MaybeHandle outer_scope, - std::unordered_map>& scope_infos_to_reuse) { +void Scope::AllocateScopeInfosRecursively(IsolateT* isolate, + MaybeHandle outer_scope) { DCHECK(scope_info_.is_null()); MaybeHandle next_outer_scope = outer_scope; - auto it = scope_infos_to_reuse.find(UniqueIdInScript()); - if (it != scope_infos_to_reuse.end()) { - scope_info_ = it->second; - CHECK(NeedsContext()); - // The ScopeInfo chain mirrors the context chain, so we only link to the - // next outer scope that needs a context. - next_outer_scope = scope_info_; - DCHECK(!scope_info_.is_null()); - DCHECK(!is_hidden_catch_scope()); - CHECK_EQ(scope_info_->scope_type(), scope_type_); - CHECK_EQ(scope_info_->ContextLength(), num_heap_slots_); -#ifdef DEBUG - // Consume the scope info. - it->second = {}; -#endif - } else if (NeedsScopeInfo()) { -#ifdef DEBUG - // Mark this ID as being used. Skip hidden scopes because they are - // synthetic, unreusable, but hard to make unique. - if (v8_flags.reuse_scope_infos && !is_hidden_catch_scope()) { - scope_infos_to_reuse[UniqueIdInScript()] = {}; - } -#endif + if (NeedsScopeInfo()) { scope_info_ = ScopeInfo::Create(isolate, zone(), this, outer_scope); - DCHECK_EQ(UniqueIdInScript(), scope_info_->UniqueIdInScript()); - // The ScopeInfo chain mirrors the context chain, so we only link to the - // next outer scope that needs a context. + // The ScopeInfo chain should mirror the context chain, so we only link to + // the next outer scope that needs a context. if (NeedsContext()) next_outer_scope = scope_info_; } // Allocate ScopeInfos for inner scopes. for (Scope* scope = inner_scope_; scope != nullptr; scope = scope->sibling_) { - DCHECK_GT(scope->UniqueIdInScript(), UniqueIdInScript()); - DCHECK_IMPLIES(scope->sibling_, scope->sibling_->UniqueIdInScript() != - scope->UniqueIdInScript()); if (!scope->is_function_scope() || scope->AsDeclarationScope()->ShouldEagerCompile()) { - scope->AllocateScopeInfosRecursively(isolate, next_outer_scope, - scope_infos_to_reuse); + scope->AllocateScopeInfosRecursively(isolate, next_outer_scope); } } } template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) void Scope:: - AllocateScopeInfosRecursively( - Isolate* isolate, MaybeHandle outer_scope, - std::unordered_map>& scope_infos_to_reuse); + AllocateScopeInfosRecursively(Isolate* isolate, + MaybeHandle outer_scope); template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) void Scope:: AllocateScopeInfosRecursively( - LocalIsolate* isolate, MaybeHandle outer_scope, - std::unordered_map>& scope_infos_to_reuse); + LocalIsolate* isolate, MaybeHandle outer_scope); void DeclarationScope::RecalcPrivateNameContextChain() { // The outermost scope in a class heritage expression is marked to skip the @@ -2776,9 +2729,7 @@ void DeclarationScope::RecordNeedsPrivateNameContextChainRecalc() { // static template -void DeclarationScope::AllocateScopeInfos(ParseInfo* info, - Handle