Bug 1172138 - Call PR_LogInit before profiler_init. r=froydnj
authorEric Rahm <erahm@mozilla.com>
Tue, 09 Jun 2015 17:44:46 -0700
changeset 247776 17c8c58041f4645584ead0c2170a21a2b4a3b698
parent 247775 ec493d9f59965561d949bc0ab95712317829df37
child 247777 2902d065f84ad8c771ebedcf9649b946c2488eaf
push id60805
push usererahm@mozilla.com
push dateWed, 10 Jun 2015 00:46:00 +0000
treeherdermozilla-inbound@17c8c58041f4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1172138
milestone41.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1172138 - Call PR_LogInit before profiler_init. r=froydnj
toolkit/xre/nsAppRunner.cpp
toolkit/xre/nsEmbedFunctions.cpp
xpcom/build/XPCOMInit.cpp
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -4271,16 +4271,18 @@ XREMain::XRE_mainRun()
 /*
  * XRE_main - A class based main entry point used by most platforms.
  *            Note that on OSX, aAppData->xreDirectory will point to
  *            .app/Contents/Resources.
  */
 int
 XREMain::XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
 {
+  ScopedLogging log;
+
   char aLocal;
   GeckoProfilerInitRAII profilerGuard(&aLocal);
 
   PROFILER_LABEL("Startup", "XRE_Main",
     js::ProfileEntry::Category::OTHER);
 
   nsresult rv = NS_OK;
 
@@ -4297,18 +4299,16 @@ XREMain::XRE_main(int argc, char* argv[]
   if (!mAppData)
     return 1;
   if (!mAppData->remotingName) {
     SetAllocatedString(mAppData->remotingName, mAppData->name);
   }
   // used throughout this file
   gAppData = mAppData;
 
-  ScopedLogging log;
-
   mozilla::IOInterposerInit ioInterposerGuard;
 
 #if defined(MOZ_WIDGET_GTK)
 #if defined(MOZ_MEMORY) || defined(__FreeBSD__) || defined(__NetBSD__)
   // Disable the slice allocator, since jemalloc already uses similar layout
   // algorithms, and using a sub-allocator tends to increase fragmentation.
   // This must be done before g_thread_init() is called.
   g_slice_set_config(G_SLICE_CONFIG_ALWAYS_MALLOC, 1);
--- a/toolkit/xre/nsEmbedFunctions.cpp
+++ b/toolkit/xre/nsEmbedFunctions.cpp
@@ -342,16 +342,19 @@ XRE_InitChildProcess(int aArgc,
     if (_fileno(stderr) == -1 ||
         _get_osfhandle(fileno(stderr)) == -1)
         freopen("CONOUT$", "w", stderr);
     if (_fileno(stdin) == -1 || _get_osfhandle(fileno(stdin)) == -1)
         freopen("CONIN$", "r", stdin);
   }
 #endif
 
+  // NB: This must be called before profiler_init
+  NS_LogInit();
+
   char aLocal;
   profiler_init(&aLocal);
 
   PROFILER_LABEL("Startup", "XRE_InitChildProcess",
     js::ProfileEntry::Category::OTHER);
 
   // Complete 'task_t' exchange for Mac OS X. This structure has the same size
   // regardless of architecture so we don't have any cross-arch issues here.
@@ -483,18 +486,16 @@ XRE_InitChildProcess(int aArgc,
       SetTaskbarGroupId(appId);
     }
   }
 #endif
 
   base::AtExitManager exitManager;
   NotificationService notificationService;
 
-  NS_LogInit();
-
   nsresult rv = XRE_InitCommandLine(aArgc, aArgv);
   if (NS_FAILED(rv)) {
     profiler_shutdown();
     NS_LogTerm();
     return NS_ERROR_FAILURE;
   }
 
   MessageLoop::Type uiLoopType;
--- a/xpcom/build/XPCOMInit.cpp
+++ b/xpcom/build/XPCOMInit.cpp
@@ -481,16 +481,18 @@ NS_InitXPCOM2(nsIServiceManager** aResul
   if (sInitialized) {
     return NS_ERROR_FAILURE;
   }
 
   sInitialized = true;
 
   mozPoisonValueInit();
 
+  NS_LogInit();
+
   char aLocal;
   profiler_init(&aLocal);
   nsresult rv = NS_OK;
 
   // We are not shutting down
   gXPCOMShuttingDown = false;
 
   // Initialize the available memory tracker before other threads have had a
@@ -503,18 +505,16 @@ NS_InitXPCOM2(nsIServiceManager** aResul
   // to read the umask without changing it, and the setting is process-
   // global, so this must be done while we are still single-threaded; the
   // nsSystemInfo object is typically created much later, when some piece
   // of chrome JS wants it.  The system call is specified as unable to fail.
   nsSystemInfo::gUserUmask = ::umask(0777);
   ::umask(nsSystemInfo::gUserUmask);
 #endif
 
-  NS_LogInit();
-
   // Set up chromium libs
   NS_ASSERTION(!sExitManager && !sMessageLoop, "Bad logic!");
 
   if (!AtExitManager::AlreadyRegistered()) {
     sExitManager = new AtExitManager();
   }
 
   if (!MessageLoop::current()) {