# HG changeset patch # User lucy # Date 1598453526 -7200 # Wed Aug 26 16:52:06 2020 +0200 # Node ID 094f38a19ae3f062a400014762790de74eeecd0b # Parent 420cb1ce9b7d82f70c1b9c94dbf7a5b6c68fccf7 8250635: MethodArityHistogram should use Compile_lock in favour of fancy checks Reviewed-by: mdoerr, thartmann diff --git a/src/hotspot/share/runtime/sharedRuntime.cpp b/src/hotspot/share/runtime/sharedRuntime.cpp --- a/src/hotspot/share/runtime/sharedRuntime.cpp +++ b/src/hotspot/share/runtime/sharedRuntime.cpp @@ -2155,8 +2155,8 @@ static int _max_size; // max. arg size seen static void add_method_to_histogram(nmethod* nm) { - if (CompiledMethod::nmethod_access_is_safe(nm)) { - Method* method = nm->method(); + Method* method = (nm == NULL) ? NULL : nm->method(); + if ((method != NULL) && nm->is_alive()) { ArgumentCount args(method->signature()); int arity = args.size() + (method->is_static() ? 0 : 1); int argsize = method->size_of_parameters(); @@ -2197,7 +2197,10 @@ public: MethodArityHistogram() { - MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); + // Take the Compile_lock to protect against changes in the CodeBlob structures + MutexLockerEx mu1(Compile_lock, Mutex::_no_safepoint_check_flag); + // Take the CodeCache_lock to protect against changes in the CodeHeap structure + MutexLockerEx mu2(CodeCache_lock, Mutex::_no_safepoint_check_flag); _max_arity = _max_size = 0; for (int i = 0; i < MAX_ARITY; i++) _arity_histogram[i] = _size_histogram[i] = 0; CodeCache::nmethods_do(add_method_to_histogram);