Hacker News new | past | comments | ask | show | jobs | submit login

Not exactly, you would have to save all registers all the time.

For caller-saved/scratch registers in interrupt handlers, not only do you have to avoid stomping over registers, anything you call has to do too. You have three options here:

- Save all the registers in each interrupt

- Only call "save all registers" functions in your function, enforce this somehow. Since things like pagefault handlers can get pretty involved, you probably don't want to do this.

- Just compile your kernel with most extra registers disabled.

There is the fourth option which involves whole program taint analysis or something to track the registers stomped on by all transitive calls from the exception handler. Requires special compiler support though.




You certainly wouldn't have to save all registers in the case of a leaf function.

And yes, optimizing this would require special compiler support. That is the point!

The compiler is the only component that is in a position to possibly do something smarter than spilling everything. Even if the compiler doesn't actually do this, letting users say what they mean is better than making them write something that will definitely be sub-optimal. It at least leaves open the possibility that the compiler could do something smarter.




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

Search: