Can java inline a large method if the most of it would be dead code at the call site?

别来无恙 提交于 2019-12-06 04:06:16

HotSpot JIT inlining policy is rather complicated. It involves many heuristics like caller method size, callee method size, IR node count, inlining depth, invocation count, call site count etc.

There are some hard limits that prevent a large method from inlining, including:

  • -XX:FreqInlineSize=325 - the maximum size in bytecodes of the callee to be inlined;
  • -XX:InlineSmallCode=2000 - do not inline the callee if it already has a compiled code of at least this size in bytes;
  • -XX:NodeCountInliningCutoff=18000 - stop inlining if parser generates this number of IR nodes;
  • -XX:DesiredMethodLimit=8000 - the maximum size in bytecodes of aggregate method after inlining. This parameter is not tunable in product builds of HotSpot, but the limit can be switched off with -XX:-ClipInlining.

There are also other limits, but as you already see, a large method does not have much chance to be inlined, even though -XX:+IncrementalInline is enabled by default.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!