Bug 1401662 - don't inline nsThreadManager::get(); r=erahm
authorNathan Froyd <froydnj@mozilla.com>
Wed, 20 Sep 2017 17:10:20 -0400
changeset 431558 a88ee0137c104a57c747cd129c45952ccf1431ad
parent 431557 06eacffae8c8d2bec170b2ad6e6bfa4f95410e39
child 431559 51711f2c9cae02483300eaaf12badc73a39e24b1
push id7785
push userryanvm@gmail.com
push dateThu, 21 Sep 2017 13:39:55 +0000
treeherdermozilla-beta@06d4034a8a03 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserahm
bugs1401662
milestone57.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 1401662 - don't inline nsThreadManager::get(); r=erahm Defining get() in the declaration of nsThreadManager implicitly sticks an "inline" on the function, which is not what we want: inlining it spreads around a lot of static initialization code. Providing an out-of-line definition is much better in terms of code size.
xpcom/threads/nsThreadManager.cpp
xpcom/threads/nsThreadManager.h
--- a/xpcom/threads/nsThreadManager.cpp
+++ b/xpcom/threads/nsThreadManager.cpp
@@ -100,16 +100,23 @@ nsThreadManager::Release()
 NS_IMPL_CLASSINFO(nsThreadManager, nullptr,
                   nsIClassInfo::THREADSAFE | nsIClassInfo::SINGLETON,
                   NS_THREADMANAGER_CID)
 NS_IMPL_QUERY_INTERFACE_CI(nsThreadManager, nsIThreadManager)
 NS_IMPL_CI_INTERFACE_GETTER(nsThreadManager, nsIThreadManager)
 
 //-----------------------------------------------------------------------------
 
+/*static*/ nsThreadManager&
+nsThreadManager::get()
+{
+  static nsThreadManager sInstance;
+  return sInstance;
+}
+
 nsresult
 nsThreadManager::Init()
 {
   // Child processes need to initialize the thread manager before they
   // initialize XPCOM in order to set up the crash reporter. This leads to
   // situations where we get initialized twice.
   if (mInitialized) {
     return NS_OK;
--- a/xpcom/threads/nsThreadManager.h
+++ b/xpcom/threads/nsThreadManager.h
@@ -15,21 +15,17 @@
 class nsIRunnable;
 
 class nsThreadManager : public nsIThreadManager
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSITHREADMANAGER
 
-  static nsThreadManager& get()
-  {
-    static nsThreadManager sInstance;
-    return sInstance;
-  }
+  static nsThreadManager& get();
 
   nsresult Init();
 
   // Shutdown all threads.  This function should only be called on the main
   // thread of the application process.
   void Shutdown();
 
   // Called by nsThread to inform the ThreadManager it exists.  This method