Introduction to GraalVM

Rukmal Senavirathne
3 min readMay 4, 2022

GraalVM is high-performance JDK distribution designed to accelerate the execution of applications written in Java and other JVM languages while also providing runtimes for JS, Python and number of other popular languages.

GraalVM Architecture

GraalVM architecture

GraalVM architecture contains multiple components,

  1. Java HotSpot VM

The current JVM provided by Sun/Oracle is called HotSpot because it seeks hot spots of use in the code (places where code is more intensively used) for “just-in-time” optimization

2. GraalVM Compiler GitHub link

It is advanced just-in-time (JIT) optimizing compiler.

What is the JIT?

The JIT compiler helps improve the performance of Java programs by compiling bytecodes into native machine code at run time. The JIT compiler is enabled by default. When a method has been compiled, the JVM calls the compiled code of that method directly instead of interpreting it.

It is written in Java

It is focus on high performance and extensibility

GraalVM adds this compiler to the HotSpot VM

3. Language Implementation framework GitHub link

The GraalVM’s language implementation framework called Truffle that makes it possible to run JVM-based languages like Python, Ruby, JavaScript on the Java VM.

With Truffle Java and other supported languages can directly interoperate with each other. It allows to run programming languages efficiency on GraalVM. It simplifies language implementation by automatically deriving high-performance code from interpreters.

GraalVM runtime modes

1. JVM Runtime

Programs run on the HotSpot JVM then GraalVM provide GraalVM compiler as the top-tier JIT compiler. JVM passes the bytecodes for Java or any other languages to the compiler then the compiler compiles that code to machine code and return it to JVM.

Interpreters for supported languages are Java programs that run on Java.

2. Native Image

Compiles Java code into standalone binary executable or native shared library byte code. That is a standalone executable called Native Image. That is not run on JVM, and run-on different runtime system called Substrate VM.

That has multiple advantages compared to JVM

1. It has faster startup time

2. Lower run time memory overhead

3. Java on Truffle

Java on Truffle place in the GraalVM architecture

This is an implementation of the JVM specification that built with the Truffle framework. This is a complete Java VM that includes all core components, implements the same API as the Java Runtime Environment library, and reuses all JARs and native libraries from GraalVM.

What is LLVM runtime?

The Low-Level Virtual Machine (LLVM) is a collection of libraries and tools that make it easy to build compilers, optimizers, Just-In-Time code generators, and many other compiler-related programs. This is a dependency package providing the default bytecode interpreter.

Polyglot programming click here

GraalVM allows users to write polyglot applications that seamlessly pass values from one language to another by means of the Truffle. In order to provide foreign polyglot values in the languages implemented with Truffle, the so-called polyglot interoperability protocol has been developed.

Feature Support click here

Table shows production-ready and experimental features in GraalVM Community newly release version by platform.

References

https://www.graalvm.org/22.1/docs/getting-started/#get-started-with-graalvm

--

--

Rukmal Senavirathne

Graduated from the Department of Computer Science and Engineering at the University of Moratuwa.