Bug 1720368 - Remove MOZ_GECKO_PROFILER ifdefs around profiler_init and profiler_shutdown calls, r=gerald.

Differential Revision: https://phabricator.services.mozilla.com/D119809
This commit is contained in:
Florian Quèze 2021-07-15 22:04:23 +00:00
parent 57d1e300f5
commit 292c1a1f60
9 changed files with 21 additions and 28 deletions

View File

@ -33,9 +33,7 @@
# include <gtk/gtk.h>
#endif
#ifdef MOZ_GECKO_PROFILER
# include "BaseProfiler.h"
#endif
#include "BaseProfiler.h"
#ifdef LIBFUZZER
# include "FuzzerDefs.h"
@ -61,10 +59,8 @@ int main(int argc, char** argv, char** envp) {
DllBlocklist_Initialize();
#endif
#ifdef MOZ_GECKO_PROFILER
char aLocal;
mozilla::baseprofiler::profiler_init(&aLocal);
#endif
XREShellData shellData;
#if defined(XP_WIN) && defined(MOZ_SANDBOX)
@ -85,9 +81,7 @@ int main(int argc, char** argv, char** envp) {
int result = bootstrap->XRE_XPCShellMain(argc, argv, envp, &shellData);
#ifdef MOZ_GECKO_PROFILER
mozilla::baseprofiler::profiler_shutdown();
#endif
#if defined(DEBUG) && defined(HAS_DLL_BLOCKLIST)
DllBlocklist_Shutdown();

View File

@ -2074,9 +2074,7 @@ NS_IMETHODIMP
nsXPCComponents_Utils::ExitIfInAutomation() {
NS_ENSURE_TRUE(xpc::IsInAutomation(), NS_ERROR_FAILURE);
#ifdef MOZ_GECKO_PROFILER
profiler_shutdown(IsFastShutdown::Yes);
#endif
mozilla::AppShutdown::DoImmediateExit();
return NS_OK;

View File

@ -1078,10 +1078,8 @@ int XRE_XPCShellMain(int argc, char** argv, char** envp,
// with the IOInterposer will be properly tracked.
mozilla::IOInterposerInit ioInterposerGuard;
#ifdef MOZ_GECKO_PROFILER
char aLocal;
profiler_init(&aLocal);
#endif
#ifdef MOZ_ASAN_REPORTER
PR_SetEnv("MOZ_DISABLE_ASAN_REPORTER=1");
@ -1440,11 +1438,9 @@ int XRE_XPCShellMain(int argc, char** argv, char** envp,
CrashReporter::UnsetExceptionHandler();
}
#ifdef MOZ_GECKO_PROFILER
// This must precede NS_LogTerm(), otherwise xpcshell return non-zero
// during some tests, which causes failures.
profiler_shutdown();
#endif
NS_LogTerm();

View File

@ -173,13 +173,11 @@ static void EnsureBaseProfilerInitialized() {
return;
}
#ifdef MOZ_GECKO_PROFILER
// The stack depth we observe here will be determined by the stack of
// whichever caller enters this code first. In practice this means that we may
// miss some root-most frames, which hopefully shouldn't ruin profiling.
int stackBase = 5;
mozilla::baseprofiler::profiler_init(&stackBase);
#endif
sInitialized = true;
}

View File

@ -72,6 +72,11 @@ static inline bool profiler_capture_backtrace_into(
static inline UniquePtr<ProfileChunkedBuffer> profiler_capture_backtrace() {
return nullptr;
}
static inline void profiler_init(void* stackTop) {}
static inline void profiler_shutdown() {}
} // namespace baseprofiler
} // namespace mozilla

View File

@ -32,6 +32,8 @@ namespace baseprofiler {
inline int profiler_main_thread_id() { return 0; }
inline bool profiler_is_active() { return false; }
} // namespace baseprofiler
} // namespace mozilla

View File

@ -637,12 +637,9 @@ MFBT_API void DllBlocklist_Initialize(uint32_t aInitFlags) {
// DLLs. Given that the base profiler is used outside the typical use
// cases, it's ok not to check user32.dll in this scenario.
const bool skipUser32Check =
(sInitFlags & eDllBlocklistInitFlagWasBootstrapped)
#ifdef MOZ_GECKO_PROFILER
||
(!IsWin10AnniversaryUpdateOrLater() && baseprofiler::profiler_is_active())
#endif
;
(sInitFlags & eDllBlocklistInitFlagWasBootstrapped) ||
(!IsWin10AnniversaryUpdateOrLater() &&
baseprofiler::profiler_is_active());
// In order to be effective against AppInit DLLs, the blocklist must be
// initialized before user32.dll is loaded into the process (bug 932100).

View File

@ -27,6 +27,11 @@
#include "mozilla/ProfilerMarkers.h"
#include "mozilla/ProfilerState.h"
enum class IsFastShutdown {
No,
Yes,
};
#ifndef MOZ_GECKO_PROFILER
# include "mozilla/UniquePtr.h"
@ -81,6 +86,11 @@ profiler_capture_backtrace() {
return nullptr;
}
static inline void profiler_init(void* stackTop) {}
static inline void profiler_shutdown(
IsFastShutdown aIsFastShutdown = IsFastShutdown::No) {}
static inline void profiler_set_process_name(
const nsACString& aProcessName, const nsACString* aETLDplus1 = nullptr) {}
@ -185,11 +195,6 @@ void profiler_init_threadmanager();
// Call this after the nsThreadManager is Init()ed
# define AUTO_PROFILER_INIT2 mozilla::AutoProfilerInit2 PROFILER_RAII
enum class IsFastShutdown {
No,
Yes,
};
// Clean up the profiler module, stopping it if required. This function may
// also save a shutdown profile if requested. No profiler calls should happen
// after this point and all profiling stack labels should have been popped.

View File

@ -238,9 +238,7 @@ void AppShutdown::MaybeFastShutdown(ShutdownPhase aPhase) {
RecordShutdownEndTimeStamp();
MaybeDoRestart();
#ifdef MOZ_GECKO_PROFILER
profiler_shutdown(IsFastShutdown::Yes);
#endif
#ifdef MOZ_BACKGROUNDTASKS
// We must unlock the profile, or else the lock file `parent.lock` will