Title: [281513] trunk
Revision
281513
Author
[email protected]
Date
2021-08-24 12:28:30 -0700 (Tue, 24 Aug 2021)

Log Message

[JSC] Add Intl Enumeration APIs
https://bugs.webkit.org/show_bug.cgi?id=214795

Reviewed by Ross Kirsling.

JSTests:

* stress/intl-datetimeformat.js:
* stress/intl-enumeration.js: Added.
(shouldBe):
(shouldThrow):
* stress/intl-locale-info.js:
(let.l.new.Intl.Locale.shouldBe):
(shouldBe):

Source/_javascript_Core:

This patch implements Intl enumeration API[1] which is in stage-3.
Supported keys are, "calendar", "collation", "currency", "numberingSystem", "timeZone", and "unit".

[1]: https://github.com/tc39/proposal-intl-enumeration

* runtime/IntlDateTimeFormat.cpp:
(JSC::IntlDateTimeFormat::localeData):
(JSC::IntlDateTimeFormat::initializeDateTimeFormat):
* runtime/IntlLocale.cpp:
(JSC::createArrayFromStringVector): Deleted.
* runtime/IntlNumberFormat.cpp:
(JSC::sanctionedSimpleUnitIdentifier):
* runtime/IntlObject.cpp:
(JSC::IntlObject::finishCreation):
(JSC::mapICUCalendarKeywordToBCP47):
(JSC::availableCalendars):
(JSC::availableCollations):
(JSC::availableCurrencies):
(JSC::availableNumberingSystems):
(JSC::canonicalizeTimeZoneNameFromICUTimeZone):
(JSC::availableTimeZones):
(JSC::availableUnits):
(JSC::JSC_DEFINE_HOST_FUNCTION):
(JSC::createArrayFromStringVector):
* runtime/IntlObject.h:
* runtime/OptionsList.h:

Source/WTF:

* wtf/text/StringImpl.cpp:
(WTF::StringImpl::createFromLiteral):
* wtf/text/StringImpl.h:

Modified Paths

Added Paths

Diff

Modified: trunk/JSTests/ChangeLog (281512 => 281513)


--- trunk/JSTests/ChangeLog	2021-08-24 19:15:10 UTC (rev 281512)
+++ trunk/JSTests/ChangeLog	2021-08-24 19:28:30 UTC (rev 281513)
@@ -1,3 +1,18 @@
+2021-08-24  Yusuke Suzuki  <[email protected]>
+
+        [JSC] Add Intl Enumeration APIs
+        https://bugs.webkit.org/show_bug.cgi?id=214795
+
+        Reviewed by Ross Kirsling.
+
+        * stress/intl-datetimeformat.js:
+        * stress/intl-enumeration.js: Added.
+        (shouldBe):
+        (shouldThrow):
+        * stress/intl-locale-info.js:
+        (let.l.new.Intl.Locale.shouldBe):
+        (shouldBe):
+
 2021-08-24  Keith Miller  <[email protected]>
 
         (r281473) stress/for-in-has-own-property-shouldnt-flush-registers.js failing on Debug

Modified: trunk/JSTests/stress/intl-datetimeformat.js (281512 => 281513)


--- trunk/JSTests/stress/intl-datetimeformat.js	2021-08-24 19:15:10 UTC (rev 281512)
+++ trunk/JSTests/stress/intl-datetimeformat.js	2021-08-24 19:28:30 UTC (rev 281513)
@@ -314,7 +314,7 @@
 shouldBe(Intl.DateTimeFormat('en-u-ca-chinese').resolvedOptions().calendar, 'chinese');
 shouldBe(Intl.DateTimeFormat('en-u-ca-coptic').resolvedOptions().calendar, 'coptic');
 shouldBe(Intl.DateTimeFormat('en-u-ca-dangi').resolvedOptions().calendar, 'dangi');
-shouldBeForICUVersion(62, Intl.DateTimeFormat('en-u-ca-ethioaa').resolvedOptions().calendar, 'ethiopic-amete-alem');
+shouldBeForICUVersion(62, Intl.DateTimeFormat('en-u-ca-ethioaa').resolvedOptions().calendar, 'ethioaa');
 shouldBe(Intl.DateTimeFormat('en-u-ca-ethiopic').resolvedOptions().calendar, 'ethiopic');
 shouldBe(Intl.DateTimeFormat('ar-SA-u-ca-gregory').resolvedOptions().calendar, 'gregory');
 shouldBe(Intl.DateTimeFormat('en-u-ca-hebrew').resolvedOptions().calendar, 'hebrew');
@@ -325,7 +325,7 @@
 shouldBe(Intl.DateTimeFormat('en-u-ca-japanese').resolvedOptions().calendar, 'japanese');
 shouldBe(Intl.DateTimeFormat('en-u-ca-persian').resolvedOptions().calendar, 'persian');
 shouldBe(Intl.DateTimeFormat('en-u-ca-roc').resolvedOptions().calendar, 'roc');
-shouldBeForICUVersion(62, Intl.DateTimeFormat('en-u-ca-ethiopic-amete-alem').resolvedOptions().calendar, 'ethiopic-amete-alem');
+shouldBeForICUVersion(62, Intl.DateTimeFormat('en-u-ca-ethiopic-amete-alem').resolvedOptions().calendar, 'ethioaa');
 shouldBe(Intl.DateTimeFormat('en-u-ca-islamic-umalqura').resolvedOptions().calendar, 'islamic-umalqura');
 shouldBe(Intl.DateTimeFormat('en-u-ca-islamic-tbla').resolvedOptions().calendar, 'islamic-tbla');
 shouldBe(Intl.DateTimeFormat('en-u-ca-islamic-civil').resolvedOptions().calendar, 'islamic-civil');

Added: trunk/JSTests/stress/intl-enumeration.js (0 => 281513)


--- trunk/JSTests/stress/intl-enumeration.js	                        (rev 0)
+++ trunk/JSTests/stress/intl-enumeration.js	2021-08-24 19:28:30 UTC (rev 281513)
@@ -0,0 +1,39 @@
+function shouldBe(actual, expected) {
+    if (actual !== expected)
+        throw new Error(`expected ${expected} but got ${actual}`);
+}
+
+function shouldThrow(func, errorType) {
+    let error;
+    try {
+        func();
+    } catch (e) {
+        error = e;
+    }
+
+    if (!(error instanceof errorType))
+        throw new Error(`Expected ${errorType.name}!`);
+}
+
+let calendars = Intl.supportedValuesOf("calendar");
+shouldBe(JSON.stringify(calendars), `["buddhist","chinese","coptic","dangi","ethioaa","ethiopic","gregory","hebrew","indian","islamic","islamic-civil","islamic-rgsa","islamic-tbla","islamic-umalqura","iso8601","japanese","persian","roc"]`);
+
+let collations = Intl.supportedValuesOf("collation");
+shouldBe(JSON.stringify(collations), `["big5han","compat","dict","gb2312","phonebk","phonetic","pinyin","reformed","searchjl","stroke","trad","unihan","zhuyin"]`);
+
+let currencies = Intl.supportedValuesOf("currency");
+shouldBe(JSON.stringify(currencies), `["AED","AFN","ALL","AMD","ANG","AOA","ARS","AUD","AWG","AZN","BAM","BBD","BDT","BGN","BHD","BIF","BMD","BND","BOB","BRL","BSD","BTN","BWP","BYN","BZD","CAD","CDF","CHF","CLP","CNY","COP","CRC","CUC","CUP","CVE","CZK","DJF","DKK","DOP","DZD","EGP","ERN","ETB","EUR","FJD","FKP","GBP","GEL","GHS","GIP","GMD","GNF","GTQ","GYD","HKD","HNL","HRK","HTG","HUF","IDR"
 ;,"ILS","INR","IQD","IRR","ISK","JMD","JOD","JPY","KES","KGS","KHR","KMF","KPW","KRW","KWD","KYD","KZT","LAK","LBP","LKR","LRD","LSL","LYD","MAD","MDL","MGA","MKD","MMK","MNT","MOP","MRU","MUR","MVR","MWK","MXN","MYR","MZN","NAD","NGN","NIO","NOK","NPR","NZD","OMR","PAB","PEN","PGK","PHP","PKR","PLN","PYG","QAR","RON","RSD","RUB","RWF","SAR","SBD","SCR","SDG","SEK","SGD",&qu
 ot;SHP","SLL","SOS","SRD","SSP","STN","SYP","SZL","THB","TJS","TMT","TND","TOP","TRY","TTD","TWD","TZS","UAH","UGX","USD","UYU","UZS","VEF","VND","VUV","WST","XAF","XCD","XOF","XPF","YER","ZAR","ZMW"]`);
+
+let numberingSystems = Intl.supportedValuesOf("numberingSystem");
+let numberingSystemsString = JSON.stringify(numberingSystems);
+shouldBe(numberingSystemsString === `["adlm","ahom","arab","arabext","armn","armnlow","bali","beng","bhks","brah","cakm","cham","cyrl","deva","diak","ethi","fullwide","geor","gong","gonm","grek","greklow","gujr","guru","hanidays","hanidec","hans","hansfin","hant","hantfin","hebr","hmng","hmnp","java","jpan","jpanfin","jpanyear","kali","khmr","knda","lana","lanatham","laoo","latn","lepc","limb","mathbold","mathdbl","mathmono","mathsanb","mathsans","mlym","modi",&q
 uot;mong","mroo","mtei","mymr","mymrshan","mymrtlng","newa","nkoo","olck","orya","osma","rohg","roman","romanlow","saur","segment","shrd","sind","sinh","sora","sund","takr","talu","taml","tamldec","telu","thai","tibt","tirh","vaii","wara","wcho"]` || numberingSystemsString === `["adlm","ahom","arab","arabext","armn","armnlow","bali","beng","bhks","brah","cakm","cham","cyrl","deva","ethi","fullwide","geor","gong","gonm","grek","greklow","gujr","guru"
 ;,"hanidays","hanidec","hans","hansfin","hant","hantfin","hebr","hmng","hmnp","java","jpan","jpanfin","jpanyear","kali","khmr","knda","lana","lanatham","laoo","latn","lepc","limb","mathbold","mathdbl","mathmono","mathsanb","mathsans","mlym","modi","mong","mroo","mtei","mymr","mymrshan","mymrtlng","newa","nkoo","olck","orya","osma","rohg","roman","romanlow","saur","shrd","sind","sinh","sora","sund","takr","talu","taml","tamldec","telu","thai",&
 quot;tibt","tirh","vaii","wara","wcho"]`, true);
+
+let timeZones = Intl.supportedValuesOf("timeZone");
+shouldBe(JSON.stringify(timeZones), `["Africa/Abidjan","Africa/Accra","Africa/Addis_Ababa","Africa/Algiers","Africa/Asmera","Africa/Bamako","Africa/Bangui","Africa/Banjul","Africa/Bissau","Africa/Blantyre","Africa/Brazzaville","Africa/Bujumbura","Africa/Cairo","Africa/Casablanca","Africa/Ceuta","Africa/Conakry","Africa/Dakar","Africa/Dar_es_Salaam","Africa/Djibouti","Africa/Douala","Africa/El_Aaiun","Africa/Freetown","Africa/Gaborone","Africa/Harare","Africa/Johannesburg","Africa/Juba","Africa/Kampala","Africa/Khartoum","Africa/Kigali","Africa/Kinshasa","Africa/Lagos","Africa/Libreville","Africa/Lome","Africa/Luanda","Africa/Lubumbashi",&q
 uot;Africa/Lusaka","Africa/Malabo","Africa/Maputo","Africa/Maseru","Africa/Mbabane","Africa/Mogadishu","Africa/Monrovia","Africa/Nairobi","Africa/Ndjamena","Africa/Niamey","Africa/Nouakchott","Africa/Ouagadougou","Africa/Porto-Novo","Africa/Sao_Tome","Africa/Tripoli","Africa/Tunis","Africa/Windhoek","America/Adak","America/Anchorage","America/Anguilla","America/Antigua","America/Araguaina","America/Argentina/La_Rioja","America/Argentina/Rio_Gallegos","America/Argentina/Salta","America/Argentina/San_Juan","America/Argentina/San_Luis","America/Argentina/Tucuman","America/Argentina/Ushuaia","America/Aruba","America/Asuncion","America/Bahia","America/Bahia_Banderas",&
 quot;America/Barbados","America/Belem","America/Belize","America/Blanc-Sablon","America/Boa_Vista","America/Bogota","America/Boise","America/Buenos_Aires","America/Cambridge_Bay","America/Campo_Grande","America/Cancun","America/Caracas","America/Catamarca","America/Cayenne","America/Cayman","America/Chicago","America/Chihuahua","America/Coral_Harbour","America/Cordoba","America/Costa_Rica","America/Creston","America/Cuiaba","America/Curacao","America/Danmarkshavn","America/Dawson","America/Dawson_Creek","America/Denver","America/Detroit","America/Dominica","America/Edmonton","America/Eirunepe","America/El_Salvador","America/Fort_Nelson","America/Fortaleza&quo
 t;,"America/Glace_Bay","America/Godthab","America/Goose_Bay","America/Grand_Turk","America/Grenada","America/Guadeloupe","America/Guatemala","America/Guayaquil","America/Guyana","America/Halifax","America/Havana","America/Hermosillo","America/Indiana/Knox","America/Indiana/Marengo","America/Indiana/Petersburg","America/Indiana/Tell_City","America/Indiana/Vevay","America/Indiana/Vincennes","America/Indiana/Winamac","America/Indianapolis","America/Inuvik","America/Iqaluit","America/Jamaica","America/Jujuy","America/Juneau","America/Kentucky/Monticello","America/Kralendijk","America/La_Paz","America/Lima","America/Los_Angeles","America/Louisville","America/Lower_Princes",
 "America/Maceio","America/Managua","America/Manaus","America/Marigot","America/Martinique","America/Matamoros","America/Mazatlan","America/Mendoza","America/Menominee","America/Merida","America/Metlakatla","America/Mexico_City","America/Miquelon","America/Moncton","America/Monterrey","America/Montevideo","America/Montreal","America/Montserrat","America/Nassau","America/New_York","America/Nipigon","America/Nome","America/Noronha","America/North_Dakota/Beulah","America/North_Dakota/Center","America/North_Dakota/New_Salem","America/Ojinaga","America/Panama","America/Pangnirtung","America/Paramaribo","America/Phoenix","America/Port-au-Prince","America/Port_of_Spain&qu
 ot;,"America/Porto_Velho","America/Puerto_Rico","America/Punta_Arenas","America/Rainy_River","America/Rankin_Inlet","America/Recife","America/Regina","America/Resolute","America/Rio_Branco","America/Santa_Isabel","America/Santarem","America/Santiago","America/Santo_Domingo","America/Sao_Paulo","America/Scoresbysund","America/Sitka","America/St_Barthelemy","America/St_Johns","America/St_Kitts","America/St_Lucia","America/St_Thomas","America/St_Vincent","America/Swift_Current","America/Tegucigalpa","America/Thule","America/Thunder_Bay","America/Tijuana","America/Toronto","America/Tortola","America/Vancouver","America/Whitehorse","America/Winnipeg","America/Yakutat&q
 uot;,"America/Yellowknife","Antarctica/Casey","Antarctica/Davis","Antarctica/DumontDUrville","Antarctica/Macquarie","Antarctica/Mawson","Antarctica/McMurdo","Antarctica/Palmer","Antarctica/Rothera","Antarctica/Syowa","Antarctica/Troll","Antarctica/Vostok","Arctic/Longyearbyen","Asia/Aden","Asia/Almaty","Asia/Amman","Asia/Anadyr","Asia/Aqtau","Asia/Aqtobe","Asia/Ashgabat","Asia/Atyrau","Asia/Baghdad","Asia/Bahrain","Asia/Baku","Asia/Bangkok","Asia/Barnaul","Asia/Beirut","Asia/Bishkek","Asia/Brunei","Asia/Calcutta","Asia/Chita","Asia/Choibalsan","Asia/Colombo","Asia/Damascus","Asia/Dhaka","Asia/Dili","Asia/Dubai","As
 ia/Dushanbe","Asia/Famagusta","Asia/Gaza","Asia/Hebron","Asia/Hong_Kong","Asia/Hovd","Asia/Irkutsk","Asia/Jakarta","Asia/Jayapura","Asia/Jerusalem","Asia/Kabul","Asia/Kamchatka","Asia/Karachi","Asia/Katmandu","Asia/Khandyga","Asia/Krasnoyarsk","Asia/Kuala_Lumpur","Asia/Kuching","Asia/Kuwait","Asia/Macau","Asia/Magadan","Asia/Makassar","Asia/Manila","Asia/Muscat","Asia/Nicosia","Asia/Novokuznetsk","Asia/Novosibirsk","Asia/Omsk","Asia/Oral","Asia/Phnom_Penh","Asia/Pontianak","Asia/Pyongyang","Asia/Qatar","Asia/Qostanay","Asia/Qyzylorda","Asia/Rangoon","Asia/Riyadh","Asia/Saigon","Asia/Sakhalin","Asia/S
 amarkand","Asia/Seoul","Asia/Shanghai","Asia/Singapore","Asia/Srednekolymsk","Asia/Taipei","Asia/Tashkent","Asia/Tbilisi","Asia/Tehran","Asia/Thimphu","Asia/Tokyo","Asia/Tomsk","Asia/Ulaanbaatar","Asia/Urumqi","Asia/Ust-Nera","Asia/Vientiane","Asia/Vladivostok","Asia/Yakutsk","Asia/Yekaterinburg","Asia/Yerevan","Atlantic/Azores","Atlantic/Bermuda","Atlantic/Canary","Atlantic/Cape_Verde","Atlantic/Faeroe","Atlantic/Madeira","Atlantic/Reykjavik","Atlantic/South_Georgia","Atlantic/St_Helena","Atlantic/Stanley","Australia/Adelaide","Australia/Brisbane","Australia/Broken_Hill","Australia/Currie","Australia/Darwin","Australia/Eucla","A
 ustralia/Hobart","Australia/Lindeman","Australia/Lord_Howe","Australia/Melbourne","Australia/Perth","Australia/Sydney","Europe/Amsterdam","Europe/Andorra","Europe/Astrakhan","Europe/Athens","Europe/Belgrade","Europe/Berlin","Europe/Bratislava","Europe/Brussels","Europe/Bucharest","Europe/Budapest","Europe/Busingen","Europe/Chisinau","Europe/Copenhagen","Europe/Dublin","Europe/Gibraltar","Europe/Guernsey","Europe/Helsinki","Europe/Isle_of_Man","Europe/Istanbul","Europe/Jersey","Europe/Kaliningrad","Europe/Kiev","Europe/Kirov","Europe/Lisbon","Europe/Ljubljana","Europe/London","Europe/Luxembourg","Europe/Madrid","Europe/Malta","Europe/Marieh
 amn","Europe/Minsk","Europe/Monaco","Europe/Moscow","Europe/Oslo","Europe/Paris","Europe/Podgorica","Europe/Prague","Europe/Riga","Europe/Rome","Europe/Samara","Europe/San_Marino","Europe/Sarajevo","Europe/Saratov","Europe/Simferopol","Europe/Skopje","Europe/Sofia","Europe/Stockholm","Europe/Tallinn","Europe/Tirane","Europe/Ulyanovsk","Europe/Uzhgorod","Europe/Vaduz","Europe/Vatican","Europe/Vienna","Europe/Vilnius","Europe/Volgograd","Europe/Warsaw","Europe/Zagreb","Europe/Zaporozhye","Europe/Zurich","Indian/Antananarivo","Indian/Chagos","Indian/Christmas","Indian/Cocos","Indian/Comoro","Indian/Kerguelen","Indian/Mahe&
 quot;,"Indian/Maldives","Indian/Mauritius","Indian/Mayotte","Indian/Reunion","Pacific/Apia","Pacific/Auckland","Pacific/Bougainville","Pacific/Chatham","Pacific/Easter","Pacific/Efate","Pacific/Enderbury","Pacific/Fakaofo","Pacific/Fiji","Pacific/Funafuti","Pacific/Galapagos","Pacific/Gambier","Pacific/Guadalcanal","Pacific/Guam","Pacific/Honolulu","Pacific/Johnston","Pacific/Kiritimati","Pacific/Kosrae","Pacific/Kwajalein","Pacific/Majuro","Pacific/Marquesas","Pacific/Midway","Pacific/Nauru","Pacific/Niue","Pacific/Norfolk","Pacific/Noumea","Pacific/Pago_Pago","Pacific/Palau","Pacific/Pitcairn","Pacific/Ponape","Pacific/Port_Moresby",&quo
 t;Pacific/Rarotonga","Pacific/Saipan","Pacific/Tahiti","Pacific/Tarawa","Pacific/Tongatapu","Pacific/Truk","Pacific/Wake","Pacific/Wallis"]`);
+
+let units = Intl.supportedValuesOf("unit");
+shouldBe(JSON.stringify(units), `["acre","bit","byte","celsius","centimeter","day","degree","fahrenheit","fluid-ounce","foot","gallon","gigabit","gigabyte","gram","hectare","hour","inch","kilobit","kilobyte","kilogram","kilometer","liter","megabit","megabyte","meter","mile","mile-scandinavian","milliliter","millimeter","millisecond","minute","month","ounce","percent","petabyte","pound","second","stone","terabit","terabyte","week","yard","year"]`);
+
+shouldThrow(() => {
+    Intl.supportedValuesOf("invalid");
+}, RangeError);

Modified: trunk/JSTests/stress/intl-locale-info.js (281512 => 281513)


--- trunk/JSTests/stress/intl-locale-info.js	2021-08-24 19:15:10 UTC (rev 281512)
+++ trunk/JSTests/stress/intl-locale-info.js	2021-08-24 19:28:30 UTC (rev 281513)
@@ -17,7 +17,7 @@
 }
 {
     let locale = new Intl.Locale("ar")
-    shouldBe(JSON.stringify(locale.calendars), `["gregory","coptic","islamic","islamicc","islamic-tbla"]`);
+    shouldBe(JSON.stringify(locale.calendars), `["gregory","coptic","islamic","islamic-civil","islamic-tbla"]`);
     shouldBe(JSON.stringify(locale.collations), `["compat","emoji","eor"]`);
     shouldBe(JSON.stringify(locale.hourCycles), `["h12"]`);
     let ns = JSON.stringify(locale.numberingSystems);
@@ -26,7 +26,7 @@
 }
 {
     let locale = new Intl.Locale("ar-EG")
-    shouldBe(JSON.stringify(locale.calendars), `["gregory","coptic","islamic","islamicc","islamic-tbla"]`);
+    shouldBe(JSON.stringify(locale.calendars), `["gregory","coptic","islamic","islamic-civil","islamic-tbla"]`);
     shouldBe(JSON.stringify(locale.collations), `["compat","emoji","eor"]`);
     shouldBe(JSON.stringify(locale.hourCycles), `["h12"]`);
     shouldBe(JSON.stringify(locale.numberingSystems), `["arab"]`);
@@ -99,7 +99,7 @@
 }
 {
     let locale = new Intl.Locale("fa")
-    shouldBe(JSON.stringify(locale.calendars), `["persian","gregory","islamic","islamicc","islamic-tbla"]`);
+    shouldBe(JSON.stringify(locale.calendars), `["persian","gregory","islamic","islamic-civil","islamic-tbla"]`);
     shouldBe(JSON.stringify(locale.collations), `["emoji","eor"]`);
     shouldBe(JSON.stringify(locale.hourCycles), `["h23"]`);
     shouldBe(JSON.stringify(locale.numberingSystems), `["arabext"]`);

Modified: trunk/Source/_javascript_Core/ChangeLog (281512 => 281513)


--- trunk/Source/_javascript_Core/ChangeLog	2021-08-24 19:15:10 UTC (rev 281512)
+++ trunk/Source/_javascript_Core/ChangeLog	2021-08-24 19:28:30 UTC (rev 281513)
@@ -1,3 +1,37 @@
+2021-08-24  Yusuke Suzuki  <[email protected]>
+
+        [JSC] Add Intl Enumeration APIs
+        https://bugs.webkit.org/show_bug.cgi?id=214795
+
+        Reviewed by Ross Kirsling.
+
+        This patch implements Intl enumeration API[1] which is in stage-3.
+        Supported keys are, "calendar", "collation", "currency", "numberingSystem", "timeZone", and "unit".
+
+        [1]: https://github.com/tc39/proposal-intl-enumeration
+
+        * runtime/IntlDateTimeFormat.cpp:
+        (JSC::IntlDateTimeFormat::localeData):
+        (JSC::IntlDateTimeFormat::initializeDateTimeFormat):
+        * runtime/IntlLocale.cpp:
+        (JSC::createArrayFromStringVector): Deleted.
+        * runtime/IntlNumberFormat.cpp:
+        (JSC::sanctionedSimpleUnitIdentifier):
+        * runtime/IntlObject.cpp:
+        (JSC::IntlObject::finishCreation):
+        (JSC::mapICUCalendarKeywordToBCP47):
+        (JSC::availableCalendars):
+        (JSC::availableCollations):
+        (JSC::availableCurrencies):
+        (JSC::availableNumberingSystems):
+        (JSC::canonicalizeTimeZoneNameFromICUTimeZone):
+        (JSC::availableTimeZones):
+        (JSC::availableUnits):
+        (JSC::JSC_DEFINE_HOST_FUNCTION):
+        (JSC::createArrayFromStringVector):
+        * runtime/IntlObject.h:
+        * runtime/OptionsList.h:
+
 2021-08-24  Keith Miller  <[email protected]>
 
         (r281473) stress/for-in-has-own-property-shouldnt-flush-registers.js failing on Debug

Modified: trunk/Source/_javascript_Core/runtime/IntlDateTimeFormat.cpp (281512 => 281513)


--- trunk/Source/_javascript_Core/runtime/IntlDateTimeFormat.cpp	2021-08-24 19:15:10 UTC (rev 281512)
+++ trunk/Source/_javascript_Core/runtime/IntlDateTimeFormat.cpp	2021-08-24 19:28:30 UTC (rev 281513)
@@ -165,6 +165,9 @@
             ASSERT(U_SUCCESS(status));
             String calendar = String(availableName, nameLength);
             keyLocaleData.append(calendar);
+            // Adding "islamicc" candidate for backward compatibility.
+            if (calendar == "islamic-civil"_s)
+                keyLocaleData.append("islamicc"_s);
             if (auto mapped = mapICUCalendarKeywordToBCP47(calendar))
                 keyLocaleData.append(WTFMove(mapped.value()));
         }
@@ -579,13 +582,13 @@
         return;
     }
 
-    m_calendar = resolved.extensions[static_cast<unsigned>(RelevantExtensionKey::Ca)];
-    if (m_calendar == "gregorian")
-        m_calendar = "gregory"_s;
-    else if (m_calendar == "islamicc")
-        m_calendar = "islamic-civil"_s;
-    else if (m_calendar == "ethioaa")
-        m_calendar = "ethiopic-amete-alem"_s;
+    {
+        String calendar = resolved.extensions[static_cast<unsigned>(RelevantExtensionKey::Ca)];
+        if (auto mapped = mapICUCalendarKeywordToBCP47(calendar))
+            m_calendar = WTFMove(mapped.value());
+        else
+            m_calendar = WTFMove(calendar);
+    }
 
     hourCycle = parseHourCycle(resolved.extensions[static_cast<unsigned>(RelevantExtensionKey::Hc)]);
     m_numberingSystem = resolved.extensions[static_cast<unsigned>(RelevantExtensionKey::Nu)];

Modified: trunk/Source/_javascript_Core/runtime/IntlLocale.cpp (281512 => 281513)


--- trunk/Source/_javascript_Core/runtime/IntlLocale.cpp	2021-08-24 19:15:10 UTC (rev 281512)
+++ trunk/Source/_javascript_Core/runtime/IntlLocale.cpp	2021-08-24 19:28:30 UTC (rev 281513)
@@ -537,23 +537,6 @@
     return m_numeric;
 }
 
-static inline JSArray* createArrayFromStringVector(JSGlobalObject* globalObject, Vector<String, 1>&& elements)
-{
-    VM& vm = globalObject->vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    JSArray* result = JSArray::tryCreate(vm, globalObject->arrayStructureForIndexingTypeDuringAllocation(ArrayWithContiguous), elements.size());
-    if (!result) {
-        throwOutOfMemoryError(globalObject, scope);
-        return nullptr;
-    }
-    for (unsigned index = 0; index < elements.size(); ++index) {
-        result->putDirectIndex(globalObject, index, jsString(vm, WTFMove(elements[index])));
-        RETURN_IF_EXCEPTION(scope, { });
-    }
-    return result;
-}
-
 JSArray* IntlLocale::calendars(JSGlobalObject* globalObject)
 {
     VM& vm = globalObject->vm();

Modified: trunk/Source/_javascript_Core/runtime/IntlNumberFormat.cpp (281512 => 281513)


--- trunk/Source/_javascript_Core/runtime/IntlNumberFormat.cpp	2021-08-24 19:15:10 UTC (rev 281512)
+++ trunk/Source/_javascript_Core/runtime/IntlNumberFormat.cpp	2021-08-24 19:28:30 UTC (rev 281513)
@@ -151,59 +151,8 @@
     return 2;
 }
 
-// Create MeasureUnit like ICU4J.
-struct MeasureUnit {
-    ASCIILiteral type;
-    ASCIILiteral subType;
-};
-
 static std::optional<MeasureUnit> sanctionedSimpleUnitIdentifier(StringView unitIdentifier)
 {
-    static constexpr MeasureUnit simpleUnits[] = {
-        { "area"_s, "acre"_s },
-        { "digital"_s, "bit"_s },
-        { "digital"_s, "byte"_s },
-        { "temperature"_s, "celsius"_s },
-        { "length"_s, "centimeter"_s },
-        { "duration"_s, "day"_s },
-        { "angle"_s, "degree"_s },
-        { "temperature"_s, "fahrenheit"_s },
-        { "volume"_s, "fluid-ounce"_s },
-        { "length"_s, "foot"_s },
-        { "volume"_s, "gallon"_s },
-        { "digital"_s, "gigabit"_s },
-        { "digital"_s, "gigabyte"_s },
-        { "mass"_s, "gram"_s },
-        { "area"_s, "hectare"_s },
-        { "duration"_s, "hour"_s },
-        { "length"_s, "inch"_s },
-        { "digital"_s, "kilobit"_s },
-        { "digital"_s, "kilobyte"_s },
-        { "mass"_s, "kilogram"_s },
-        { "length"_s, "kilometer"_s },
-        { "volume"_s, "liter"_s },
-        { "digital"_s, "megabit"_s },
-        { "digital"_s, "megabyte"_s },
-        { "length"_s, "meter"_s },
-        { "length"_s, "mile"_s },
-        { "length"_s, "mile-scandinavian"_s },
-        { "volume"_s, "milliliter"_s },
-        { "length"_s, "millimeter"_s },
-        { "duration"_s, "millisecond"_s },
-        { "duration"_s, "minute"_s },
-        { "duration"_s, "month"_s },
-        { "mass"_s, "ounce"_s },
-        { "concentr"_s, "percent"_s },
-        { "digital"_s, "petabyte"_s },
-        { "mass"_s, "pound"_s },
-        { "duration"_s, "second"_s },
-        { "mass"_s, "stone"_s },
-        { "digital"_s, "terabit"_s },
-        { "digital"_s, "terabyte"_s },
-        { "duration"_s, "week"_s },
-        { "length"_s, "yard"_s },
-        { "duration"_s, "year"_s },
-    };
     ASSERT(
         std::is_sorted(std::begin(simpleUnits), std::end(simpleUnits),
             [](const MeasureUnit& a, const MeasureUnit& b) {

Modified: trunk/Source/_javascript_Core/runtime/IntlObject.cpp (281512 => 281513)


--- trunk/Source/_javascript_Core/runtime/IntlObject.cpp	2021-08-24 19:15:10 UTC (rev 281512)
+++ trunk/Source/_javascript_Core/runtime/IntlObject.cpp	2021-08-24 19:28:30 UTC (rev 281513)
@@ -58,6 +58,7 @@
 #include "JSCInlines.h"
 #include "Options.h"
 #include <unicode/ubrk.h>
+#include <unicode/ucal.h>
 #include <unicode/ucol.h>
 #include <unicode/ufieldpositer.h>
 #include <unicode/uloc.h>
@@ -75,6 +76,7 @@
 STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(IntlObject);
 
 static JSC_DECLARE_HOST_FUNCTION(intlObjectFuncGetCanonicalLocales);
+static JSC_DECLARE_HOST_FUNCTION(intlObjectFuncSupportedValuesOf);
 
 static JSValue createCollatorConstructor(VM& vm, JSObject* object)
 {
@@ -172,6 +174,52 @@
         ufieldpositer_close(iterator);
 }
 
+const MeasureUnit simpleUnits[43] = {
+    { "area"_s, "acre"_s },
+    { "digital"_s, "bit"_s },
+    { "digital"_s, "byte"_s },
+    { "temperature"_s, "celsius"_s },
+    { "length"_s, "centimeter"_s },
+    { "duration"_s, "day"_s },
+    { "angle"_s, "degree"_s },
+    { "temperature"_s, "fahrenheit"_s },
+    { "volume"_s, "fluid-ounce"_s },
+    { "length"_s, "foot"_s },
+    { "volume"_s, "gallon"_s },
+    { "digital"_s, "gigabit"_s },
+    { "digital"_s, "gigabyte"_s },
+    { "mass"_s, "gram"_s },
+    { "area"_s, "hectare"_s },
+    { "duration"_s, "hour"_s },
+    { "length"_s, "inch"_s },
+    { "digital"_s, "kilobit"_s },
+    { "digital"_s, "kilobyte"_s },
+    { "mass"_s, "kilogram"_s },
+    { "length"_s, "kilometer"_s },
+    { "volume"_s, "liter"_s },
+    { "digital"_s, "megabit"_s },
+    { "digital"_s, "megabyte"_s },
+    { "length"_s, "meter"_s },
+    { "length"_s, "mile"_s },
+    { "length"_s, "mile-scandinavian"_s },
+    { "volume"_s, "milliliter"_s },
+    { "length"_s, "millimeter"_s },
+    { "duration"_s, "millisecond"_s },
+    { "duration"_s, "minute"_s },
+    { "duration"_s, "month"_s },
+    { "mass"_s, "ounce"_s },
+    { "concentr"_s, "percent"_s },
+    { "digital"_s, "petabyte"_s },
+    { "mass"_s, "pound"_s },
+    { "duration"_s, "second"_s },
+    { "mass"_s, "stone"_s },
+    { "digital"_s, "terabit"_s },
+    { "digital"_s, "terabyte"_s },
+    { "duration"_s, "week"_s },
+    { "length"_s, "yard"_s },
+    { "duration"_s, "year"_s },
+};
+
 IntlObject::IntlObject(VM& vm, Structure* structure)
     : Base(vm, structure)
 {
@@ -184,7 +232,7 @@
     return object;
 }
 
-void IntlObject::finishCreation(VM& vm, JSGlobalObject*)
+void IntlObject::finishCreation(VM& vm, JSGlobalObject* globalObject)
 {
     Base::finishCreation(vm);
     ASSERT(inherits(vm, info()));
@@ -199,6 +247,8 @@
 #else
     UNUSED_PARAM(&createListFormatConstructor);
 #endif
+    if (Options::useIntlEnumeration())
+        JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("supportedValuesOf", intlObjectFuncSupportedValuesOf, static_cast<unsigned>(PropertyAttribute::DontEnum), 1);
 }
 
 Structure* IntlObject::createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
@@ -1468,8 +1518,8 @@
 {
     if (calendar == "gregorian"_s)
         return "gregory"_s;
-    if (calendar == "islamic-civil"_s)
-        return "islamicc"_s;
+    // islamicc is deprecated in BCP47, and islamic-civil is preferred.
+    // https://github.com/unicode-org/cldr/blob/master/common/bcp47/calendar.xml
     if (calendar == "ethiopic-amete-alem"_s)
         return "ethioaa"_s;
     return std::nullopt;
@@ -1524,4 +1574,311 @@
     return JSValue::encode(localeArray);
 }
 
+// https://tc39.es/proposal-intl-enumeration/#sec-availablecalendars
+static JSArray* availableCalendars(JSGlobalObject* globalObject)
+{
+    VM& vm = globalObject->vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
+
+    UErrorCode status = U_ZERO_ERROR;
+    auto enumeration = std::unique_ptr<UEnumeration, ICUDeleter<uenum_close>>(ucal_getKeywordValuesForLocale("calendars", "und", false, &status));
+    if (U_FAILURE(status)) {
+        throwTypeError(globalObject, scope, "failed to enumerate available calendars"_s);
+        return { };
+    }
+
+    int32_t count = uenum_count(enumeration.get(), &status);
+    if (U_FAILURE(status)) {
+        throwTypeError(globalObject, scope, "failed to enumerate available calendars"_s);
+        return { };
+    }
+
+    Vector<String, 1> elements;
+    elements.reserveInitialCapacity(count);
+    for (int32_t index = 0; index < count; ++index) {
+        int32_t length = 0;
+        const char* pointer = uenum_next(enumeration.get(), &length, &status);
+        if (U_FAILURE(status)) {
+            throwTypeError(globalObject, scope, "failed to enumerate available calendars"_s);
+            return { };
+        }
+        String calendar(pointer, length);
+        if (auto mapped = mapICUCalendarKeywordToBCP47(calendar))
+            elements.append(WTFMove(mapped.value()));
+        else
+            elements.append(WTFMove(calendar));
+    }
+
+    // The AvailableCalendars abstract operation returns a List, ordered as if an Array of the same
+    // values had been sorted using %Array.prototype.sort% using undefined as comparefn
+    std::sort(elements.begin(), elements.end(),
+        [](const String& a, const String& b) {
+            return WTF::codePointCompare(a, b) < 0;
+        });
+
+    return createArrayFromStringVector(globalObject, WTFMove(elements));
+}
+
+// https://tc39.es/proposal-intl-enumeration/#sec-availablecollations
+static JSArray* availableCollations(JSGlobalObject* globalObject)
+{
+    VM& vm = globalObject->vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
+
+    UErrorCode status = U_ZERO_ERROR;
+    auto enumeration = std::unique_ptr<UEnumeration, ICUDeleter<uenum_close>>(ucol_getKeywordValues("collation", &status));
+    if (U_FAILURE(status)) {
+        throwTypeError(globalObject, scope, "failed to enumerate available collations"_s);
+        return { };
+    }
+
+    int32_t count = uenum_count(enumeration.get(), &status);
+    if (U_FAILURE(status)) {
+        throwTypeError(globalObject, scope, "failed to enumerate available collations"_s);
+        return { };
+    }
+
+    Vector<String, 1> elements;
+    elements.reserveInitialCapacity(count);
+    for (int32_t index = 0; index < count; ++index) {
+        int32_t length = 0;
+        const char* pointer = uenum_next(enumeration.get(), &length, &status);
+        if (U_FAILURE(status)) {
+            throwTypeError(globalObject, scope, "failed to enumerate available collations"_s);
+            return { };
+        }
+        String collation(pointer, length);
+        if (collation == "standard"_s || collation == "search"_s)
+            continue;
+        if (auto mapped = mapICUCollationKeywordToBCP47(collation))
+            elements.append(WTFMove(mapped.value()));
+        else
+            elements.append(WTFMove(collation));
+    }
+
+    // The AvailableCollations abstract operation returns a List, ordered as if an Array of the same
+    // values had been sorted using %Array.prototype.sort% using undefined as comparefn
+    std::sort(elements.begin(), elements.end(),
+        [](const String& a, const String& b) {
+            return WTF::codePointCompare(a, b) < 0;
+        });
+
+    return createArrayFromStringVector(globalObject, WTFMove(elements));
+}
+
+// https://tc39.es/proposal-intl-enumeration/#sec-availablecurrencies
+static JSArray* availableCurrencies(JSGlobalObject* globalObject)
+{
+    VM& vm = globalObject->vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
+
+    UErrorCode status = U_ZERO_ERROR;
+    auto enumeration = std::unique_ptr<UEnumeration, ICUDeleter<uenum_close>>(ucurr_openISOCurrencies(UCURR_COMMON | UCURR_NON_DEPRECATED, &status));
+    if (U_FAILURE(status)) {
+        throwTypeError(globalObject, scope, "failed to enumerate available currencies"_s);
+        return { };
+    }
+
+    int32_t count = uenum_count(enumeration.get(), &status);
+    if (U_FAILURE(status)) {
+        throwTypeError(globalObject, scope, "failed to enumerate available currencies"_s);
+        return { };
+    }
+
+    Vector<String, 1> elements;
+    elements.reserveInitialCapacity(count);
+    for (int32_t index = 0; index < count; ++index) {
+        int32_t length = 0;
+        const char* currency = uenum_next(enumeration.get(), &length, &status);
+        if (U_FAILURE(status)) {
+            throwTypeError(globalObject, scope, "failed to enumerate available currencies"_s);
+            return { };
+        }
+        elements.constructAndAppend(currency, length);
+    }
+
+    // The AvailableCurrencies abstract operation returns a List, ordered as if an Array of the same
+    // values had been sorted using %Array.prototype.sort% using undefined as comparefn
+    std::sort(elements.begin(), elements.end(),
+        [](const String& a, const String& b) {
+            return WTF::codePointCompare(a, b) < 0;
+        });
+
+    return createArrayFromStringVector(globalObject, WTFMove(elements));
+}
+
+// https://tc39.es/proposal-intl-enumeration/#sec-availablenumberingsystems
+static JSArray* availableNumberingSystems(JSGlobalObject* globalObject)
+{
+    VM& vm = globalObject->vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
+
+    UErrorCode status = U_ZERO_ERROR;
+    auto enumeration = std::unique_ptr<UEnumeration, ICUDeleter<uenum_close>>(unumsys_openAvailableNames(&status));
+    if (U_FAILURE(status)) {
+        throwTypeError(globalObject, scope, "failed to enumerate available numbering systems"_s);
+        return { };
+    }
+
+    int32_t count = uenum_count(enumeration.get(), &status);
+    if (U_FAILURE(status)) {
+        throwTypeError(globalObject, scope, "failed to enumerate available numbering systems"_s);
+        return { };
+    }
+
+    Vector<String, 1> elements;
+    elements.reserveInitialCapacity(count);
+    for (int32_t index = 0; index < count; ++index) {
+        int32_t length = 0;
+        const char* numberingSystem = uenum_next(enumeration.get(), &length, &status);
+        if (U_FAILURE(status)) {
+            throwTypeError(globalObject, scope, "failed to enumerate available numbering systems"_s);
+            return { };
+        }
+        elements.constructAndAppend(numberingSystem, length);
+    }
+
+    // The AvailableNumberingSystems abstract operation returns a List, ordered as if an Array of the same
+    // values had been sorted using %Array.prototype.sort% using undefined as comparefn
+    std::sort(elements.begin(), elements.end(),
+        [](const String& a, const String& b) {
+            return WTF::codePointCompare(a, b) < 0;
+        });
+
+    return createArrayFromStringVector(globalObject, WTFMove(elements));
+}
+
+// https://tc39.es/proposal-intl-enumeration/#sec-canonicalizetimezonename
+static std::optional<String> canonicalizeTimeZoneNameFromICUTimeZone(const String& timeZoneName)
+{
+    // Some time zone names are included in ICU, but they are not included in the IANA Time Zone Database.
+    // We need to filter them out.
+    if (timeZoneName.startsWith("SystemV/"))
+        return std::nullopt;
+    if (timeZoneName.startsWith("Etc/"))
+        return std::nullopt;
+    // IANA time zone names include '/'. Some of them are not including, but it is in backward links.
+    // And ICU already resolved these backward links.
+    if (!timeZoneName.contains('/'))
+        return std::nullopt;
+
+    return timeZoneName;
+}
+
+// https://tc39.es/proposal-intl-enumeration/#sec-availabletimezones
+static JSArray* availableTimeZones(JSGlobalObject* globalObject)
+{
+    VM& vm = globalObject->vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
+
+    UErrorCode status = U_ZERO_ERROR;
+    auto enumeration = std::unique_ptr<UEnumeration, ICUDeleter<uenum_close>>(ucal_openTimeZoneIDEnumeration(UCAL_ZONE_TYPE_CANONICAL, nullptr, nullptr, &status));
+    if (U_FAILURE(status)) {
+        throwTypeError(globalObject, scope, "failed to enumerate available timezones"_s);
+        return { };
+    }
+
+    int32_t count = uenum_count(enumeration.get(), &status);
+    if (U_FAILURE(status)) {
+        throwTypeError(globalObject, scope, "failed to enumerate available timezones"_s);
+        return { };
+    }
+
+    Vector<String, 1> elements;
+    elements.reserveInitialCapacity(count);
+    for (int32_t index = 0; index < count; ++index) {
+        int32_t length = 0;
+        const char* pointer = uenum_next(enumeration.get(), &length, &status);
+        if (U_FAILURE(status)) {
+            throwTypeError(globalObject, scope, "failed to enumerate available timezones"_s);
+            return { };
+        }
+        String timeZone(pointer, length);
+        if (auto mapped = canonicalizeTimeZoneNameFromICUTimeZone(timeZone))
+            elements.append(WTFMove(mapped.value()));
+    }
+
+    // 4. Sort result in order as if an Array of the same values had been sorted using %Array.prototype.sort% using undefined as comparefn.
+    std::sort(elements.begin(), elements.end(),
+        [](const String& a, const String& b) {
+            return WTF::codePointCompare(a, b) < 0;
+        });
+
+    return createArrayFromStringVector(globalObject, WTFMove(elements));
+}
+
+// https://tc39.es/proposal-intl-enumeration/#sec-availableunits
+static JSArray* availableUnits(JSGlobalObject* globalObject)
+{
+    VM& vm = globalObject->vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
+
+    JSArray* result = JSArray::tryCreate(vm, globalObject->arrayStructureForIndexingTypeDuringAllocation(ArrayWithUndecided), std::size(simpleUnits));
+    if (!result) {
+        throwOutOfMemoryError(globalObject, scope);
+        return { };
+    }
+
+    ASSERT(
+        std::is_sorted(std::begin(simpleUnits), std::end(simpleUnits),
+            [](const MeasureUnit& a, const MeasureUnit& b) {
+                return WTF::codePointCompare(StringView(a.subType), StringView(b.subType)) < 0;
+            }));
+
+    int32_t index = 0;
+    for (const MeasureUnit& unit : simpleUnits) {
+        result->putDirectIndex(globalObject, index++, jsString(vm, StringImpl::createFromLiteral(unit.subType)));
+        RETURN_IF_EXCEPTION(scope, { });
+    }
+    return result;
+}
+
+// https://tc39.es/proposal-intl-enumeration/#sec-intl.supportedvaluesof
+JSC_DEFINE_HOST_FUNCTION(intlObjectFuncSupportedValuesOf, (JSGlobalObject* globalObject, CallFrame* callFrame))
+{
+    VM& vm = globalObject->vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
+
+    String key = callFrame->argument(0).toWTFString(globalObject);
+    RETURN_IF_EXCEPTION(scope, { });
+
+    if (key == "calendar"_s)
+        RELEASE_AND_RETURN(scope, JSValue::encode(availableCalendars(globalObject)));
+
+    if (key == "collation"_s)
+        RELEASE_AND_RETURN(scope, JSValue::encode(availableCollations(globalObject)));
+
+    if (key == "currency"_s)
+        RELEASE_AND_RETURN(scope, JSValue::encode(availableCurrencies(globalObject)));
+
+    if (key == "numberingSystem"_s)
+        RELEASE_AND_RETURN(scope, JSValue::encode(availableNumberingSystems(globalObject)));
+
+    if (key == "timeZone"_s)
+        RELEASE_AND_RETURN(scope, JSValue::encode(availableTimeZones(globalObject)));
+
+    if (key == "unit"_s)
+        RELEASE_AND_RETURN(scope, JSValue::encode(availableUnits(globalObject)));
+
+    throwRangeError(globalObject, scope, "Unknown key for Intl.supportedValuesOf"_s);
+    return { };
+}
+
+JSArray* createArrayFromStringVector(JSGlobalObject* globalObject, Vector<String, 1>&& elements)
+{
+    VM& vm = globalObject->vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
+
+    JSArray* result = JSArray::tryCreate(vm, globalObject->arrayStructureForIndexingTypeDuringAllocation(ArrayWithContiguous), elements.size());
+    if (!result) {
+        throwOutOfMemoryError(globalObject, scope);
+        return nullptr;
+    }
+    for (unsigned index = 0; index < elements.size(); ++index) {
+        result->putDirectIndex(globalObject, index, jsString(vm, WTFMove(elements[index])));
+        RETURN_IF_EXCEPTION(scope, { });
+    }
+    return result;
+}
+
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/runtime/IntlObject.h (281512 => 281513)


--- trunk/Source/_javascript_Core/runtime/IntlObject.h	2021-08-24 19:15:10 UTC (rev 281512)
+++ trunk/Source/_javascript_Core/runtime/IntlObject.h	2021-08-24 19:28:30 UTC (rev 281513)
@@ -60,6 +60,13 @@
 static constexpr uint8_t numberOfRelevantExtensionKeys = 0 JSC_INTL_RELEVANT_EXTENSION_KEYS(JSC_COUNT_INTL_RELEVANT_EXTENSION_KEYS);
 #undef JSC_COUNT_INTL_RELEVANT_EXTENSION_KEYS
 
+struct MeasureUnit {
+    ASCIILiteral type;
+    ASCIILiteral subType;
+};
+
+extern JS_EXPORT_PRIVATE const MeasureUnit simpleUnits[43];
+
 class IntlObject final : public JSNonFinalObject {
 public:
     using Base = JSNonFinalObject;
@@ -141,4 +148,6 @@
 std::optional<String> mapICUCalendarKeywordToBCP47(const String&);
 std::optional<String> mapBCP47ToICUCalendarKeyword(const String&);
 
+JSArray* createArrayFromStringVector(JSGlobalObject*, Vector<String, 1>&&);
+
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/runtime/OptionsList.h (281512 => 281513)


--- trunk/Source/_javascript_Core/runtime/OptionsList.h	2021-08-24 19:15:10 UTC (rev 281512)
+++ trunk/Source/_javascript_Core/runtime/OptionsList.h	2021-08-24 19:28:30 UTC (rev 281513)
@@ -541,6 +541,7 @@
     v(Bool, useDataICSharing, false, Normal, nullptr) \
     v(Bool, useTemporal, false, Normal, "Expose the Temporal object.") \
     v(Bool, useArrayFindLastMethod, true, Normal, "Expose the findLast() and findLastIndex() methods on Array and %TypedArray%.") \
+    v(Bool, useIntlEnumeration, true, Normal, "Expose the Intl enumeration APIs.") \
 
 
 enum OptionEquivalence {

Modified: trunk/Source/WTF/ChangeLog (281512 => 281513)


--- trunk/Source/WTF/ChangeLog	2021-08-24 19:15:10 UTC (rev 281512)
+++ trunk/Source/WTF/ChangeLog	2021-08-24 19:28:30 UTC (rev 281513)
@@ -1,3 +1,14 @@
+2021-08-24  Yusuke Suzuki  <[email protected]>
+
+        [JSC] Add Intl Enumeration APIs
+        https://bugs.webkit.org/show_bug.cgi?id=214795
+
+        Reviewed by Ross Kirsling.
+
+        * wtf/text/StringImpl.cpp:
+        (WTF::StringImpl::createFromLiteral):
+        * wtf/text/StringImpl.h:
+
 2021-08-24  Tim Nguyen  <[email protected]>
 
         Implement inert attribute behind feature flag

Modified: trunk/Source/WTF/wtf/text/StringImpl.cpp (281512 => 281513)


--- trunk/Source/WTF/wtf/text/StringImpl.cpp	2021-08-24 19:15:10 UTC (rev 281512)
+++ trunk/Source/WTF/wtf/text/StringImpl.cpp	2021-08-24 19:28:30 UTC (rev 281513)
@@ -163,6 +163,11 @@
     return createFromLiteral(characters, strlen(characters));
 }
 
+Ref<StringImpl> StringImpl::createFromLiteral(ASCIILiteral literal)
+{
+    return createFromLiteral(literal.characters(), literal.length());
+}
+
 Ref<StringImpl> StringImpl::createWithoutCopying(const UChar* characters, unsigned length)
 {
     if (!length)

Modified: trunk/Source/WTF/wtf/text/StringImpl.h (281512 => 281513)


--- trunk/Source/WTF/wtf/text/StringImpl.h	2021-08-24 19:15:10 UTC (rev 281512)
+++ trunk/Source/WTF/wtf/text/StringImpl.h	2021-08-24 19:28:30 UTC (rev 281513)
@@ -33,6 +33,7 @@
 #include <wtf/StdLibExtras.h>
 #include <wtf/Vector.h>
 #include <wtf/text/ASCIIFastPath.h>
+#include <wtf/text/ASCIILiteral.h>
 #include <wtf/text/ConversionMode.h>
 #include <wtf/text/StringBuffer.h>
 #include <wtf/text/StringCommon.h>
@@ -249,6 +250,7 @@
     // FIXME: Replace calls to these overloads of createFromLiteral to createWithoutCopying instead.
     WTF_EXPORT_PRIVATE static Ref<StringImpl> createFromLiteral(const char*, unsigned length);
     WTF_EXPORT_PRIVATE static Ref<StringImpl> createFromLiteral(const char*);
+    WTF_EXPORT_PRIVATE static Ref<StringImpl> createFromLiteral(ASCIILiteral);
 
     WTF_EXPORT_PRIVATE static Ref<StringImpl> createWithoutCopying(const UChar*, unsigned length);
     WTF_EXPORT_PRIVATE static Ref<StringImpl> createWithoutCopying(const LChar*, unsigned length);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to