Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 7d0200e4e6ed21a62e502459658984fe341dcf61
      
https://github.com/WebKit/WebKit/commit/7d0200e4e6ed21a62e502459658984fe341dcf61
  Author: Sosuke Suzuki <[email protected]>
  Date:   2026-08-04 (Tue, 04 Aug 2026)

  Changed paths:
    A JSTests/stress/string-locale-compare-locales-cache-language-change.js
    M Source/JavaScriptCore/runtime/IntlCache.h
    M Source/JavaScriptCore/runtime/JSGlobalObject.cpp
    M Source/JavaScriptCore/runtime/JSGlobalObject.h

  Log Message:
  -----------
  [JSC] `String#localeCompare` collator cache goes stale across language changes
https://bugs.webkit.org/show_bug.cgi?id=321039

Reviewed by Yusuke Suzuki.

318542@main added a per-JSGlobalObject collator cache for
`String#localeCompare(that, locale)` keyed only by the locale string.
An unavailable-but-well-formed locale (e.g. "xx") resolves via
DefaultLocale(), which follows the user preferred languages, so the same
locale string can produce a different collator after a language change.
The cache is not wired into IntlCache's languages epoch, so
`"ö".localeCompare("z", "xx")` keeps the pre-change ordering.

Record the languages epoch observed by IntlCache when caching, and treat
a mismatch as a cache miss.

    $vm.setUserPreferredLanguages(["en-US"]);
    // "ö".localeCompare("z", "xx") -> -1
    $vm.setUserPreferredLanguages(["sv-SE"]);
    // "ö".localeCompare("z", "xx") -> still -1, expected 1

Test: JSTests/stress/string-locale-compare-locales-cache-language-change.js

* JSTests/stress/string-locale-compare-locales-cache-language-change.js: Added.
(shouldBe):
(setTimeout):
* Source/JavaScriptCore/runtime/IntlCache.h:
(JSC::IntlCache::languagesEpoch const):
* Source/JavaScriptCore/runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::cachedLocaleCompareCollator):
* Source/JavaScriptCore/runtime/JSGlobalObject.h:

Canonical link: https://commits.webkit.org/318616@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to