堆栈是否在缓存中? [英] Is the stack in a cache?

查看:45
本文介绍了堆栈是否在缓存中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在现代计算机中,我知道当前代码区域位于高速缓存中.但是,在许多计算机语言实现中,本地(自动)变量将位于堆栈中,因此会有大量内存访问堆栈.

In modern computers I know that the current code region is in a high-speed cache. However, in many computer language implementations the local (automatic) variables will be on the stack, so there will be a lot of memory accesses to the stack.

堆栈是否在正常架构中的另一个缓存中?

Is the stack in another cache in normal architectures?

如果不是,假设堆栈可以重新定位到本地",即非常靠近当前代码段,这样它就会在用于代码的缓存中.这会加速自动变量的内存访问吗?

If, not, suppose the stack could be relocated to be "local", ie very near to the current code segment, so that it would be within the cache being used for the code. Would this speed up memory access for automatic variables?

推荐答案

实际上,当您将一个值从 CPU 寄存器推送到堆栈时,该值将首先缓存在一个隐藏的寄存器中.这是可能的,因为现代 CPU(至少可以追溯到 15 年前)拥有的寄存器多于寄存器名称,因此可以使用未命名的寄存器.

In practice, when you push a value from a CPU register to the stack, the value will first be cached in a hidden register. This is possible because modern CPU's (dating back at least 15 years) have more registers than register names, so there are unnamed registers which can be used for this.

这篇关于堆栈是否在缓存中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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