RFR: 8261090: Store old classfiles in static CDS archive

Calvin Cheung ccheung at openjdk.java.net
Thu Apr 15 17:13:36 UTC 2021


On Wed, 14 Apr 2021 01:05:27 GMT, Jiangli Zhou <jiangli at openjdk.org> wrote:

>> Please review this RFE for storing old classfiles with major version < 50 in static CDS archive.
>> During static CDS dump time, old classes won't be verified/rewritten. They will be verified/rewritten during runtime.
>> Therefore, the `_constMethod`, `_constants`, and `_cache` of old classes must be stored in the RW region of the archive for runtime rewriting. The `ConstantPool::remove_unshareable_info` will be skipped during dump time and the `ConstantPool::restore_unshareable_info` will be skipped during runtime for old classes.
>> 
>> Passed tiers 1,2,3,4 tests on mach5.
>
> src/hotspot/share/memory/metaspaceShared.cpp line 759:
> 
>> 757:   Thread* THREAD = current; // For exception macros.
>> 758:   Arguments::assert_is_dumping_archive();
>> 759:   if (ik->is_loaded() && !ik->is_linked() && !MetaspaceShared::is_old_class(ik) &&
> 
> It would be desirable to support the cases when verification is not enabled, which are not rare. For old classes, bytecode rewriting and class linking can still be done at dump time in those cases, with your current proposed change that includes old classes in the archive image. Otherwise, runtime would have to spend CPU cycles to do rewriting/linking for old classes when not truly necessary.

I think that should be done in a separate RFE. It has security implication -- it may not be a good idea to implement a performance feature that you can get only by disabling verification. This will need more community input and security review.
What we have implemented in this PR is a compromise -- support old classes in CDS as much as we can, without breaking any security mechanisms.
There are also alternatives for further improvement. For example, we can modify the old verifier to store verification constraints in the CDS archive. This will require more work, but will preserve the Java security model.

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

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


More information about the hotspot-runtime-dev mailing list