Repository navigation
Commit e6d0f57
committed
[YARR] String list fast path drops a non-final empty alternative
https://bugs.webkit.org/show_bug.cgi?id=316288
Reviewed by Yusuke Suzuki.
A regex like /^(?:c||b)/ matched against "bccc" returned "b" under the
RegExp JIT instead of the empty string. The JIT "string list" fast path
plants each alternative's success jump off its character comparisons, so
an empty alternative emits no jump and execution falls through into the
next alternative as if the empty one had failed. The interpreter and the
spec match the empty alternative and return a zero-length match.
Without a trailing end-of-line anchor a string list is terminal: the
first empty alternative always matches and ends the overall match, so any
alternatives after it are unreachable. Drop them while building the
pattern, which leaves the empty alternative last so the JIT matches it via
its existing fall-through success path. Alternatives after an empty one
are kept when the list is end-of-line anchored, since there the empty
alternative does not guarantee an overall match.
* JSTests/stress/regexp-string-list-empty-alternative.js: Added.
* Source/JavaScriptCore/yarr/YarrPattern.cpp:
(JSC::Yarr::YarrPatternConstructor::checkForTerminalParentheses):
Canonical link: https://commits.webkit.org/314686@main1 parent d376be4 commit e6d0f57
2 files changed
Lines changed: 98 additions & 2 deletions
File tree
- JSTests/stress
- Source/JavaScriptCore/yarr
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2013 | 2013 | | |
2014 | 2014 | | |
2015 | 2015 | | |
2016 | | - | |
| 2016 | + | |
2017 | 2017 | | |
2018 | 2018 | | |
2019 | 2019 | | |
| |||
2041 | 2041 | | |
2042 | 2042 | | |
2043 | 2043 | | |
| 2044 | + | |
| 2045 | + | |
2044 | 2046 | | |
2045 | 2047 | | |
2046 | 2048 | | |
| 2049 | + | |
| 2050 | + | |
| 2051 | + | |
2047 | 2052 | | |
2048 | 2053 | | |
2049 | 2054 | | |
| |||
2055 | 2060 | | |
2056 | 2061 | | |
2057 | 2062 | | |
| 2063 | + | |
2058 | 2064 | | |
2059 | | - | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
| 2069 | + | |
| 2070 | + | |
| 2071 | + | |
| 2072 | + | |
2060 | 2073 | | |
2061 | 2074 | | |
2062 | 2075 | | |
| |||
0 commit comments