JIT 自动内联的方法的大小是多少?
What is the size of methods that JIT automatically inlines?
我听说 JIT 会自动内联小方法,例如 getter(它们大约有 5 个字节)。边界是什么?是否有任何 JVM 标志?
https://docs.oracle.com/javase/8/embedded/develop-apps-platforms/codecache.htm#BABGGHJE
MaxInlineSize
Default: 35
Maximum bytecode size of a method to be inlined
有关 JDK 7 和更早版本的信息,请参阅文档 Java HotSpot VM Options。
HotSpot JIT 内联策略相当复杂。它涉及许多启发式方法,如调用方方法大小、被调用方方法大小、IR 节点计数、内联深度、调用计数、调用站点计数、抛出计数、方法签名等。
访问器方法 (getters/setters) 和普通方法(字节码数少于 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)
我听说 JIT 会自动内联小方法,例如 getter(它们大约有 5 个字节)。边界是什么?是否有任何 JVM 标志?
https://docs.oracle.com/javase/8/embedded/develop-apps-platforms/codecache.htm#BABGGHJE
MaxInlineSize
Default: 35
Maximum bytecode size of a method to be inlined
有关 JDK 7 和更早版本的信息,请参阅文档 Java HotSpot VM Options。
HotSpot JIT 内联策略相当复杂。它涉及许多启发式方法,如调用方方法大小、被调用方方法大小、IR 节点计数、内联深度、调用计数、调用站点计数、抛出计数、方法签名等。
访问器方法 (getters/setters) 和普通方法(字节码数少于 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)