mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-17 01:24:33 +02:00
8304687: Move add_to_hierarchy
Reviewed-by: dholmes, fparain
This commit is contained in:
parent
63d4afbeb1
commit
bf917ba6af
9 changed files with 53 additions and 56 deletions
|
@ -1205,6 +1205,46 @@ void InstanceKlass::set_initialization_state_and_notify(ClassState state, JavaTh
|
|||
ml.notify_all();
|
||||
}
|
||||
|
||||
// Update hierarchy. This is done before the new klass has been added to the SystemDictionary. The Compile_lock
|
||||
// is grabbed, to ensure that the compiler is not using the class hierarchy.
|
||||
void InstanceKlass::add_to_hierarchy(JavaThread* current) {
|
||||
assert(!SafepointSynchronize::is_at_safepoint(), "must NOT be at safepoint");
|
||||
|
||||
// In case we are not using CHA based vtables we need to make sure the loaded
|
||||
// deopt is completed before anyone links this class.
|
||||
// Linking is done with _init_monitor held, by loading and deopting with it
|
||||
// held we make sure the deopt is completed before linking.
|
||||
if (!UseVtableBasedCHA) {
|
||||
init_monitor()->lock();
|
||||
}
|
||||
|
||||
DeoptimizationScope deopt_scope;
|
||||
{
|
||||
MutexLocker ml(current, Compile_lock);
|
||||
|
||||
set_init_state(InstanceKlass::loaded);
|
||||
// make sure init_state store is already done.
|
||||
// The compiler reads the hierarchy outside of the Compile_lock.
|
||||
// Access ordering is used to add to hierarchy.
|
||||
|
||||
// Link into hierarchy.
|
||||
append_to_sibling_list(); // add to superklass/sibling list
|
||||
process_interfaces(); // handle all "implements" declarations
|
||||
|
||||
// Now mark all code that depended on old class hierarchy.
|
||||
// Note: must be done *after* linking k into the hierarchy (was bug 12/9/97)
|
||||
if (Universe::is_fully_initialized()) {
|
||||
CodeCache::mark_dependents_on(&deopt_scope, this);
|
||||
}
|
||||
}
|
||||
// Perform the deopt handshake outside Compile_lock.
|
||||
deopt_scope.deoptimize_marked();
|
||||
|
||||
if (!UseVtableBasedCHA) {
|
||||
init_monitor()->unlock();
|
||||
}
|
||||
}
|
||||
|
||||
InstanceKlass* InstanceKlass::implementor() const {
|
||||
InstanceKlass* volatile* ik = adr_implementor();
|
||||
if (ik == nullptr) {
|
||||
|
@ -2512,7 +2552,7 @@ void InstanceKlass::remove_unshareable_info() {
|
|||
// Reset to the 'allocated' state to prevent any premature accessing to
|
||||
// a shared class at runtime while the class is still being loaded and
|
||||
// restored. A class' init_state is set to 'loaded' at runtime when it's
|
||||
// being added to class hierarchy (see SystemDictionary:::add_to_hierarchy()).
|
||||
// being added to class hierarchy (see InstanceKlass:::add_to_hierarchy()).
|
||||
_init_state = allocated;
|
||||
|
||||
{ // Otherwise this needs to take out the Compile_lock.
|
||||
|
@ -2586,7 +2626,7 @@ void InstanceKlass::init_shared_package_entry() {
|
|||
|
||||
void InstanceKlass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain,
|
||||
PackageEntry* pkg_entry, TRAPS) {
|
||||
// SystemDictionary::add_to_hierarchy() sets the init_state to loaded
|
||||
// InstanceKlass::add_to_hierarchy() sets the init_state to loaded
|
||||
// before the InstanceKlass is added to the SystemDictionary. Make
|
||||
// sure the current state is <loaded.
|
||||
assert(!is_loaded(), "invalid init state");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue