“进入"与“push ebp;"mov ebp, esp;sub esp, imm"和“离开"与“mov esp,ebp;流行音乐" [英] "enter" vs "push ebp; mov ebp, esp; sub esp, imm" and "leave" vs "mov esp, ebp; pop ebp"

查看:41
本文介绍了“进入"与“push ebp;"mov ebp, esp;sub esp, imm"和“离开"与“mov esp,ebp;流行音乐"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

enter

push ebp
mov  ebp, esp
sub  esp, imm

说明?有性能差异吗?如果是这样,哪个更快?为什么编译器总是使用后者?

instructions? Is there a performence difference? If so, which is faster and why do compilers always use the latter?

leave

mov  esp, ebp
pop  ebp

说明.

推荐答案

存在性能差异,尤其是对于enter.在现代处理器上,这解码为大约 10 到 20 µops,而三个指令序列大约为 4 到 6,具体取决于架构.有关详细信息,请参阅 Agner Fog 的说明表.

There is a performance difference, especially for enter. On modern processors this decodes to some 10 to 20 µops, while the three instruction sequence is about 4 to 6, depending on the architecture. For details consult Agner Fog's instruction tables.

此外,enter 指令通常具有相当高的延迟,例如,与三个指令序列的 3 个时钟依赖链相比,core2 上有 8 个时钟.

Additionally the enter instruction usually has a quite high latency, for example 8 clocks on a core2, compared to the 3 clocks dependency chain of the three instruction sequence.

此外,为了调度目的,编译器可能会分散这三个指令序列,当然这取决于周围的代码,以允许更多的指令并行执行.

Furthermore the three instruction sequence may be spread out by the compiler for scheduling purposes, depending on the surrounding code of course, to allow more parallel execution of instructions.

这篇关于“进入"与“push ebp;"mov ebp, esp;sub esp, imm"和“离开"与“mov esp,ebp;流行音乐"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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