🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #12904

Re: subroutine frequency

#12904
From: jgp
Date: Thu, 29 Jan 1987 01:37
29 lines
2187 bytes
In article <1881@homxc.UUCP> dwc@homxc.UUCP writes:
>In some other article someone else writes:
>>If the routine is called many times the cost of saving and
>>restoring registers during the call and return can offset any
>>speed savings thru register usage.
>am i missing something or does the frequency of calls not matter?
I agree that the frequency shouldn't matter.  The real question would
be if any compiler is smart enough to ignore a register declaration if
the resulting code would run slower (eg. if a parameter is only accessed
once, outside of a loop, the compiler would probably be better off to
ignore a register declaration).

>do compilers take the time to keep track of which registers have
>been used and only save the 'dirty' ones or do most call and
>return mechanisms save the entire register set on the stack?
It depends on the architecture and the compiler, the three easy ways
to do it are:
	a) save all registers
	b) have the caller save only the registers it is using
	c) have the callee save only the registers it will use
pdp-11's use "a" since they only have 3 register variables anyway.  Most
68k compilers use "c" since you get about 12 register variables.  I don't
know of anyone who uses "b" but it should be about as efficient as "c".

The method used has a large effect on whether setjmp/longjmp can put the
correct values back into register variables (SYSVID says they may be
unpredictable :-(.
-- 
Jim Prescott	rochester!moscom!jgp
Technical Details
Message-ID: <898@moscom.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!rutgers!sri-spam!sri-unix!hplabs!decwrl!decvax!tektronix!uw-beaver!cornell!rochester!ur-tut!ur-valhalla!moscom!jgp
References: <1881@homxc.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!rutgers!sri-spam!sri-unix!hplabs!decwrl!decvax!tektronix!uw-beaver!cornell!rochester!ur-tut!ur-valhalla!moscom!jgp
From: jgp@moscom.UUCP
Newsgroups: comp.arch
Subject: Re: subroutine frequency
Message-ID: <898@moscom.UUCP>
Date: Wed, 28-Jan-87 20:37:48 EST
Article-I.D.: moscom.898
Posted: Wed Jan 28 20:37:48 1987
Date-Received: Sat, 31-Jan-87 04:04:53 EST
References: <1881@homxc.UUCP>
Reply-To: jgp@moscom.UUCP (Jim Prescott)
Organization: MOSCOM Corp, E Rochester, NY, USA
Lines: 29
Keywords: register stack frame variable
Summary: Register variables can slow down code and break setjmp