[webkit-changes] [WebKit/WebKit] 0f30a2: [JSC] Relanding 280425 at main with tweaks
Yusuke Suzuki
noreply at github.com
Fri Aug 23 13:40:27 PDT 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 0f30a2dccb2841b4fe0fb2a3bb10c399a366bf71
https://github.com/WebKit/WebKit/commit/0f30a2dccb2841b4fe0fb2a3bb10c399a366bf71
Author: Yusuke Suzuki <ysuzuki at apple.com>
Date: 2024-08-23 (Fri, 23 Aug 2024)
Changed paths:
A JSTests/microbenchmarks/regexp-match-alphanumeric.js
A JSTests/microbenchmarks/regexp-match-multiple-single-chars.js
A JSTests/microbenchmarks/regexp-match-separators.js
M Source/JavaScriptCore/assembler/MacroAssembler.h
M Source/JavaScriptCore/assembler/MacroAssemblerARM64.h
M Source/JavaScriptCore/assembler/MacroAssemblerARMv7.h
M Source/JavaScriptCore/assembler/MacroAssemblerRISCV64.h
M Source/JavaScriptCore/assembler/MacroAssemblerX86_64.h
M Source/JavaScriptCore/yarr/YarrJIT.cpp
Log Message:
-----------
[JSC] Relanding 280425 at main with tweaks
https://bugs.webkit.org/show_bug.cgi?id=278566
rdar://134575576
Reviewed by David Degazio.
This patch is relanding David's 280425 at main again with some assertions and fixes.
1. higherMatchStart computation was using `<` before. But it should be `<=` since the range's `hi` is included.
2. Use std::span for range computations.
3. Add std::sort explicitly for ranges and matches. We think this is sorted, but we are skeptical about whether we have a case not being sorted.
To catch that, we also added ASSERT(std::is_sorted) to allow fuzzers etc. to catch these patterns.
Original commit message:
Changes how YarrJIT handles character class matches via the following:
1. Optimize single-range checks from two branches into subtract + branch.
2. Use a bit-vector test to quickly match a set of individual characters,
as opposed to the current strategy of O(n) sequential equality checks.
3. Make the logic of matchCharacterClassRange more recursive. We use the
optimized single-range test if there is only a single range, and use
the new bit-vector test if the whole set of ranges and character matches
fits within a small-enough range. Moreover, the binary search is now
totally recursive, meaning we can use these specialized checks for
recursive checks within the binary search too, whereas currently binary
search is kind of all-or-nothing.
4. A few small optimizations are removed - YarrJIT no longer special-cases
ASCII letters in character class matches, since character set matching
is now faster. Turning adjacent character matches into length-two ranges
is also removed during CharacterClass construction since this doesn't
really do anything other than make the binary search do extra work (I'd
be really surprised if this was ever particularly profitable).
Overall, this seems to be a somewhat modest but appreciable perf win on
microbenchmarks. On the added ASCII alphanumeric test I'm seeing about 10%
improvement with this new approach, and on the single-chars test I'm seeing
more like 20% improvement. I've added a test for a set of separator chars
too, and we have maybe a small ~2% improvement on my machine - this is pretty
small and hopefully improvable? Not so exciting, but let's have the
microbenchmark in the tree anyway.
* JSTests/microbenchmarks/regexp-match-alphanumeric.js: Added.
* JSTests/microbenchmarks/regexp-match-multiple-single-chars.js: Added.
* JSTests/microbenchmarks/regexp-match-separators.js: Added.
(let.src):
(dot):
(test):
(i.let.re):
* Source/JavaScriptCore/assembler/MacroAssembler.h:
(JSC::MacroAssembler::lshiftPtr):
(JSC::MacroAssembler::lshift32):
* Source/JavaScriptCore/assembler/MacroAssemblerARM64.h:
(JSC::MacroAssemblerARM64::lshift32):
(JSC::MacroAssemblerARM64::lshift64):
* Source/JavaScriptCore/assembler/MacroAssemblerARMv7.h:
(JSC::MacroAssemblerARMv7::lshift32):
* Source/JavaScriptCore/assembler/MacroAssemblerRISCV64.h:
(JSC::MacroAssemblerRISCV64::lshift32):
* Source/JavaScriptCore/assembler/MacroAssemblerX86_64.h:
(JSC::MacroAssemblerX86_64::lshift64):
* Source/JavaScriptCore/yarr/YarrJIT.cpp:
Canonical link: https://commits.webkit.org/282671@main
To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications
More information about the webkit-changes
mailing list