[Q:] tail calls and parameter passing

Fermin Reig <reig@dcs.gla.ac.uk>
19 Nov 1998 23:23:17 -0500

          From comp.compilers

Related articles
[Q:] tail calls and parameter passing reig@dcs.gla.ac.uk (Fermin Reig) (1998-11-19)
Re: [Q:] tail calls and parameter passing gary@wheel.tiac.net (1998-11-21)
Re: [Q:] tail calls and parameter passing ramsdell@linus.mitre.org (John D. Ramsdell) (1998-11-21)
Re: [Q:] tail calls and parameter passing monnier+comp/compilers/news/@tequila.cs.yale.edu (Stefan Monnier) (1998-11-24)
Re: [Q:] tail calls and parameter passing bijuthom@ibm.net (Biju Thomas) (1998-11-24)
| List of all articles for this month |

From: Fermin Reig <reig@dcs.gla.ac.uk>
Newsgroups: comp.compilers
Date: 19 Nov 1998 23:23:17 -0500
Organization: Dept. of Computing Science, Glasgow University
Keywords: optimize

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.


Fermin Reig
--
Fermin Reig
Department of Computing Science, University of Glasgow
http://www.dcs.gla.ac.uk/~reig


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.