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.
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.
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:
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.
Are you a Developer working with PDF files?
Our developers guide contains a large number of technical posts to help you understand the PDF file Format.
Do you need to solve any of these problems?
|Display PDF documents in a Web app|
|Use PDF Forms in a web browser|
|Convert PDF Documents to an image|
|Work with PDF Documents in Java|