Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I wonder if setjmp/longjmp can be implemented in hardware, i.e. introduce an instruction set that points, save and switch the current registers called register window that can be switched by saving a pointer.

This way both setjmp and longjmp are basically few cycles and exception handling would be hella fast.



The DEC VAX-11 instruction set had SVPCTX and LDPCTX for the kernel which made context switch simple. But they were reserved instructions; so they couldn't be used for setjmp() and longjmp(). VAX-11 also had queue instructions which made rescheduling simple. This was basically:

  SETIPL
  SVPCTX
  INSQUE
  FFS
  REMQUE
  LDPCTX
  SETIPL
Yeah, there was a little more. See page 188 of ... http://bitsavers.informatik.uni-stuttgart.de/pdf/dec/vax/vms...


Intel has e.g. push all/pop all instructions. It doesn't save everything needed for setjmp/longjmp (like fpu state) but does a decent job.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: