RFR: 8251261: CDS dumping should not clear states in live classes

Yumin Qi minqi at openjdk.java.net
Tue Sep 22 02:46:23 UTC 2020


On Mon, 21 Sep 2020 23:54:39 GMT, Calvin Cheung <ccheung at openjdk.org> wrote:

>> We had an issue when CDS dumped a static archive (java -Xshare:dump), it would call `Klass::remove_unshareable_info()`
>> too early. In one of the test failures, ZGC was still scanning the heap and stepped on a class whose mirror has been
>> removed.  The fix is to avoid modifying the states of the Java classes during -Xshare:dump. Instead, we call
>> `Klass::remove_unshareable_info()` only on the **copy** of the classes which are written into the archive. It's safe to
>> do so because these copies are visible only to the CDS dumping code. They aren't accessible by the GC or any other
>> subsystems.  It turns out that we were already doing this for the dynamic archive. So I just generalized the code in
>> dynamicArchive.cpp and moved it to archiveBuilder.cpp. So this PR is one step forward for [JDK-8234693 Consolidate CDS
>> static and dynamic archive dumping code](https://bugs.openjdk.java.net/browse/JDK-8234693).  I also fixed another case
>> where we modify the global VM state -- I removed `Universe::clear_basic_type_mirrors()`.
>> ----
>> 
>> We are still modifying some global VM states (such as SystemDictionary::_well_known_klasses). They seem harmless now,
>> but we might have to do more fixes in the future.
>
> src/hotspot/share/memory/heapShared.cpp line 401:
> 
>> 399:   }
>> 400:
>> 401:   assert(relocated_k->is_shared(), "must be a shared class");
> 
> Why is this assert removed?

The delete is reasonable since line 293 already assert that relocated_k is a relocated klass in shared region which
must be shared class I think.

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

PR: https://git.openjdk.java.net/jdk/pull/227


More information about the hotspot-runtime-dev mailing list