Bug 983957 - Remove SPS ifdef from IOInterposer to unbreak non-SPS platforms. r=aklotz, a=lsblakk
authorJan Beich <jbeich@tormail.org>
Tue, 18 Mar 2014 16:24:36 -0600
changeset 191244 af2b86deaf5daf393c9101b99f04939442a5785f
parent 191243 b75e5179a9ef04f9ee46cb561f8a5726c7f1acd6
child 191245 eef4866eba7b96e8f75dd2bf6fe9bed564a0e401
push id3503
push userraliiev@mozilla.com
push dateMon, 28 Apr 2014 18:51:11 +0000
treeherdermozilla-beta@c95ac01e332e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaklotz, lsblakk
bugs983957
milestone30.0a2
Bug 983957 - Remove SPS ifdef from IOInterposer to unbreak non-SPS platforms. r=aklotz, a=lsblakk
xpcom/build/IOInterposer.cpp
xpcom/build/IOInterposer.h
xpcom/build/NSPRInterposer.h
xpcom/build/PoisonIOInterposer.h
xpcom/build/PoisonIOInterposerStub.cpp
xpcom/build/moz.build
--- a/xpcom/build/IOInterposer.cpp
+++ b/xpcom/build/IOInterposer.cpp
@@ -152,19 +152,17 @@ IOInterposeObserver::Operation IOInterpo
     bool isMainThread = XRE_GetWindowsEnvironment() !=
                           WindowsEnvironmentType_Metro;
 #else
     bool isMainThread = true;
 #endif
     sIsMainThread.set(isMainThread);
   }
   // Now we initialize the various interposers depending on platform
-#if defined(XP_WIN) || defined(XP_MACOSX)
   InitPoisonIOInterposer();
-#endif
   // We don't hook NSPR on Windows because PoisonIOInterposer captures a
   // superset of the former's events.
 #if !defined(XP_WIN)
   InitNSPRIOInterposing();
 #endif
 }
 
 /* static */ bool
--- a/xpcom/build/IOInterposer.h
+++ b/xpcom/build/IOInterposer.h
@@ -141,18 +141,16 @@ protected:
   /**
    * We don't use NS_IsMainThread() because we need to be able to determine the
    * main thread outside of XPCOM Initialization. IOInterposer observers should
    * call this function instead.
    */
   static bool IsMainThread();
 };
 
-#ifdef MOZ_ENABLE_PROFILER_SPS
-
 /**
  * Class offering the public static IOInterposer API.
  *
  * This class is responsible for ensuring that events are routed to the
  * appropriate observers. Methods Init() and Clear() should only be called from
  * the main-thread at startup and shutdown, respectively.
  *
  * Remark: Instances of this class will never be created, you should consider it
@@ -255,44 +253,24 @@ public:
    *
    * @param aIsMainThread true if IOInterposer should treat the current thread
    *                      as the main thread.
    */
   static void
   RegisterCurrentThread(bool aIsMainThread = false);
 };
 
-#else /* MOZ_ENABLE_PROFILER_SPS */
-
-class IOInterposer MOZ_FINAL
-{
-  IOInterposer();
-public:
-  static inline void Init()                                               {}
-  static inline void Clear()                                              {}
-  static inline void Disable()                                            {}
-  static inline void Report(IOInterposeObserver::Observation& aOb)        {}
-  static inline void Register(IOInterposeObserver::Operation aOp,
-                              IOInterposeObserver* aObserver)             {}
-  static inline void Unregister(IOInterposeObserver::Operation aOp,
-                                IOInterposeObserver* aObserver)           {}
-  static inline bool IsObservedOperation(IOInterposeObserver::Operation aOp) {
-    return false;
-  }
-  static inline void RegisterCurrentThread(bool)                          {}
-};
-
-#endif /* MOZ_ENABLE_PROFILER_SPS */
-
 class IOInterposerInit
 {
 public:
   IOInterposerInit()
   {
+#if defined(MOZ_ENABLE_PROFILER_SPS)
     IOInterposer::Init();
+#endif
   }
 
   // No destructor needed at the moment -- this stuff stays active for the
   // life of the process. This may change in the future.
 };
 
 } // namespace mozilla
 
--- a/xpcom/build/NSPRInterposer.h
+++ b/xpcom/build/NSPRInterposer.h
@@ -1,17 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef NSPRINTERPOSER_H_
 #define NSPRINTERPOSER_H_
 
-#ifdef MOZ_ENABLE_PROFILER_SPS
-
 namespace mozilla {
 
 /**
  * Initialize IO interposing for NSPR. This will report NSPR read, writes and
  * fsyncs to the IOInterposerObserver. It is only safe to call this from the
  * main-thread when no other threads are running.
  */
 void InitNSPRIOInterposing();
@@ -20,11 +18,9 @@ void InitNSPRIOInterposing();
  * Removes interception of NSPR IO methods as setup by InitNSPRIOInterposing.
  * Note, that it is only safe to call this on the main-thread when all other
  * threads have stopped. Which is typically the case at shutdown.
  */
 void ClearNSPRIOInterposing();
 
 } // namespace mozilla
 
-#endif // MOZ_ENABLE_PROFILER_SPS
-
 #endif // NSPRINTERPOSER_H_
--- a/xpcom/build/PoisonIOInterposer.h
+++ b/xpcom/build/PoisonIOInterposer.h
@@ -21,17 +21,17 @@ void MozillaRegisterDebugFILE(FILE *f);
 /** Unregister file descriptor from being ignored by poisoning IO interposer */
 void MozillaUnRegisterDebugFD(int fd);
 
 /** Unregister file from being ignored by poisoning IO interposer */
 void MozillaUnRegisterDebugFILE(FILE *f);
 
 MOZ_END_EXTERN_C
 
-#if defined(MOZ_ENABLE_PROFILER_SPS) && (defined(XP_WIN) || defined(XP_MACOSX))
+#if defined(XP_WIN) || defined(XP_MACOSX)
 
 #ifdef __cplusplus
 namespace mozilla {
 
 /**
  * Check if a file is registered as a debug file.
  */
 bool IsDebugFile(intptr_t aFileID);
@@ -58,24 +58,24 @@ void OnlyReportDirtyWrites();
  * Clear IO poisoning, this is only safe to do on the main-thread when no other
  * threads are running.
  */
 void ClearPoisonIOInterposer();
 
 } // namespace mozilla
 #endif /* __cplusplus */
 
-#else /* MOZ_ENABLE_PROFILER_SPS && (XP_WIN || XP_MACOSX) */
+#else /* XP_WIN || XP_MACOSX */
 
 #ifdef __cplusplus
 namespace mozilla {
 inline bool IsDebugFile(intptr_t aFileID){ return true; }
 inline void InitPoisonIOInterposer(){}
 inline void ClearPoisonIOInterposer(){}
 #ifdef XP_MACOSX
 inline void OnlyReportDirtyWrites(){}
 #endif /* XP_MACOSX */
 } // namespace mozilla
 #endif /* __cplusplus */
 
-#endif /* MOZ_ENABLE_PROFILER_SPS && (XP_WIN || XP_MACOSX) */
+#endif /* XP_WIN || XP_MACOSX */
 
 #endif // mozilla_PoisonIOInterposer_h
--- a/xpcom/build/PoisonIOInterposerStub.cpp
+++ b/xpcom/build/PoisonIOInterposerStub.cpp
@@ -3,16 +3,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <stdio.h>
 
 extern "C" {
 
-  // Define empty implementations so we can compile when
-  // MOZ_ENABLE_PROFILER_SPS is undefined
   void MozillaRegisterDebugFD(int fd) {}
   void MozillaRegisterDebugFILE(FILE *f) {}
   void MozillaUnRegisterDebugFD(int fd) {}
   void MozillaUnRegisterDebugFILE(FILE *f) {}
 
 }
\ No newline at end of file
--- a/xpcom/build/moz.build
+++ b/xpcom/build/moz.build
@@ -22,54 +22,48 @@ EXPORTS.mozilla += [
     'ServiceList.h',
     'Services.h',
     'XPCOM.h',
 ]
 
 if CONFIG['OS_ARCH'] == 'WINNT':
     EXPORTS += ['nsWindowsDllInterceptor.h']
     EXPORTS.mozilla += ['perfprobe.h']
-    SOURCES += ['perfprobe.cpp']
-    if CONFIG['MOZ_ENABLE_PROFILER_SPS']:
-        SOURCES += [
-            'PoisonIOInterposerBase.cpp',
-            'PoisonIOInterposerWin.cpp',
-        ]
-    else:
-        SOURCES += ['PoisonIOInterposerStub.cpp']
-elif CONFIG['OS_ARCH'] == 'Darwin' and CONFIG['MOZ_ENABLE_PROFILER_SPS']:
+    SOURCES += [
+        'perfprobe.cpp',
+        'PoisonIOInterposerBase.cpp',
+        'PoisonIOInterposerWin.cpp',
+    ]
+elif CONFIG['OS_ARCH'] == 'Darwin':
     SOURCES += [
         'mach_override.c',
         'PoisonIOInterposerBase.cpp',
         'PoisonIOInterposerMac.cpp',
     ]
 else:
     SOURCES += ['PoisonIOInterposerStub.cpp']
 
 include('../glue/objs.mozbuild')
 
 UNIFIED_SOURCES += xpcom_gluens_src_cppsrcs
 UNIFIED_SOURCES += xpcom_glue_src_cppsrcs
 
 UNIFIED_SOURCES += [
     'FrozenFunctions.cpp',
+    'IOInterposer.cpp',
     'LateWriteChecks.cpp',
     'nsXPComInit.cpp',
     'nsXPCOMStrings.cpp',
     'Services.cpp',
 ]
 
-if CONFIG['MOZ_ENABLE_PROFILER_SPS']:
+if CONFIG['OS_ARCH'] != 'WINNT':
     SOURCES += [
-        'IOInterposer.cpp',
+        'NSPRInterposer.cpp',
     ]
-    if CONFIG['OS_ARCH'] != 'WINNT':
-      SOURCES += [
-          'NSPRInterposer.cpp',
-      ]
 
 # FileLocation.cpp and Omnijar.cpp cannot be built in unified mode because they
 # use plarena.h.
 SOURCES += [
     'FileLocation.cpp',
     'Omnijar.cpp',
 ]