Bug 942488 - Don't report pseudo-stacks without SPS profiler. r=nchen
authorJan Beich <jbeich@tormail.org>
Mon, 25 Nov 2013 09:24:00 -0500
changeset 172987 e38d1e0ed82a274b30e9a7af391dcd640d167bf6
parent 172986 0c586ac02573e0e2c86865d239b73c81ca314d35
child 172988 364bd220cdb7a0b4c8ab1f9ecfef2ef980160b80
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnchen
bugs942488
milestone28.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 942488 - Don't report pseudo-stacks without SPS profiler. r=nchen
xpcom/threads/ThreadStackHelper.cpp
xpcom/threads/ThreadStackHelper.h
--- a/xpcom/threads/ThreadStackHelper.cpp
+++ b/xpcom/threads/ThreadStackHelper.cpp
@@ -45,18 +45,21 @@ ThreadStackHelper::Shutdown()
   if (sInitialized == 1) {
     MOZ_ALWAYS_TRUE(!::sem_destroy(&sSem));
   }
   sInitialized--;
 #endif
 }
 
 ThreadStackHelper::ThreadStackHelper()
-  : mPseudoStack(mozilla_get_pseudo_stack())
-  , mStackBuffer()
+  :
+#ifdef MOZ_ENABLE_PROFILER_SPS
+    mPseudoStack(mozilla_get_pseudo_stack()),
+#endif
+    mStackBuffer()
   , mMaxStackSize(mStackBuffer.capacity())
 {
 #if defined(XP_LINUX)
   mThreadID = ::syscall(SYS_gettid);
 #elif defined(XP_WIN)
   mInitialized = !!::DuplicateHandle(
     ::GetCurrentProcess(), ::GetCurrentThread(),
     ::GetCurrentProcess(), &mThreadID,
@@ -142,34 +145,40 @@ ThreadStackHelper::SigAction(int aSignal
   ::sem_post(&sSem);
 }
 
 #endif // XP_LINUX
 
 bool
 ThreadStackHelper::PrepareStackBuffer(Stack& aStack) {
   aStack.clear();
+#ifdef MOZ_ENABLE_PROFILER_SPS
   if (!mPseudoStack) {
     return false;
   }
   mStackBuffer.clear();
   return mStackBuffer.reserve(mMaxStackSize);
+#else
+  return false;
+#endif
 }
 
 void
 ThreadStackHelper::FillStackBuffer() {
+#ifdef MOZ_ENABLE_PROFILER_SPS
   size_t reservedSize = mMaxStackSize;
 
   // Go from front to back
   const volatile StackEntry* entry = mPseudoStack->mStack;
   const volatile StackEntry* end = entry + mPseudoStack->stackSize();
   for (; reservedSize-- && entry != end; entry++) {
     /* We only accept non-copy labels, because
        we are unable to actually copy labels here */
     if (!entry->isCopyLabel()) {
       mStackBuffer.infallibleAppend(entry->label());
     }
   }
   // If we exited early due to buffer size, expand the buffer for next time
   mMaxStackSize += (end - entry);
+#endif
 }
 
 } // namespace mozilla
--- a/xpcom/threads/ThreadStackHelper.h
+++ b/xpcom/threads/ThreadStackHelper.h
@@ -35,17 +35,19 @@ namespace mozilla {
  * with custom text and markers are not included.
  */
 class ThreadStackHelper
 {
 public:
   typedef Telemetry::HangHistogram::Stack Stack;
 
 private:
+#ifdef MOZ_ENABLE_PROFILER_SPS
   const PseudoStack* const mPseudoStack;
+#endif
   Stack mStackBuffer;
   size_t mMaxStackSize;
 
   bool PrepareStackBuffer(Stack& aStack);
   void FillStackBuffer();
 
 public:
   /**