Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 7a8cc2f8bf6e9dac9da96686bb2bb23d60684de7
https://github.com/WebKit/WebKit/commit/7a8cc2f8bf6e9dac9da96686bb2bb23d60684de7
Author: Sosuke Suzuki <[email protected]>
Date: 2026-10-12 (Mon, 12 Oct 2026)
Changed paths:
A JSTests/microbenchmarks/regexp-unicode-property-letters.js
A JSTests/stress/regexp-large-character-class-bit-table.js
M Source/JavaScriptCore/assembler/MacroAssemblerARM64.h
M Source/JavaScriptCore/assembler/MacroAssemblerX86_64.h
M Source/JavaScriptCore/assembler/testmasm.cpp
M Source/JavaScriptCore/yarr/YarrJIT.cpp
M Source/JavaScriptCore/yarr/YarrJIT.h
M Source/JavaScriptCore/yarr/YarrPattern.cpp
M Source/JavaScriptCore/yarr/YarrPattern.h
M Source/JavaScriptCore/yarr/YarrTZoneImpls.cpp
Log Message:
-----------
[YARR] Use bit tables instead of inlined cmp for unicode property escapes
https://bugs.webkit.org/show_bug.cgi?id=325109
Reviewed by Yusuke Suzuki.
YARR JIT generates an inline compare for every range of a character
class. This is fine for classes with few ranges, but \p{L} has 685
ranges and single code points, which makes the machine code large and
the binary search of compares hard for the branch predictor when the
input is random.
For 16-bit strings, generate a lookup into a bit table instead when a
class has 128 or more entries below U+20000. The table is created on
the heap at compile time, owned by the YarrCodeBlock, and holds one bit
per code point in 64-bit words, with identical words stored once. Code
points above the table still use the inline compares.
The machine code for 16-bit strings gets smaller (bytes, ARM64):
Before After
/\p{L}/u 13,868 664
/\p{L}+/u 27,528 1,152
/[\p{L}\p{N}_]+/u 31,960 1,152
The table for \p{L} takes 6,110 bytes. For a class with fewer entries
that is used only once in a RegExp, the table can be larger than the
machine code it replaces (up to +2.4KB for the Unicode properties).
Baseline Patched
regexp-unicode-property-letters 201.5661+-3.7035 ^ 132.7817+-1.6501
^ definitely 1.5180x faster
regexp-keyword-parsing 48.9658+-0.5182 48.7552+-0.3934
regexp-match-alphanumeric 762.3085+-7.5222 ? 762.7953+-5.8209
?
Tests: JSTests/microbenchmarks/regexp-unicode-property-letters.js
JSTests/stress/regexp-large-character-class-bit-table.js
Source/JavaScriptCore/assembler/testmasm.cpp
* JSTests/microbenchmarks/regexp-unicode-property-letters.js: Added.
* JSTests/stress/regexp-large-character-class-bit-table.js: Added.
(shouldBe):
(makeRanges):
(classSource):
(codePointsToCheck):
(prototype.source):
(prototype.check):
(mixed.source):
(bmp.source):
(high.source):
* Source/JavaScriptCore/assembler/MacroAssemblerARM64.h:
(JSC::MacroAssemblerARM64::load64):
* Source/JavaScriptCore/assembler/MacroAssemblerX86_64.h:
(JSC::MacroAssemblerX86_64::load64):
* Source/JavaScriptCore/assembler/testmasm.cpp:
(JSC::testLoad64ExtendedAddress):
* Source/JavaScriptCore/yarr/YarrJIT.cpp:
* Source/JavaScriptCore/yarr/YarrJIT.h:
* Source/JavaScriptCore/yarr/YarrPattern.cpp:
(JSC::Yarr::CharacterClassBitTable::CharacterClassBitTable):
* Source/JavaScriptCore/yarr/YarrPattern.h:
* Source/JavaScriptCore/yarr/YarrTZoneImpls.cpp:
Canonical link: https://commits.webkit.org/323543@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications