Re: When/why did function calls get cheap?

Alex Colvin <alexc@std.com>
24 Feb 2003 14:35:49 -0500

          From comp.compilers

Related articles
[6 earlier articles]
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)
Re: When/why did function calls get cheap? joachim_d@gmx.de (Joachim Durchholz) (2003-03-09)
Re: When/why did function calls get cheap? klimas@klimas-consulting.com (Andreas Klimas) (2003-03-09)
Re: When/why did function calls get cheap? bonzini@gnu.org (2003-03-14)
Re: When/why did function calls get cheap? jcrens@earthlink.net (Jack Crenshaw) (2003-03-14)
[4 later articles]
| List of all articles for this month |
From: Alex Colvin <alexc@std.com>
Newsgroups: comp.compilers
Date: 24 Feb 2003 14:35:49 -0500
Organization: The World : www.TheWorld.com : Since 1989
References: 03-02-073 03-02-122
Keywords: architecture, practice, comment
Posted-Date: 24 Feb 2003 14:35:49 EST

>> My understanding is that in Olden Times, Real Programmers avoided
>> using lots of small functions because the overhead of a function call
>> was considered high. But then, somewhere along the way, the compiler
>> writers got clever and made function calls cheap so now nobody worries
>> about it.


>In addition to speed, changes in computer architecture have
>also had their effect:


Another factor is that programming language calls have moved closer to
what the hardware supports. Compare procedure calls in C and even C++ to
calls in PL/I and Algol.


C and C++ do not support dynamically sized automatic data, so the size of
a stack frame is fixed and all automatic data is at known offsets.
No do they support nested procedures with support for nonlocal auto
references, which typically involves display links.


C and C++ also pass parameters by value (including reference values).
Algol passed thunks, which had to be executed.


Function calls are still expensive in languages such as PERL.
Sprinkling C++ liberally with exception handlers, constructors and
destructors, and virtual functions might achieve the same effect.


--
mac the naïf
[The x86 supports nested scopes with ENTER and LEAVE. I'll agree that
Algol thunks are very hard to implement, but according to someone who
was there at the time, call-by-name was a mistake. They were trying
to define call-by-reference and overgeneralized. -John]


Post a followup to this message

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