2 ms·
In an implementation of a language that can't take the address of a local variable, you can move some stack frames to the new segment when you switch segments,
by kragen 5y ago
In an implementation of a language that can't take the address of a local variable, you can move some stack frames to the new segment when you switch segments, 256 bytes or so. Then, to oscillate around the boundary, you need to return enough times to deallocate those 256 bytes. This will cost enough to swamp the cost of switching segments.
(If you can take the address of a local variable, but you have garbage collection and can handle memory allocation failures by exiting, you can heap-allocate whatever local variables have their address taken.)
Segmented stacks are a particularly efficient way to implement call/cc.