LibJS: Optimize array destructuring assignment for builtin iterators

...by avoiding `{ value, done }` iterator result value allocation. This
change applies the same otimization 81b6a11 added for `for..in` and
`for..of`.

Makes following micro benchmark go 22% faster on my computer:
```js
function f() {
    const arr = [];
    for (let i = 0; i < 10_000_000; i++) {
        arr.push([i]);
    }
    let sum = 0;
    for (let [i] of arr) {
        sum += i;
    }
}

f();
```
This commit is contained in:
Aliaksandr Kalenik 2025-05-01 16:05:24 +03:00 committed by Alexander Kalenik
commit 60bd5012fe
Notes: github-actions[bot] 2025-05-01 13:58:54 +00:00
4 changed files with 11 additions and 15 deletions

View file

@ -2721,10 +2721,10 @@ private:
Operand m_iterator_record;
};
class ForOfNext final : public Instruction {
class IteratorNextUnpack final : public Instruction {
public:
ForOfNext(Operand dst_value, Operand dst_done, Operand iterator_record)
: Instruction(Type::ForOfNext)
IteratorNextUnpack(Operand dst_value, Operand dst_done, Operand iterator_record)
: Instruction(Type::IteratorNextUnpack)
, m_dst_value(dst_value)
, m_dst_done(dst_done)
, m_iterator_record(iterator_record)