I believe that instead of segmented stacks, the runtime should determine a 
tight upper bound for stack space for the a task's function, and only allocate 
a fixed stack of that size, falling back to a large "C-sized" stack if a bound 
cannot be determined.

Such a bound can always be computed if there is no recursion, dynamic dispatch, 
dynamic allocation on the stack, or foreign C functions.

And in fact, it can probably be computed even for foreign C functions, as long 
as DWARF exception tables are available, or some constraints on machine code 
are assumed (i.e. that negative offsets are not applied to pointers to the 
stack stored in memory).

This would allow for instance to transform many simple internal iterators into 
external ones automatically via coroutines, without large memory overhead.
                                          
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to