зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1464506 - profiler_is_active_and_thread_is_registered - r=canaltinova
This can be used while the profiler is running, to know if the current thread is registered -- regardless of whether it is actively profiled. This will help distinguish registered but non-profiled threads from threads that are not even registered (e.g., OS-generated threads). Differential Revision: https://phabricator.services.mozilla.com/D76281
This commit is contained in:
Родитель
1c13f92ad4
Коммит
6fdf365051
|
@ -4796,6 +4796,16 @@ bool mozilla::profiler::detail::IsThreadBeingProfiled() {
|
|||
return racyRegisteredThread && racyRegisteredThread->IsBeingProfiled();
|
||||
}
|
||||
|
||||
bool mozilla::profiler::detail::IsThreadRegistered() {
|
||||
MOZ_RELEASE_ASSERT(CorePS::Exists());
|
||||
|
||||
const RacyRegisteredThread* racyRegisteredThread =
|
||||
TLSRegisteredThread::RacyRegisteredThread();
|
||||
// The simple presence of this TLS pointer is proof that the thread is
|
||||
// registered.
|
||||
return !!racyRegisteredThread;
|
||||
}
|
||||
|
||||
bool profiler_thread_is_sleeping() {
|
||||
MOZ_RELEASE_ASSERT(NS_IsMainThread());
|
||||
MOZ_RELEASE_ASSERT(CorePS::Exists());
|
||||
|
|
|
@ -290,6 +290,7 @@ class RacyFeatures {
|
|||
};
|
||||
|
||||
bool IsThreadBeingProfiled();
|
||||
bool IsThreadRegistered();
|
||||
|
||||
} // namespace detail
|
||||
} // namespace profiler
|
||||
|
@ -536,6 +537,14 @@ inline bool profiler_thread_is_being_profiled() {
|
|||
mozilla::profiler::detail::IsThreadBeingProfiled();
|
||||
}
|
||||
|
||||
// During profiling, if the current thread is registered, return true
|
||||
// (regardless of whether it is actively being profiled).
|
||||
// (Same caveats and recommented usage as profiler_is_active().)
|
||||
inline bool profiler_is_active_and_thread_is_registered() {
|
||||
return profiler_is_active() &&
|
||||
mozilla::profiler::detail::IsThreadRegistered();
|
||||
}
|
||||
|
||||
// Is the profiler active and paused? Returns false if the profiler is inactive.
|
||||
bool profiler_is_paused();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче