我正在阅读 Ulrich Drepper 的“每个计算机科学家都应该了解的关于内存的知识”。
在第 6.2.2 节中,内容如下:
[...] instructions have to be decoded before they can be executed and, to speed this up (important on x86 and x86-64), instructions are actually cached in the decoded form, not in the byte/word form read from memory.
作者所说的指令的“解码”形式是什么意思?指令本身的意思不就是它们的意思吗?例如,“添加”是“添加”...
它的“解码”形式是什么?为什么他们需要缓存它?它不会是确定性的吗? “解码”流水线中的指令是否需要时间,为什么?
最佳答案
现代 Intel CPU 实际上使用所谓的 microcode 执行许多指令.微码由用更简单的低级指令集编写的代码组成,用于实现高级指令(例如,以 rep
为前缀的指令可能被实现为微码循环)。因为这实际上需要 CPU 本身将您的输入指令流“编译”成微码,所以可以想象缓存的是这个微码(以避免重复编译的开销)。
当然,缓存“解码”指令的精确细节因处理器而异,因此不可能有一般性陈述。
关于assembly - 指令的解码形式是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30061932/