Closed Bug 1644590 Opened 4 years ago Closed 4 years ago

Add a fast path for atom regexps in PrepareAndExecuteRegExp

Categories

(Core :: JavaScript Engine: JIT, enhancement, P1)

enhancement

Tracking

()

RESOLVED FIXED
mozilla79
Tracking Status
firefox79 --- fixed

People

(Reporter: iain, Assigned: iain)

References

Details

Attachments

(1 file)

If a regexp pattern is just a single atom (like /foo/), we can use a normal string search instead of compiling regexp code. However, the Ion stubs for RegExpMatcher/Searcher/Tester don't handle atom regexps directly; instead, they fall back to an OOL VM call. This makes atom matching significantly slower than regexp matching.

It's pretty easy to check for atom regexps in PrepareAndExecuteRegExp, and call the string search code directly. Microbenchmarking on my machine, this is about twice as fast as the old approach, and basically the same speed as a comparable regexp (at a fraction of the memory usage, since we only need to store the pattern atom).

We fill in the match pairs for atom regexps using an ABI call, then use the normal jit path for everything else (checking for errors, allocating results, etc...).

I also made a drive-by fix to remove the cx argument from RegExpShared::executeAtom, since we don't need it.

Severity: -- → N/A
Pushed by iireland@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/ade4376497cf
Add fast path for atom regexps r=jandem
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla79
Regressions: 1874719
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: