cdecl and pascal keywords
Linus Torvalds
torvalds at cs.Helsinki.FI
Wed Jan 2 05:30:08 AEST 1991
In article <898 at tuura.UUCP> risto at tuura.UUCP (Risto Lankinen) writes:
[lots of interesting stuff deleted ...]
>By the way, an 'extremely optimizing' compiler could fight back a bit with
>_cdecl, by leaving the stack arguments intact between calls, should there be
>a (rare) piece of code, where exactly (or almost exactly) the same arguments
>are used in subsequent calls, and the arguments were declared as const.
In fact the compiler needn't be THAT optimizing to use the _cdecl to
speed up programs - it can defer stack cleanup until really necessary.
Thus instead of cleaning up the stack after EVERY call, it can call a
few functions and clean up the stack for ALL calls with one instruction
(ADD #n,A7 on mc68k etc.) This, I believe is done (optionally) by gcc.
Of course the compiler must be pretty certain that the stack doesn't get
TOO big, but it isn't (shouldn't) be that difficult to check for. IE:
....
pea addr # argument on stack, then
bsr _func1 # call _func1
move.l #0,-(a7) # don't clean up, just put new arg
bsr _func2 # on top of stack and call _func2
addq.l #8,a7 # now clean up both call arguments
...
Obviously, the speedup isn't dramatic, just my $ 0.02
>
>Terveisin: Risto Lankinen
>--
>Risto Lankinen / product specialist ***************************************
>Nokia Data Systems, Technology Dept * 2 2 *
>THIS SPACE INTENTIONALLY LEFT BLANK * 2 -1 is PRIME! Now working on 2 +1 *
>replies: risto at yj.data.nokia.fi ***************************************
Linus Torvalds torvalds at cs.helsinki.fi
More information about the Comp.lang.c
mailing list