/
githubmirror
/
panama-vector
Обзор
Документация
Войти
/
githubmirror
/
panama-vector
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/hotspot/share/runtime/hotCodeSampler.cpp
136 строк
4 KB
Chad Rakoczy
8382135: AArch64: HotCodeCollectorMoveFunction.java fails intermittently
30 июн 2026, 22:44
30 июн 2026, 22:44
c7816b0
Код
Авторство
О чём код?
/* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. * */ #ifdef COMPILER2 #include "code/codeCache.hpp" #include "logging/log.hpp" #include "runtime/hotCodeSampler.hpp" #include "runtime/javaThread.inline.hpp" #if INCLUDE_JFR #include "jfr/utilities/jfrTryLock.hpp" using SuspendedThreadTaskTryLock = JfrMutexTryLock; #endif bool ThreadSampler::sample_all_java_threads() { // Collect samples for each JavaThread for (JavaThreadIteratorWithHandle jtiwh; JavaThread *jt = jtiwh.next(); ) { if (jt->is_hidden_from_external_view() || jt->in_deopt_handler() || (jt->thread_state() != _thread_in_native && jt->thread_state() != _thread_in_Java)) { continue; } GetPCTask task(jt); { #if INCLUDE_JFR SuspendedThreadTaskTryLock try_lock(SuspendedThreadTask_lock); if (!try_lock.acquired()) { log_debug(hotcode)("Suspend lock held by JFR sampler; stopping this sampling round, will retry after %u seconds", HotCodeIntervalSeconds); return false; } #endif task.run(); } address pc = task.pc(); if (pc == nullptr) { continue; } CodeBlob* cb = CodeCache::find_blob(pc); if (cb != nullptr && cb->is_nmethod()) { bool created = false; int *count = _samples.put_if_absent(cb->as_nmethod(), 0, &created); (*count)++; if (created) { _samples.maybe_grow(); } } } return true; } Candidates::Candidates(ThreadSampler& sampler) : _hot_sample_count(0), _non_profiled_sample_count(0) { auto func = [&](nmethod* nm, int count) { if (CodeCache::get_code_blob_type(nm) == CodeBlobType::MethodNonProfiled) { _candidates.append(Pair<nmethod*, int>(nm, count)); add_non_profiled_sample_count(count); } else if (CodeCache::get_code_blob_type(nm) == CodeBlobType::MethodHot) { add_hot_sample_count(count); } }; sampler.iterate_samples(func); log_info(hotcode)("Generated candidate list from %d samples corresponding to %d nmethods", _non_profiled_sample_count + _hot_sample_count, _candidates.length()); } void Candidates::add_candidate(nmethod* nm, int count) { _candidates.append(Pair<nmethod*, int>(nm, count)); } void Candidates::add_hot_sample_count(int count) { _hot_sample_count += count; } void Candidates::add_non_profiled_sample_count(int count) { _non_profiled_sample_count += count; } void Candidates::sort() { _candidates.sort( [](Pair<nmethod*, int>* a, Pair<nmethod*, int>* b) { if (a->second > b->second) return 1; if (a->second < b->second) return -1; return 0; } ); } bool Candidates::has_candidates() { return !_candidates.is_empty(); } nmethod* Candidates::get_candidate() { assert(has_candidates(), "must not be empty"); Pair<nmethod*, int> candidate = _candidates.pop(); _hot_sample_count += candidate.second; _non_profiled_sample_count -= candidate.second; return candidate.first; } double Candidates::get_hot_sample_percent() { if (_hot_sample_count + _non_profiled_sample_count == 0) { return 0; } return 100.0 * _hot_sample_count / (_hot_sample_count + _non_profiled_sample_count); } #endif // COMPILER2