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

Implement Async Generators #2720

Closed
bterlson opened this issue Mar 20, 2017 · 21 comments
Closed

Implement Async Generators #2720

bterlson opened this issue Mar 20, 2017 · 21 comments

Comments

@bterlson
Copy link
Contributor

Proposal is here: https://github.com/tc39/proposal-async-iteration
Basic idea is a combination of an async function and a generator - essentially a generator you can await within.

There are already a number of test262 tests and v8 has an implementation we can compare against.

@zbraniecki
Copy link

SpiderMonkey also has it implemented - https://bugzilla.mozilla.org/show_bug.cgi?id=1331092

@benjamingr
Copy link

Any update on this?

@bterlson
Copy link
Contributor Author

bterlson commented Dec 4, 2017

@benjamingr I have no update to share yet, but I'll be sure to update this issue (and the roadmap) when I do!

@zbraniecki
Copy link

This has been accepted into ES2018. With support in SpiderMonkey, V8 and jsc, it would be great to get this in ChakraCore soon.

@rektide
Copy link

rektide commented Mar 2, 2018

I don't know ChakraCore teams standard practice, but it would be SUPER HELPFUL to have a Platform Status thing to track.

@BobChao87
Copy link

BobChao87 commented Mar 5, 2018

@rektide Are you perhaps looking for Edge's Platform Status?

Unfortunately, it looks like the async iterators/generators/loops aren't quite there yet, but overall it's a very good resource.

@rhuanjl
Copy link
Collaborator

rhuanjl commented Jul 25, 2018

Is there any update on this feature/plan for when it will be implemented?

@ciscoo
Copy link

ciscoo commented Aug 9, 2018

@rhuanjl See the link posted by @BobChao87

It is currently marked as UNDER CONSIDERATION and:

Roadmap Priority: High — We intend to begin development soon.

So to answer your question, no idea when really, but soon. 🤷‍♂️

@rhuanjl
Copy link
Collaborator

rhuanjl commented Aug 9, 2018

@ciscoo the platform status isn't exactly up to date also it's Edge not Chakracore - features make it to CC some time before they make it to edge.

For 2 e.g.s of not up to date:

  1. Promise.prototype.finally per Edge platform status is in development BUT - it's fully functional in chakracore 1.10 (see PR 3520).
  2. Object rest/spread - per Edge platform status is under consideration BUT - it's actually experimentally implemented in CC - supported but behind a flag so should at least say in development.

@falsandtru
Copy link

Why does no one still implement or schedule this feature?

@rhuanjl
Copy link
Collaborator

rhuanjl commented Oct 23, 2018

Would an external contribution be welcome here?

(Not certain I could manage this but could give it a try if an external PR would be welcome)

@EdMaurer
Copy link
Contributor

Yes, it would, but this feature is thought to require a good amount of effort.

@rhuanjl
Copy link
Collaborator

rhuanjl commented Oct 24, 2018

Aware that this will be sizeable but i’ll make a start and see how it goes.

I’ll aim to have a PR ready to submit by mid-December but I can’t promise anything.

Please let me know by updating here if someone internally is scheduled to work on it (and hence I should stop).

@rhuanjl
Copy link
Collaborator

rhuanjl commented Nov 15, 2018

I think I'm nearly there with async generator functions - will aim to open a PR this weekend.

I have not touched for-await-of or Symbol.asyncIterator yet, I will endeavour to do those in a later PR. I want to submit what I've done on async generator functions before doing the other aspects of this feature as it's going to be over 1000 lines as it is.

@pleath
Copy link
Contributor

pleath commented Nov 15, 2018

Cool. How did you solve the problem you described earlier regarding the need to distinguish between yield and await?

@rhuanjl
Copy link
Collaborator

rhuanjl commented Nov 15, 2018

So when the asyncGenerator yields there are three possible cases:

  1. await
  2. yield
  3. yield*

Points 1 and 2 would both return to the same place with an object that had { value : something, done : false }

Point 3 would come in at the same place with an arbitrary object provided by the next call for the iterator in question.

For point 3 - add a boolean value to the ResumeYieldData struct to specifically detect this (still working on this point)

For point 1 vs point 2 omit the done value from the yielded object if it's an await (condition check in the byte code emitter for async generator await around the emission of byte code for the done value) - so after ruling out yield* can use JavascriptOperators::HasProperty to test if it was yield or await.

@rhuanjl
Copy link
Collaborator

rhuanjl commented Dec 9, 2018

@EdMaurer you were right it was a lot of effort; but I had several free weekends and needed something to do :) Hopefully someone has time to review it.

@zenparsing
Copy link
Contributor

Thanks so much @rhuanjl! We'll make sure it gets a look. I can't wait to get this in!

@rhuanjl
Copy link
Collaborator

rhuanjl commented Jun 30, 2019

Well this now is implemented behind a feature flag.

I assume it needs TTD and profiler support before it's enabled, is there anything else it needs?

Also please point me in the right direction if a PR would be welcome for the remaining points. (not sure where to start with the profiler or TTD)

@rhuanjl
Copy link
Collaborator

rhuanjl commented Sep 18, 2019

Asked before but asking again. Is there anything I can do to help get this enabled?

@rhuanjl rhuanjl added this to the vCommunity (1.12) milestone Apr 13, 2020
@rhuanjl
Copy link
Collaborator

rhuanjl commented Dec 14, 2020

This was enabled by #6456

@rhuanjl rhuanjl closed this as completed Dec 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests