Closed Bug 1784023 Opened 2 years ago Closed 2 years ago

Inline String.prototype.endsWith with constant search strings

Categories

(Core :: JavaScript Engine: JIT, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
105 Branch
Tracking Status
firefox105 --- fixed

People

(Reporter: anba, Assigned: anba)

References

Details

Attachments

(5 files)

Like bug 1782959, except for endsWith instead of startsWith.

Real world use case:
This saves a couple of thousand VM calls to endsWith per second when watching videos on reddit.


Additionally also fold str.indexOf(searchStr) == 0 to str.startsWith(searchStr), because I saw some sites benefiting from this optimisation.

Adding a comma after JS_FS_END ensures clang-format will add each entry on a
separate line.

For now simply call into the VM. Part 3 will add an optimisation when the
search string is a constant.

Depends on D154210

This is similar to the optimisation for String.prototype.startsWith.

Depends on D154211

The next part will try to optimise indexOf() when it can be folded to
startsWith().

Depends on D154212

Pushed by andre.bargull@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/c4538d007f20
Part 1: Add comma after JS_FS_END for nicer formatting. r=jandem
https://hg.mozilla.org/integration/autoland/rev/c28f80a3d291
Part 2: Inline String.prototype.endsWith. r=jandem
https://hg.mozilla.org/integration/autoland/rev/22bd3cd5785d
Part 3: Inline String.prototype.endsWith with a constant search string. r=jandem
https://hg.mozilla.org/integration/autoland/rev/242adcdcf927
Part 4: Inline String.prototype.indexOf() with a VM-call. r=jandem
https://hg.mozilla.org/integration/autoland/rev/53f620bb8261
Part 5: Fold MStringIndexOf to MStringStartsWith. r=jandem
Blocks: 1864323
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: