Bug 1337189 (part 4) - #include platform-*.cc from platform.cpp. r=mstange.
authorNicholas Nethercote <nnethercote@mozilla.com>
Tue, 07 Feb 2017 16:09:39 +1100
changeset 341579 e6f643603520c375fdcea9e8f0273d0862e7b783
parent 341578 6f55b285bad3f6f84035bb392fde332f76fd6f4c
child 341580 9fb286937e67a44ae1de84157dabe1f50b0d2562
push id31338
push usercbook@mozilla.com
push dateThu, 09 Feb 2017 15:04:28 +0000
treeherdermozilla-central@88d6a5ed1018 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1337189
milestone54.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 1337189 (part 4) - #include platform-*.cc from platform.cpp. r=mstange. platform-*.cc and platform.cpp belong together conceptually, and combining them into a single compilation unit makes it easier to share things and avoids the need for some declarations in headers. The patch also removes old_sigsave_signal_handler_ which is a long-dead field that clang now detects and complains about.
tools/profiler/core/platform-linux.cc
tools/profiler/core/platform-macos.cc
tools/profiler/core/platform-win32.cc
tools/profiler/core/platform.cpp
tools/profiler/core/platform.h
tools/profiler/moz.build
--- a/tools/profiler/core/platform-linux.cc
+++ b/tools/profiler/core/platform-linux.cc
@@ -58,28 +58,22 @@
 #include <unistd.h>     // sysconf
 #include <semaphore.h>
 #ifdef __GLIBC__
 #include <execinfo.h>   // backtrace, backtrace_symbols
 #endif  // def __GLIBC__
 #include <strings.h>    // index
 #include <errno.h>
 #include <stdarg.h>
+
 #include "prenv.h"
-#include "platform.h"
-#include "GeckoProfiler.h"
-#include "mozilla/Mutex.h"
 #include "mozilla/Atomics.h"
 #include "mozilla/LinuxSignal.h"
-#include "mozilla/TimeStamp.h"
 #include "mozilla/DebugOnly.h"
 #include "ProfileEntry.h"
-#include "nsThreadUtils.h"
-#include "ThreadInfo.h"
-#include "ThreadResponsiveness.h"
 
 #if defined(__ARM_EABI__) && defined(ANDROID)
  // Should also work on other Android and ARM Linux, but not tested there yet.
 # define USE_EHABI_STACKWALK
 # include "EHABIStackWalk.h"
 #elif defined(SPS_PLAT_amd64_linux) || defined(SPS_PLAT_x86_linux)
 # define USE_LUL_STACKWALK
 # include "lul/LulMain.h"
--- a/tools/profiler/core/platform-macos.cc
+++ b/tools/profiler/core/platform-macos.cc
@@ -24,25 +24,19 @@
 #include <sys/types.h>
 #include <sys/sysctl.h>
 #include <stdarg.h>
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
 #include <math.h>
 
-#include "ThreadResponsiveness.h"
-#include "nsThreadUtils.h"
-
 // Memory profile
 #include "nsMemoryReporterManager.h"
 
-#include "platform.h"
-#include "mozilla/TimeStamp.h"
-
 using mozilla::TimeStamp;
 using mozilla::TimeDuration;
 
 // this port is based off of v8 svn revision 9837
 
 #ifdef DEBUG
 // 0 is never a valid thread id on MacOSX since a pthread_t is a pointer.
 static const pthread_t kNoThread = (pthread_t) 0;
--- a/tools/profiler/core/platform-win32.cc
+++ b/tools/profiler/core/platform-win32.cc
@@ -24,20 +24,17 @@
 // AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 // OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 // SUCH DAMAGE.
 
 #include <windows.h>
 #include <mmsystem.h>
 #include <process.h>
-#include "platform.h"
 #include "ProfileEntry.h"
-#include "ThreadInfo.h"
-#include "ThreadResponsiveness.h"
 
 // Memory profile
 #include "nsMemoryReporterManager.h"
 
 #include "mozilla/StackWalk_windows.h"
 
 
 class PlatformData {
--- a/tools/profiler/core/platform.cpp
+++ b/tools/profiler/core/platform.cpp
@@ -15,16 +15,17 @@
 #include "mozilla/UniquePtr.h"
 #include "GeckoProfiler.h"
 #include "ProfilerIOInterposeObserver.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/ThreadLocal.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/Sprintf.h"
 #include "PseudoStack.h"
+#include "ThreadInfo.h"
 #include "nsIObserverService.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsXULAppAPI.h"
 #include "nsProfilerStartParams.h"
 #include "mozilla/Services.h"
 #include "nsThreadUtils.h"
 #include "ProfilerMarkers.h"
@@ -1247,8 +1248,21 @@ profiler_add_marker(const char *aMarker,
   mozilla::TimeStamp origin = (aPayload && !aPayload->GetStartTime().IsNull()) ?
                      aPayload->GetStartTime() : mozilla::TimeStamp::Now();
   mozilla::TimeDuration delta = origin - sStartTime;
   stack->addMarker(aMarker, payload.release(), delta.ToMilliseconds());
 }
 
 // END externally visible functions
 ////////////////////////////////////////////////////////////////////////
+
+// We #include these files directly because it means those files can use
+// declarations from this file trivially.
+#if defined(SPS_OS_windows)
+# include "platform-win32.cc"
+#elif defined(SPS_OS_darwin)
+# include "platform-macos.cc"
+#elif defined(SPS_OS_linux) || defined(SPS_OS_android)
+# include "platform-linux.cc"
+#else
+# error "bad platform"
+#endif
+
--- a/tools/profiler/core/platform.h
+++ b/tools/profiler/core/platform.h
@@ -368,17 +368,16 @@ private:
   Atomic32 paused_;
   Atomic32 active_;
   const int entrySize_;
 
   // Refactor me!
 #if defined(SPS_OS_linux) || defined(SPS_OS_android)
   bool signal_handler_installed_;
   struct sigaction old_sigprof_signal_handler_;
-  struct sigaction old_sigsave_signal_handler_;
   bool signal_sender_launched_;
   pthread_t signal_sender_thread_;
 #endif
 
   RefPtr<ProfileBuffer> mBuffer;
   bool mAddLeafAddresses;
   bool mUseStackWalk;
   bool mProfileJS;
--- a/tools/profiler/moz.build
+++ b/tools/profiler/moz.build
@@ -55,39 +55,36 @@ if CONFIG['MOZ_GECKO_PROFILER']:
             'lul/LulDwarf.cpp',
             'lul/LulDwarfSummariser.cpp',
             'lul/LulElf.cpp',
             'lul/LulMain.cpp',
             'lul/platform-linux-lul.cpp',
         ]
         # These files cannot be built in unified mode because of name clashes with mozglue headers on Android.
         SOURCES += [
-            'core/platform-linux.cc',
             'core/shared-libraries-linux.cc',
         ]
         if not CONFIG['MOZ_CRASHREPORTER']:
             SOURCES += [
                 '/toolkit/crashreporter/google-breakpad/src/common/linux/elfutils.cc',
                 '/toolkit/crashreporter/google-breakpad/src/common/linux/file_id.cc',
                 '/toolkit/crashreporter/google-breakpad/src/common/linux/guid_creator.cc',
                 '/toolkit/crashreporter/google-breakpad/src/common/linux/linux_libc_support.cc',
                 '/toolkit/crashreporter/google-breakpad/src/common/linux/memory_mapped_file.cc',
             ]
         if CONFIG['CPU_ARCH'] == 'arm':
             SOURCES += [
                 'core/EHABIStackWalk.cpp',
             ]
     elif CONFIG['OS_TARGET'] == 'Darwin':
         UNIFIED_SOURCES += [
-            'core/platform-macos.cc',
             'core/shared-libraries-macos.cc',
         ]
     elif CONFIG['OS_TARGET'] == 'WINNT':
         SOURCES += [
-            'core/platform-win32.cc',
             'core/shared-libraries-win32.cc',
         ]
 
     LOCAL_INCLUDES += [
         '/docshell/base',
         '/ipc/chromium/src',
         '/mozglue/linker',
         '/toolkit/crashreporter/google-breakpad/src',