JIT自动内联的方法大小是多少?

我听说JIT自动内联小方法,比如getter(它们大约有5个字节)。 边界是什么? 有没有JVM标志?

HotSpot JIT内联策略相当复杂。 它涉及许多启发式方法,如调用方法大小,被调用方法大小,IR节点计数,内联深度,调用计数,调用站点计数,投掷计数,方法签名等。

对于访问器方法(getter / setter)和普通方法(字节码计数小于6),会跳过某些限制。

相关的源代码主要在bytecodeInfo.cpp中 。
请参阅InlineTree::try_to_inlineshould_inlineshould_not_inline函数。

控制内联的主要JVM标志是

 -XX:MaxInlineLevel (maximum number of nested calls that are inlined) -XX:MaxInlineSize (maximum bytecode size of a method to be inlined) -XX:FreqInlineSize (maximum bytecode size of a frequent method to be inlined) -XX:MaxTrivialSize (maximum bytecode size of a trivial method to be inlined) -XX:MinInliningThreshold (min. invocation count a method needs to have to be inlined) -XX:LiveNodeCountInliningCutoff (max number of live nodes in a method) 

https://docs.oracle.com/javase/8/embedded/develop-apps-platforms/codecache.htm#BABGGHJE

MaxInlineSize

默认值:35

要内联的方法的最大字节码大小

请参阅JDK 7及更早版本的Java HotSpot VM选项文档。