Tue, 17 Dec 2019 05:07:06 +0000
8225141: Better handling of classes in error state in fast class initialization checks
Reviewed-by: andrew
src/share/vm/oops/instanceKlass.cpp | file | annotate | diff | comparison | revisions | |
src/share/vm/oops/instanceKlass.hpp | file | annotate | diff | comparison | revisions |
1.1 --- a/src/share/vm/oops/instanceKlass.cpp Wed Dec 04 16:24:15 2019 +0000 1.2 +++ b/src/share/vm/oops/instanceKlass.cpp Tue Dec 17 05:07:06 2019 +0000 1.3 @@ -294,6 +294,7 @@ 1.4 set_has_unloaded_dependent(false); 1.5 set_init_state(InstanceKlass::allocated); 1.6 set_init_thread(NULL); 1.7 + set_init_state(allocated); 1.8 set_reference_type(rt); 1.9 set_oop_map_cache(NULL); 1.10 set_jni_ids(NULL); 1.11 @@ -978,11 +979,13 @@ 1.12 oop init_lock = this_oop->init_lock(); 1.13 if (init_lock != NULL) { 1.14 ObjectLocker ol(init_lock, THREAD); 1.15 + this_oop->set_init_thread(NULL); // reset _init_thread before changing _init_state 1.16 this_oop->set_init_state(state); 1.17 this_oop->fence_and_clear_init_lock(); 1.18 ol.notify_all(CHECK); 1.19 } else { 1.20 assert(init_lock != NULL, "The initialization state should never be set twice"); 1.21 + this_oop->set_init_thread(NULL); // reset _init_thread before changing _init_state 1.22 this_oop->set_init_state(state); 1.23 } 1.24 } 1.25 @@ -3602,6 +3605,7 @@ 1.26 bool good_state = is_shared() ? (_init_state <= state) 1.27 : (_init_state < state); 1.28 assert(good_state || state == allocated, "illegal state transition"); 1.29 + set_initialization_state_and_notify_implassert(_init_thread == NULL, "should be cleared before state change"); 1.30 _init_state = (u1)state; 1.31 } 1.32 #endif
2.1 --- a/src/share/vm/oops/instanceKlass.hpp Wed Dec 04 16:24:15 2019 +0000 2.2 +++ b/src/share/vm/oops/instanceKlass.hpp Tue Dec 17 05:07:06 2019 +0000 2.3 @@ -241,7 +241,7 @@ 2.4 u2 _misc_flags; 2.5 u2 _minor_version; // minor version number of class file 2.6 u2 _major_version; // major version number of class file 2.7 - Thread* _init_thread; // Pointer to current thread doing initialization (to handle recusive initialization) 2.8 + Thread* _init_thread; // Pointer to current thread doing initialization (to handle recursive initialization) 2.9 int _vtable_len; // length of Java vtable (in words) 2.10 int _itable_len; // length of Java itable (in words) 2.11 OopMapCache* volatile _oop_map_cache; // OopMapCache for all methods in the klass (allocated lazily)