8332923: ObjectMonitorUsage.java failed with unexpected waiter_count

Co-authored-by: Jiawei Tang <jwtang@openjdk.org>
Reviewed-by: sspitsyn, alanb, amitkumar
This commit is contained in:
SendaoYan 2024-06-01 11:31:19 +00:00 committed by Serguei Spitsyn
parent d29d5bfb7f
commit 51b2f80627
2 changed files with 5 additions and 5 deletions

View File

@ -1475,7 +1475,7 @@ JvmtiEnvBase::get_object_monitor_usage(JavaThread* calling_thread, jobject objec
owning_thread = ObjectSynchronizer::get_lock_owner(tlh.list(), hobj);
if (owning_thread != nullptr) {
oop thread_oop = get_vthread_or_thread_oop(owning_thread);
bool is_virtual = java_lang_VirtualThread::is_instance(thread_oop);
bool is_virtual = thread_oop->is_a(vmClasses::BaseVirtualThread_klass());
if (is_virtual) {
thread_oop = nullptr;
}
@ -1522,7 +1522,7 @@ JvmtiEnvBase::get_object_monitor_usage(JavaThread* calling_thread, jobject objec
waiter = mon->next_waiter(waiter)) {
JavaThread *w = mon->thread_of_waiter(waiter);
oop thread_oop = get_vthread_or_thread_oop(w);
if (java_lang_VirtualThread::is_instance(thread_oop)) {
if (thread_oop->is_a(vmClasses::BaseVirtualThread_klass())) {
skipped++;
}
nWait++;
@ -1572,9 +1572,9 @@ JvmtiEnvBase::get_object_monitor_usage(JavaThread* calling_thread, jobject objec
for (int i = 0; i < nWait; i++) {
JavaThread *w = mon->thread_of_waiter(waiter);
oop thread_oop = get_vthread_or_thread_oop(w);
bool is_virtual = java_lang_VirtualThread::is_instance(thread_oop);
bool is_virtual = thread_oop->is_a(vmClasses::BaseVirtualThread_klass());
assert(w != nullptr, "sanity check");
if (java_lang_VirtualThread::is_instance(thread_oop)) {
if (is_virtual) {
skipped++;
} else {
// If the thread was found on the ObjectWaiter list, then

View File

@ -1196,7 +1196,7 @@ GrowableArray<JavaThread*>* Threads::get_pending_threads(ThreadsList * t_list,
if (!p->can_call_java()) continue;
oop thread_oop = JvmtiEnvBase::get_vthread_or_thread_oop(p);
if (java_lang_VirtualThread::is_instance(thread_oop)) {
if (thread_oop->is_a(vmClasses::BaseVirtualThread_klass())) {
continue;
}
// The first stage of async deflation does not affect any field