19

I'm reading JEP 317. It says that Graal (a new experimental Java-based JIT compiler) will be part of JDK 10, but then it says that is already available in JDK 9. So, what's the point of JEP 317 then? Does Java 9 include Graal or not?

ZhekaKozlov
  • 36,558
  • 20
  • 126
  • 155
  • 5
    "*So, what's the point of JEP 317 then?*" - I think this question is better asked over [(one of the) openjdk mailing lists](http://mail.openjdk.java.net/mailman/listinfo). From the JEP, it sounds like Graal was originally developed as (part of a) AOT-compiler and as such released with JDK 9. The JEP proposes to use Graal as experimental JIT-Compiler as well. – Turing85 Jan 14 '18 at 18:36
  • 1
    @Turing85 But `-XX:+UseJVMCICompiler` option is already available in JDK 9 which is not about AOT. – ZhekaKozlov Jan 14 '18 at 18:41

2 Answers2

19

From one of my memos, on linux-x64 (out-of-the-box) to use Graal on JDK 9, you can enable it using :

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

Source: Tweet from Chris.


If you're explicitly willing to make use of the org.graalvm.* classes, they are not present in the JDK-9 build except for the Linux distribution here and the JEP-317#Experimental Java-Based JIT Compiler's status also reads something similar.

Status    Integrated
Scope JDK
Release   10

Update:- To use Graal on JDK10, one can enable it using:-

-XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:+UseJVMCICompiler -Djvmci.Compiler=graal
Naman
  • 27,789
  • 26
  • 218
  • 353
  • excellent find! is there a place to read about actual difference between the compilers? Or at least what does it do different? – Eugene Jan 14 '18 at 19:01
  • 2
    @ZhekaKozlov Correcting myself, the `jdk.aot` and `jdk.internal.vm.compiler` modules are packaged in the Linux 64 bit build for JDK version `9.0.1` and not for macOS. Updated the link to the binary in the answer as well. http://www.oracle.com/technetwork/java/javase/downloads/jdk9-downloads-3848520.html. Additionally, they are also there in early access builds for JDK10. – Naman Jan 15 '18 at 13:47
  • 1
    @nullpointer You are right. I didn't consider that different OSes can have a different set of modules. – ZhekaKozlov Jan 15 '18 at 13:53
1

Graal is included in 9 but it used in a different way.

In Java 9 Graal is used as an AOT(Ahead of time) compiler which allows users to use the jaotc tool to create manually compiled .so libraries.

These libraries can then be loaded at JVM startup and directly used.

A detailed description can be found at the related Java 9 JEP: http://openjdk.java.net/jeps/295

In Java 10 Graal, as described in JEP 317, can be used as the JIT compiler instead of HotSpot.

This means that classes will be compiled in the JVM "on the fly" instead of requiring manual compilation beforehand.

MartyIX
  • 27,828
  • 29
  • 136
  • 207
Giorgos Gaganis
  • 635
  • 7
  • 8