Inline String.prototype.startsWith 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)
Bug 1734405 added code to perform inline string comparisons. We can reuse that code to speed-up String.prototype.startsWith when the search string is a constant string. (Constant search strings are quite common [1] when compared to non-constant search string [2].)
Real-world use case:
Scrolling down on https://www.twitch.tv/directory generates 100K calls to String.prototype.startsWith whenever new content is loaded. After this patch, only the non-Warp calls are left (10-30K calls in total).
[1] Constant search string: https://searchfox.org/mozilla-central/search?q=%5C.startsWith%5C%28%5B%22%27%5D&path=&case=true®exp=true
[2] Non-constant search string: https://searchfox.org/mozilla-central/search?q=%5C.startsWith%5C%28%5B%5E%22%27%5D&path=&case=true®exp=true
| Assignee | ||
Comment 1•3 years ago
|
||
For now simply call into the VM. Part 3 will add an optimisation when the
search string is a constant, which is by far the most common use.
| Assignee | ||
Comment 2•3 years ago
|
||
Part 3 will use this function.
Depends on D153592
| Assignee | ||
Comment 3•3 years ago
|
||
This is by far the most common use and it's easy to optimise this case.
Depends on D153593
| Assignee | ||
Comment 4•3 years ago
|
||
Instead of directly calling startsWith, some code uses substring to check
for string prefixes. Let's detect this pattern, so we can use the faster code
path added in part 3.
Depends on D153594
| Assignee | ||
Comment 5•3 years ago
|
||
This ensures the folded MSubstr from part 4 can actually be DCE'ed.
Depends on D153595
Comment 7•3 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/e899c9759efb
https://hg.mozilla.org/mozilla-central/rev/143b9d7369d6
https://hg.mozilla.org/mozilla-central/rev/a67e33b06bf3
https://hg.mozilla.org/mozilla-central/rev/d795d3eb83e2
https://hg.mozilla.org/mozilla-central/rev/41bc59adbe5f
Description
•