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•1 year 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•1 year ago
|
||
Part 3 will use this function.
Depends on D153592
Assignee | ||
Comment 3•1 year ago
|
||
This is by far the most common use and it's easy to optimise this case.
Depends on D153593
Assignee | ||
Comment 4•1 year 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•1 year ago
|
||
This ensures the folded MSubstr from part 4 can actually be DCE'ed.
Depends on D153595
Pushed by andre.bargull@gmail.com: https://hg.mozilla.org/integration/autoland/rev/e899c9759efb Part 1: Inline String.prototype.startsWith. r=jandem https://hg.mozilla.org/integration/autoland/rev/143b9d7369d6 Part 2: Move character comparison out of visitCompareSInline. r=jandem https://hg.mozilla.org/integration/autoland/rev/a67e33b06bf3 Part 3: Inline String.prototype.startsWith with a constant search string. r=jandem https://hg.mozilla.org/integration/autoland/rev/d795d3eb83e2 Part 4: Fold substring as startsWith pattern. r=jandem https://hg.mozilla.org/integration/autoland/rev/41bc59adbe5f Part 5: Implement recover support for MSubstr. r=jandem
Comment 7•1 year 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
•