Re: When/why did function calls get cheap?

anton@mips.complang.tuwien.ac.at (Anton Ertl)
21 Feb 2003 00:54:54 -0500

          From comp.compilers

Related articles
[2 earlier articles]
Re: When/why did function calls get cheap? gah@ugcs.caltech.edu (Glen Herrmannsfeldt) (2003-02-13)
Re: When/why did function calls get cheap? bje@redhat.com (Ben Elliston) (2003-02-21)
Re: When/why did function calls get cheap? joachim_d@gmx.de (Joachim Durchholz) (2003-02-21)
Re: When/why did function calls get cheap? marcov@toad.stack.nl (Marco van de Voort) (2003-02-21)
Re: When/why did function calls get cheap? firefly@diku.dk (Peter Finderup Lund) (2003-02-21)
Re: When/why did function calls get cheap? firefly@diku.dk (Peter Finderup Lund) (2003-02-21)
Re: When/why did function calls get cheap? anton@mips.complang.tuwien.ac.at (2003-02-21)
Re: When/why did function calls get cheap? jplevyak@yahoo.com (John Plevyak) (2003-02-21)
Re: When/why did function calls get cheap? {spamtrap}@qeng-ho.org (Arthur Chance) (2003-02-24)
Re: When/why did function calls get cheap? gah@ugcs.caltech.edu (Glen Herrmannsfeldt) (2003-02-24)
Re: When/why did function calls get cheap? alexc@std.com (Alex Colvin) (2003-02-24)
Re: When/why did function calls get cheap? vbdis@aol.com (2003-02-24)
Re: When/why did function calls get cheap? firefly@diku.dk (Peter Finderup Lund) (2003-03-09)
[8 later articles]
| List of all articles for this month |
From: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.compilers
Date: 21 Feb 2003 00:54:54 -0500
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
References: 03-02-073 03-02-085
Keywords: performance, history
Posted-Date: 21 Feb 2003 00:54:54 EST

"John R. Strohm" <strohm@airmail.net> writes:
>Function calls aren't that expensive. They are becoming more
>expensive nowadays, because of the cost of cache misses on processors
>with horrendously long pipelines and superscalar execution and all
>that stuff.


I would not know that these factors are making them more expensive.


Compared to a naively inlined function, calling it reduces the spatial
locality a little, but if the function is called from several places,
the temporal locality is better with the function call. If you have
problems with I-cache misses, I would rather recommend trying to find
functions to factor out than to inline functions. This also depends
on the size of the function. It is typically a good idea to inline
very small functions (because the calling code needs more space than
the inlined code).


In the pipeline, direct calls and returns are very predictable, and
therefore don't cost that much.


Additional costs of function calls are in register saving and
restoring and parameter passing.


One would have to do measurements to see whether calls have become
relatively more or less expensive in the last decade.


- anton
--
M. Anton Ertl
anton@mips.complang.tuwien.ac.at
http://www.complang.tuwien.ac.at/anton/home.html


Post a followup to this message

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