Taking a deep dive into HotSpot and the C2 JIT compiler
In the previous chapter, we walked through the evolution of JVM and how the C2 JIT compiler evolved. In this section, we will dig deeper into the JVM C2 JIT compiler. Using sample code, we will go through the optimizations that the JIT compiler performs at runtime. To appreciate the Graal JIT compiler, it is very important to understand how the C2 JIT compiler works.
Profile-guided optimization is the key principle for JIT compilers. While AOT compilers can optimize the static code, most of the time, that is just not good enough. It's important to understand the runtime characteristics of the application to identify opportunities for optimization. JVM has a built-in profiler that dynamically instruments the application to profile some key parameters and to identify opportunities for optimizations. Once identified, it will compile that code to the native language and switch from running the interpreted code to faster-compiled...