Changeset 255120 in webkit


Ignore:
Timestamp:
Jan 25, 2020, 9:03:59 AM (5 years ago)
Author:
mark.lam@apple.com
Message:

Move singleton Intl string locales out of JSGlobalObject.
https://bugs.webkit.org/show_bug.cgi?id=206791
<rdar://problem/58889037>

Source/JavaScriptCore:

Reviewed by Yusuke Suzuki and Andy Wagoner.

We were creating an instance of these for each JSGlobalObject when they can be a
global singleton since they are always initialized with the same intl data
(barring a mid-flight change in intl settings, which we don't support even in the
existing code).

It turns out that intlPluralRulesAvailableLocales() wasn't called anywhere.
IntlPluralRules code currently just uses intlNumberFormatAvailableLocales().
To document that this is intentional, we do the following:

  1. have IntlPluralRules code call intlPluralRulesAvailableLocales(), and
  2. have intlPluralRulesAvailableLocales() call intlNumberFormatAvailableLocales() for its implementation.

See https://bugs.webkit.org/show_bug.cgi?id=206791#c7 and
https://bugs.webkit.org/show_bug.cgi?id=206791#c8.

In addMissingScriptLocales(), I'm deliberately naming the string with underscores
because it's much easier to read pa_PK_String and see that it refers to "pa-PK"
as opposed to paPKString. Ditto for zh_CN_String, zh_HK_String, zh_SG_String,
and zh_TW_String.

  • runtime/IntlCollator.cpp:

(JSC::IntlCollator::initializeCollator):

  • runtime/IntlCollatorConstructor.cpp:

(JSC::IntlCollatorConstructorFuncSupportedLocalesOf):

  • runtime/IntlDateTimeFormat.cpp:

(JSC::IntlDateTimeFormat::initializeDateTimeFormat):

  • runtime/IntlDateTimeFormatConstructor.cpp:

(JSC::IntlDateTimeFormatConstructorFuncSupportedLocalesOf):

  • runtime/IntlNumberFormat.cpp:

(JSC::IntlNumberFormat::initializeNumberFormat):

  • runtime/IntlNumberFormatConstructor.cpp:

(JSC::IntlNumberFormatConstructorFuncSupportedLocalesOf):

  • runtime/IntlObject.cpp:

(JSC::convertICULocaleToBCP47LanguageTag):
(JSC::addMissingScriptLocales):
(JSC::intlCollatorAvailableLocales):
(JSC::intlDateTimeFormatAvailableLocales):
(JSC::intlNumberFormatAvailableLocales):
(JSC::defaultLocale):

  • runtime/IntlObject.h:
  • runtime/IntlPluralRules.cpp:

(JSC::IntlPluralRules::initializePluralRules):

  • runtime/IntlPluralRulesConstructor.cpp:

(JSC::IntlPluralRulesConstructorFuncSupportedLocalesOf):

  • runtime/JSGlobalObject.cpp:

(JSC::addMissingScriptLocales): Deleted.
(JSC::JSGlobalObject::intlCollatorAvailableLocales): Deleted.
(JSC::JSGlobalObject::intlDateTimeFormatAvailableLocales): Deleted.
(JSC::JSGlobalObject::intlNumberFormatAvailableLocales): Deleted.
(JSC::JSGlobalObject::intlPluralRulesAvailableLocales): Deleted.

  • runtime/JSGlobalObject.h:

Source/WTF:

Reviewed by Yusuke Suzuki.

Fix a bug in StringImpl::createStaticStringImpl(): I forgot to set its hash value
when I introduced it. StaticStringImpls require that its hash code be set ahead
of time, and cannot be mutated at runtime. See the comment in the definition of
StaticStringImpl in StringImpl.h.

  • wtf/text/StringImpl.cpp:

(WTF::StringImpl::createStaticStringImpl):

Location:
trunk/Source
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r255112 r255120  
     12020-01-24  Mark Lam  <mark.lam@apple.com>
     2
     3        Move singleton Intl string locales out of JSGlobalObject.
     4        https://bugs.webkit.org/show_bug.cgi?id=206791
     5        <rdar://problem/58889037>
     6
     7        Reviewed by Yusuke Suzuki and Andy Wagoner.
     8
     9        We were creating an instance of these for each JSGlobalObject when they can be a
     10        global singleton since they are always initialized with the same intl data
     11        (barring a mid-flight change in intl settings, which we don't support even in the
     12        existing code).
     13
     14        It turns out that intlPluralRulesAvailableLocales() wasn't called anywhere.
     15        IntlPluralRules code currently just uses intlNumberFormatAvailableLocales().
     16        To document that this is intentional, we do the following:
     17        1. have IntlPluralRules code call intlPluralRulesAvailableLocales(), and
     18        2. have intlPluralRulesAvailableLocales() call intlNumberFormatAvailableLocales()
     19           for its implementation.
     20        See https://bugs.webkit.org/show_bug.cgi?id=206791#c7 and
     21        https://bugs.webkit.org/show_bug.cgi?id=206791#c8.
     22
     23        In addMissingScriptLocales(), I'm deliberately naming the string with underscores
     24        because it's much easier to read pa_PK_String and see that it refers to "pa-PK"
     25        as opposed to paPKString.  Ditto for zh_CN_String, zh_HK_String, zh_SG_String,
     26        and zh_TW_String.
     27
     28        * runtime/IntlCollator.cpp:
     29        (JSC::IntlCollator::initializeCollator):
     30        * runtime/IntlCollatorConstructor.cpp:
     31        (JSC::IntlCollatorConstructorFuncSupportedLocalesOf):
     32        * runtime/IntlDateTimeFormat.cpp:
     33        (JSC::IntlDateTimeFormat::initializeDateTimeFormat):
     34        * runtime/IntlDateTimeFormatConstructor.cpp:
     35        (JSC::IntlDateTimeFormatConstructorFuncSupportedLocalesOf):
     36        * runtime/IntlNumberFormat.cpp:
     37        (JSC::IntlNumberFormat::initializeNumberFormat):
     38        * runtime/IntlNumberFormatConstructor.cpp:
     39        (JSC::IntlNumberFormatConstructorFuncSupportedLocalesOf):
     40        * runtime/IntlObject.cpp:
     41        (JSC::convertICULocaleToBCP47LanguageTag):
     42        (JSC::addMissingScriptLocales):
     43        (JSC::intlCollatorAvailableLocales):
     44        (JSC::intlDateTimeFormatAvailableLocales):
     45        (JSC::intlNumberFormatAvailableLocales):
     46        (JSC::defaultLocale):
     47        * runtime/IntlObject.h:
     48        * runtime/IntlPluralRules.cpp:
     49        (JSC::IntlPluralRules::initializePluralRules):
     50        * runtime/IntlPluralRulesConstructor.cpp:
     51        (JSC::IntlPluralRulesConstructorFuncSupportedLocalesOf):
     52        * runtime/JSGlobalObject.cpp:
     53        (JSC::addMissingScriptLocales): Deleted.
     54        (JSC::JSGlobalObject::intlCollatorAvailableLocales): Deleted.
     55        (JSC::JSGlobalObject::intlDateTimeFormatAvailableLocales): Deleted.
     56        (JSC::JSGlobalObject::intlNumberFormatAvailableLocales): Deleted.
     57        (JSC::JSGlobalObject::intlPluralRulesAvailableLocales): Deleted.
     58        * runtime/JSGlobalObject.h:
     59
    1602020-01-24  Mark Lam  <mark.lam@apple.com>
    261
  • trunk/Source/JavaScriptCore/runtime/IntlCollator.cpp

    r253019 r255120  
    22 * Copyright (C) 2015 Andy VanWagoner (andy@vanwagoner.family)
    33 * Copyright (C) 2015 Sukolsak Sakshuwong (sukolsak@gmail.com)
    4  * Copyright (C) 2016-2019 Apple Inc. All Rights Reserved.
     4 * Copyright (C) 2016-2020 Apple Inc. All Rights Reserved.
    55 *
    66 * Redistribution and use in source and binary forms, with or without
     
    220220    }
    221221
    222     auto& availableLocales = globalObject->intlCollatorAvailableLocales();
     222    auto& availableLocales = intlCollatorAvailableLocales();
    223223    auto result = resolveLocale(globalObject, availableLocales, requestedLocales, opt, relevantCollatorExtensionKeys, WTF_ARRAY_LENGTH(relevantCollatorExtensionKeys), localeData);
    224224
  • trunk/Source/JavaScriptCore/runtime/IntlCollatorConstructor.cpp

    r252520 r255120  
    22 * Copyright (C) 2015 Andy VanWagoner (andy@vanwagoner.family)
    33 * Copyright (C) 2015 Sukolsak Sakshuwong (sukolsak@gmail.com)
    4  * Copyright (C) 2016 Apple Inc. All Rights Reserved.
     4 * Copyright (C) 2016-2020 Apple Inc. All Rights Reserved.
    55 *
    66 * Redistribution and use in source and binary forms, with or without
     
    140140
    141141    // 3. Return SupportedLocales(%Collator%.[[availableLocales]], requestedLocales, options).
    142     RELEASE_AND_RETURN(scope, JSValue::encode(supportedLocales(globalObject, globalObject->intlCollatorAvailableLocales(), requestedLocales, callFrame->argument(1))));
     142    RELEASE_AND_RETURN(scope, JSValue::encode(supportedLocales(globalObject, intlCollatorAvailableLocales(), requestedLocales, callFrame->argument(1))));
    143143}
    144144
  • trunk/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp

    r253865 r255120  
    11/*
    22 * Copyright (C) 2015 Andy VanWagoner (andy@vanwagoner.family)
    3  * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
     3 * Copyright (C) 2016-2020 Apple Inc. All rights reserved.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
     
    471471        opt.add("hc"_s, String());
    472472
    473     const HashSet<String> availableLocales = globalObject->intlDateTimeFormatAvailableLocales();
     473    const HashSet<String>& availableLocales = intlDateTimeFormatAvailableLocales();
    474474    HashMap<String, String> resolved = resolveLocale(globalObject, availableLocales, requestedLocales, opt, IntlDTFInternal::relevantExtensionKeys, WTF_ARRAY_LENGTH(IntlDTFInternal::relevantExtensionKeys), IntlDTFInternal::localeData);
    475475
  • trunk/Source/JavaScriptCore/runtime/IntlDateTimeFormatConstructor.cpp

    r252520 r255120  
    134134
    135135    // 1. Let availableLocales be %DateTimeFormat%.[[availableLocales]].
    136     const HashSet<String> availableLocales = globalObject->intlDateTimeFormatAvailableLocales();
     136    const HashSet<String>& availableLocales = intlDateTimeFormatAvailableLocales();
    137137
    138138    // 2. Let requestedLocales be CanonicalizeLocaleList(locales).
  • trunk/Source/JavaScriptCore/runtime/IntlNumberFormat.cpp

    r253865 r255120  
    22 * Copyright (C) 2015 Andy VanWagoner (andy@vanwagoner.family)
    33 * Copyright (C) 2016 Sukolsak Sakshuwong (sukolsak@gmail.com)
    4  * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
     4 * Copyright (C) 2016-2020 Apple Inc. All rights reserved.
    55 *
    66 * Redistribution and use in source and binary forms, with or without
     
    180180    opt.add("localeMatcher"_s, matcher);
    181181
    182     auto& availableLocales = globalObject->intlNumberFormatAvailableLocales();
     182    auto& availableLocales = intlNumberFormatAvailableLocales();
    183183    auto result = resolveLocale(globalObject, availableLocales, requestedLocales, opt, relevantNumberExtensionKeys, WTF_ARRAY_LENGTH(relevantNumberExtensionKeys), IntlNFInternal::localeData);
    184184
  • trunk/Source/JavaScriptCore/runtime/IntlNumberFormatConstructor.cpp

    r252520 r255120  
    11/*
    22 * Copyright (C) 2015 Andy VanWagoner (andy@vanwagoner.family)
    3  * Copyright (C) 2016 Apple Inc. All Rights Reserved.
     3 * Copyright (C) 2016-2020 Apple Inc. All Rights Reserved.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
     
    134134
    135135    // 1. Let availableLocales be %NumberFormat%.[[availableLocales]].
    136     const HashSet<String> availableLocales = globalObject->intlNumberFormatAvailableLocales();
     136    const HashSet<String>& availableLocales = intlNumberFormatAvailableLocales();
    137137
    138138    // 2. Let requestedLocales be CanonicalizeLocaleList(locales).
  • trunk/Source/JavaScriptCore/runtime/IntlObject.cpp

    r255112 r255120  
    4747#include "ObjectPrototype.h"
    4848#include "Options.h"
     49#include <unicode/ucol.h>
     50#include <unicode/udat.h>
    4951#include <unicode/uloc.h>
     52#include <unicode/unum.h>
    5053#include <unicode/unumsys.h>
    5154#include <wtf/Assertions.h>
     
    5356#include <wtf/NeverDestroyed.h>
    5457#include <wtf/text/StringBuilder.h>
     58#include <wtf/text/StringImpl.h>
    5559
    5660namespace JSC {
     
    129133}
    130134
    131 String convertICULocaleToBCP47LanguageTag(const char* localeID)
     135static String convertICULocaleToBCP47LanguageTag(const char* localeID)
    132136{
    133137    UErrorCode status = U_ZERO_ERROR;
     
    140144    }
    141145    if (!U_FAILURE(status))
    142         return String(buffer.data(), length);
     146        return String(StringImpl::createStaticStringImpl(buffer.data(), length));
    143147    return String();
     148}
     149
     150static void addMissingScriptLocales(HashSet<String>& availableLocales)
     151{
     152    static const NeverDestroyed<String> pa_PK_String(MAKE_STATIC_STRING_IMPL("pa-PK"));
     153    static const NeverDestroyed<String> zh_CN_String(MAKE_STATIC_STRING_IMPL("zh-CN"));
     154    static const NeverDestroyed<String> zh_HK_String(MAKE_STATIC_STRING_IMPL("zh-HK"));
     155    static const NeverDestroyed<String> zh_SG_String(MAKE_STATIC_STRING_IMPL("zh-SG"));
     156    static const NeverDestroyed<String> zh_TW_String(MAKE_STATIC_STRING_IMPL("zh-TW"));
     157    if (availableLocales.contains("pa-Arab-PK"))
     158        availableLocales.add(pa_PK_String.get());
     159    if (availableLocales.contains("zh-Hans-CN"))
     160        availableLocales.add(zh_CN_String.get());
     161    if (availableLocales.contains("zh-Hant-HK"))
     162        availableLocales.add(zh_HK_String.get());
     163    if (availableLocales.contains("zh-Hans-SG"))
     164        availableLocales.add(zh_SG_String.get());
     165    if (availableLocales.contains("zh-Hant-TW"))
     166        availableLocales.add(zh_TW_String.get());
     167}
     168
     169const HashSet<String>& intlCollatorAvailableLocales()
     170{
     171    static NeverDestroyed<HashSet<String>> cachedAvailableLocales;
     172    HashSet<String>& availableLocales = cachedAvailableLocales.get();
     173
     174    static std::once_flag initializeOnce;
     175    std::call_once(initializeOnce, [&] {
     176        ASSERT(availableLocales.isEmpty());
     177        int32_t count = ucol_countAvailable();
     178        for (int32_t i = 0; i < count; ++i) {
     179            String locale = convertICULocaleToBCP47LanguageTag(ucol_getAvailable(i));
     180            if (!locale.isEmpty())
     181                availableLocales.add(locale);
     182        }
     183        addMissingScriptLocales(availableLocales);
     184    });
     185    return availableLocales;
     186}
     187
     188const HashSet<String>& intlDateTimeFormatAvailableLocales()
     189{
     190    static NeverDestroyed<HashSet<String>> cachedAvailableLocales;
     191    HashSet<String>& availableLocales = cachedAvailableLocales.get();
     192
     193    static std::once_flag initializeOnce;
     194    std::call_once(initializeOnce, [&] {
     195        ASSERT(availableLocales.isEmpty());
     196        int32_t count = udat_countAvailable();
     197        for (int32_t i = 0; i < count; ++i) {
     198            String locale = convertICULocaleToBCP47LanguageTag(udat_getAvailable(i));
     199            if (!locale.isEmpty())
     200                availableLocales.add(locale);
     201        }
     202        addMissingScriptLocales(availableLocales);
     203    });
     204    return availableLocales;
     205}
     206
     207const HashSet<String>& intlNumberFormatAvailableLocales()
     208{
     209    static NeverDestroyed<HashSet<String>> cachedAvailableLocales;
     210    HashSet<String>& availableLocales = cachedAvailableLocales.get();
     211
     212    static std::once_flag initializeOnce;
     213    std::call_once(initializeOnce, [&] {
     214        ASSERT(availableLocales.isEmpty());
     215        int32_t count = unum_countAvailable();
     216        for (int32_t i = 0; i < count; ++i) {
     217            String locale = convertICULocaleToBCP47LanguageTag(unum_getAvailable(i));
     218            if (!locale.isEmpty())
     219                availableLocales.add(locale);
     220        }
     221        addMissingScriptLocales(availableLocales);
     222    });
     223    return availableLocales;
    144224}
    145225
     
    623703    // If all else fails, ask ICU. It will probably say something bogus like en_us even if the user
    624704    // has configured some other language, but being wrong is better than crashing.
    625     String locale = convertICULocaleToBCP47LanguageTag(uloc_getDefault());
    626     if (!locale.isEmpty())
    627         return locale;
     705    static NeverDestroyed<String> icuDefaultLocalString;
     706    static std::once_flag initializeOnce;
     707    std::call_once(initializeOnce, [&] {
     708        icuDefaultLocalString.get() = convertICULocaleToBCP47LanguageTag(uloc_getDefault());
     709    });
     710    if (!icuDefaultLocalString->isEmpty())
     711        return icuDefaultLocalString.get();
    628712
    629713    return "en"_s;
  • trunk/Source/JavaScriptCore/runtime/IntlObject.h

    r251425 r255120  
    11/*
    22 * Copyright (C) 2015 Andy VanWagoner (andy@vanwagoner.family)
    3  * Copyright (C) 2019 Apple Inc. All rights reserved.
     3 * Copyright (C) 2019-2020 Apple Inc. All rights reserved.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
     
    5858
    5959String defaultLocale(JSGlobalObject*);
    60 String convertICULocaleToBCP47LanguageTag(const char* localeID);
     60const HashSet<String>& intlCollatorAvailableLocales();
     61const HashSet<String>& intlDateTimeFormatAvailableLocales();
     62const HashSet<String>& intlNumberFormatAvailableLocales();
     63inline const HashSet<String>& intlPluralRulesAvailableLocales() { return intlNumberFormatAvailableLocales(); }
     64
    6165bool intlBooleanOption(JSGlobalObject*, JSValue options, PropertyName, bool& usesFallback);
    6266String intlStringOption(JSGlobalObject*, JSValue options, PropertyName, std::initializer_list<const char*> values, const char* notFound, const char* fallback);
  • trunk/Source/JavaScriptCore/runtime/IntlPluralRules.cpp

    r253019 r255120  
    11/*
    22 * Copyright (C) 2018 Andy VanWagoner (andy@vanwagoner.family)
    3  * Copyright (C) 2019 Apple Inc. All rights reserved.
     3 * Copyright (C) 2019-2020 Apple Inc. All rights reserved.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
     
    122122    localeOpt.add(vm.propertyNames->localeMatcher.string(), localeMatcher);
    123123
    124     const HashSet<String> availableLocales = globalObject->intlNumberFormatAvailableLocales();
     124    const HashSet<String>& availableLocales = intlPluralRulesAvailableLocales();
    125125    HashMap<String, String> resolved = resolveLocale(globalObject, availableLocales, requestedLocales, localeOpt, nullptr, 0, IntlPRInternal::localeData);
    126126    m_locale = resolved.get(vm.propertyNames->locale.string());
  • trunk/Source/JavaScriptCore/runtime/IntlPluralRulesConstructor.cpp

    r252520 r255120  
    11/*
    22 * Copyright (C) 2018 Andy VanWagoner (andy@vanwagoner.family)
     3 * Copyright (C) 2020 Apple Inc. All rights reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    118119    // 13.3.2 Intl.PluralRules.supportedLocalesOf (locales [, options ])
    119120    // https://tc39.github.io/ecma402/#sec-intl.pluralrules.supportedlocalesof
    120     const HashSet<String> availableLocales = globalObject->intlNumberFormatAvailableLocales();
     121    const HashSet<String>& availableLocales = intlPluralRulesAvailableLocales();
    121122
    122123    Vector<String> requestedLocales = canonicalizeLocaleList(globalObject, callFrame->argument(0));
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r254447 r255120  
    218218#include "IntlPluralRules.h"
    219219#include "IntlPluralRulesPrototype.h"
    220 #include <unicode/ucol.h>
    221 #include <unicode/udat.h>
    222 #include <unicode/unum.h>
    223220#endif // ENABLE(INTL)
    224221
     
    20682065}
    20692066
    2070 # if ENABLE(INTL)
    2071 static void addMissingScriptLocales(HashSet<String>& availableLocales)
    2072 {
    2073     if (availableLocales.contains("pa-Arab-PK"))
    2074         availableLocales.add("pa-PK"_s);
    2075     if (availableLocales.contains("zh-Hans-CN"))
    2076         availableLocales.add("zh-CN"_s);
    2077     if (availableLocales.contains("zh-Hant-HK"))
    2078         availableLocales.add("zh-HK"_s);
    2079     if (availableLocales.contains("zh-Hans-SG"))
    2080         availableLocales.add("zh-SG"_s);
    2081     if (availableLocales.contains("zh-Hant-TW"))
    2082         availableLocales.add("zh-TW"_s);
    2083 }
    2084 
    2085 const HashSet<String>& JSGlobalObject::intlCollatorAvailableLocales()
    2086 {
    2087     if (m_intlCollatorAvailableLocales.isEmpty()) {
    2088         int32_t count = ucol_countAvailable();
    2089         for (int32_t i = 0; i < count; ++i) {
    2090             String locale = convertICULocaleToBCP47LanguageTag(ucol_getAvailable(i));
    2091             if (!locale.isEmpty())
    2092                 m_intlCollatorAvailableLocales.add(locale);
    2093         }
    2094         addMissingScriptLocales(m_intlCollatorAvailableLocales);
    2095     }
    2096     return m_intlCollatorAvailableLocales;
    2097 }
    2098 
    2099 const HashSet<String>& JSGlobalObject::intlDateTimeFormatAvailableLocales()
    2100 {
    2101     if (m_intlDateTimeFormatAvailableLocales.isEmpty()) {
    2102         int32_t count = udat_countAvailable();
    2103         for (int32_t i = 0; i < count; ++i) {
    2104             String locale = convertICULocaleToBCP47LanguageTag(udat_getAvailable(i));
    2105             if (!locale.isEmpty())
    2106                 m_intlDateTimeFormatAvailableLocales.add(locale);
    2107         }
    2108         addMissingScriptLocales(m_intlDateTimeFormatAvailableLocales);
    2109     }
    2110     return m_intlDateTimeFormatAvailableLocales;
    2111 }
    2112 
    2113 const HashSet<String>& JSGlobalObject::intlNumberFormatAvailableLocales()
    2114 {
    2115     if (m_intlNumberFormatAvailableLocales.isEmpty()) {
    2116         int32_t count = unum_countAvailable();
    2117         for (int32_t i = 0; i < count; ++i) {
    2118             String locale = convertICULocaleToBCP47LanguageTag(unum_getAvailable(i));
    2119             if (!locale.isEmpty())
    2120                 m_intlNumberFormatAvailableLocales.add(locale);
    2121         }
    2122         addMissingScriptLocales(m_intlNumberFormatAvailableLocales);
    2123     }
    2124     return m_intlNumberFormatAvailableLocales;
    2125 }
    2126 
    2127 const HashSet<String>& JSGlobalObject::intlPluralRulesAvailableLocales()
    2128 {
    2129     if (m_intlPluralRulesAvailableLocales.isEmpty()) {
    2130         int32_t count = uloc_countAvailable();
    2131         for (int32_t i = 0; i < count; ++i) {
    2132             String locale = convertICULocaleToBCP47LanguageTag(uloc_getAvailable(i));
    2133             if (!locale.isEmpty())
    2134                 m_intlPluralRulesAvailableLocales.add(locale);
    2135         }
    2136         addMissingScriptLocales(m_intlPluralRulesAvailableLocales);
    2137     }
    2138     return m_intlPluralRulesAvailableLocales;
    2139 }
    2140 
    2141 #endif // ENABLE(INTL)
    2142 
    21432067void JSGlobalObject::bumpGlobalLexicalBindingEpoch(VM& vm)
    21442068{
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h

    r254252 r255120  
    436436#endif
    437437
    438 #if ENABLE(INTL)
    439     HashSet<String> m_intlCollatorAvailableLocales;
    440     HashSet<String> m_intlDateTimeFormatAvailableLocales;
    441     HashSet<String> m_intlNumberFormatAvailableLocales;
    442     HashSet<String> m_intlPluralRulesAvailableLocales;
    443 #endif // ENABLE(INTL)
    444 
    445438    RefPtr<WatchpointSet> m_masqueradesAsUndefinedWatchpoint;
    446439    RefPtr<WatchpointSet> m_havingABadTimeWatchpoint;
     
    799792#endif
    800793
    801 #if ENABLE(INTL)
    802     const HashSet<String>& intlCollatorAvailableLocales();
    803     const HashSet<String>& intlDateTimeFormatAvailableLocales();
    804     const HashSet<String>& intlNumberFormatAvailableLocales();
    805     const HashSet<String>& intlPluralRulesAvailableLocales();
    806 #endif // ENABLE(INTL)
    807 
    808794    void bumpGlobalLexicalBindingEpoch(VM&);
    809795    unsigned globalLexicalBindingEpoch() const { return m_globalLexicalBindingEpoch; }
  • trunk/Source/WTF/ChangeLog

    r255112 r255120  
     12020-01-24  Mark Lam  <mark.lam@apple.com>
     2
     3        Move singleton Intl string locales out of JSGlobalObject.
     4        https://bugs.webkit.org/show_bug.cgi?id=206791
     5        <rdar://problem/58889037>
     6
     7        Reviewed by Yusuke Suzuki.
     8
     9        Fix a bug in StringImpl::createStaticStringImpl(): I forgot to set its hash value
     10        when I introduced it.  StaticStringImpls require that its hash code be set ahead
     11        of time, and cannot be mutated at runtime.  See the comment in the definition of
     12        StaticStringImpl in StringImpl.h.
     13
     14        * wtf/text/StringImpl.cpp:
     15        (WTF::StringImpl::createStaticStringImpl):
     16
    1172020-01-24  Mark Lam  <mark.lam@apple.com>
    218
  • trunk/Source/WTF/wtf/text/StringImpl.cpp

    r255112 r255120  
    284284Ref<StringImpl> StringImpl::createStaticStringImpl(const char* characters, unsigned length)
    285285{
    286     ASSERT(charactersAreAllASCII<LChar>(reinterpret_cast<const LChar*>(characters), length));
    287     Ref<StringImpl> result = createInternal(reinterpret_cast<const LChar*>(characters), length);
     286    const LChar* lcharCharacters = reinterpret_cast<const LChar*>(characters);
     287    ASSERT(charactersAreAllASCII<LChar>(lcharCharacters, length));
     288    Ref<StringImpl> result = createInternal(lcharCharacters, length);
     289    result->setHash(StringHasher::computeHashAndMaskTop8Bits(lcharCharacters, length));
    288290    result->m_refCount |= s_refCountFlagIsStaticString;
    289291    return result;
Note: See TracChangeset for help on using the changeset viewer.