[LLVMdev] [Segmented Stacks] Week 1

Joerg Sonnenberger joerg at britannica.bec.de
Thu Jun 23 14:14:53 PDT 2011


On Thu, Jun 23, 2011 at 03:21:58PM -0400, Brian Hurt wrote:
> Segmented stacks are exciting to me, but only if the stacklets can be 
> freed.  Here's why: if segmented stacks allow for "infinite" stacks, tail 
> call optimization becomes a lot less important in functional languages- 
> still useful, but not live or die.

We discussed this on IRC a while ago. IMHO it is good enough if the
stack segments are kept in a double linked list and the allocation
callback (slow path!) checks if the current segment is the last. If it
isn't, it can reuse the next segment and free all others.

Advantage is that longjmp/setjmp and stack unwinding functions just
work. Function exit doesn't have to do any checks either, so it is
faster. Down side is that a deep recursion followed by code not using
much stack will keep the unused stack around potentially for ever.

Joerg



More information about the llvm-dev mailing list