I am using non-local jumps (setjmp, longjmp). I would like to know if it can be a problem for the performances. Does setjmp save all the stack, or just some pointers ?
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Like Jens said, if it ever becomes a noticeable bottleneck, redesign it since that is not how
setjmpis supposed to be used.As for your question:
This probably depends on which architecture you are running your program on and exactly what the compiler does with your code. On ARM,
gotois probably translated into a single branch instruction which is quite fast.setjmpandlongjmpon the other hand need to save and restore all registers in order to resume execution after the jump. On an ARMv7-a with NEON support, this would require saving roughly 16 32-bit registers and up to 16 128-bit registers which is quite a bit of extra work compared to a simple branch.I have no idea if less work is required on x86, but I would suspect that
gotois a lot cheaper there too.