Closed Bug 1839422 Opened 1 year ago Closed 11 months ago

Improve RegExpSearcher and use it in more cases

Categories

(Core :: JavaScript Engine, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
118 Branch
Tracking Status
firefox118 --- fixed

People

(Reporter: jandem, Assigned: jandem)

References

(Blocks 2 open bugs)

Details

(Whiteboard: [sp3])

Attachments

(5 files)

RegExpSearcher is a more optimized version of RegExpMatcher: it returns the match index and length as a single int32 value and this is nice for places where we don't need to allocate a match object. Because it packs two integers in an int32 value, we can't use it for longer strings, resulting either in more self-hosted code or in places where we just use RegExpMatcher instead.

A while ago I wrote some patches to change RegExpSearcher to return only the match index, and store the length separately in the JSContext where another intrinsic can get it from. This lets us simplify some regexp builtins where we can now use RegExpSearcher in more cases, and it also lets us switch some callers of RegExpMatcher to RegExpSearcher.

Whiteboard: [sp3]
Severity: -- → S2
Type: task → enhancement
Priority: -- → P3
Severity: S2 → N/A

Change the interface so that instead of packing the match index and limit in a
single int32 value, we now only return the index and store the match limit in a
field on the context where we can load it from with a separate intrinsic.

This lets us simplify RegExpReplace because we don't need separate functions
for short and long strings.

This eliminates some match result object allocations.

Depends on D181658

Blocks: 1844868

It's uncommon to use split with a regular expression that has capturing groups.
In this case we can use RegExpSearcher to avoid allocating a full result object.

Depends on D181660

Pushed by jdemooij@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/67c8402938e6
part 1 - Change RegExpSearcher interface so it can be used for longer strings. r=iain
https://hg.mozilla.org/integration/autoland/rev/4ffda9b4f4cd
part 2 - Use RegExpSearcher in RegExpGlobalMatchOpt and RegExpSplit. r=iain
https://hg.mozilla.org/integration/autoland/rev/3e05476949f1
part 3 - Optimize RegExpSearcherLastLimit in the JITs. r=iain
https://hg.mozilla.org/integration/autoland/rev/d2b9dcdf5a9b
part 4 - Add RegExpSearcher fast path to RegExpSplit. r=iain
https://hg.mozilla.org/integration/autoland/rev/c028aea4532a
part 5 - Optimize RegExpHasCaptureGroups intrinsic in the JITs. r=iain

(In reply to Pulsebot from comment #6)

Pushed by jdemooij@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/67c8402938e6
part 1 - Change RegExpSearcher interface so it can be used for longer
strings. r=iain
https://hg.mozilla.org/integration/autoland/rev/4ffda9b4f4cd
part 2 - Use RegExpSearcher in RegExpGlobalMatchOpt and RegExpSplit. r=iain
https://hg.mozilla.org/integration/autoland/rev/3e05476949f1
part 3 - Optimize RegExpSearcherLastLimit in the JITs. r=iain
https://hg.mozilla.org/integration/autoland/rev/d2b9dcdf5a9b
part 4 - Add RegExpSearcher fast path to RegExpSplit. r=iain
https://hg.mozilla.org/integration/autoland/rev/c028aea4532a
part 5 - Optimize RegExpHasCaptureGroups intrinsic in the JITs. r=iain

== Change summary for alert #39208 (as of Thu, 03 Aug 2023 08:30:52 GMT) ==

Improvements:

Ratio Test Platform Options Absolute values (old vs new) Performance Profiles
13% google-mail LastVisualChange macosx1015-64-shippable-qr cold fission webrender 1,534.24 -> 1,337.36 Before/After

For up to date results, see: https://treeherder.mozilla.org/perfherder/alerts?id=39208

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: