HotSpot JIT内联策略:自上而下或下至上 [英] HotSpot JIT inlining strategy: top-down or down-top

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

问题描述

假设我们有3个方法:从方法1调用方法2,从方法2调用方法3.
方法2和3各自的大小为30个字节码。另外,假设确定性方法2总是从方法1中调用一次,方法3总是从方法2中调用一次。

Suppose we have 3 methods: method 2 is called from method 1, method 3 is called from method 2. Methods 2 and 3 are of size 30 bytecodes each. Also, suppose for definiteness method 2 is always called from method 1 exactly once, and method 3 is always called from method 2 exaclty once.

如果方法2首先被内联,方法3将直接从方法1的主体调用,并且可以依次内联。如果方法3首先内联到方法2中,后者的大小将变为大约60个字节码,并且无法内联,因为默认 MaxInlineSize 阈值是35个字节码。

If method 2 is inlined first, method 3 will be called from the body of method 1 directly, and could be inlined in its turn. If method 3 is inlined into method 2 first, the size of the latter will become about 60 bytecodes, and it couldn't be inlined, because default MaxInlineSize threshold is 35 bytecodes.

HotSpot JIT以哪种顺序内联方法:自上而下或自上而下?

In which order HotSpot JIT inlines methods: top-down or down-top?

推荐答案

MaxInlineSize 会影响至少执行一次但小于 MinInliningThreshold 次数的方法的编译。对于执行超过 MinInliningThreshold 的方法,有一个不同的设置 -XX:FreqInlineSize = ... 具有更大的(平台相关) ) 默认值。无论 MaxInlineSize ,热点仍然是内联的。您可以通过运行带有 -XX的应用程序来测试它:+ UnlockDiagnosticVMOptions -XX:+ PrintInlining -XX:MaxInlineSize = 0 。它仍将报告热点的内联(这些与评论(热))。只有先前报告的方法与评论已执行< MinInliningThreshold时间可能会使评论太大。如果您设置 FreqInlineSize ,您可能会收到hot method too big之类的评论。我从未在默认设置下看到它们。

The MaxInlineSize affects compilations of methods executed at least one time but less than MinInliningThreshold times only. For methods executed more than MinInliningThreshold there is a different setting -XX:FreqInlineSize=… having a far bigger (platform dependent) default value. Hotspots are still inlined regardless of the MaxInlineSize. You may test it by running an application with -XX:+UnlockDiagnosticVMOptions -XX:+PrintInlining -XX:MaxInlineSize=0. It will still report inlining of hot spots (these with the comment "(hot)"). Only methods formerly reported as inlined with the comment "executed < MinInliningThreshold times" might then get the comment to "too big". If you set down the FreqInlineSize you might receive comments like "hot method too big". I never saw them with the default setting.

这篇关于HotSpot JIT内联策略:自上而下或下至上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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