dam@mtgzz.att.com (d.a.morano) (01/27/89)
In article <9467@ihlpb.ATT.COM>, gregg@ihlpb.ATT.COM (Wonderly) writes: > It strikes me that setjmp() could save all GP registers. I know of at > least one implementation were a jmp_buf is enough space for the entire > register set. longjmp() of course just reloads the registers grabs the > return value passed, and jumps to the return address given to it (on the > stack or elsewhere). The expense is a consideration but the results are > guaranteed in the cases I can think of. I have implemented setjmp/longjmp assembly routines for both the MC680x0 and WE32x00 processors and this is exactly what I did. The inefficiency of saving all of the registers is worth it from a safety point of view in order to allow the compiler to perform its best register optimizations. It is not clear to me why there seems to be so much interest in the performance of setjmp. It is only a few assembly instructions as it is. I am not even sure why ANSI made setjmp and longjmp macros. I know that some computer vendors (in Europe ??) complained that their architectures did not support these as subroutines, but an implementation that saves all of the registers in a subroutine seems to me to be both safe and relatively straight forward, on any architecture that I am familiar ! I can only assume that I do not fully understand the issues involved. Dave Morano AT&T Bell Laboratories, MT mtgzz!dam