Why does the Mac ABI require 16-byte stack alignment for x86-32?

前端 未结 10 2185
野趣味
野趣味 2020-11-27 16:01

I can understand this requirement for the old PPC RISC systems and even for x86-64, but for the old tried-and-true x86? In this case, the stack needs to be aligned on 4 byte

10条回答
  •  -上瘾入骨i
    2020-11-27 16:38

    This is an efficiency issue.

    Making sure the stack is 16-byte aligned in every function that uses the new SSE instructions adds a lot of overhead for using those instructions, effectively reducing performance.

    On the other hand, keeping the stack 16-byte aligned at all times ensures that you can use SSE instructions freely with no performance penalty. There is no cost to this (cost measured in instructions at least). It only involves changing a constant in the prologue of the function.

    Wasting stack space is cheap, it is probably the hottest part of the cache.

提交回复
热议问题