[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-hotspot-runtime-dev
Subject:    RFR JDK-8232222: Set state to 'linked' when an archived class is restored at runtime
From:       Jiangli Zhou <jianglizhou () google ! com>
Date:       2019-11-28 17:33:46
Message-ID: CALrW1jxBmX2QA+R4=v5S2QzDJrwVumRu0vqKvhPmf2JtME3t7w () mail ! gmail ! com
[Download RAW message or body]

Hi,

Please review the following optimization related to archived classes'
(from builtin loaders) runtime restoration and linking. It is not
intended for OpenJDK 14. After reviewers review the change, I'll wait
for 14 fork before pushing.

webrev: http://cr.openjdk.java.net/~jiangli/8232222/webrev.00/
RFE: https://bugs.openjdk.java.net/browse/JDK-8232222

Motivation and details of the change, which are duplicated in the RFE
=====================================================

When linking a class, InstanceKlass::link_class_impl() first links all
super classes and super interfaces of the current class. For the
current class, it then verifies and rewrites the bytecode, links
methods, initializes the itable and vtable, and sets the current class
to 'linked' state.

When loading an archived class at runtime,
SystemDictionary::load_shared_class makes sure the super types (all
super classes and super interfaces) in the class hierarchy are loaded
first. If not, the archived class is not used. The archived class is
restored when 'loading' from the archive. At the end of the
restoration, all methods are linked. As bytecode verification and
rewriting are done at CDS dump time, the runtime does not redo the
operations for an archived class.

If we make sure the itable and vtable are properly initialized (not
needed for classes loaded by the NULL class loader) and
SystemDictionaryShared::check_verification_constraints is performed
for an archived class during restoration, then the archived class
(from builtin loaders) is effectively in 'linked' state.

For all archived classes loaded by the builtin loaders, we can safely
set to 'linked' state at the end of restoration. As a result, we can
save the work for iterating the super types in
InstanceKlass::link_class_impl() at runtime.

Performance results
================

With both JDK 11 and the latest jdk/jdk, the proposed change saves
~1.5M instruction execution when running HelloWorld with the default
CDS. Please see raw data in the RFE. For applications using more
archived classes at runtime, larger saving should be experienced.

Testing
======
Tested with all jtreg cds/* tests, which include all appcds tests.
Submit repo testing passed.

The change has also gone through internal testing with very large
number of tests (all with default CDS enabled) for more than a month.

Best,
Jiangli
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic