Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!usc!ucsd!ucbvax!hplabs!hpda!hpcupt1!jamiller From: jamiller@hpcupt1.HP.COM (Jim Miller) Newsgroups: comp.lang.c Subject: Re: function calls Message-ID: <5940022@hpcupt1.HP.COM> Date: 15 Mar 90 20:36:20 GMT References: <1990Mar14.172152.25436@utzoo.uucp> Organization: Hewlett Packard, Cupertino Lines: 27 > >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