Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 8d2c95ee3bddc2a22eea90781f8d8d943741b4c2
      
https://github.com/WebKit/WebKit/commit/8d2c95ee3bddc2a22eea90781f8d8d943741b4c2
  Author: Yusuke Suzuki <[email protected]>
  Date:   2026-10-05 (Mon, 05 Oct 2026)

  Changed paths:
    A JSTests/stress/regexp-stringlist-eol-length-groups.js
    M Source/JavaScriptCore/yarr/YarrJIT.cpp

  Log Message:
  -----------
  [YARR] EOL StringList can do better length checks
https://bugs.webkit.org/show_bug.cgi?id=326323
rdar://189167809

Reviewed by Yijia Huang.

When YarrJIT uses EOL StringList (e.g.
`/^(?:aaaa|bbbb|cccc|dd|ee|ff|g)$/`), we sort strings with length since
there is no remaining characters after this matching (so entire strings
should be match or fail for one string list element). This means,
instead of doing,

    if (input.length <= "aaaa".length) {
        if (compare(input, "function"))
            return true;
    }
    if (input.length <= "bbbb".length) {
        ...
    }

we can do better like,

    if (input.length == 4) {
        if (compare(input, "aaaa"))
            return true;
        if (compare(input, "bbbb"))
            return true;
        if (compare(input, "cccc"))
            return true;
        return false;
    } else if (input.length == 2) {
        if (compare(input, "dd"))
            return true;
        if (compare(input, "ee"))
            return true;
        return false;
    }
    ...

This patch applies this optimization.

Test: JSTests/stress/regexp-stringlist-eol-length-groups.js

* JSTests/stress/regexp-stringlist-eol-length-groups.js: Added.
(shouldBe):
(candidates):
(const.cases.lists.map.words):
(unicodeLists.map.words):
(test):
* Source/JavaScriptCore/yarr/YarrJIT.cpp:

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



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

Reply via email to