4 ms·
yes, you understood correctly. The intuition here is that the rest of the callers saved registers are already saved by the compiler itself in the stack, you jus
by gpderetta 6y ago
yes, you understood correctly. The intuition here is that the rest of the callers saved registers are already saved by the compiler itself in the stack, you just need to complete the work. In fact, via GCC inline ASM, you can leave to the compiler the job of saving all registers and the swap routine doesn't have to touch memory at all [1]
You can actually do it on a single stack though: when you detect a stack overflow, you traverse the stack and garbage collect no longer referenced stack frames (in practice you copy referenced stack frames to a new stack). The "small" catch is that your functions can no longer return and you need to commit to pure CPS, so this technique [2] is only used for some compilers-to-c for other languages with first class continuations.
[1] https://github.com/gpderetta/delimited/blob/master/delimited.hpp#L264 https://github.com/gpderetta/delimited/blob/master/delimited...
the idea is very simple, 99% of the complexity here is because I'm trying to transparently (i.e. with zero cost) propagate C++ exceptions across coroutines.
[2] https://wiki.c2.com/?CheneyOnTheMta https://wiki.c2.com/?CheneyOnTheMta