function calls

Jim Miller jamiller at hpcupt1.HP.COM
Fri Mar 16 06:36:20 AEST 1990


>
>Most machines implement call/return with single instructions.  However, this
>tends to be the tip of the iceberg for procedure call overhead.  The interface
>_MUST_ do the following:
>
>1) Save/restore all register values that are still 'live' values for the
>   caller.
...
>procedures - including 'leaf' routines.  Basically, 'leafness' has very
>little to do with procedure call overhead.  Because modern machines tend
>to have a _large_ number of registers, implementing (1) is usually quite
>expensive - and it can't be made cheaper without interprocedural analysis
>which in turn can't be done as long as separate compilation is possible.
>Oh, well---
>
>J. Giles

Not completely true. The calling convention can have some registers
"caller save" and others "callee save".  So the caller only saves those
registers that the callee is allowed to use without restoring your
values when returning.  So if the leaf only needs the argument registers
and one or two more, then the callee doesn't have to save anything,
and a good compiler doesn't have to save much (if anything) in the
caller.  The HP Risk machine does this, with some success.  Milage
will vary with machine and application.

    jim miller



More information about the Comp.lang.c mailing list