Search code examples
openj9

How to use AOT compiler in Openj9?


I have already known there is a "dynamic AOT" in Openj9, where Openjdk9 has a AOT compiler (jaotc) to compile byte code to shared library.

But Openj9 doesn't have program like jaotc, it uses "shared classes" to store JITed code, which is expected to be used by the other JVMs to speed up their startup time.

I have the following questions:

  1. How do I make sure whether Openj9 JVM use JITed code produced by another JVM? (In openjdk9, there is an option "-XX:+PrintAOT" to observe)
  2. How to use the AOT of Openj9? I execute a program with option "-Xshareclasses", and just execute this program again?
  3. Is there any document about Openj9 AOT?

It will be appreciated if any advice. Thanks!


Solution

  • You are correct, for AOT to be enabled on OpenJ9, the -Xshareclasses option has to be enabled.

    1. How do I make sure whether Openj9 JVM use JITed code produced by another JVM? (In openjdk9, there is an option "-XX:+PrintAOT" to observe)

    Use option -Xshareclasses:verboseAOT. You should see output messages such as the following:

    Stored AOT code for ROMMethod 0x000000000FFAE2C8 in shared cache.
    

    And on subsequent runs, you will see messages such as:

    Found AOT code for ROMMethod 0x000000001003C178 in shared cache.        
    
    1. How to use the AOT of Openj9? I execute a program with option "-Xshareclasses", and just execute this program again?

    If you want to persist and reuse AOTed code on subsequent runs of your java program, run with -Xshareclasses:persistent (the 'persistent' suboption is default on Linux and Windows platforms when -Xshareclasses is enabled). With this option, the cache is created on disk, which persists beyond operating system restarts. You can also optionally provide a name for your shared classes cache (name=subparameter) to distinguish between shared caches for different applications.

    1. Is there any document about Openj9 AOT?

    May I point you to the following documentation:

    The AOT Compiler

    -Xshareclasses

    I will also open a github issue to check whether more documentation about AOT is available or can be created.