Bug 1405921 - Remove StackTop.{h,cpp}. r=mstange.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 05 Oct 2017 11:57:22 +1100
changeset 438765 022145f347d963fc1fb6b13b34acd10376d18434
parent 438764 7c7df778de296330fc013134ceffed6d5c39f492
child 438766 840478b0ff4953b59756d206dc37bf0eb0babf36
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1405921
milestone58.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 1405921 - Remove StackTop.{h,cpp}. r=mstange. The platform-*.cpp files are a better place for GetStackTop().
tools/profiler/core/StackTop.cpp
tools/profiler/core/StackTop.h
tools/profiler/core/platform-linux-android.cpp
tools/profiler/core/platform-macos.cpp
tools/profiler/core/platform-win32.cpp
tools/profiler/core/platform.h
tools/profiler/moz.build
deleted file mode 100644
--- a/tools/profiler/core/StackTop.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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 "PlatformMacros.h"
-
-#if defined(GP_OS_darwin)
-#include <mach/task.h>
-#include <mach/thread_act.h>
-#include <pthread.h>
-#elif defined(GP_OS_windows)
-#include <windows.h>
-#endif
-
-#include "StackTop.h"
-
-void *GetStackTop(void *guess) {
-#if defined(GP_OS_darwin)
-  pthread_t thread = pthread_self();
-  return pthread_get_stackaddr_np(thread);
-#elif defined(GP_OS_windows)
-#if defined(_MSC_VER) && defined(GP_ARCH_x86)
-  // offset 0x18 from the FS segment register gives a pointer to
-  // the thread information block for the current thread
-  NT_TIB* pTib;
-  __asm {
-    MOV EAX, FS:[18h]
-      MOV pTib, EAX
-  }
-  return static_cast<void*>(pTib->StackBase);
-#elif defined(__GNUC__) && defined(GP_ARCH_x86)
-  // offset 0x18 from the FS segment register gives a pointer to
-  // the thread information block for the current thread
-  NT_TIB* pTib;
-  asm ( "movl %%fs:0x18, %0\n"
-       : "=r" (pTib)
-      );
-  return static_cast<void*>(pTib->StackBase);
-#elif defined(GP_ARCH_amd64)
-  PNT_TIB64 pTib = reinterpret_cast<PNT_TIB64>(NtCurrentTeb());
-  return reinterpret_cast<void*>(pTib->StackBase);
-#else
-#error Need a way to get the stack bounds on this platform (Windows)
-#endif
-#else
-  return guess;
-#endif
-}
deleted file mode 100644
--- a/tools/profiler/core/StackTop.h
+++ /dev/null
@@ -1,10 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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 MOZ_STACK_TOP_H
-#define MOZ_STACK_TOP_H
-void *GetStackTop(void *guess);
-#endif
--- a/tools/profiler/core/platform-linux-android.cpp
+++ b/tools/profiler/core/platform-linux-android.cpp
@@ -70,16 +70,22 @@
 using namespace mozilla;
 
 /* static */ int
 Thread::GetCurrentId()
 {
   return gettid();
 }
 
+void*
+GetStackTop(void* aGuess)
+{
+  return aGuess;
+}
+
 static void
 PopulateRegsFromContext(Registers& aRegs, ucontext_t* aContext)
 {
   aRegs.mContext = aContext;
   mcontext_t& mcontext = aContext->uc_mcontext;
 
   // Extracting the sample from the context is extremely machine dependent.
 #if defined(GP_ARCH_x86)
--- a/tools/profiler/core/platform-macos.cpp
+++ b/tools/profiler/core/platform-macos.cpp
@@ -13,16 +13,17 @@
 
 #include <pthread.h>
 #include <semaphore.h>
 #include <signal.h>
 #include <libkern/OSAtomic.h>
 #include <mach/mach.h>
 #include <mach/semaphore.h>
 #include <mach/task.h>
+#include <mach/thread_act.h>
 #include <mach/vm_statistics.h>
 #include <sys/time.h>
 #include <sys/resource.h>
 #include <sys/types.h>
 #include <sys/sysctl.h>
 #include <stdarg.h>
 #include <stdlib.h>
 #include <string.h>
@@ -32,16 +33,23 @@
 // this port is based off of v8 svn revision 9837
 
 /* static */ int
 Thread::GetCurrentId()
 {
   return gettid();
 }
 
+void*
+GetStackTop(void* aGuess)
+{
+  pthread_t thread = pthread_self();
+  return pthread_get_stackaddr_np(thread);
+}
+
 class PlatformData
 {
 public:
   explicit PlatformData(int aThreadId) : mProfiledThread(mach_thread_self())
   {
     MOZ_COUNT_CTOR(PlatformData);
   }
 
--- a/tools/profiler/core/platform-win32.cpp
+++ b/tools/profiler/core/platform-win32.cpp
@@ -43,16 +43,46 @@
 /* static */ int
 Thread::GetCurrentId()
 {
   DWORD threadId = GetCurrentThreadId();
   MOZ_ASSERT(threadId <= INT32_MAX, "native thread ID is > INT32_MAX");
   return int(threadId);
 }
 
+void*
+GetStackTop(void* aGuess)
+{
+#if defined(GP_ARCH_x86)
+  // Offset 0x18 from the FS segment register gives a pointer to the thread
+  // information block for the current thread.
+  NT_TIB* pTib;
+#if defined(_MSC_VER)
+  __asm {
+    MOV EAX, FS:[18h]
+      MOV pTib, EAX
+  }
+#elif defined(__GNUC__)
+  asm ( "movl %%fs:0x18, %0\n"
+       : "=r" (pTib)
+      );
+#else
+#error "unimplemented"
+#endif
+  return static_cast<void*>(pTib->StackBase);
+
+#elif defined(GP_ARCH_amd64)
+  PNT_TIB64 pTib = reinterpret_cast<PNT_TIB64>(NtCurrentTeb());
+  return reinterpret_cast<void*>(pTib->StackBase);
+
+#else
+#error "unimplemented"
+#endif
+}
+
 static void
 PopulateRegsFromContext(Registers& aRegs, CONTEXT* aContext)
 {
 #if defined(GP_ARCH_amd64)
   aRegs.mPC = reinterpret_cast<Address>(aContext->Rip);
   aRegs.mSP = reinterpret_cast<Address>(aContext->Rsp);
   aRegs.mFP = reinterpret_cast<Address>(aContext->Rbp);
 #elif defined(GP_ARCH_x86)
--- a/tools/profiler/core/platform.h
+++ b/tools/profiler/core/platform.h
@@ -36,17 +36,16 @@
 #include "mozilla/Logging.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/StaticMutex.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/UniquePtr.h"
 #include "mozilla/Unused.h"
 #include "PlatformMacros.h"
 #include <vector>
-#include "StackTop.h"
 
 // We need a definition of gettid(), but glibc doesn't provide a
 // wrapper for it.
 #if defined(__GLIBC__)
 #include <unistd.h>
 #include <sys/syscall.h>
 static inline pid_t gettid()
 {
--- a/tools/profiler/moz.build
+++ b/tools/profiler/moz.build
@@ -19,17 +19,16 @@ if CONFIG['MOZ_GECKO_PROFILER']:
     ]
     UNIFIED_SOURCES += [
         'core/platform.cpp',
         'core/ProfileBuffer.cpp',
         'core/ProfileBufferEntry.cpp',
         'core/ProfileJSONWriter.cpp',
         'core/ProfilerBacktrace.cpp',
         'core/ProfilerMarkerPayload.cpp',
-        'core/StackTop.cpp',
         'core/ThreadInfo.cpp',
         'gecko/ChildProfilerController.cpp',
         'gecko/nsProfilerFactory.cpp',
         'gecko/nsProfilerStartParams.cpp',
         'gecko/ProfilerChild.cpp',
         'gecko/ProfilerIOInterposeObserver.cpp',
         'gecko/ProfilerParent.cpp',
         'gecko/ThreadResponsiveness.cpp',