RFR: 8301106 allow cds interned strings to be moved by gc

David Holmes dholmes at openjdk.org
Fri Feb 17 06:38:17 UTC 2023


On Thu, 16 Feb 2023 19:14:15 GMT, Ioi Lam <iklam at openjdk.org> wrote:

> **Background:**
> 
> Currently, the archived java strings are mapped in the G1 "[closed archive](https://github.com/openjdk/jdk/blob/574b48c6925ebfb31345fc46c7d23aa4153f99b0/src/hotspot/share/gc/g1/heapRegionType.hpp#L80-L92)" region. This essentially pins all the strings in memory.
> 
> As a prerequisite for  ([JDK-8296263](https://bugs.openjdk.org/browse/JDK-8296263)), this PR removes the requirement of pinning the archived strings. This will allow the CDS archive heap to be mapped in garbage collectors that do not support object pinning.
> 
> **Code changes:**
> 
> - The archived strings are referenced through an objArray (`_shared_strings_array`) to keep them alive. As a result, it's no longer necessary to pin them.
> - Since it's possible for the GC to move these strings, the `_shared_table` in stringTable.cpp is modified to store a 32-bit index for each archived string. This index is used to retrieve the archived string from `_shared_strings_array` at runtime.
> 
> Note that CDS has a limit on the size of archived objArrays. When there's a large number of strings, we use a two-level table. See the comments around  `_shared_strings_array` in the header file.
> 
> **Testing**
> 
> Tiers 1 - 4

src/hotspot/share/cds/archiveHeapLoader.hpp line 68:

> 66:   }
> 67: 
> 68:   static bool are_archived_strings_available() {

The functions don't seem to carry their weight any more. Perhaps we can just rename `is_fully_available` to `is_archive_available` and always call it directly?

src/hotspot/share/cds/heapShared.cpp line 592:

> 590:   assert(HeapShared::can_write(), "must be");
> 591: 
> 592:   {

Why do  you need a new  scope here?

-------------

PR: https://git.openjdk.org/jdk/pull/12607


More information about the hotspot-runtime-dev mailing list