4

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!

cwei
  • 105
  • 5

1 Answers1

5

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.

Pyves
  • 6,333
  • 7
  • 41
  • 59
deesebas
  • 66
  • 2
  • P.S.: I opened this issue : https://github.com/eclipse/openj9/issues/97 and was pointed to the correct documentation for OpenJ9, which I've updated in the links above. – deesebas Sep 21 '17 at 23:51
  • It really helps me a lot. Thanks, @deesebas! – cwei Sep 22 '17 at 05:38
  • If I run the subsequent java program, which wants to reuse AOTed code, do I need to set "cacheDir" for this subsequent program? It seems that AOTed code is produced by openj9 jvm, then cache is created on disk. So the first java program doesn't need to continue executing when the subsequent program want to reuse AOTed code. Am I right? – cwei Sep 22 '17 at 05:46
  • While you may optionally specify a directory explicitly using cacheDir, by default the shared classes cache is created (and reused) from a default location (for e.g. /tmp/javasharedresources on Linux). You are correct, in the case of a persistent cache, the shared cache is created and persisted on disk, and so the first program doesn't need to continue executing for the subsequent program to reuse the AOT code. Here is some more information, hope you find it useful! [Class data sharing] (https://www.ibm.com/support/knowledgecenter/SSYKE2_9.0.0/com.ibm.java.vm.9.0.doc/docs/shrc.html) – deesebas Sep 22 '17 at 06:26
  • 1
    AOT Compiler IBM link broken. – user207421 May 09 '18 at 04:50