aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzgu <unknown>2019-12-17 05:07:06 +0000
committerbell-sw <liberica@bell-sw.com>2020-01-19 09:12:37 +0300
commit6cd5911e2e66a63c55e5aeaaa93b2999b8180ed6 (patch)
treecc041c4bb780838448308a82c9895da00d28eb81
parent3c7f40589f64db946cc2917db0de33918b4d2ba9 (diff)
downloadjdk8u_hotspot-6cd5911e2e66a63c55e5aeaaa93b2999b8180ed6.tar.gz
8225141: Better handling of classes in error state in fast class initialization checks
Reviewed-by: andrew
-rw-r--r--src/share/vm/oops/instanceKlass.cpp4
-rw-r--r--src/share/vm/oops/instanceKlass.hpp2
2 files changed, 5 insertions, 1 deletions
diff --git a/src/share/vm/oops/instanceKlass.cpp b/src/share/vm/oops/instanceKlass.cpp
index 0204188ad..8f96915c5 100644
--- a/src/share/vm/oops/instanceKlass.cpp
+++ b/src/share/vm/oops/instanceKlass.cpp
@@ -294,6 +294,7 @@ InstanceKlass::InstanceKlass(int vtable_len,
set_has_unloaded_dependent(false);
set_init_state(InstanceKlass::allocated);
set_init_thread(NULL);
+ set_init_state(allocated);
set_reference_type(rt);
set_oop_map_cache(NULL);
set_jni_ids(NULL);
@@ -978,11 +979,13 @@ void InstanceKlass::set_initialization_state_and_notify_impl(instanceKlassHandle
oop init_lock = this_oop->init_lock();
if (init_lock != NULL) {
ObjectLocker ol(init_lock, THREAD);
+ this_oop->set_init_thread(NULL); // reset _init_thread before changing _init_state
this_oop->set_init_state(state);
this_oop->fence_and_clear_init_lock();
ol.notify_all(CHECK);
} else {
assert(init_lock != NULL, "The initialization state should never be set twice");
+ this_oop->set_init_thread(NULL); // reset _init_thread before changing _init_state
this_oop->set_init_state(state);
}
}
@@ -3602,6 +3605,7 @@ void InstanceKlass::set_init_state(ClassState state) {
bool good_state = is_shared() ? (_init_state <= state)
: (_init_state < state);
assert(good_state || state == allocated, "illegal state transition");
+ set_initialization_state_and_notify_implassert(_init_thread == NULL, "should be cleared before state change");
_init_state = (u1)state;
}
#endif
diff --git a/src/share/vm/oops/instanceKlass.hpp b/src/share/vm/oops/instanceKlass.hpp
index 444eadd38..49d552822 100644
--- a/src/share/vm/oops/instanceKlass.hpp
+++ b/src/share/vm/oops/instanceKlass.hpp
@@ -241,7 +241,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)
int _vtable_len; // length of Java vtable (in words)
int _itable_len; // length of Java itable (in words)
OopMapCache* volatile _oop_map_cache; // OopMapCache for all methods in the klass (allocated lazily)