GraalVM 22.0 digs up fresh Truffle APIs, better heap isolation

GraalVM 22.0 digs up fresh Truffle APIs, better heap isolation

Oracle-bred GraalVM just saw its version count being upped to 22.0, promising enterprise customers heap isolation while open source users are meant to profit from Native Image and Truffle enhancements.

GraalVM is a runtime for applications written in Java, JavaScript, LLVM languages like C, Python, Ruby, R, and Scala, which comes in an open source community and a commercial flavour. The latter is included in Oracle Cloud, Java SE, and Java Desktop subscriptions, and offers additional performance optimisations, security features, and round-the-clock support from Oracle.

Since the last update, the compiler inside the enterprise edition has been reworked to treat profiling information more efficiently, which includes automatically switching to an ahead-of-time mode where useful. The enterprise variant also comes fitted with loop rotation optimization, a mechanism to turn uncounted loops into counted ones so they can profit from the same optimizations, and an initial version of Polyglot Isolates. Isolates ensure heaps of host and guest applications are separated to improve security and memory isolation, while reducing startup and warmup time.

New additions available to all users mainly concern the project’s Native Image technology and the Truffle framework for creating GraalVM languages and instrumentations. Native Image allows developers to ahead-of-time compile Java code into standalone executables, which are meant to distinguish themselves from JVM programs by a reduced startup time and memory overhead. The latest iteration tries to up the ante by producing smaller images thanks to a new encoding for stack frame metadata and making the serial garbage collector the default (which is also hoped to reduce GC time).

It also learned to work with more options of the Java Platform Module System and apply module-related ones in a way that should help prevent class loading errors. A new attribute allows devs to specify whether an entry point should automatically be added to a shared library, while progress bars and additional information in the output of native-image provide better insight into the state of a build.

An enhancement in Truffle that seems worth highlighting are sharing layers, a set of language instances sharing code with one or more polyglot contexts. It was added to ensure that every node created by a language instance can only be observed by one language at a time, which is hoped to simplify language implementations since node sharing doesn’t have to be supported in all cases anymore. In this context, new options --engine.TraceCodeSharing, --engine.ForceCodeSharing, and --engine.DisableCodeSharing could also be of interest, as they let devs log debug information on code sharing, and force the process for testing purposes.

Other than that Truffle now comes with an Exit API offering a unified form for closing of contexts across languages, and additional interfaces for com.oracle.truffle.api.frame.Frame and com.oracle.truffle.api.frame.FrameDescriptor, that support the copying and swapping of frame slots, and add namespaces of index-based and auxiliary slots in Frame.

GraalVM 22 drops support for Java 8 and removes JDK versions 12-16, users however gain support for most Ruby 3 changes, except parser and key argument changes and parallel execution feature Ractor. More information on compatibility and changes can be found in the GraalVM release notes.