From af1a3fdf33588c6ff6da1be9605da8f0df6bcc50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Sat, 1 May 2021 12:00:43 +0200 Subject: [PATCH 1/2] deps: V8: cherry-pick 035c305ce776 Original commit message: [Intl] call new ListFormatter::createInstance The one we currently using is now marked as internal and to be removed for 68. Migrating to the style which already avaiable in ICU 67-1. Bug: v8:11031 Change-Id: I668382a2e1b8602ddca02bf231c5008a6c92bf2d Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2477751 Reviewed-by: Jakob Kummerow Commit-Queue: Frank Tang Cr-Commit-Position: refs/heads/master@{#70638} Refs: https://github.com/v8/v8/commit/035c305ce7761f51328b45f1bd83e26aef267c9d PR-URL: https://github.com/nodejs/node/pull/38497 Reviewed-By: Jiawen Geng --- common.gypi | 2 +- deps/v8/src/objects/js-list-format.cc | 55 +++++++++------------------ 2 files changed, 19 insertions(+), 38 deletions(-) diff --git a/common.gypi b/common.gypi index 32ceb385180688..34bf547d5e9147 100644 --- a/common.gypi +++ b/common.gypi @@ -34,7 +34,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.55', + 'v8_embedder_string': '-node.56', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/src/objects/js-list-format.cc b/deps/v8/src/objects/js-list-format.cc index 4f303b18745829..982e9a317e6808 100644 --- a/deps/v8/src/objects/js-list-format.cc +++ b/deps/v8/src/objects/js-list-format.cc @@ -29,46 +29,27 @@ namespace v8 { namespace internal { namespace { -const char* kStandard = "standard"; -const char* kOr = "or"; -const char* kUnit = "unit"; -const char* kStandardShort = "standard-short"; -const char* kOrShort = "or-short"; -const char* kUnitShort = "unit-short"; -const char* kStandardNarrow = "standard-narrow"; -const char* kOrNarrow = "or-narrow"; -const char* kUnitNarrow = "unit-narrow"; - -const char* GetIcuStyleString(JSListFormat::Style style, - JSListFormat::Type type) { + +UListFormatterWidth GetIcuWidth(JSListFormat::Style style) { + switch (style) { + case JSListFormat::Style::LONG: + return ULISTFMT_WIDTH_WIDE; + case JSListFormat::Style::SHORT: + return ULISTFMT_WIDTH_SHORT; + case JSListFormat::Style::NARROW: + return ULISTFMT_WIDTH_NARROW; + } + UNREACHABLE(); +} + +UListFormatterType GetIcuType(JSListFormat::Type type) { switch (type) { case JSListFormat::Type::CONJUNCTION: - switch (style) { - case JSListFormat::Style::LONG: - return kStandard; - case JSListFormat::Style::SHORT: - return kStandardShort; - case JSListFormat::Style::NARROW: - return kStandardNarrow; - } + return ULISTFMT_TYPE_AND; case JSListFormat::Type::DISJUNCTION: - switch (style) { - case JSListFormat::Style::LONG: - return kOr; - case JSListFormat::Style::SHORT: - return kOrShort; - case JSListFormat::Style::NARROW: - return kOrNarrow; - } + return ULISTFMT_TYPE_OR; case JSListFormat::Type::UNIT: - switch (style) { - case JSListFormat::Style::LONG: - return kUnit; - case JSListFormat::Style::SHORT: - return kUnitShort; - case JSListFormat::Style::NARROW: - return kUnitNarrow; - } + return ULISTFMT_TYPE_UNITS; } UNREACHABLE(); } @@ -170,7 +151,7 @@ MaybeHandle JSListFormat::New(Isolate* isolate, Handle map, icu::Locale icu_locale = r.icu_locale; UErrorCode status = U_ZERO_ERROR; icu::ListFormatter* formatter = icu::ListFormatter::createInstance( - icu_locale, GetIcuStyleString(style_enum, type_enum), status); + icu_locale, GetIcuType(type_enum), GetIcuWidth(style_enum), status); if (U_FAILURE(status)) { delete formatter; FATAL("Failed to create ICU list formatter, are ICU data files missing?"); From 7d8c7a44572910fb5230b843cfad740de7357282 Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Thu, 17 Jun 2021 16:10:14 -0400 Subject: [PATCH 2/2] deps: restore minimum ICU version to 65 This modifies 40df0dc so that the changes it applies are only used if ICU 67 or greater is used, and restores the previous code path for versions of ICU below 67. The minimum ICU version was bumped to 67 in Node.js 14.6.0 by https://github.com/nodejs/node/pull/34356 but the referenced V8 commit[1] isn't on `v14.x-staging` and appears to have been reverted on V8 8.4[2] so this PR also restores the minimum ICU version to 65. [1] https://github.com/v8/v8/commit/611e412768a7bc87a20d0315635b0bf76a5bab46 [2] https://github.com/v8/v8/commit/eeccedee1882f1f870b37d12978cd818934b375d PR-URL: https://github.com/nodejs/node/pull/39068 Reviewed-By: Michael Dawson Reviewed-By: Colin Ihrig Reviewed-By: Beth Griggs --- deps/v8/src/objects/js-list-format.cc | 51 +++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/deps/v8/src/objects/js-list-format.cc b/deps/v8/src/objects/js-list-format.cc index 982e9a317e6808..6363ef63cbf4e7 100644 --- a/deps/v8/src/objects/js-list-format.cc +++ b/deps/v8/src/objects/js-list-format.cc @@ -24,12 +24,58 @@ #include "unicode/fpositer.h" #include "unicode/listformatter.h" #include "unicode/ulistformatter.h" +#include "unicode/uvernum.h" namespace v8 { namespace internal { namespace { +#if U_ICU_VERSION_MAJOR_NUM < 67 +const char* kStandard = "standard"; +const char* kOr = "or"; +const char* kUnit = "unit"; +const char* kStandardShort = "standard-short"; +const char* kOrShort = "or-short"; +const char* kUnitShort = "unit-short"; +const char* kStandardNarrow = "standard-narrow"; +const char* kOrNarrow = "or-narrow"; +const char* kUnitNarrow = "unit-narrow"; + +const char* GetIcuStyleString(JSListFormat::Style style, + JSListFormat::Type type) { + switch (type) { + case JSListFormat::Type::CONJUNCTION: + switch (style) { + case JSListFormat::Style::LONG: + return kStandard; + case JSListFormat::Style::SHORT: + return kStandardShort; + case JSListFormat::Style::NARROW: + return kStandardNarrow; + } + case JSListFormat::Type::DISJUNCTION: + switch (style) { + case JSListFormat::Style::LONG: + return kOr; + case JSListFormat::Style::SHORT: + return kOrShort; + case JSListFormat::Style::NARROW: + return kOrNarrow; + } + case JSListFormat::Type::UNIT: + switch (style) { + case JSListFormat::Style::LONG: + return kUnit; + case JSListFormat::Style::SHORT: + return kUnitShort; + case JSListFormat::Style::NARROW: + return kUnitNarrow; + } + } + UNREACHABLE(); +} +#else UListFormatterWidth GetIcuWidth(JSListFormat::Style style) { switch (style) { case JSListFormat::Style::LONG: @@ -53,6 +99,7 @@ UListFormatterType GetIcuType(JSListFormat::Type type) { } UNREACHABLE(); } +#endif } // namespace @@ -151,7 +198,11 @@ MaybeHandle JSListFormat::New(Isolate* isolate, Handle map, icu::Locale icu_locale = r.icu_locale; UErrorCode status = U_ZERO_ERROR; icu::ListFormatter* formatter = icu::ListFormatter::createInstance( +#if U_ICU_VERSION_MAJOR_NUM < 67 + icu_locale, GetIcuStyleString(style_enum, type_enum), status); +#else icu_locale, GetIcuType(type_enum), GetIcuWidth(style_enum), status); +#endif if (U_FAILURE(status)) { delete formatter; FATAL("Failed to create ICU list formatter, are ICU data files missing?");