developing high performance coroutines for ARMs
summary
Prototype coroutine implementation for ARM uses hand-written assembly to swap SP and save/restore callee-saved registers, treating the coroutine object so its stack pointer is the first field and allowing the caller to supply the stack buffer. Context switches cost about 22 cycles per context switch; creating and entering a coroutine adds overhead so a simple state machine runs ~11 cycles per state while the coroutine path measures ~47 cycles, so the break-even is around 70 states. It passes 32/64-bit values via argument registers and supports lambdas/function objects on bare metal.
AI-written summary · about
