8225141: Better handling of classes in error state in fast class initialization checks

Reviewed-by: dlong, dholmes
This commit is contained in:
Vladimir Ivanov 2019-06-06 13:46:03 +03:00
parent 6346d77b03
commit 829c81bbf9
2 changed files with 6 additions and 1 deletions

View File

@ -438,6 +438,8 @@ InstanceKlass::InstanceKlass(const ClassFileParser& parser, unsigned kind, Klass
_static_field_size(parser.static_field_size()),
_nonstatic_oop_map_size(nonstatic_oop_map_size(parser.total_oop_map_count())),
_itable_len(parser.itable_size()),
_init_thread(NULL),
_init_state(allocated),
_reference_type(parser.reference_type())
{
set_vtable_length(parser.vtable_size());
@ -1071,11 +1073,13 @@ void InstanceKlass::set_initialization_state_and_notify(ClassState state, TRAPS)
Handle h_init_lock(THREAD, init_lock());
if (h_init_lock() != NULL) {
ObjectLocker ol(h_init_lock, THREAD);
set_init_thread(NULL); // reset _init_thread before changing _init_state
set_init_state(state);
fence_and_clear_init_lock();
ol.notify_all(CHECK);
} else {
assert(h_init_lock() != NULL, "The initialization state should never be set twice");
set_init_thread(NULL); // reset _init_thread before changing _init_state
set_init_state(state);
}
}
@ -3710,6 +3714,7 @@ void InstanceKlass::set_init_state(ClassState state) {
: (_init_state < state);
assert(good_state || state == allocated, "illegal state transition");
#endif
assert(_init_thread == NULL, "should be cleared before state change");
_init_state = (u1)state;
}

View File

@ -247,7 +247,7 @@ class InstanceKlass: public Klass {
u2 _misc_flags;
u2 _minor_version; // minor version number of class file
u2 _major_version; // major version number of class file
Thread* _init_thread; // Pointer to current thread doing initialization (to handle recusive initialization)
Thread* _init_thread; // Pointer to current thread doing initialization (to handle recursive initialization)
OopMapCache* volatile _oop_map_cache; // OopMapCache for all methods in the klass (allocated lazily)
JNIid* _jni_ids; // First JNI identifier for static fields in this class
jmethodID* volatile _methods_jmethod_ids; // jmethodIDs corresponding to method_idnum, or NULL if none