Inline String.prototype.endsWith with constant search strings
Categories
(Core :: JavaScript Engine: JIT, enhancement)
Tracking
()
| 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.
| Assignee | ||
Comment 1•3 years ago
|
||
Adding a comma after JS_FS_END ensures clang-format will add each entry on a
separate line.
| Assignee | ||
Comment 2•3 years ago
|
||
For now simply call into the VM. Part 3 will add an optimisation when the
search string is a constant.
Depends on D154210
| Assignee | ||
Comment 3•3 years ago
|
||
This is similar to the optimisation for String.prototype.startsWith.
Depends on D154211
| Assignee | ||
Comment 4•3 years ago
|
||
The next part will try to optimise indexOf() when it can be folded to
startsWith().
Depends on D154212
| Assignee | ||
Comment 5•3 years ago
|
||
Depends on D154213
Comment 7•3 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/c4538d007f20
https://hg.mozilla.org/mozilla-central/rev/c28f80a3d291
https://hg.mozilla.org/mozilla-central/rev/22bd3cd5785d
https://hg.mozilla.org/mozilla-central/rev/242adcdcf927
https://hg.mozilla.org/mozilla-central/rev/53f620bb8261
Description
•