Move some TypedArray builtins from self-hosted code to C++
Categories
(Core :: JavaScript: Standard Library, enhancement, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox136 | --- | fixed |
People
(Reporter: anba, Assigned: anba)
References
Details
Attachments
(12 files)
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review |
Bug 1939135 spends a large amount of time in GC code, because the website calls TypedArrayJoin
, which creates many ropes of small inline strings. Moving TypedArrayJoin
to C++ to make it more similar to js::array_join
avoids creating many string ropes.
In addition to TypedArrayJoin
, let's also move the following functions to C++:
TypedArrayIndexOf
(can use SIMD when in C++)TypedArrayLastIndexOf
TypedArrayIncludes
(can use SIMD when in C++)TypedArrayFill
(can usememset
when in C++)TypedArrayReverse
TypedArrayToReversed
TypedArrayWith
Using C++ improves performance in many cases and also avoids going megamorphic when self-hosted built-ins are called with different TypedArray kinds.
Assignee | ||
Comment 1•1 month ago
|
||
The implementation loosely follows js::array_join
.
Assignee | ||
Comment 2•1 month ago
|
||
Used in the next part.
Assignee | ||
Comment 3•1 month ago
|
||
Shared memory can't use SIMD, because data-races lead to UB in C++.
Assignee | ||
Comment 4•1 month ago
|
||
Assignee | ||
Comment 5•1 month ago
|
||
Delegates to TypedArrayIndexOf
for SIMD optimised code paths, unless
searching for NaN
.
Assignee | ||
Comment 6•1 month ago
|
||
As an optimisation, use std::memset
resp. AtomicOperations::memsetSafeWhenRacy
if possible.
Assignee | ||
Comment 7•1 month ago
|
||
Assignee | ||
Comment 8•1 month ago
|
||
This removes some duplicate code and also adds a fast-path for the common case
when the input is an Int32 value.
Assignee | ||
Comment 9•1 month ago
|
||
Assignee | ||
Comment 10•1 month ago
|
||
Assignee | ||
Comment 11•1 month ago
|
||
Prefer (Un)SharedOps
to match the other code in this file.
Assignee | ||
Comment 12•1 month ago
|
||
Updated•1 month ago
|
Comment 13•1 month ago
|
||
Comment 14•1 month ago
|
||
Backed out for causing build bustages
Backout link: https://hg.mozilla.org/integration/autoland/rev/32f8744fbd6c272dd5991a0dce23b613a160a78b
Assignee | ||
Comment 15•1 month ago
|
||
(In reply to Sandor Molnar[:smolnar] from comment #14)
Backed out for causing build bustages
Thanks. Forgot to add the SIMD fallback implementation for non-x86 targets.
Comment 16•1 month ago
|
||
Comment 17•1 month ago
|
||
Just a FYI: This increased the XUL size by 56KB on Windows. This metric is not tracked directly for perf, so no action is expected.
Comment 18•1 month ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/d1d73f454db6
https://hg.mozilla.org/mozilla-central/rev/e8cf9870c8a0
https://hg.mozilla.org/mozilla-central/rev/b3ce1da10762
https://hg.mozilla.org/mozilla-central/rev/1a7fab3a784a
https://hg.mozilla.org/mozilla-central/rev/b35b2fd58724
https://hg.mozilla.org/mozilla-central/rev/419414519c43
https://hg.mozilla.org/mozilla-central/rev/9700e2704fff
https://hg.mozilla.org/mozilla-central/rev/829b0986166e
https://hg.mozilla.org/mozilla-central/rev/b8709ae86ced
https://hg.mozilla.org/mozilla-central/rev/a0b02649824d
https://hg.mozilla.org/mozilla-central/rev/5a3393e105c6
https://hg.mozilla.org/mozilla-central/rev/922d4aaa9028
https://hg.mozilla.org/mozilla-central/rev/3a6b0cf19d8f
Assignee | ||
Comment 19•29 days ago
|
||
(In reply to Mayank Bansal from comment #17)
Just a FYI: This increased the XUL size by 56KB on Windows. This metric is not tracked directly for perf, so no action is expected.
Interesting. I guess we could try if sharing code improve this. For example we instantiate TypedArrayReverse
24 times (= 12 (each element type) * 2 (shared and unshared)). If we instead only instantiate one version per element-width, we'd use only 4 * 2 = 8 TypedArrayReverse
functions.
Description
•