Java:JIT方法内联 [英] Java: JIT method inlining

查看:530
本文介绍了Java:JIT方法内联的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么时候 Java JIT内联一个方法调用?它是基于#times调用调用者方法(如果是,该数字是什么?),或者其他一些标准(那将是什么?)

When does Java JIT inline a method call? Is it based on #times the caller method is called (if yes, what would that number be?), or some other criteria (and what would that be?)

我已经读过JIT可以内联'final'方法,但它也会根据运行时统计信息内联非最终方法,所以想知道什么是触发条件。

I've read that JIT can inline 'final' methods, but it also inlines nonfinal methods based on runtime statistics, so want to know what is that triggering criteria.

我想答案会因JVM的实现而有所不同,但也许所有这些答案都有共同之处?

I guess the answers would differ based on JVM implementation, but maybe there's something common across all of them?

推荐答案

简短的回答是随时可以的。

The short answer is whenever it wants.

JITC经常会自动内联小型的最终或伪终结方法,首先收集任何统计数据。这是因为很容易看出内联实际上节省了代码字节与编码调用(或至少它几乎是清洗)。

Very often a JITC will inline small final or pseudo-final methods automatically, without first gathering any stats. This is because it's easy to see that the inlining actually saves code bytes vs coding the call (or at least that it's nearly a "wash").

内联真正的非除非统计数据表明它是值得的,否则通常不会进行最终方法,因为如果出现意外的子类,内联的非决赛必须以某种方式保护。

Inlining truly non-final methods is not usually done unless stats suggest it's worthwhile, since inlined non-finals must be "guarded" somehow in case an unexpected subclass comes through.

关于数字有些东西可能在它被JITCed或内联之前被调用,这是高度可变的,并且即使在正在运行的JVM中也可能会有所不同。

As to the number of times something may be called before it's JITCed or inlined, that's highly variable, and is likely to vary even within a running JVM.

这篇关于Java:JIT方法内联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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