Modified: trunk/JSTests/ChangeLog (264826 => 264827)
--- trunk/JSTests/ChangeLog 2020-07-24 15:34:25 UTC (rev 264826)
+++ trunk/JSTests/ChangeLog 2020-07-24 15:49:50 UTC (rev 264827)
@@ -1,3 +1,13 @@
+2020-07-24 Yusuke Suzuki <[email protected]>
+
+ [JSC] Do not use hardened Array for Intl supportedLocalesOf
+ https://bugs.webkit.org/show_bug.cgi?id=214676
+
+ Reviewed by Mark Lam.
+
+ * stress/intl-suppored-locales-of.js: Added.
+ (shouldBe):
+
2020-07-24 Angelos Oikonomopoulos <[email protected]>
Skip crashing test on mips
Added: trunk/JSTests/stress/intl-suppored-locales-of.js (0 => 264827)
--- trunk/JSTests/stress/intl-suppored-locales-of.js (rev 0)
+++ trunk/JSTests/stress/intl-suppored-locales-of.js 2020-07-24 15:49:50 UTC (rev 264827)
@@ -0,0 +1,26 @@
+//@ runDefault("--useIntlDisplayNames=1")
+function shouldBe(actual, expected) {
+ if (actual !== expected)
+ throw new Error('bad value: ' + actual);
+}
+
+let constructors = [
+ Intl.Collator,
+ Intl.DateTimeFormat,
+ Intl.DisplayNames,
+ Intl.NumberFormat,
+ Intl.PluralRules,
+ Intl.RelativeTimeFormat,
+];
+
+for (let constructor of constructors) {
+ let array = constructor.supportedLocalesOf("en");
+ for (let index = 0; index < array.length; ++index) {
+ let descriptor = Reflect.getOwnPropertyDescriptor(array, index);
+ shouldBe(descriptor.writable, true);
+ shouldBe(descriptor.configurable, true);
+ }
+ let descriptor = Reflect.getOwnPropertyDescriptor(array, "length");
+ shouldBe(descriptor.writable, true);
+ shouldBe(descriptor.configurable, false);
+}
Modified: trunk/Source/_javascript_Core/ChangeLog (264826 => 264827)
--- trunk/Source/_javascript_Core/ChangeLog 2020-07-24 15:34:25 UTC (rev 264826)
+++ trunk/Source/_javascript_Core/ChangeLog 2020-07-24 15:49:50 UTC (rev 264827)
@@ -1,3 +1,17 @@
+2020-07-24 Yusuke Suzuki <[email protected]>
+
+ [JSC] Do not use hardened Array for Intl supportedLocalesOf
+ https://bugs.webkit.org/show_bug.cgi?id=214676
+
+ Reviewed by Mark Lam.
+
+ We do not need to call getOwnPropertyNames & defineOwnProperty because hardening array of Intl.XXX.supportedLocalesOf is removed from the spec.
+ We should just return an array from bestFitSupportedLocales or lookupSupportedLocales, while this change is not observable to users (but it is better
+ for performance). This fully fixes https://github.com/tc39/ecma402/pull/278.
+
+ * runtime/IntlObject.cpp:
+ (JSC::supportedLocales):
+
2020-07-23 Yusuke Suzuki <[email protected]>
[JSC] Arrow function |this| resolution should not be trapped by with-scope
Modified: trunk/Source/_javascript_Core/runtime/IntlObject.cpp (264826 => 264827)
--- trunk/Source/_javascript_Core/runtime/IntlObject.cpp 2020-07-24 15:34:25 UTC (rev 264826)
+++ trunk/Source/_javascript_Core/runtime/IntlObject.cpp 2020-07-24 15:49:50 UTC (rev 264827)
@@ -771,26 +771,9 @@
LocaleMatcher localeMatcher = intlOption<LocaleMatcher>(globalObject, options, vm.propertyNames->localeMatcher, { { "lookup"_s, LocaleMatcher::Lookup }, { "best fit"_s, LocaleMatcher::BestFit } }, "localeMatcher must be either \"lookup\" or \"best fit\""_s, LocaleMatcher::BestFit);
RETURN_IF_EXCEPTION(scope, JSValue());
- JSArray* supportedLocales = localeMatcher == LocaleMatcher::BestFit
- ? bestFitSupportedLocales(globalObject, availableLocales, requestedLocales)
- : lookupSupportedLocales(globalObject, availableLocales, requestedLocales);
- RETURN_IF_EXCEPTION(scope, JSValue());
-
- PropertyNameArray keys(vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude);
- supportedLocales->getOwnPropertyNames(supportedLocales, globalObject, keys, EnumerationMode());
- RETURN_IF_EXCEPTION(scope, JSValue());
-
- PropertyDescriptor desc;
-
- size_t len = keys.size();
- for (size_t i = 0; i < len; ++i) {
- supportedLocales->defineOwnProperty(supportedLocales, globalObject, keys[i], desc, true);
- RETURN_IF_EXCEPTION(scope, JSValue());
- }
- supportedLocales->defineOwnProperty(supportedLocales, globalObject, vm.propertyNames->length, desc, true);
- RETURN_IF_EXCEPTION(scope, JSValue());
-
- return supportedLocales;
+ if (localeMatcher == LocaleMatcher::BestFit)
+ RELEASE_AND_RETURN(scope, bestFitSupportedLocales(globalObject, availableLocales, requestedLocales));
+ RELEASE_AND_RETURN(scope, lookupSupportedLocales(globalObject, availableLocales, requestedLocales));
}
Vector<String> numberingSystemsForLocale(const String& locale)