--- old/src/hotspot/share/code/codeCache.cpp 2019-05-21 12:00:02.374454920 +0200 +++ new/src/hotspot/share/code/codeCache.cpp 2019-05-21 12:00:01.901438822 +0200 @@ -1146,21 +1146,21 @@ } #endif // INCLUDE_JVMTI -// Deoptimize all(most) methods +// Mark methods for deopt (if safe or possible). void CodeCache::mark_all_nmethods_for_deoptimization() { MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); CompiledMethodIterator iter(CompiledMethodIterator::only_alive_and_not_unloading); while(iter.next()) { CompiledMethod* nm = iter.method(); - // Not installed are unsafe to mark for deopt, normally never deopted. - // A not_entrant method may become a zombie at any time, - // since we don't know on which side of last safepoint it became not_entrant - // (state must be in_use). - // Native method are unsafe to mark for deopt, normally never deopted. if (!nm->method()->is_method_handle_intrinsic() && !nm->is_not_installed() && nm->is_in_use() && !nm->is_native_method()) { + // Intrinsics and native methods are never deopted. A method that is + // not installed yet or is not in use is not safe to deopt; the + // is_in_use() check covers the not_entrant and not zombie cases. + // Note: A not_entrant method can become a zombie at anytime if it was + // made not_entrant before the previous safepoint/handshake. nm->mark_for_deoptimization(); } } @@ -1188,12 +1188,12 @@ CompiledMethodIterator iter(CompiledMethodIterator::only_alive_and_not_unloading); while(iter.next()) { CompiledMethod* nm = iter.method(); - // only_alive_and_not_unloading returns not_entrant nmethods. - // A not_entrant can become a zombie at anytime, - // if it was made not_entrant before previous safepoint/handshake. - // We check that it is not not_entrant and not zombie, - // by checking is_in_use(). if (nm->is_marked_for_deoptimization() && nm->is_in_use()) { + // only_alive_and_not_unloading() can return not_entrant nmethods. + // A not_entrant method can become a zombie at anytime if it was + // made not_entrant before the previous safepoint/handshake. The + // is_in_use() check covers the not_entrant and not zombie cases + // that have become true after the method was marked for deopt. nm->make_not_entrant(); } }