Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[JSC] Extend BoyerMoore search more
https://bugs.webkit.org/show_bug.cgi?id=251903 rdar://105160925 Reviewed by Michael Saboff. This patch further extends BoyerMoore search coverage to unlock this in various regular expressions. In particular, this supports nested disjunctions, like, /aaa|(bbb|cccc)/ can be supported now. This patch improves JetStream2/regexp by 12%. * Source/JavaScriptCore/yarr/YarrJIT.cpp: Canonical link: https://commits.webkit.org/260054@main
- Loading branch information
1 parent
52f0003
commit bb136cc
Showing
3 changed files
with
261 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
function shouldBe(actual, expected) { | ||
if (actual !== expected) | ||
throw new Error('bad value: ' + actual); | ||
} | ||
|
||
{ | ||
let regexp = /aaaa|(bbb|cccc)/; // => [abc][abc][abc] | ||
shouldBe(regexp.test("bbb"), true); | ||
shouldBe(regexp.test("aabb"), false); | ||
} | ||
|
||
{ | ||
let regexp = /aaaa|(bbb|cccc)?/; // => | ||
shouldBe(regexp.test("bbb"), true); | ||
shouldBe(regexp.test("aabb"), true); | ||
shouldBe(regexp.test(""), true); | ||
} | ||
|
||
{ | ||
let regexp = /aaaa|a(bbb|cccc)?/; // => [a] | ||
shouldBe(regexp.test("aaaa"), true); | ||
shouldBe(regexp.test("a"), true); | ||
shouldBe(regexp.test("abbb"), true); | ||
shouldBe(regexp.test("acccc"), true); | ||
shouldBe(regexp.test("dcccc"), false); | ||
} | ||
|
||
{ | ||
let regexp = /aaaa|(bbb|cccc)?dd/; // => [abcd] | ||
shouldBe(regexp.test("bbb"), false); | ||
shouldBe(regexp.test("aaaa"), true); | ||
shouldBe(regexp.test("aabb"), false); | ||
shouldBe(regexp.test("dd"), true); | ||
} | ||
|
||
{ | ||
let regexp = /aaaa|(bbb|cccc?)?dd/; // => [abc][abc][abc] | ||
shouldBe(regexp.test("bbb"), false); | ||
shouldBe(regexp.test("aaaa"), true); | ||
shouldBe(regexp.test("aabb"), false); | ||
shouldBe(regexp.test("dd"), true); | ||
} | ||
|
||
{ | ||
let regexp = /aaaa|(b|cccc)dd/; // => [abc][acd] | ||
shouldBe(regexp.test("bbb"), false); | ||
shouldBe(regexp.test("aaaa"), true); | ||
shouldBe(regexp.test("aabb"), false); | ||
shouldBe(regexp.test("ccccdd"), true); | ||
shouldBe(regexp.test("ccccdd"), true); | ||
} | ||
|
||
{ | ||
let regexp = /aaaaaaa|(bb?|cc?)dddddd/; // => [abc][acd] | ||
shouldBe(regexp.test("aaaaaaa"), true); | ||
shouldBe(regexp.test("bdddddd"), true); | ||
shouldBe(regexp.test("cdddddd"), true); | ||
shouldBe(regexp.test("bbdddddd"), true); | ||
shouldBe(regexp.test("ccdddddd"), true); | ||
shouldBe(regexp.test("dddddd"), false); | ||
shouldBe(regexp.test("dddddd"), false); | ||
shouldBe(regexp.test("bddddd"), false); | ||
shouldBe(regexp.test("cddddd"), false); | ||
shouldBe(regexp.test("bbddddd"), false); | ||
shouldBe(regexp.test("ccddddd"), false); | ||
shouldBe(regexp.test("aaaaaabdddddd"), true); | ||
shouldBe(regexp.test("aaaaaacdddddd"), true); | ||
shouldBe(regexp.test("aaaaaabbdddddd"), true); | ||
shouldBe(regexp.test("aaaaaaccdddddd"), true); | ||
} | ||
|
||
{ | ||
let regexp = /\baaaaaaa|(bb?|cc?)dddddd/; // => [abc][acd] | ||
shouldBe(regexp.test("aaaaaaa"), true); | ||
shouldBe(regexp.test("bdddddd"), true); | ||
shouldBe(regexp.test("cdddddd"), true); | ||
shouldBe(regexp.test("bbdddddd"), true); | ||
shouldBe(regexp.test("ccdddddd"), true); | ||
shouldBe(regexp.test("dddddd"), false); | ||
shouldBe(regexp.test("dddddd"), false); | ||
shouldBe(regexp.test("bddddd"), false); | ||
shouldBe(regexp.test("cddddd"), false); | ||
shouldBe(regexp.test("bbddddd"), false); | ||
shouldBe(regexp.test("ccddddd"), false); | ||
shouldBe(regexp.test("baaaaaaa"), false); | ||
shouldBe(regexp.test("aaaaaabdddddd"), true); | ||
shouldBe(regexp.test("aaaaaacdddddd"), true); | ||
shouldBe(regexp.test("aaaaaabbdddddd"), true); | ||
shouldBe(regexp.test("aaaaaaccdddddd"), true); | ||
} |
Oops, something went wrong.