Re: Proper Tail Recursive C++

hbaker@netcom.com (Henry Baker)
5 Mar 1997 13:45:20 -0500

          From comp.compilers

Related articles
[3 earlier articles]
Re: Proper Tail Recursive C++ will@ccs.neu.edu (William D Clinger) (1997-02-23)
Re: Proper Tail Recursive C++ fjh@mundook.cs.mu.OZ.AU (1997-02-23)
Re: Proper Tail Recursive C++ bothner@cygnus.com (1997-02-23)
Re: Proper Tail Recursive C++ andy@wonderworks.co.uk (Andy Armstrong) (1997-02-27)
Re: Proper Tail Recursive C++ gary@wheel.tiac.net (1997-03-01)
Re: Proper Tail Recursive C++ Wilco.Dijkstra@armltd.co.uk (Wilco Dijkstra) (1997-03-01)
Re: Proper Tail Recursive C++ hbaker@netcom.com (1997-03-05)
Re: Proper Tail Recursive C++ njl@cyberpass.net (1997-03-09)
Re: Proper Tail Recursive C++ hbaker@netcom.com (1997-03-13)
Re: Proper Tail Recursive C++ fjh@murlibobo.cs.mu.OZ.AU (1997-03-13)
Re: Proper Tail Recursive C++ ramsdell@linus.mitre.org (1997-03-16)
Re: Proper Tail Recursive C++ danwang@atomic.CS.Princeton.EDU (1997-03-18)
Re: Proper Tail Recursive C++ njl@cyberpass.net (1997-03-21)
[1 later articles]
| List of all articles for this month |
From: hbaker@netcom.com (Henry Baker)
Newsgroups: comp.compilers
Date: 5 Mar 1997 13:45:20 -0500
Organization: Compilers Central
References: 97-02-111 97-02-131 97-02-141 97-03-010
Keywords: storage, C++, optimize

wdijkstr@armltd.co.uk wrote:
> In order to be able to generate a tail-recursive call to f, a C/C++
> compiler needs to know the following:
>
> A It is OK to access data *below* the current stack frame. In other
> words, the stack is not used by interrupts, exception handlers, etc.
>
> B The function which is called, nor its decendants do use the stack in
> a way which may overwrite the live parts of the array. Or, simply,
> the function which is called must be a simple leaf function (doesn't
> use stack).
>
> For many runtime systems A can never hold, and B is simple too hard to
> check at compile time (except for the case that g was before f in the
> source).


On some run-time systems it may be possible to 'redefine' the topmost
stack frame to be bigger on each 'tail-call'. Thus, you may be able
to achieve 'tail-calling' even though the tail call allocates live
storage. I would imagine that such a system would require both a
'stack' and a 'frame' pointer to work correctly.


--


Post a followup to this message

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