From b533a51856978877cc8e164ce2f481c4dcbc2f7e Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Fri, 20 Sep 2024 13:17:30 -0400 Subject: [PATCH] deps: V8: backport 0d5d6e71bbb0 Original commit message: Remove `--js-promise-withresolvers` runtime flag Co-authored-by: Antoine du Hamel Bug: 42204122 Change-Id: I017a0d1ae0f8225513206ffb7806a4250be75d4c Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5843972 Reviewed-by: Igor Sheludko Commit-Queue: Erik Corry Reviewed-by: Shu-yu Guo Cr-Commit-Position: refs/heads/main@{#96215} Refs: https://github.com/v8/v8/commit/0d5d6e71bbb0d2b0a12567fffa7e3375c427bc92 PR-URL: https://github.com/nodejs/node/pull/55115 Backport-PR-URL: https://github.com/nodejs/node/pull/55260 Reviewed-By: Jiawen Geng Reviewed-By: Luigi Pinca --- common.gypi | 2 +- deps/v8/src/flags/flag-definitions.h | 3 +-- deps/v8/src/init/bootstrapper.cc | 26 +++++++------------ .../mjsunit/harmony/promise-withresolvers.js | 2 +- deps/v8/test/test262/testcfg.py | 1 - 5 files changed, 12 insertions(+), 22 deletions(-) diff --git a/common.gypi b/common.gypi index b8db901423620c..de83a566724a36 100644 --- a/common.gypi +++ b/common.gypi @@ -36,7 +36,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.20', + 'v8_embedder_string': '-node.21', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/src/flags/flag-definitions.h b/deps/v8/src/flags/flag-definitions.h index 0d50ac1522ef87..340d770020a6d0 100644 --- a/deps/v8/src/flags/flag-definitions.h +++ b/deps/v8/src/flags/flag-definitions.h @@ -299,8 +299,7 @@ DEFINE_BOOL(js_shipping, true, "enable all shipped JavaScript features") V(harmony_set_methods, "harmony Set Methods") \ V(harmony_import_attributes, "harmony import attributes") -#define JAVASCRIPT_SHIPPING_FEATURES_BASE(V) \ - V(js_promise_withresolvers, "Promise.withResolvers") +#define JAVASCRIPT_SHIPPING_FEATURES_BASE(V) #ifdef V8_INTL_SUPPORT #define HARMONY_SHIPPING(V) HARMONY_SHIPPING_BASE(V) diff --git a/deps/v8/src/init/bootstrapper.cc b/deps/v8/src/init/bootstrapper.cc index 0d5b3ec7e9a455..3b151ea3e86a16 100644 --- a/deps/v8/src/init/bootstrapper.cc +++ b/deps/v8/src/init/bootstrapper.cc @@ -3217,6 +3217,15 @@ void Genesis::InitializeGlobal(Handle global_object, InstallFunctionWithBuiltinId(isolate_, promise_fun, "reject", Builtin::kPromiseReject, 1, true); + std::array, 3> fields{factory->promise_string(), + factory->resolve_string(), + factory->reject_string()}; + DirectHandle result_map = + CreateLiteralObjectMapFromCache(isolate_, fields); + native_context()->set_promise_withresolvers_result_map(*result_map); + InstallFunctionWithBuiltinId(isolate_, promise_fun, "withResolvers", + Builtin::kPromiseWithResolvers, 0, true); + SetConstructorInstanceType(isolate_, promise_fun, JS_PROMISE_CONSTRUCTOR_TYPE); @@ -5445,23 +5454,6 @@ void Genesis::InitializeGlobal_harmony_iterator_helpers() { #undef ITERATOR_HELPERS } -void Genesis::InitializeGlobal_js_promise_withresolvers() { - if (!v8_flags.js_promise_withresolvers) return; - - Factory* factory = isolate()->factory(); - - std::array, 3> fields{factory->promise_string(), - factory->resolve_string(), - factory->reject_string()}; - Handle result_map = CreateLiteralObjectMapFromCache(isolate(), fields); - native_context()->set_promise_withresolvers_result_map(*result_map); - - Handle promise_fun = - handle(native_context()->promise_function(), isolate()); - InstallFunctionWithBuiltinId(isolate(), promise_fun, "withResolvers", - Builtin::kPromiseWithResolvers, 0, true); -} - void Genesis::InitializeGlobal_harmony_set_methods() { if (!v8_flags.harmony_set_methods) return; diff --git a/deps/v8/test/mjsunit/harmony/promise-withresolvers.js b/deps/v8/test/mjsunit/harmony/promise-withresolvers.js index 9cb244a73fb653..9466a6ab5ba78c 100644 --- a/deps/v8/test/mjsunit/harmony/promise-withresolvers.js +++ b/deps/v8/test/mjsunit/harmony/promise-withresolvers.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --js-promise-withresolvers --allow-natives-syntax +// Flags: --allow-natives-syntax const desc = Object.getOwnPropertyDescriptor(Promise, 'withResolvers'); assertTrue(desc.configurable); diff --git a/deps/v8/test/test262/testcfg.py b/deps/v8/test/test262/testcfg.py index ec4fad84078075..10b6243926396f 100644 --- a/deps/v8/test/test262/testcfg.py +++ b/deps/v8/test/test262/testcfg.py @@ -58,7 +58,6 @@ 'json-parse-with-source': '--harmony-json-parse-with-source', 'iterator-helpers': '--harmony-iterator-helpers', 'set-methods': '--harmony-set-methods', - 'promise-with-resolvers': '--js-promise-withresolvers', 'Array.fromAsync': '--harmony-array-from-async', 'import-attributes': '--harmony-import-attributes', 'regexp-duplicate-named-groups': '--js-regexp-duplicate-named-groups',