[LLVMdev] [Segmented Stacks] Week 1

Brian Hurt bhurt at spnz.org
Thu Jun 30 15:24:25 PDT 2011



On Thu, 23 Jun 2011, Joerg Sonnenberger wrote:

> 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.

Perhaps there can be a function that can be called to trim the stack (keep 
1 segment and free the rest)?  This could then be called occassionally- 
say, at the start of a GC pass.

Brian




More information about the llvm-dev mailing list