凡在.NET局部变量存储在哪里? [英] Where are .NET local variables stored?

查看:163
本文介绍了凡在.NET局部变量存储在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在IL,您可以定义使用 .locals 指令的局部变量。凡被这些变量存储堆栈或堆?

In IL, you can define local variables using the .locals directive. Where are these variables stored, stack or heap?

推荐答案

这是JIT编译器非常多的实现细节。它会非常努力地存储局部变量在CPU寄存器,效率非常高。堆栈是通常的后备存储,万一有不可用于存储所有的局部变量足够的寄存器

It is very much an implementation detail of the JIT compiler. It will try very hard to store local variables in a CPU register, very efficient. The stack is the usual backing store, in case there aren't enough registers available to store all the local variables.

在x86和x64抖动例如相差很大。 64有很多更多的寄存器可用。这也适用于传递给方法的参数。 86允许2在CPU寄存器传递,64允许4.加任何可以存储在FPU堆栈或XMM寄存器。所以,有确实四个不同的地方局部变量可以被存储

Big difference between the x86 and x64 jitters for example. x64 has a lot more registers available. This also applies to the arguments passed to a method. x86 allows 2 passed in a CPU register, x64 allows 4. Plus whatever can be stored in the FPU stack or XMM registers. So, there are really four distinct places a local variable can be stored.

这篇关于凡在.NET局部变量存储在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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