Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 0aef258bf9a077cad0a2a3ed2201210588d51a63
      
https://github.com/WebKit/WebKit/commit/0aef258bf9a077cad0a2a3ed2201210588d51a63
  Author: Sosuke Suzuki <[email protected]>
  Date:   2026-05-07 (Thu, 07 May 2026)

  Changed paths:
    M Source/JavaScriptCore/yarr/YarrPattern.h
    M Source/JavaScriptCore/yarr/generateYarrUnicodePropertyTables.py

  Log Message:
  -----------
  [YARR] Encode Unicode property tables as `constexpr` data instead of inline 
construction code
https://bugs.webkit.org/show_bug.cgi?id=314281

Reviewed by Yusuke Suzuki.

Yarr's `\p{...}` character classes are constructed by generated
createCharacterClassN() functions, which together account for ~468 KB of
__TEXT,__text in a Release arm64 build. createCharacterClass367 (RGI_Emoji)
alone is 124 KB.

Two issues:

1. Emoji string sequence classes emit thousands of inline
   Vector<char32_t>(std::span) constructions. Vector is not trivially
   constructible, so each becomes ~38 bytes of code.

2. CharacterRange's constructor is not constexpr, so
   std::initializer_list<CharacterRange> backing arrays cannot be placed in
   read-only data and are built element-by-element on the stack at runtime.

Fix (1) by emitting a flat constexpr char32_t data array plus a constexpr
per-string length array, and reconstructing m_strings with a small loop.
Fix (2) by marking CharacterRange's constructor constexpr.

This reduces these functions from ~468 KB to ~63 KB of code, with ~150 KB of
data moving to __TEXT,__const, for a net binary size reduction of ~283 KB.
No change to RegExp matching performance; RegExp compilation of emoji
property escapes is slightly faster.

* Source/JavaScriptCore/yarr/YarrPattern.h:
(JSC::Yarr::CharacterRange::CharacterRange):
* Source/JavaScriptCore/yarr/generateYarrUnicodePropertyTables.py:
(PropertyData.dumpStringTables):
(PropertyData.dump):
(PropertyData.convertStringToCppFormat): Deleted.

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



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

Reply via email to