jaksky
jaksky

Reputation: 3405

JVM disable inlining for a particular class or method

I am trying to write some benchmark just to measure effect of inlining a method. Does anybody know if is it possible to disable inlining for a particular class or method on HostSpot JVM?

I found -XX:-Inline which disable inlining in total.

Upvotes: 5

Views: 1823

Answers (1)

Mick Mnemonic
Mick Mnemonic

Reputation: 7956

You can use the -XX:CompileCommand JVM option to control just-in-time compilation. The option can be used for excluding certain methods (or all methods of a class) to be compiled, and more. From the documentation:

Specifies a command to perform on a method. For example, to exclude the indexOf() method of the String class from being compiled, use the following:

-XX:CompileCommand=exclude,java/lang/String.indexOf

If you only want to prevent method inlining, you can use the dontinline command with the same syntax, e.g.

-XX:CompileCommand=dontinline,java/lang/String.indexOf

The same JVM option is used internally by the popular Java microbenchmark harness, JMH.

Upvotes: 11

Related Questions