mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
Repeated simple loops like "a+".repeat(100) compile to a chain of greedy loop instructions. When one loop failed, the VM only knew how to give back one character at a time unless the next instruction was a literal char, so V8's regexp-fallback case ran into the backtrack limit instead of finding the obvious match. When a greedy simple loop is followed by more loops for the same matcher, sum their minimum counts and backtrack far enough to leave the missing suffix in one step. If that suffix is already available to the right, still give back one character so the VM makes progress instead of reusing the same greedy state forever. The RegExp runtime test now covers the Chromium regexp-fallback case through exec(), global exec(), and both replace() paths, plus bounded same-matcher chains where the suffix minimum is partly missing or already available.