hotspot inlining

Does anyone know the rules governing what code hotspot is able to inline? I have several method calls in tight loop. The code will start to get pretty nasty looking without them, so I’d rather not do the inlining myself if I can.

Has Sun published any information on what code you can expect will be inlined, or is there any way to determine this with a profiling tool? I guess I can do it by hand and measure performance, but I’d rather not if there’s a way involving less work ;D

I think the cloests you’ll find to a definative answer is from Jeff’s book. appendex B.3.1 is about inlining in the -server version of HotSpot. I think the book was written about the time of Java 1.2 and I think I’ve read the -client HotSpot has since learned how to inline.

Both standard and server* jvm know how to inline, believe me.
Actually, my tests about inlining show that if you make a loop that makes some calls, they are inlined, and following some few rules, you can make hotspot’s inlining faster than inlining by hand. (yes… you read it well :o )
i did not make tests for the number of functions inlined or the length of the called methods. this could be interesting, but at least, if you have to inline two to ten small methods (20-50 lines) it goes well.

  • A regression in 1.4.0 server made the inlining slower than 1.3 client. Did not test under 1.4.1 to see if that was corrected. will do that soon.

This extra flag controls the maximum size of inlinable methods (I presume the size is in “bytecodes” but I don’t know for sure):

-XX:MaxInlineSize=64

Additionally this flag tells the compiler how many times to interpret a method before it compiles it. If I were writing the compiler I’d have it do its inlining recursively before performing a compilation:

-XX:CompileThreshold=500

The default for server is 10000 ISTR, and client is 1500.

Cas :slight_smile:

I’d say that you must avoid manual inlining in any way. It makes your code unmaintainable and most probably not any faster.
It can even slow down your code a great deal which, as some of you may remember, I found out the hard way :slight_smile:

Anyway thats my 2 cents.

Erik