[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tail calls (was Re: the benefits of immutability)

Perry E. Metzger <perry@piermont.com> asks:
> Speaking of tail calls, it appears the latest gcc (gcc 3.3.1) does
> full tail call optimizations, which it calls "sibling call
> optimization". Does anyone know if the feature is reliable enough to
> exploit in implementing higher level languages on top of C that need
> tail call optimization?

I used gcc in my implementation of Eager Haskell, and found that it
eliminated all the interprocedural tail calls (rendering the original
hack that inspired Eager Haskell irrelevant, I might add).  That said,
I was implementing a system with exact GC, which meant maintaining a
separate shadow stack for pointer values, and I used the regparm(n)
calling convention heavily on x86.  Both of these things together mean
that gcc doesn't have to work particularly hard to get sibling calls
to work.

-Jan-Willem Maessen