From 0c771c35fad1867d016d54dfdf018a219a4a0718 Mon Sep 17 00:00:00 2001 From: "Node.js GitHub Bot" Date: Sun, 25 Aug 2024 00:32:18 +0000 Subject: [PATCH] deps: patch V8 to 12.8.374.22 Refs: https://github.com/v8/v8/compare/12.8.374.13...12.8.374.22 PR-URL: https://github.com/nodejs/node/pull/54435 Reviewed-By: Rafael Gonzaga Reviewed-By: Jiawen Geng Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Marco Ippolito --- deps/v8/include/v8-version.h | 2 +- deps/v8/src/ast/scopes.cc | 22 +-- deps/v8/src/codegen/compiler.cc | 150 ++---------------- deps/v8/src/compiler/operation-typer.cc | 1 + deps/v8/src/flags/flag-definitions.h | 1 - deps/v8/src/objects/js-date-time-format.cc | 2 +- deps/v8/src/objects/scope-info.cc | 3 +- .../v8/src/objects/shared-function-info-inl.h | 10 +- deps/v8/src/objects/shared-function-info.cc | 11 -- deps/v8/src/objects/shared-function-info.h | 2 - .../v8/src/wasm/baseline/liftoff-assembler.cc | 35 +--- deps/v8/src/wasm/baseline/liftoff-assembler.h | 6 +- deps/v8/src/wasm/baseline/liftoff-compiler.cc | 2 +- deps/v8/src/wasm/wasm-js.cc | 8 +- deps/v8/test/intl/regress-40855035.js | 6 - deps/v8/test/mjsunit/wasm/stack-switching.js | 21 +++ 16 files changed, 71 insertions(+), 211 deletions(-) delete mode 100644 deps/v8/test/intl/regress-40855035.js diff --git a/deps/v8/include/v8-version.h b/deps/v8/include/v8-version.h index e038daf0b24877..e8ca1b5b46fa72 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 13 +#define V8_PATCH_LEVEL 22 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) diff --git a/deps/v8/src/ast/scopes.cc b/deps/v8/src/ast/scopes.cc index eef58fe37ec67f..d6f168e7258c48 100644 --- a/deps/v8/src/ast/scopes.cc +++ b/deps/v8/src/ast/scopes.cc @@ -2607,8 +2607,7 @@ void ModuleScope::AllocateModuleVariables() { } } -// Needs to be kept in sync with ScopeInfo::UniqueIdInScript and -// SharedFunctionInfo::UniqueIdInScript. +// 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. @@ -2801,10 +2800,9 @@ void DeclarationScope::AllocateScopeInfos(ParseInfo* info, Tagged outer = sfi->HasOuterScopeInfo() ? sfi->GetOuterScopeInfo() : Tagged(); - // Look at all inner functions whether they have scope infos that we should - // reuse. Also look at the compiled function itself, and reuse its function - // scope info if it exists. - for (int i = info->literal()->function_literal_id(); + // Look at all the existing inner functions (they are numbered id+1 until + // max_id+1) to reattach their outer scope infos to corresponding scopes. + for (int i = info->literal()->function_literal_id() + 1; i < info->max_info_id() + 1; ++i) { Tagged maybe_info = infos->get(i); if (maybe_info.IsWeak()) { @@ -2812,14 +2810,10 @@ void DeclarationScope::AllocateScopeInfos(ParseInfo* info, Tagged scope_info; if (Is(info)) { Tagged sfi = Cast(info); - if (!sfi->scope_info()->IsEmpty() && - sfi->scope_info()->HasContext()) { - scope_info = sfi->scope_info(); - } else if (sfi->HasOuterScopeInfo()) { - scope_info = sfi->GetOuterScopeInfo(); - } else { - continue; - } + // Reuse outer scope infos. Don't look at sfi->scope_info() because + // that might be empty if the sfi isn't compiled yet. + if (!sfi->HasOuterScopeInfo()) continue; + scope_info = sfi->GetOuterScopeInfo(); } else { scope_info = Cast(info); } diff --git a/deps/v8/src/codegen/compiler.cc b/deps/v8/src/codegen/compiler.cc index 2de8fe8ad32cb8..0a95368d3b904e 100644 --- a/deps/v8/src/codegen/compiler.cc +++ b/deps/v8/src/codegen/compiler.cc @@ -2022,39 +2022,18 @@ class ConstantPoolPointerForwarder { } void RecordScopeInfos(Tagged maybe_old_info) { - RecordScopeInfos(maybe_old_info.GetHeapObjectAssumeWeak()); - } - - // Record all scope infos relevant for a shared function info or scope info - // (recorded for eval). - void RecordScopeInfos(Tagged info) { Tagged scope_info; + Tagged info = maybe_old_info.GetHeapObjectAssumeWeak(); if (Is(info)) { Tagged old_sfi = Cast(info); - // Also record context-having own scope infos for SFIs. - if (!old_sfi->scope_info()->IsEmpty() && - old_sfi->scope_info()->HasContext()) { - scope_info = old_sfi->scope_info(); - } else if (old_sfi->HasOuterScopeInfo()) { - scope_info = old_sfi->GetOuterScopeInfo(); - } else { - return; - } + if (!old_sfi->HasOuterScopeInfo()) return; + scope_info = old_sfi->GetOuterScopeInfo(); } else { scope_info = Cast(info); } - while (true) { - auto it = scope_infos_to_update_.find(scope_info->UniqueIdInScript()); - if (it != scope_infos_to_update_.end()) { - // Once we find an already recorded scope info, it need to match the one - // on the chain. - if (V8_UNLIKELY(*it->second != scope_info)) { - info->Print(); - (*it->second)->Print(); - scope_info->Print(); - UNREACHABLE(); - } + if (scope_infos_to_update_.find(scope_info->UniqueIdInScript()) != + scope_infos_to_update_.end()) { return; } scope_infos_to_update_[scope_info->UniqueIdInScript()] = @@ -2083,51 +2062,17 @@ class ConstantPoolPointerForwarder { !scope_infos_to_update_.empty(); } - // Find an own scope info for the sfi based on the UniqueIdInScript that the - // own scope info would have. This works even if the SFI doesn't yet have a - // scope info attached by computing UniqueIdInScript from the SFI position. - // - // This should only directly be used for SFIs that already existed on the - // script. Their outer scope info will already be correct. - bool InstallOwnScopeInfo(Tagged sfi) { - auto it = scope_infos_to_update_.find(sfi->UniqueIdInScript()); - if (it == scope_infos_to_update_.end()) return false; - sfi->SetScopeInfo(*it->second); - return true; - } - - // Either replace the own scope info of the sfi, or the first outer scope info - // that was recorded. - // - // This has to be used for all newly created SFIs since their outer scope info - // also may need to be reattached. - void UpdateScopeInfo(Tagged sfi) { - // This should not be called on already existing SFIs. Their scope infos are - // already correct. - DCHECK_NE(MakeWeak(sfi), - old_script_->infos()->get(sfi->function_literal_id())); - if (InstallOwnScopeInfo(sfi)) return; + void UpdateOuterScopeInfo(Tagged sfi) { if (!sfi->HasOuterScopeInfo()) return; - - Tagged parent = - sfi->scope_info()->IsEmpty() ? Tagged() : sfi->scope_info(); Tagged outer_info = sfi->GetOuterScopeInfo(); - auto it = scope_infos_to_update_.find(outer_info->UniqueIdInScript()); - while (it == scope_infos_to_update_.end()) { - if (!outer_info->HasOuterScopeInfo()) return; - parent = outer_info; - outer_info = outer_info->OuterScopeInfo(); - it = scope_infos_to_update_.find(outer_info->UniqueIdInScript()); - } + if (it == scope_infos_to_update_.end()) return; if (outer_info == *it->second) return; - VerifyScopeInfo(outer_info, *it->second); - - if (parent.is_null()) { - sfi->set_raw_outer_scope_info_or_feedback_metadata(*it->second); + if (sfi->is_compiled()) { + sfi->scope_info()->set_outer_scope_info(*it->second); } else { - parent->set_outer_scope_info(*it->second); + sfi->set_raw_outer_scope_info_or_feedback_metadata(*it->second); } } @@ -2309,16 +2254,6 @@ void BackgroundMergeTask::BeginMergeInBackground( new_compiled_data_for_cached_sfis_.push_back( {local_heap->NewPersistentHandle(old_sfi), local_heap->NewPersistentHandle(new_sfi)}); - // Pick up existing scope infos from the old sfi. The new sfi will be - // copied over the old sfi later. This will ensure that we'll keep - // using the old sfis. This will also allow us check later whether new - // scope infos have appeared that need to be reused. - if (!old_sfi->scope_info()->IsEmpty()) { - new_sfi->SetScopeInfo(old_sfi->scope_info()); - } else if (old_sfi->HasOuterScopeInfo()) { - new_sfi->scope_info()->set_outer_scope_info( - old_sfi->GetOuterScopeInfo()); - } forwarder.AddBytecodeArray(new_sfi->GetBytecodeArray(isolate)); } } else { @@ -2343,23 +2278,13 @@ void BackgroundMergeTask::BeginMergeInBackground( if (forwarder.HasAnythingToForward()) { for (DirectHandle new_sfi : used_new_sfis_) { - forwarder.UpdateScopeInfo(*new_sfi); - } - for (const auto& new_compiled_data : new_compiled_data_for_cached_sfis_) { - // It's possible that new_compiled_data.cached_sfi had - // scope_info()->IsEmpty() while an inner function has scope info if the - // cached_sfi was recreated when an outer function was recompiled. If so, - // new_compiled_data.new_sfi does not have a reused scope info yet, and - // we'll have found it when we visited the inner function. Try to pick it - // up here. - forwarder.InstallOwnScopeInfo(*new_compiled_data.new_sfi); + forwarder.UpdateOuterScopeInfo(*new_sfi); } forwarder.IterateAndForwardPointers(); } persistent_handles_ = local_heap->DetachPersistentHandles(); state_ = kPendingForegroundWork; } - Handle BackgroundMergeTask::CompleteMergeInForeground( Isolate* isolate, DirectHandle