Java 10’s Experimental JIT Compiler explained in 5 minutes

This month’s theme is Java 10 to tie in with the release of the new Java version. Despite being only 6 months since Java 9, there are some really exciting new features. I am going to look at the experimental JIT compiler that is part of Project Graal.

What is Project Graal?

Project Graal was created by Oracle with the ultimate goal of improving JVM based languages performance to better match the performance levels that native languages enjoy. One part of this project involves implementing a high performance dynamic Java compiler and interpreter AKA a Just-In-Time (JIT) compiler. This feature is described further in JEP 317

What is a Just-In-Time Compiler?

JIT compilation is a form of dynamic compilation which combines the use of Ahead-Of-Time (AOT) compilation and interpretation, and thus has advantages and disadvantages from both technologies.

Ahead-Of-Time Compilation
An AOT compiler was added to the OpenJDK as part of the Java 9 release. The main goal was to improve the start-up time of Java applications with minimum impact to the application’s peak performance. Whilst not as fast as a warmed up JIT compilation AOT avoids incurring performance penalties from having to repeat interpreted invocations.

Interpretation
A process which interprets the code and performs the specified actions. There are different ways an interpreter can work: it can parse the code and execute it directly, turn the code into an intermediate representation and execute that, or it can execute code that has already been pre-compiled. Each of these different methods have their own advantages and disadvantages.

JIT compilation combines the start-up speed of AOT compiled code with the flexibility of interpretation to create a faster solution. The main difference between JIT and AOT is that instead of interpreting bytecode every time a method is invoked, a JIT compiler will compile the bytecode into the machine code instructions of the running machine, and then invoke this object code instead. Another difference is that AOT also turns the bytecode of a virtual machine into native machine code so the interpreted code can be executed.

How to use the experimental compiler

Unfortunately, this feature isn’t for everyone as it only works for Linux/x64 platforms at the moment.

It is very easy to enable the experimental JIT compiler though as it is already included as part of the JDK. You just have to set the following options when running Java from the command line:

-XX:+UnlockExperimentalVMOptions -XX:+UseJVMCICompiler

Then you can start testing it out. The JIT compiler itself is still in its testing phase though and it’s worth being aware that at this time this option is not being created/added to meet or beat the performance of the existing JIT compilers. It is there to investigate the feasibility of a Java-based JIT for the JDK.

And there you have it – an explanation of Java 10’s experimental JIT compiler.

If you’re a first-time reader, or simply want to be notified when we post new articles and updates, you can keep up to date by social media (Twitter, Facebook and Google+) or the Blog RSS.

Related Posts:

The following two tabs change content below.

Georgia Ingham

Java Developer at IDRsolutions
Georgia is a Java Developer at IDRSolutions. She is currently working along side the team on the development of JPedal and JPDf2HTML5. Her hobbies include reading and cycling.
Georgia

About Georgia Ingham

Georgia is a Java Developer at IDRSolutions. She is currently working along side the team on the development of JPedal and JPDf2HTML5. Her hobbies include reading and cycling.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>