LibJS: Skip iteration result allocation in AsyncFunctionDriverWrapper

- Create less GC pressure by making each `await` in async function skip
  iteration result object allocation.
- Skip uncached `Object::get()` calls to extract `value` and `done` from
  the iteration result object.

With this change, following function goes 30% faster on my computer:
```js
(async () => {
    const resolved = Promise.resolve();
    for (let i = 0; i < 5_000_000; i++) {
        await resolved;
    }
})();
```
This commit is contained in:
Aliaksandr Kalenik 2025-05-09 04:23:30 +03:00 committed by Andreas Kling
commit 4c789ac689
Notes: github-actions[bot] 2025-05-09 10:31:18 +00:00
7 changed files with 47 additions and 28 deletions

View file

@ -37,7 +37,7 @@ private:
IteratorHelper(Realm&, Object& prototype, GC::Ref<IteratorRecord>, GC::Ref<Closure>, GC::Ptr<AbruptClosure>);
virtual void visit_edges(Visitor&) override;
virtual ThrowCompletionOr<Value> execute(VM&, JS::Completion const& completion) override;
virtual ThrowCompletionOr<IterationResult> execute(VM&, JS::Completion const& completion) override;
GC::Ref<IteratorRecord> m_underlying_iterator; // [[UnderlyingIterator]]
GC::Ref<Closure> m_closure;