Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal to reconsider avoiding exposing of %AsyncFromSyncIteratorPrototype% #190

Closed
zloirock opened this issue Jul 6, 2022 · 1 comment · Fixed by #197
Closed

Proposal to reconsider avoiding exposing of %AsyncFromSyncIteratorPrototype% #190

zloirock opened this issue Jul 6, 2022 · 1 comment · Fixed by #197

Comments

@zloirock
Copy link
Contributor

zloirock commented Jul 6, 2022

Related to #182 (an extra wrapper for %AsyncFromSyncIteratorPrototype%)

The previous discussion in #172

I agree that the previous approach is observable and will cause a problem for optimization. However, the new approach also will cause a problem with optimization.

I don't wanna analyze the spec completely, but

await AsyncIterator.from([1]).toArray();

in my testing environment, before #182 runs microtasks 16 times, after - 24, I'm not sure about the correct number of ticks since some of them can be used for some other internal needs. However, this number makes me think about the need for such a change.

Removing extra ticks is a problem that now TC39 tries to solve - tc39/ecma262#2772 - and here we have such increasing.

Maybe makes sense to use another approach? For example, to make %AsyncFromSyncIteratorPrototype% exposing, but operations on it unobservable. How? For example, make .next, .return and .throw on this object non-writable / non-configurable.

@bakkot
Copy link
Collaborator

bakkot commented Jul 6, 2022

I think this is more of a problem with WrapForValidAsyncIteratorPrototype, actually - it can directly return the value from the underlying iterator, like WrapForValidIteratorPrototype does, instead of creating and resolving a Promise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants