即时编译-总是存储与执行 [英] Just in Time Compilation - Storing vs Doing always

查看:59
本文介绍了即时编译-总是存储与执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
为什么JVM不缓存JIT编译代码?

Possible Duplicate:
Why doesn't the JVM cache JIT compiled code?

我了解JIT编译是使用热点机制编译为本地代码,因为它是对OS,Hardwards等的优化,因此可以非常快速地

I understand that JIT compilation is compilation to native code using hotspot mechanisms, which can be very very fast as it is optimization to the OS, Hardwards, etc.

我的问题是,为什么Java不将符合JIT要求的代码存储在文件中的某个地方,而将其用于以后的用途?这也可以减少初始预热"时间.

My question is, why does Java not store that JIT complied code somewhere in file and use the same for future purposes? This can reduce the 'initial warm-up' time as well.

请让我知道我在这里想念的东西.

Please let me know what I am missing here.

要添加到我的问题: 为什么Java不将完整的代码编译为本机并始终使用该代码(对于特定的JVM,OS,平台)?为什么选择准时制?

To add to my question: Why does not Java complie the complete code to native and use that always(for a specific JVM,OS, platform)? Why JIT?

推荐答案

如果我没记错的话,已经尝试过缓存和共享JIT编译的代码,但是发现这不是一个好主意.

If I remember correctly, caching and sharing of JIT-compiled code has been tried, and found to be not a good idea.

一方面,现代的HotSpot JIT编译器会在当前CPU模型和当前执行的使用模式的上下文中生成并优化代码.如果要缓存已编译的代码,则很有可能代码不是最佳的.

On the one hand, a modern HotSpot JIT compiler generates and optimizes code in the context of the current CPU model, and the usage patterns of the current execution. If it were to cache compiled code, then there is a good chance that the code would not be optimal.

另一方面,显然存在各种棘手的技术问题.例如,缓存的代码将成为潜在的安全漏洞,例如,共享该代码的区域必须由所有应用程序/用户均可写入.但这意味着一个用户可能会干扰另一用户的应用程序的运行.

On the other hand, there are apparently a variety of tricking technical problems. For instance, the cached code becomes a potential security hole, For instance, the code area needs to be writeable by all applications / users that share it. But that means that one user could potentially interfere with the running of another user's applications.

这篇关于即时编译-总是存储与执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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