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

Generators and Async functions are not jitted #5877

Closed
rhuanjl opened this issue Dec 15, 2018 · 3 comments · Fixed by #6662
Closed

Generators and Async functions are not jitted #5877

rhuanjl opened this issue Dec 15, 2018 · 3 comments · Fixed by #6662

Comments

@rhuanjl
Copy link
Collaborator

rhuanjl commented Dec 15, 2018

I assume this is a point that is known internally - but it wasn't in the issue log on Github. Currently Generator functions and async functions are always run only in the interpreter.

There is a flag -Jites6Generators to enable jitting them - but using this always results in a crash in the Jit - it encounters an unallocated register the first time it tries to Jit a ResumeYield op. src10pnd is set to a nullptr by this and it goes wrong from there: https://github.com/Microsoft/ChakraCore/blob/8527dc23954bdf77b17d25e472857f58a3b03f8a/lib/Backend/IRBuilder.cpp#L1875

I stumbled upon this whilst working on #5834 there are a few TODOs and equivalent notes in comments about this all dating back to the initial GitHub commit 3 years ago.

I've tried to investigate how to fix this but I'm a bit out of my depth in the Jit code.

@pleath
Copy link
Contributor

pleath commented Dec 15, 2018

That's right. Jitting generators is a large work item, much larger than support for async generators, and one that we haven't had a chance to take on.

@fatcerberus
Copy link
Contributor

I’m kind of curious myself what the concrete challenge for jitting here is - I suppose a big source of difficulty would be that the JIT in general assumes it can store local state on the stack but coroutines violate that assumption...

@LouisLaf
Copy link
Collaborator

LouisLaf commented Jan 9, 2019

Basic JIT isn't trivial, but shouldn't be too hard. Optimizing well in the presence of generators is much harder, much like it is for optimizing within a try block.
We had someone take a stab at it a while back as you pointed out, but there were a lot of problems with the design. We decided to shelve it and focus on optimizing other ES6 features first. We'll get back to it hopefully at some point, but not in the short term.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment