dispatchrun / coroutine

Durable coroutines for Go

Home Page:https://dispatch.run

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

compiler: replace coroutine.Yield calls with method call on coroutine context

achille-roussel opened this issue · comments

The implementation of coroutine.Yiled is a call to coroutine.LoadContext followed by a call to the Yield method on the returned coroutine context. However, the generated coroutine code makes a call to coroutine.LoadContext when entering a function, in each coroutine the context is already available as a local variable, which means that we are making an extra call to coroutine.LoadContext in coroutine.Yield that could be replaced by a direct method call on the context that we already loaded.