<div dir="ltr">The code generation for coroutine resume is pretty much the same as a switch statement; for a few suspend points it generates if(state==x) goto label else..., and for many suspend points it uses a jump table.<div><br><div><a href="https://godbolt.org/g/U3d1sz">https://godbolt.org/g/U3d1sz</a><br></div><div><br></div><div>I would have guessed that it would save the resume state as a call address directly, rather than save the state as an index into a jump table. What advantage does the switch approach have? Why not just save a new resume address in the frame prefix after each resume?</div></div></div>