Bug 1722261 - Move profiler_thread_is_being_profiled to ProfilerThreadState.h and use ThreadRegistration - r=canaltinova

Differential Revision: https://phabricator.services.mozilla.com/D121848
This commit is contained in:
Gerald Squelart 2021-08-24 04:47:16 +00:00
Родитель 27339446a1
Коммит dec6c72992
4 изменённых файлов: 13 добавлений и 21 удалений

Просмотреть файл

@ -35,10 +35,6 @@ class RacyRegisteredThread final {
mThreadRegistration.mData.mIsBeingProfiled = aIsBeingProfiled;
}
bool IsBeingProfiled() const {
return mThreadRegistration.mData.mIsBeingProfiled;
}
// This is called on every profiler restart. Put things that should happen at
// that time here.
void ReinitializeOnResume() {

Просмотреть файл

@ -5597,14 +5597,6 @@ void profiler_thread_wake() {
racyRegisteredThread->SetAwake();
}
bool mozilla::profiler::detail::IsThreadBeingProfiled() {
MOZ_RELEASE_ASSERT(CorePS::Exists());
const RacyRegisteredThread* racyRegisteredThread =
TLSRegisteredThread::RacyRegisteredThread();
return racyRegisteredThread && racyRegisteredThread->IsBeingProfiled();
}
bool profiler_thread_is_sleeping() {
MOZ_RELEASE_ASSERT(NS_IsMainThread());
MOZ_RELEASE_ASSERT(CorePS::Exists());

Просмотреть файл

@ -164,7 +164,6 @@ using ProfilingStateChangeCallback = std::function<void(ProfilingState)>;
[[nodiscard]] inline bool profiler_is_active() { return false; }
[[nodiscard]] inline bool profiler_can_accept_markers() { return false; }
[[nodiscard]] inline bool profiler_thread_is_being_profiled() { return false; }
[[nodiscard]] inline bool profiler_feature_active(uint32_t aFeature) {
return false;
}
@ -276,7 +275,6 @@ class RacyFeatures {
sActiveAndFeatures;
};
[[nodiscard]] bool IsThreadBeingProfiled();
} // namespace mozilla::profiler::detail
//---------------------------------------------------------------------------
@ -315,13 +313,6 @@ class RacyFeatures {
return mozilla::profiler::detail::RacyFeatures::IsActiveAndUnpaused();
}
// Is the profiler active, and is the current thread being profiled?
// (Same caveats and recommented usage as profiler_is_active().)
[[nodiscard]] inline bool profiler_thread_is_being_profiled() {
return profiler_is_active() &&
mozilla::profiler::detail::IsThreadBeingProfiled();
}
// Is the profiler active and paused? Returns false if the profiler is inactive.
[[nodiscard]] bool profiler_is_paused();

Просмотреть файл

@ -22,4 +22,17 @@
mozilla::profiler::ThreadRegistration::IsRegistered();
}
// Is the profiler active, and is the current thread being profiled?
// (Same caveats and recommented usage as profiler_is_active().)
[[nodiscard]] inline bool profiler_thread_is_being_profiled() {
return profiler_is_active() &&
mozilla::profiler::ThreadRegistration::WithOnThreadRefOr(
[](mozilla::profiler::ThreadRegistration::OnThreadRef aTR) {
return aTR.UnlockedConstReaderAndAtomicRWCRef()
.IsBeingProfiled();
},
false);
;
}
#endif // ProfilerThreadState_h