From e3cfbd9de99b66a24127561298a08a0dba01a40c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Wed, 16 Jun 2021 07:24:33 +0200 Subject: [PATCH] deps: V8: cherry-pick b0a7f5691113 Original commit message: Update to ICU68-1 ICU68-1 change the output skeleton format. So we need to change resolvedOptions code for 68 migration. Chromium roll https://chromium-review.googlesource.com/c/chromium/src/+/2474093 Bug: v8:10945 Change-Id: I3b2c7fbe8abb22df8fa51287c498ca3245b8c55b Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2477431 Commit-Queue: Frank Tang Reviewed-by: Jakob Kummerow Reviewed-by: Shu-yu Guo Cr-Commit-Position: refs/heads/master@{#70972} Refs: https://github.com/v8/v8/commit/b0a7f5691113534c2cf771f2dd3cece5e93bc7d4 --- common.gypi | 2 +- deps/v8/DEPS | 2 +- deps/v8/src/objects/js-number-format.cc | 80 ++++++++++--------------- deps/v8/test/cctest/test-api-icu.cc | 2 +- 4 files changed, 33 insertions(+), 53 deletions(-) diff --git a/common.gypi b/common.gypi index ef018284eb13a7..5755d8e4744393 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.73', + 'v8_embedder_string': '-node.74', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/DEPS b/deps/v8/DEPS index 9c347a078ba69e..6b47368456cd61 100644 --- a/deps/v8/DEPS +++ b/deps/v8/DEPS @@ -76,7 +76,7 @@ deps = { 'v8/third_party/depot_tools': Var('chromium_url') + '/chromium/tools/depot_tools.git' + '@' + 'd4e6fb6573e0955110a2c69be29557f6626d9ae6', 'v8/third_party/icu': - Var('chromium_url') + '/chromium/deps/icu.git' + '@' + 'f2223961702f00a8833874b0560d615a2cc42738', + Var('chromium_url') + '/chromium/deps/icu.git' + '@' + 'c2a4cae149aae7fd30c4cbe3cf1b30df03b386f1', 'v8/third_party/instrumented_libraries': Var('chromium_url') + '/chromium/src/third_party/instrumented_libraries.git' + '@' + 'bb3f1802c237dd19105dd0f7919f99e536a39d10', 'v8/buildtools': diff --git a/deps/v8/src/objects/js-number-format.cc b/deps/v8/src/objects/js-number-format.cc index c5b3d06fcafed9..8da733cd7cd4a4 100644 --- a/deps/v8/src/objects/js-number-format.cc +++ b/deps/v8/src/objects/js-number-format.cc @@ -389,17 +389,17 @@ Handle CurrencySignString(Isolate* isolate, Handle UnitDisplayString(Isolate* isolate, const icu::UnicodeString& skeleton) { // Ex: skeleton as - // "measure-unit/length-meter .### rounding-mode-half-up unit-width-full-name" + // "unit/length-meter .### rounding-mode-half-up unit-width-full-name" if (skeleton.indexOf("unit-width-full-name") >= 0) { return ReadOnlyRoots(isolate).long_string_handle(); } // Ex: skeleton as - // "measure-unit/length-meter .### rounding-mode-half-up unit-width-narrow". + // "unit/length-meter .### rounding-mode-half-up unit-width-narrow". if (skeleton.indexOf("unit-width-narrow") >= 0) { return ReadOnlyRoots(isolate).narrow_string_handle(); } // Ex: skeleton as - // "measure-unit/length-foot .### rounding-mode-half-up" + // "unit/length-foot .### rounding-mode-half-up" return ReadOnlyRoots(isolate).short_string_handle(); } @@ -422,7 +422,7 @@ Notation NotationFromSkeleton(const icu::UnicodeString& skeleton) { return Notation::COMPACT; } // Ex: skeleton as - // "measure-unit/length-foot .### rounding-mode-half-up" + // "unit/length-foot .### rounding-mode-half-up" return Notation::STANDARD; } @@ -562,14 +562,14 @@ namespace { // Ex: percent .### rounding-mode-half-up // Special case for "percent" -// Ex: "measure-unit/length-kilometer per-measure-unit/duration-hour .### -// rounding-mode-half-up" should return "kilometer-per-unit". -// Ex: "measure-unit/duration-year .### rounding-mode-half-up" should return +// Ex: "unit/milliliter-per-acre .### rounding-mode-half-up" +// should return "milliliter-per-acre". +// Ex: "unit/year .### rounding-mode-half-up" should return // "year". std::string UnitFromSkeleton(const icu::UnicodeString& skeleton) { std::string str; str = skeleton.toUTF8String(str); - std::string search("measure-unit/"); + std::string search("unit/"); size_t begin = str.find(search); if (begin == str.npos) { // Special case for "percent". @@ -578,64 +578,44 @@ std::string UnitFromSkeleton(const icu::UnicodeString& skeleton) { } return ""; } - // Skip the type (ex: "length"). - // "measure-unit/length-kilometer per-measure-unit/duration-hour" - // b - begin = str.find("-", begin + search.size()); + // Ex: + // "unit/acre .### rounding-mode-half-up" + // b + // Ex: + // "unit/milliliter-per-acre .### rounding-mode-half-up" + // b + begin += search.size(); if (begin == str.npos) { return ""; } - begin++; // Skip the '-'. // Find the end of the subtype. size_t end = str.find(" ", begin); - // "measure-unit/length-kilometer per-measure-unit/duration-hour" - // b e + // Ex: + // "unit/acre .### rounding-mode-half-up" + // b e + // Ex: + // "unit/milliliter-per-acre .### rounding-mode-half-up" + // b e if (end == str.npos) { end = str.size(); - return str.substr(begin, end - begin); - } - // "measure-unit/length-kilometer per-measure-unit/duration-hour" - // b e - // [result ] - std::string result = str.substr(begin, end - begin); - begin = end + 1; - // "measure-unit/length-kilometer per-measure-unit/duration-hour" - // [result ]eb - std::string search_per("per-measure-unit/"); - begin = str.find(search_per, begin); - // "measure-unit/length-kilometer per-measure-unit/duration-hour" - // [result ]e b - if (begin == str.npos) { - return result; - } - // Skip the type (ex: "duration"). - begin = str.find("-", begin + search_per.size()); - // "measure-unit/length-kilometer per-measure-unit/duration-hour" - // [result ]e b - if (begin == str.npos) { - return result; } - begin++; // Skip the '-'. - // "measure-unit/length-kilometer per-measure-unit/duration-hour" - // [result ]e b - end = str.find(" ", begin); - if (end == str.npos) { - end = str.size(); - } - // "measure-unit/length-kilometer per-measure-unit/duration-hour" - // [result ] b e - return result + "-per-" + str.substr(begin, end - begin); + return str.substr(begin, end - begin); } Style StyleFromSkeleton(const icu::UnicodeString& skeleton) { if (skeleton.indexOf("currency/") >= 0) { return Style::CURRENCY; } - if (skeleton.indexOf("measure-unit/") >= 0) { - if (skeleton.indexOf("scale/100") >= 0 && - skeleton.indexOf("measure-unit/concentr-percent") >= 0) { + if (skeleton.indexOf("percent") >= 0) { + // percent precision-integer rounding-mode-half-up scale/100 + if (skeleton.indexOf("scale/100") >= 0) { return Style::PERCENT; + } else { + return Style::UNIT; } + } + // Before ICU68: "measure-unit/", since ICU68 "unit/" + if (skeleton.indexOf("unit/") >= 0) { return Style::UNIT; } return Style::DECIMAL; diff --git a/deps/v8/test/cctest/test-api-icu.cc b/deps/v8/test/cctest/test-api-icu.cc index c5e617fdd2a2ac..8527ee72d365c6 100644 --- a/deps/v8/test/cctest/test-api-icu.cc +++ b/deps/v8/test/cctest/test-api-icu.cc @@ -47,7 +47,7 @@ TEST(LocaleConfigurationChangeNotification) { SetIcuLocale("zh_CN"); isolate->LocaleConfigurationChangeNotification(); - CheckLocaleSpecificValues("zh-CN", "2020/2/14 下午1:45:00", "10,000.3"); + CheckLocaleSpecificValues("zh-CN", "2020/2/14下午1:45:00", "10,000.3"); UErrorCode error_code = U_ZERO_ERROR; icu::Locale::setDefault(default_locale, error_code);