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;
}