[webkit-changes] [WebKit/WebKit] 33a069: [Yarr] Improve processing of \s* and related simpl...

Michael Saboff noreply at github.com
Wed Dec 25 04:33:01 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 33a069473f47b0242c67a1a4f9ae3a0ad249480d
      https://github.com/WebKit/WebKit/commit/33a069473f47b0242c67a1a4f9ae3a0ad249480d
  Author: Michael Saboff <msaboff at apple.com>
  Date:   2024-12-25 (Wed, 25 Dec 2024)

  Changed paths:
    A JSTests/microbenchmarks/regexp-greedy-whitespace.js
    M Source/JavaScriptCore/yarr/YarrJIT.cpp
    M Source/JavaScriptCore/yarr/YarrPattern.cpp
    M Source/JavaScriptCore/yarr/YarrPattern.h
    M Source/JavaScriptCore/yarr/create_regex_tables

  Log Message:
  -----------
  [Yarr] Improve processing of \s* and related simple Character Class atoms
https://bugs.webkit.org/show_bug.cgi?id=285121
rdar://141967884

Reviewed by Yusuke Suzuki.

This has three fixes to improve the processing of simple character classes like \s or [abc].

1. Added code to YarrGenerator::matchCharacterClass() and related methods to generate a single
   branch instead of a branch over a branch.  e.g
     Before:
       <112> 0x11aabce30:    b.eq     0x11aabce38 -> <120>
       <116> 0x11aabce34:    b        0x11aabce44 -> <132>
       <120> 0x11aabce38:    ...
     After:
       <112> 0x11aabce30:    b.ne     0x11aabce38 -> <128>
       <126> 0x11aabce38:    ...
   Part of this change can be used for future branch over branch elimination.
2. Fixed an issue in CharacterClass::copyOnly8BitCharacterData() where we didn't copy the table
   data.  This applies to the built-in whitespace and word classes.
3. Made a minor fix in the whitespace character class generation to turn the separate characters
   0x2028, 0x2029 into the range 0x2028..0x2029.

Added a micro benchmark to measure the perf improvement of \s+ for both 8 bit and 16 bit string.
The speedup for that micro benchmark is:
                              Baseline            NoBrAroundBr

regexp-greedy-whitespace  60.3322+-0.5647   ^   51.9861+-1.1278    ^ definitely 1.1605x faster

<geometric>               60.3322+-0.5647   ^   51.9861+-1.1278    ^ definitely 1.1605x faster

* JSTests/microbenchmarks/regexp-greedy-whitespace.js: Added.
(arrayToString):
(objectToString):
(dumpValue):
(compareArray):
(compareGroups):
(testRegExp):
(testRegExpSyntaxError):
* Source/JavaScriptCore/yarr/YarrJIT.cpp:
* Source/JavaScriptCore/yarr/YarrPattern.cpp:
(JSC::Yarr::CharacterClass::copyOnly8BitCharacterData):
* Source/JavaScriptCore/yarr/YarrPattern.h:
(JSC::Yarr::CharacterClass::CharacterClass):
* Source/JavaScriptCore/yarr/create_regex_tables:

Canonical link: https://commits.webkit.org/288284@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