From e065ae560c15e7bbd24450a43b85ab601faefeeb Mon Sep 17 00:00:00 2001 From: Guanqiang Han Date: Sat, 17 Jan 2026 13:25:25 +0000 Subject: [PATCH] revert --- src/hotspot/share/runtime/deoptimization.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/runtime/deoptimization.cpp b/src/hotspot/share/runtime/deoptimization.cpp index b7af5998616..9494b73bdd1 100644 --- a/src/hotspot/share/runtime/deoptimization.cpp +++ b/src/hotspot/share/runtime/deoptimization.cpp @@ -2150,6 +2150,16 @@ JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* current, jint tr // Print a bunch of diagnostics, if requested. if (TraceDeoptimization || LogCompilation || is_receiver_constraint_failure) { ResourceMark rm; + + // Lock to read ProfileData, and ensure lock is not broken by a safepoint + // We must do this already now, since we cannot acquire this lock while + // holding the tty lock (lock ordering by rank). + ConditionalMutexLocker ml((trap_mdo != nullptr) ? trap_mdo->extra_data_lock() : nullptr, + (trap_mdo != nullptr), + Mutex::_no_safepoint_check_flag); + + ttyLocker ttyl; + char buf[100]; if (xtty != nullptr) { xtty->begin_head("uncommon_trap thread='%zu' %s", @@ -2178,7 +2188,6 @@ JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* current, jint tr xtty->name(class_name); } if (xtty != nullptr && trap_mdo != nullptr && (int)reason < (int)MethodData::_trap_hist_limit) { - MutexLocker ml(trap_mdo->extra_data_lock(), Mutex::_no_safepoint_check_flag); // Dump the relevant MDO state. // This is the deopt count for the current reason, any previous // reasons or recompiles seen at this point. @@ -2232,7 +2241,6 @@ JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* current, jint tr class_name->print_symbol_on(&st); } st.cr(); - ttyLocker ttyl; tty->print_raw(st.freeze()); } if (xtty != nullptr) {