fastcall真的更快吗? [英] Is fastcall really faster?

查看:388
本文介绍了fastcall真的更快吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

fastcall调用约定真的比其他调用约定更快,例如cdecl?
是否有任何基准显示调用约定对性能有何影响?

解决方案

。对于Xenon PowerPC,例如,由于在堆栈上传递数据时的负载 - 命中 - 存储问题,它可能是一个数量级的差异。我经验性地定时了 cdecl 函数的开销,大约45个周期,而 fastcall 的开销大约为4。 >

对于乱序的x86(Intel和AMD),影响可能会小得多,因为寄存器都被隐藏和重命名。



答案真的是你需要在你关心的特定平台上自行进行基准测试。


Is the fastcall calling convention really faster than other calling conventions, such as cdecl? Are there any benchmarks out there that show how performance is affected by calling convention?

解决方案

It depends on the platform. For a Xenon PowerPC, for example, it can be an order of magnitude difference due to a load-hit-store issue with passing data on the stack. I empirically timed the overhead of a cdecl function at about 45 cycles compared to ~4 for a fastcall.

For an out-of-order x86 (Intel and AMD), the impact may be much less, because the registers are all shadowed and renamed anyway.

The answer really is that you need to benchmark it yourself on the particular platform you care about.

这篇关于fastcall真的更快吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆