Variable Parameters

Henry Spencer henry at utzoo.uucp
Wed Jan 3 03:44:37 AEST 1990


In article <366 at sixhub.UUCP> davidsen at sixhub.UUCP (bill davidsen) writes:
>| ... On some machines, the information can be deduced
>| from details of the stack frame or the calling sequence, but on many
>| modern systems, it has to be explicitly provided at significant cost.
>
>  As I mentioned, the original versions which with I worked in the 70's
>did have the caller provide the information, but the cost was only one
>word in the call sequence (no CPU overhead). As common as calls are in
>C, they are a very small % of the code...

They are not a small percentage of the time, however -- many C programs
can spend a *lot* of time calling and returning if the sequences are
inefficient.  (There are C programs, I'm told, which spend 50% of their
time in call/return on a VAX.)  Reserving a word somewhere to hold the
argument count is reasonable... but *where*?  The code may not be readable
at all (in fact, that was the reason why nargs() originally disappeared
from C).  Getting the value into data space, in general, takes run-time
overhead on calls, and there is generally a considerable performance win
in trimming every last unnecessary nanosecond out of calls.

With ANSI C requiring prototypes to be in scope for varargs calls, there
are now compilers that use different calling sequences for varargs and
non-varargs functions.  If everyone could be persuaded to do that, the
efficiency argument would be largely moot:  a bit of overhead in varargs
calls, and *only* varargs calls, is not a problem (indeed, there is often
considerable overhead there anyway).
-- 
1972: Saturn V #15 flight-ready|     Henry Spencer at U of Toronto Zoology
1990: birds nesting in engines | uunet!attcan!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.lang.c mailing list