C2 (HotSpot)
More info
- Owner
- Oracle (formerly Sun Microsystems)
- Released
- Type
- JIT compiler
- License
- GPLv2
- Source
- github.com/openjdk/jdk
The JVM's heavyweight JIT compiler, the "server compiler", which takes the hottest methods and optimizes them on the bet that the program keeps behaving the way it has so far.
HotSpot grew out of Animorphic Systems' work on the Smalltalk dialect Strongtalk and was bought by Sun in 1997. C2 was built around Cliff Click's sea of nodes and accounts for most of Java's reputation for speed: aggressive inlining driven by profiles gathered by the interpreter and C1, escape analysis that removes allocations and locks, and optimistic assumptions backed out through deoptimization when they turn out wrong. Since tiered compilation became the default in Java 8, C2 only steps in after C1 has been running the code for a while.
The codebase is C++ and has long been considered hard to change, which is what motivated Graal: a replacement written in Java that could be switched on in OpenJDK for a while and was later removed again. So C2 is still here, a quarter of a century on.