AMD has an ABI specification that describes the calling convention to use on x86-64. All OSes follow it, except for Windows which has it's own x86-64 calling convention. Why?
Does anyone know the technical, historical, or political reasons for this difference, or is it purely a matter of NIHsyndrome?
I understand that different OSes may have different needs for higher level things, but that doesn't explain why for example the register parameter passing order on Windows is rcx - rdx …
我发现了以下问题:fastcall真的更快吗?
没有给出x86的明确答案所以我决定创建基准.
这是代码:
#include <time.h>
int __fastcall func(int i)
{
return i + 5;
}
int _stdcall func2(int i)
{
return i + 5;
}
int _tmain(int argc, _TCHAR* argv[])
{
int iter = 100;
int x = 0;
clock_t t = clock();
for (int j = 0; j <= iter;j++)
for (int i = 0; i <= 1000000;i++)
x = func(x & 0xFF);
printf("%d\n", clock() - t);
t = clock();
for (int j = 0; j <= iter;j++) …
Run Code Online (Sandbox Code Playgroud) 在英特尔64和IA-32架构软件开发人员手册说,大约由单一处理器的行动("在P6更多最近的处理器系列内存排序和"第8.2.2节)重新排序如下:
读取可以使用较旧的写入到不同位置进行重新排序,但不能使用较旧的写入到同一位置.
接下来讨论与早期处理器相比放松的点时,它说:
存储缓冲区转发,当读取将写入传递到同一存储器位置时.
据我所知,"存储缓冲区转发"并未在任何地方精确定义(也不是"通过").读取将写入传递到同一位置是什么意思,因为上面说它不能通过写入同一位置来重新排序?
我会听一些人说__fastcall
比这更快__cdecl
并且__stdcall
导致它将两个参数放入寄存器,而不是其他一个调用; 但是,另一方面,这不是C中使用的标准.
我想知道什么是__fastcall
不合适的,就像C中的标准,以及何时我将在我的代码中使用它.
我fastcall
在许多函数之前看过附加的符号.为什么用它?
考虑到:
微软特定
__fastcall调用约定指定函数的参数尽可能在寄存器中传递.以下列表显示了此调用约定的实现.
并且寄存器中的读/写时间比堆栈中的更快,我们在C#中是否有任何__fastcall等价物?
c++ ×3
fastcall ×2
assembly ×1
c ×1
c# ×1
cdecl ×1
concurrency ×1
intel ×1
memory-model ×1
optimization ×1
visual-c++ ×1
windows ×1
x86-64 ×1