Book Image

Supercharge Your Applications with GraalVM

By : A B Vijay Kumar
Book Image

Supercharge Your Applications with GraalVM

By: A B Vijay Kumar

Overview of this book

GraalVM is a universal virtual machine that allows programmers to compile and run applications written in both JVM and non-JVM languages. It improves the performance and efficiency of applications, making it an ideal companion for cloud-native or microservices-based applications. This book is a hands-on guide, with step-by-step instructions on how to work with GraalVM. Starting with a quick introduction to the GraalVM architecture and how things work under the hood, you'll discover the performance benefits of running your Java applications on GraalVM. You'll then learn how to create native images and understand how AOT (ahead-of-time) can improve application performance significantly. The book covers examples of building polyglot applications that will help you explore the interoperability between languages running on the same VM. You'll also see how you can use the Truffle framework to implement any language of your choice to run optimally on GraalVM. By the end of this book, you'll not only have learned how GraalVM is beneficial in cloud-native and microservices development but also how to leverage its capabilities to create high-performing polyglot applications.
Table of Contents (17 chapters)
1
Section 1: The Evolution of JVM
4
Section 2: Getting Up and Running with GraalVM – Architecture and Implementation
8
Section 3: Polyglot with Graal
13
Section 4: Microservices with Graal

Graal JIT and the JVM Compiler Interface (JVMCI)

In the previous sections, as we walked through the various features and advancements that JIT compilers underwent, it is very clear that C2 is very sophisticated. However, C2 compiler implementation has its downsides. C2 is implemented in the C/C++ language. While C/C++ is fast, it is not type-safe and it does not have garbage collection. Hence, the code becomes very complex. C2 implementation is very complex, as it has become more and more complex to change the code for new enhancements and bug fixes.

In the meantime, Java has matured to run as fast as C/C++ in many cases. Java is type-safe with garbage collection. Java is simpler and easier to manage than C/C++. The key advantages of Java are its exception handling capabilities, memory management, better IDE/profiling, and tooling support. The JIT compiler is nothing but a program that takes in a bytecode, byte[], optimizes it, compiles it, and returns an array of machine code,...