Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
480 views
in Technique[技术] by (71.8m points)

java - What is the size of methods that JIT automatically inlines?

I've heard that JIT automatically inlines small methods, like getters (they have about 5 bytes). What is the boundary? Is there any JVM flag?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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, throw count, method signatures etc.

Some limits are skipped for accessor methods (getters/setters) and for trivial methods (bytecode count less than 6).

The related source code is mostly in bytecodeInfo.cpp.
See InlineTree::try_to_inline, should_inline, should_not_inline functions.

The main JVM flags to control inlining are

-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)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...