7

My JVM has -server option, I believe it enables JVM to use C2 compiler which is meant to use for server applications which tend to run longer than client counterparts. However, GRAAL JIT (which is enabled by -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:+UseJVMCICompiler) is meant to replace C2 and my JVM starts even when I give both options like below.

-server -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:+UseJVMCICompiler

which compiler does it end up using? Graal JIT or C2?

Sagar
  • 5,315
  • 6
  • 37
  • 66
  • Note that `-server` selects a _VM_, not a compiler. Nowadays, the server VM defaults to tiered C1 + C2 compilation (but you can actually make it use C1 only or C2 only for example). `UseJVMCICompiler` is an option available in the server VM that makes it use a compiler implemented with the JVMCI API in replacement of C2. – Gilles D. Apr 05 '19 at 08:49

1 Answers1

8

That -server is simply ignored, read this answer for example. What you can do is run with some extra commands:

 java -XX:+UnlockExperimentalVMOptions 
      -XX:+EnableJVMCI 
      -XX:+UseJVMCICompiler  
      -Dgraal.ShowConfiguration=info  // this
      -XX:+EagerJVMCI  // and this matters

The result is will contain:

Using Graal compiler configuration 'community' ..... 
Eugene
  • 117,005
  • 15
  • 201
  • 306
  • can you please elaborate a little more on `-XX:+EagerJVMCI`, is that absolutely necessary to use Graal JIT? – Sagar Apr 05 '19 at 16:06
  • 3
    @Sagar code first starts in interpreted mode, there are 5 tiers iirc that are trigered once code gets "hotter". Well graal is lazy loaded only upon the first tear, so unless you call some method that is compiled with graal ( and implicitly it gets initialized ) , you will not see anything. That flag makes it initialize eager – Eugene Apr 05 '19 at 19:49