|[Q:] tail calls and parameter passing firstname.lastname@example.org (Fermin Reig) (1998-11-19)|
|Re: [Q:] tail calls and parameter passing email@example.com (1998-11-21)|
|Re: [Q:] tail calls and parameter passing firstname.lastname@example.org (John D. Ramsdell) (1998-11-21)|
|Re: [Q:] tail calls and parameter passing email@example.com (Stefan Monnier) (1998-11-24)|
|Re: [Q:] tail calls and parameter passing firstname.lastname@example.org (Biju Thomas) (1998-11-24)|
|From:||Fermin Reig <email@example.com>|
|Date:||19 Nov 1998 23:23:17 -0500|
|Organization:||Dept. of Computing Science, Glasgow University|
I would appreciate pointers to papers that describe implementations of
tail call optimization in languages that implement activation frames
in the stack.
The literature does not seem to have enough details on
implementation. In particular, I'd like to know how implementors solve
the following problem:
Consider a procedure F that only calls procedure G and all of G's
parameters fit in registers. In this scenario, F does not need to
reserve any space for memory arguments in its own frame. Suppose now
that G makes a tail call to H, *which expects one argument in
memory*. Since it is a tail call, G deallocates its frame just before
transferring control to H. The stack now holds H's frame on top of F's
frame, just as if F had called H (by virtue of the tail call all
traces of G have vanished from the picture). Now, if H tries to access
its memory argument from its caller's frame, it will try to read it
from F's frame, but F never reserved any space for overflow arguments
in its own frame!
The tail call sequence can be as large as one wants: G -> H -> ... and
one of these procedures may expect any number of arguments in the
stack (in the caller's frame).
Moreover, F can be in a different module from G, H ..., so when we
compile F we may know how many memory arguments G expects (none), but
we have no way of knowing that G will make the tail call.
Any pointers or descriptions appreciated.
Department of Computing Science, University of Glasgow
Return to the
Search the comp.compilers archives again.