This commit is contained in:
Guanqiang Han 2026-01-17 13:25:25 +00:00
parent 350680364b
commit e065ae560c

View File

@ -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) {