JEP 399: Intermediate-Representation Graph Serialization

OwnerIgor Ignatyev
Componenthotspot / compiler
Discussionhotspot dash compiler dash dev at openjdk dot java dot net
Reviewed byAleksandre Iline, Mikael Vidstedt, Vladimir Kozlov
Created2014/05/19 18:30
Updated2021/03/11 00:12


To aid in testing, create a facility to serialize and deserialize the intermediate-representation (IR) graphs used in the HotSpot run-time compilers.


It is not a goal to provide a means to serialize IR graphs for purposes other than testing.


It is not possible, today, for HotSpot run-time compiler tests to test compiler optimizations directly. To test a specific optimization, they resort to manipulating the JVM into a state in which that optimization will be performed. These are “gray box” tests, since they depend upon HotSpot implementation details but do not have access to HotSpot internals. They are fragile, since a change in the implementation can render a test useless.

Most run-time compiler optimizations operate upon an IR graph. If we could load a graph into the JVM, perform a specific optimization on it, and then export it for analysis then we could write stable and robust optimizer tests that do not depend upon HotSpot implementation details. This would also simplify the development of optimizer regression tests.


We propose to introduce new HotSpot WhiteBox APIs to import an IR graph, perform a specific optimization on it, and then export it:

where IRHandle is a reference to an IR graph object and OptimizationEnum is an enumeration of all supported optimizations.

There is already a serial format for the C2 IR, namely the XML format used by the Ideal Graph Visualizer (IGV). We propose to use that format, extending it as necessary for the C1 IR. Using the IGV format will also allow us to enhance the IGV tool so that it can serve as a WSYIWYG-editor for IR graphs.

Risks and Assumptions

Adding this code to product builds will slightly increase the size of If that becomes an issue then we can move it into a separate dynamically-linked library.