Iterating over fast arrays currently is 2.5x slower than it should be. Example:
for (const x of [1,2,3]) print(x)
It goes through the whole rigamarole of:
- invoking
[Symbol.iterator]()
- creating an iterator object
iter
- repeatedly invoking
iter.next() until it's exhausted
For fast arrays, all three steps are pure overhead.
A fast array fast path is in principle easy to implement except for the perennial problem of mutation while iterating. Maybe track the array's JSShape and bail out if it changes?
Bailing out can be done by calling js_create_array_iterator() and updating it->idx to the current index.
Iterating over fast arrays currently is 2.5x slower than it should be. Example:
It goes through the whole rigamarole of:
[Symbol.iterator]()iteriter.next()until it's exhaustedFor fast arrays, all three steps are pure overhead.
A fast array fast path is in principle easy to implement except for the perennial problem of mutation while iterating. Maybe track the array's
JSShapeand bail out if it changes?Bailing out can be done by calling
js_create_array_iterator()and updatingit->idxto the current index.