是否.NET CLR JIT编译每个方法,每一次? [英] Does the .Net CLR JIT compile every method, every time?

查看:257
本文介绍了是否.NET CLR JIT编译每个方法,每一次?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,爪哇的HotSpot JIT有时会跳过的JIT编译一个方法,如果它期望编译开销比运行在帧间preTED模式的方法的开销更低。是否.NET CLR都基于类似的启发式工作?

I know that Java's HotSpot JIT will sometimes skip JIT compiling a method if it expects the overhead of compilation to be lower than the overhead of running the method in interpreted mode. Does the .Net CLR have work based upon a similar heuristic?

推荐答案

注:这个答案是每运行上下文。在code为每次运行该程序时,通常即时编译。使用 NGEN 或的。NET本地改变了这个故事,也...

Note: this answer is on a "per-run" context. The code is normally JITted each time you run the program. Using ngen or .NET Native changes that story, too...

与热点,CLR的JIT编译永远的完全的每一次运行。它从来没有跨$ P $点,它永远不会重新编译比以前根据实际使用情况较重的优化。

Unlike HotSpot, the CLR JIT always compiles exactly once per run. It never interprets, and it never recompiles with heavier optimisation than before based on actual usage.

这可能会改变,当然,但它一直以来V1这样,我不希望它很快改变。​​

This may change, of course, but it's been that way since v1 and I don't expect it to change any time soon.

的优点是,它使JIT简单了很多 - 有没有必要考虑老code已经运行,撤销基于premises的优化而不再有效等。

The advantage is that it makes the JIT a lot simpler - there's no need to consider "old" code which is already running, undo optimisations based on premises which are no longer valid etc.

在.NET中的有利的一个观点是,大多数CLR语言进行方法非虚默认情况下,这意味着有更多的内联可以做到的。热点可以内联的方法,直到它的第一个覆盖在该点撤销优化(或做一些聪明的东西,在某些情况下,有条件地仍然使用内联code,根据实际类型)。用较少的虚方法担心,.NET可以在很大程度上忽略不能够内联任何虚拟的痛苦。

One point in .NET's favour is that most CLR languages make methods non-virtual by default, which means a lot more inlining can be done. HotSpot can inline a method until it's first overridden at which point it undoes the optimisation (or does some clever stuff in some cases to conditionally still use the inlined code, based on actual type). With fewer virtual methods to worry about, .NET can largely ignore the pain of not being able to inline anything virtual.

编辑:以上介绍的桌面框架。紧凑的框架抛出了本土code时,要根据需要JITting了。然而,这仍然是不喜欢热区自适应优化。

The above describes the desktop framework. The Compact Framework throws out native code when it wants to, JITting again as necessary. However, this still isn't like HotSpots adaptive optimisation.

微框架不JIT可言显然,除preting的code来代替。这是有道理的,非常有限的设备。 (我不能说我很了解微架构。)

The micro framework doesn't JIT at all apparently, interpreting the code instead. This makes sense for very constrained devices. (I can't say I know much about the micro framework.)

这篇关于是否.NET CLR JIT编译每个方法,每一次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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