Add fast path when TypedArray.from is called with arrays
Categories
(Core :: JavaScript Engine, enhancement)
Tracking
()
People
(Reporter: anba, Assigned: anba)
References
Details
Attachments
(2 files)
14.95 KB,
patch
|
jandem
:
review+
|
Details | Diff | Splinter Review |
6.22 KB,
patch
|
jandem
:
review+
|
Details | Diff | Splinter Review |
bug 1491813 will need some helpers to detect built-in TypedArray constructors and an unchanged %ArrayIteratorPrototype%.next property. These two helpers can also be used to optimise the case when TypedArray.from(...)
is called with normal arrays. So let's do this first here to unblock the work on bug 1491813.
Assignee | ||
Comment 1•5 years ago
|
||
Adds a fast path when TypedArray.from is called with a packed array.
The fast path can be applied when the following conditions hold:
- There is no mapper function which could modify the input array during the iteration.
- The constructor is a built-in TypedArray constructor.
- The iterator function is the builtin Array.prototype[Symbol.iterator] function
ArrayValues
. - The array itself is a packed array.
- And finally ArrayIteratorPrototype is still in its initial state.
This optimisation allows to omit creating a temporary list in IterableToList
and instead directly fill the TypedArray elements from the input array using the existing ElementSpecific<T, UnsharedOps>::initFromIterablePackedArray
function.
Drive-by change:
- Change
ForOfPIC::createForOfPICObject
to directly create a tenured object, because this object is created once and then stored indefinitely in the global object. - Make some
ForOfPIC
methods private.
The IsTypedArrayConstructor
and ArrayIteratorPrototypeOptimizable
helpers will also be necessary in bug 1491813.
Assignee | ||
Comment 2•5 years ago
|
||
Allow to replace the IsTypedArrayConstructor
call with a constant when the function is always called with TypedArray constructor functions.
Assignee | ||
Comment 3•5 years ago
|
||
I also have a patch to inline ArrayIteratorPrototypeOptimizable
, but since I'm not quite sure about possible gc-barrier interactions I need to be aware of when reading GCPtr<>
fields directly from assembler code, I'd like to defer that part for now.
Updated•5 years ago
|
Comment 4•5 years ago
|
||
Comment on attachment 9040504 [details] [diff] [review] bug1522157-part1-fastpath-for-packedarray.patch Review of attachment 9040504 [details] [diff] [review]: ----------------------------------------------------------------- LGTM!
Assignee | ||
Comment 5•5 years ago
|
||
Try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=c0049909891557179fae1ac711f5740adc139efb
Pushed by nerli@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/d58a5867916b
Part 1: Add fast path when TypedArray.from is called with packed arrays. r=jandem
https://hg.mozilla.org/integration/mozilla-inbound/rev/f801cbd96efc
Part 2: Inline IsTypedArrayConstructor with a constant if possible. r=jandem
Comment 7•5 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/d58a5867916b
https://hg.mozilla.org/mozilla-central/rev/f801cbd96efc
Updated•5 years ago
|
Description
•