1. Overview

In the JDK 16 and 17 timeframe, we plan to enhance the CDS Archived Heap to implement the following:

As shown below, the Root List makes it easy to support other collectors.

2. Archived Heap in JDK 15

This section describes the implementation, and the problems, of the Archived Heap in JDK 15.

In JDK 15, the Archived Heap is supported only by G1 with compressed oops. Other types of GC are not supported. Uncompressed oops are not supported.

The Archived Heap is divided into two parts

The Open Region is problematic:

Luckily, in JDK 15, all unreachable objects in the Open Region are of Type A. I.e., once we have made an archived object reachable, it will always be reachable.

3. Challenges in JDK 16

In JDK 16, we have implemented JDK-8244778 (Archive full module graph in CDS). With this change, we have introduced objects of Type B into the Open Region:

4. Root List - Distinguishing Live and Dead Objects in Open Region

In JDK 16, with JDK-8253081, we will implement a Root List in the Archived Heap to allow the GC to reliably determine whether an archived object is alive or dead:

At VM bootstrap, the Root List contains all objects in the Open Region that may be referenced in the future, including

When a mirror M becomes referenced by a newly loaded class K, M will be removed from the Root List, and K will be responsible for
keeping M alive.

Other types of roots are also similarly removed from the Root List when they become referenced.

The Root List is implemented as a ObjArray stored inside a global OopHandle, so it will always be scanned by the GC. Therefore, the GC can use reachability to tell whether an object in the Open Region is live or dead. In fact, the Open Region now becomes just like other regular G1 regions. We should be able to remove most of G1's special handling code for the Open Region.

In the example above:

5. Support Archived Heap for other collectors

With the Root List, it should be fairly easy to support Archived Heap for SerialGC and ParallelGC. See JDK-8234679 - Support CDS shared heap in non-G1 garbage collectors.

6. Support Uncompressed Oops for the Archived Heap

In JDK 15, the class metadata references archived heap objects using narrowOop (e.g. Klass::_archived_mirror). With the Root List, these references are changed to be integer indices. As a result, most of the Archived Heap code should be agnostic to oop encoding. This will make it easier to support uncompressed oops in Archived Heap.