I have now worked at Oracle for 3 years. I learned a lot during this time, especially considering that I focused mostly on HPC (high-performance computing) and theoretical computer science in my education at ETH, and had no formal education in compilers. Over the last years, I had the opportunity to learn a lot from my fellow C2 engineers, at Oracle but also from other companies and even individual contributors working on OpenJDK. I would now like to summarize my understanding of the C2 Compiler in the HotSpot JVM, and hopefully make it easier for others to break into C2.

Target audiences:

  • New hires working on HotSpot’s C2 Compiler.
  • People working on the JVM that want to learn more about C2.
  • Anybody interested about the JVM and (JIT) Compilers.

Topics I hope to address in this series:

  • Parsing Java bytecode into IR (see-of-nodes).
  • IGVN and CCP (canonicalization and local optimizations).
  • Loop optimizations.
  • Matching in the backend for specific CPUs.

Additionally:

  • Debugging C2 using RR (or GDB), and the help of JVM flags.
  • Analyzing the generated Assembly code: what did C2 do with my Java code?
  • Benchmarks: stand-alone (just a single Java file) or using JMH.
  • Testing: how to write good tests to verify optimizations are applied and create correct Assembly code (using IR framework, random inputs, etc).

A note to new individual External Contributors

The HotSpot JVM is part of the OpenJDK, which means anybody is welcome to contribute. In fact, I regularly review code contributions from individuals at other companies involved with OpenJDK, but also individual contributors who work on C2 in their free time.

You are very welcome to join the communal effort to improve HotSpot, and improve your own skills in the process. I personally can help you mostly with C2, because that is what I have been working on over the last years. People often have their own ideas: that is fantastic. But it is important to first discuss ideas, so you don’t put a lot of time into something that then will be rejected in the code review. I would suggest you start by reaching out to us, and ask if there are any simple tasks where you can make a helpful contribution, and learn the processes of code review.

Helpful Links

Here some other links to get you started:

Links to read more about the inner workings of C2:

Conclusion for Part 0

Ok. Now that we have discussed some preliminary things, we can get started with the technical material :)

Continue with Part 1

Please leave a comment below

To edit/delete a comment: click on the date above your comment, e.g. just now or 5 minutes ago. This takes you to the GitHub issue page associated with this blog post. Find your comment, and edit/delete it by clicking the three dots ... on the top right.