setjmp/longjmp

Henry Spencer henry at utzoo.UUCP
Wed Nov 14 06:17:02 AEST 1984


> > Alas, even pushing a constant on every function call is a lot of expense
> > when every call has to pay it just so a few can do longjmp().
> 
> I find it hard to believe that your compiler is so good at optimizing
> code that a single instructuion (okay, 2 instructions on our honeywell)
> on each function call is going to make that much difference.

I'm on a pdp11, where the calling sequence is not all that great, maybe
eight or ten instructions (I forget...).  Even adding one instruction to
this is perhaps a 5-15% difference in speed.  This is *not trivial* when
we are talking about the most commonly-used control structure in C code --
if, while, and such don't even come close -- and when you bear in mind
that the function-call sequence has a history of being a major factor in
the speed of C code.  No joke:  when you profile a program on a machine
like the 11, where the C calling sequence stubs show up in the profile,
they usually aren't all that far down the sorted list.  Function-call
overhead is a major expense in C programs.
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,linus,decvax}!utzoo!henry



More information about the Comp.lang.c mailing list