9

I am doing some performance tests on the JVM, and I would like to measure the impact of intrinsics usage.

I would like to disable the JIT use of intrinsics for some methods without going into the interpreted mode. Is there a way to do that ? Thank you

Bionix1441
  • 2,135
  • 1
  • 30
  • 65

1 Answers1

10

Use

java -XX:+UnlockDiagnosticVMOptions -XX:DisableIntrinsic=_<method_name>[,...]

For example

java -XX:+UnlockDiagnosticVMOptions -XX:DisableIntrinsic=_equals,_hashCode

As @apangin noticed, you may use -XX:+PrintIntrinsics first to see which methods are actually intrinsified in your test and disable them.

Tagir Valeev
  • 97,161
  • 19
  • 222
  • 334
  • 3
    It may be even easier to build a custom HotSpot where `Compile::make_vm_intrinsic` always returns NULL to disable all intrinsics at once. – apangin May 21 '15 at 10:56
  • That's probably an overkill if author just wants to measure some specific thing. But sounds cool! – Tagir Valeev May 21 '15 at 10:59
  • 5
    Oh, I think there is a simple solution: first use `-XX:+PrintIntrinsics` to print all compiled intrinsics, then `-XX:DisableIntrinsic=` to disable them. – apangin May 21 '15 at 11:01
  • Added this to the answer. – Tagir Valeev May 21 '15 at 11:02
  • 5
    BTW, I've created a [table of all JVM intrinsics](https://gist.github.com/anonymous/1e9f4cab9f659982df82) – apangin May 21 '15 at 11:29
  • 1
    @apangin, interesting! Which JVM version is this? I don't see anything which appeared in Java 8 – Tagir Valeev May 21 '15 at 11:33
  • 1
    Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/78410/discussion-between-tagir-valeev-and-apangin). – Tagir Valeev May 21 '15 at 11:37
  • 3
    That were JDK 7u80 intrinsics. Now [JDK 8u45 intrinsics](https://gist.github.com/apangin/7a9b7062a4bd0cd41fcc). – apangin May 21 '15 at 11:46
  • 1
    I have one more question how do you disable all of the intrinsic methods ? – Bionix1441 May 21 '15 at 11:46
  • 2
    @Bionix1441 Unfortunately there is no such switch in stock JVM. So, you have to either patch JVM or disable them one by one. – apangin May 21 '15 at 12:18
  • Up-to-date searchable table with all JDK intrinsics split per versions: https://chriswhocodes.com/hotspot_intrinsics_openjdk17.html – Dan M. Jan 24 '22 at 14:38