On Wednesday, September 26, 2018 2:34:02 AM MSK Konstantin Osipov wrote: > * Georgy Kirichenko [18/09/22 00:21]: > > A fiber's coro context stores execution state for a corresponding > > already yielded fiber. If fiber is on the execution then it hasn't > > valid stored coro state and might be backtraced without a special unwind > > context builder. > > I did not understand what's going on from the comment. I assume > this is an optimization, in which you try to avoid re-fetching the > registers in some cases? > > Please clarify. > > > -- Each yielded fiber has a preserved coro state stored in a corresponding variable however an executing fiber has a volatile state placed in CPU registers (stack pointer, instruction pointer and non-volatile registers) and corresponding context-storing variable value is invalid. For already yielded fiber we use a special asm-written handler to make a temporary switch to the preserved state and capture executing context what is not needed for executing fiber. After the patch for the executing fiber NULL is passed to the backtrace function as coro context and then backtrace function could decide should it use special context-switching handler or might just use unw_getcontext from the unwind library.