Related articles |
---|
Help on code generation and register allocation Forum.Thomas.Krause@gmx.de (Thomas Krause) (2006-02-07) |
Re: Help on code generation and register allocation d148f3wg02@sneakemail.com (Karsten Nyblad) (2006-02-11) |
Re: Help on code generation and register allocation kym@ukato.freeshell.org (russell kym horsell) (2006-02-11) |
Re: Help on code generation and register allocation avayvod@gmail.com (Whywhat) (2006-02-11) |
Re: Help on code generation and register allocation u.hobelmann@web.de (Ulrich Hobelmann) (2006-02-12) |
Re: Help on code generation and register allocation avayvod@gmail.com (Whywhat) (2006-02-14) |
Re: Help on code generation and register allocation u.hobelmann@web.de (Ulrich Hobelmann) (2006-02-14) |
Re: Help on code generation and register allocation torbenm@app-5.diku.dk (2006-02-17) |
Re: Help on code generation and register allocation boldyrev@cgitftp.uiggm.nsc.ru (Ivan Boldyrev) (2006-02-17) |
Re: Help on code generation and register allocation fw@deneb.enyo.de (Florian Weimer) (2006-02-17) |
Re: Help on code generation and register allocation Forum.Thomas.Krause@gmx.de (Thomas Krause) (2006-02-20) |
From: | torbenm@app-5.diku.dk (=?iso-8859-1?q?Torben_=C6gidius_Mogensen?=) |
Newsgroups: | comp.compilers |
Date: | 17 Feb 2006 00:08:58 -0500 |
Organization: | Department of Computer Science, University of Copenhagen |
References: | 06-02-055 06-02-072 06-02-088 06-02-096 06-02-103 |
Keywords: | code, optimize |
Posted-Date: | 17 Feb 2006 00:08:58 EST |
Ulrich Hobelmann <u.hobelmann@web.de> writes:
> If tail recursion were completely target independent (and an
> optimization), I don't see why not all compilers would Just Do It.
> Especially GCC in Intel doesn't do it (except maybe for
> self-tail-recursion), which means that you have to use trampolines, or
> weird source code transformations to achieve the same effects (e.g. when
> you want to transform a DFA to machine code, routines tail-calling each
> other).
Tail-recursion optimisation is primarily applied to save stack space
rather than time. Some languages (like Scheme) require tail-recursion
(direct or indirect, even if through call/cc or higher-order function
calls) to use stack space independent on the number of calls, so when
compiling these languages to machines (such as JVM) that do not
directly support tail-calls, you have to go through complex maneuvres
such as trampolines.
As you say, in some cases tail-call optimisation adds extra
operations, so you can't guarantee that you save time (though in most
cases you do). Self-tail-recursion is an obvious place where you will
almost always save time as well as space by doing the optimisation.
Torben
Return to the
comp.compilers page.
Search the
comp.compilers archives again.