What is the size of methods that JIT automatically inlines?
Asked Answered
H

2

9

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?

Hemo answered 12/4, 2016 at 22:31 Comment(0)
G
20

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)
Grandmamma answered 12/4, 2016 at 23:12 Comment(0)
P
4

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

See the document Java HotSpot VM Options for JDK 7 and earlier releases.

Pindaric answered 12/4, 2016 at 22:36 Comment(2)
@Louis Wasserman Thanks. I know about that. I thought that there is something like "MinAutoInlineSize" but I am probably wrong.Hemo
@jpos Why would there be a minimum? The smaller the method the better it is to inline it.Smell

© 2022 - 2024 — McMap. All rights reserved.