[Top][All Lists]

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

Re: [Lightning] Tail calls - a better way

From: Paulo César Pereira de Andrade
Subject: Re: [Lightning] Tail calls - a better way
Date: Sat, 10 Jan 2015 11:59:14 -0200

2015-01-09 20:12 GMT-02:00 Francis McCabe <address@hidden>:
> Could not help butting in here.
> Paulo suggests the ‘classic’ way of implementing tail calls - by ‘sliding’ 
> the new activation over the old one.
> It turns out that there is a strictly faster way of implementing tail call 
> optimization: garbage collecting the evaluation stack.
> The idea would be to continue processing tail calls in the identical way to 
> regular calls - but, when a GC is required (by stack overflow for example) 
> the evaluation stack can be garbage collected of junk frames.
> In terms of support required, it would have to be similar to other GC support 
> schemes; except that there would have to be standard ways of walking the 
> stack - something that is useful for other applications (like debugging).

  That should require some special chaining of return addresses,
and possibly runtime information about modified callee save
registers, that would either, be all saved in the base of the
stack, or the saved value recovered from one of the frames.
I can see how this would not be too complicated, and quite

  But if using the "real, hardware stack" I think the best approach
is the classical one, otherwise, either would need too costly
checks every stack frame, or highly non portable ways to handle
faults, that are better done in the kernel.

> Frank McCabe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]