Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v14.x] deps: V8: cherry-pick b0a7f5691113 #39051

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -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.76',

##### V8 defaults for Node.js #####

Expand Down
2 changes: 1 addition & 1 deletion deps/v8/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
80 changes: 30 additions & 50 deletions deps/v8/src/objects/js-number-format.cc
Original file line number Diff line number Diff line change
Expand Up @@ -389,17 +389,17 @@ Handle<String> CurrencySignString(Isolate* isolate,
Handle<String> 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();
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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<std::string>(str);
std::string search("measure-unit/");
std::string search("unit/");
size_t begin = str.find(search);
if (begin == str.npos) {
// Special case for "percent".
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/test/cctest/test-api-icu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 5 additions & 3 deletions deps/v8/test/intl/regress-1074578.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ const df2 = new Intl.DateTimeFormat(
const d3 = new Date("2020-03-09T00:00Z");
const d4 = new Date("2021-03-09T00:00Z");

// Before tz202a change will get "March 8, 2020 at 5:00:00 PM PDT"
assertEquals("March 8, 2020 at 5:00:00 PM MST", df2.format(d3));
// Before tz2020a change will get "March 8, 2020 at 5:00:00 PM PDT"
// In tz2020a it should be "March 8, 2020 at 5:00:00 PM MST"
// but tz2020b roll this back.
assertEquals("March 8, 2020 at 5:00:00 PM PDT", df2.format(d3));

// Before tz202a change will get "March 8, 2021 at 4:00:00 PM PST"
// Before tz2020a change will get "March 8, 2021 at 4:00:00 PM PST"
assertEquals("March 8, 2021 at 5:00:00 PM MST", df2.format(d4));

// C. Test America/Nuuk renamed from America/Godthab.
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/test/intl/regress-7982.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ assertEquals("zh-TW-u-ca-chinese", new Intl.Locale("zh-TW-u-ca-chinese").minimiz
assertEquals("zh-Hant-HK-u-ca-chinese", new Intl.Locale("zh-HK-u-ca-chinese").maximize().toString());
assertEquals("zh-HK-u-ca-chinese", new Intl.Locale("zh-HK-u-ca-chinese").minimize().toString());
assertEquals("zh-Hant-TW-u-ca-chinese", new Intl.Locale("zh-Hant-u-ca-chinese").maximize().toString());
assertEquals("zh-Hant-u-ca-chinese", new Intl.Locale("zh-Hant-u-ca-chinese").minimize().toString());
assertEquals("zh-TW-u-ca-chinese", new Intl.Locale("zh-Hant-u-ca-chinese").minimize().toString());
assertEquals("zh-Hans-CN-u-ca-chinese", new Intl.Locale("zh-Hans-u-ca-chinese").maximize().toString());
assertEquals("zh-u-ca-chinese", new Intl.Locale("zh-Hans-u-ca-chinese").minimize().toString());
assertEquals("zh-Hant-CN-u-ca-chinese", new Intl.Locale("zh-Hant-CN-u-ca-chinese").maximize().toString());
Expand Down
3 changes: 0 additions & 3 deletions deps/v8/test/test262/test262.status
Original file line number Diff line number Diff line change
Expand Up @@ -507,9 +507,6 @@
'intl402/Intl/getCanonicalLocales/unicode-ext-canonicalize-yes-to-true': [FAIL],
'intl402/Intl/getCanonicalLocales/unicode-ext-key-with-digit': [FAIL],

# http://crbug/v8/10448
'intl402/Locale/prototype/minimize/removing-likely-subtags-first-adds-likely-subtags': [FAIL],

# https://bugs.chromium.org/p/v8/issues/detail?id=9646
'built-ins/ThrowTypeError/name': [FAIL],
'language/expressions/class/name': [FAIL],
Expand Down
7 changes: 7 additions & 0 deletions test/parallel/test-intl.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ if (!common.hasIntl) {
const numberFormat = new Intl.NumberFormat(['en']).format(12345.67890);
assert.strictEqual(numberFormat, '12,345.679');
}
// Number format resolved options
{
const numberFormat = new Intl.NumberFormat('en-US', { style: 'percent' });
const resolvedOptions = numberFormat.resolvedOptions();
assert.strictEqual(resolvedOptions.locale, 'en-US');
assert.strictEqual(resolvedOptions.style, 'percent');
}
// Significant Digits
{
const loc = ['en-US'];
Expand Down