4 ms·
> If I want a function to restore certain registers, wouldn’t it be simpler if I was the one that save them on my memory, call the function, and then override t
by chrisseaton 4y ago
> If I want a function to restore certain registers, wouldn’t it be simpler if I was the one that save them on my memory, call the function, and then override the registers with whatever values the function set?
That's a waste if the callee doesn't use them.
- otikik 4y agoIndeed. But isn’t it also a waste when someone doesn’t follow through and then we have situations like the one described on the article?
- catiopatio 4y agoSuch cases are rare bugs in a small amount of code — mostly just compilers and hand-written assembly. Preemptively saving and restoring all registers in all callers would appreciably slow down every single function call on every device in the world using that ABI. The cumulative cost would be astronomical.