What's the advantage of having nonvolatile registers in a calling convention?

后端 未结 3 1438
粉色の甜心
粉色の甜心 2021-01-15 15:36

I\'m programming a JIT compiler and I\'ve been surprised to discover that so many of the x86-64 registers are nonvolatile (callee-preserved) in the Win64 calling convention.

3条回答
  •  失恋的感觉
    2021-01-15 16:19

    If registers are caller-saves, then the caller always has to save or reload those registers around a function call. But if registers are callee-saves, then the callee only has to save the registers that it uses, and only when it knows they're going to be used (i.e. maybe not at all in an early-exit scenario). The disadvantage of this convention is that the callee doesn't have knowledge of the caller, so it might be saving registers that are dead anyway, but I guess that's seen as a smaller concern.

提交回复
热议问题