解决方法
HotSpot JIT内联策略相当复杂.它涉及许多启发式方法,如调用方法大小,被调用方法大小,IR节点计数,内联深度,调用计数,调用站点计数,投掷计数,方法签名等.
对于访问器方法(getter / setter)和普通方法(字节码计数小于6),会跳过某些限制.
相关的源代码大多在bytecodeInfo.cpp.
请参阅InlineTree :: try_to_inline,should_inline,should_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)