Permalink
Browse files

Bug 724079. Add back the mac backend. r=ehsan

This should improve latency and perhaps fix the crashes
we're seeing in bug 721025.
  • Loading branch information...
1 parent cfba660 commit 32cebed6148111a985d2abf2832f84c6ae7e556e @jrmuizel jrmuizel committed Feb 3, 2012
Showing with 325 additions and 11 deletions.
  1. +1 −5 tools/profiler/Makefile.in
  2. +15 −6 tools/profiler/TableTicker.cpp
  3. +309 −0 tools/profiler/platform-macos.cc
@@ -85,16 +85,12 @@ CPPSRCS += \
$(NULL)
endif
ifeq ($(OS_TARGET),Darwin)
-# For now we use platform-linux.cc because we can't unwind
-# another thread on mac using backtrace(), the implementation
-# for platform-macosx.cc is in the hg history and should be
-# used when we can stackwalk using a thread handle.
DEFINES += -DMOZ_ENABLE_PROFILER_SPS
CPPSRCS += \
shared-libraries-macos.cc \
- platform-linux.cc \
+ platform-macos.cc \
TableTicker.cpp \
$(NULL)
endif
@@ -45,9 +45,10 @@
#include "prenv.h"
#include "shared-libraries.h"
#include "mozilla/StringBuilder.h"
+#include "mozilla/StackWalk.h"
// we eventually want to make this runtime switchable
-#if defined(MOZ_PROFILING) && (defined(XP_MACOSX) || defined(XP_UNIX))
+#if defined(MOZ_PROFILING) && (defined(XP_UNIX) && !defined(XP_MACOSX))
#ifndef ANDROID
#define USE_BACKTRACE
#endif
@@ -56,7 +57,7 @@
#include <execinfo.h>
#endif
-#if defined(MOZ_PROFILING) && defined(XP_WIN)
+#if defined(MOZ_PROFILING) && (defined(XP_MACOSX) || defined(XP_WIN))
#define USE_NS_STACKWALK
#endif
#ifdef USE_NS_STACKWALK
@@ -353,7 +354,7 @@ class TableTicker: public Sampler {
private:
// Not implemented on platforms which do not support backtracing
- void doBacktrace(Profile &aProfile);
+ void doBacktrace(Profile &aProfile, Address pc);
private:
Profile mProfile;
@@ -419,8 +420,9 @@ void TableTicker::HandleSaveRequest()
NS_DispatchToMainThread(runnable);
}
+
#ifdef USE_BACKTRACE
-void TableTicker::doBacktrace(Profile &aProfile)
+void TableTicker::doBacktrace(Profile &aProfile, Address pc)
{
void *array[100];
int count = backtrace (array, 100);
@@ -434,6 +436,7 @@ void TableTicker::doBacktrace(Profile &aProfile)
}
#endif
+
#ifdef USE_NS_STACKWALK
typedef struct {
void** array;
@@ -452,17 +455,23 @@ void StackWalkCallback(void* aPC, void* aClosure)
array->array[array->count++] = aPC;
}
-void TableTicker::doBacktrace(Profile &aProfile)
+void TableTicker::doBacktrace(Profile &aProfile, Address fp)
{
+#ifndef XP_MACOSX
uintptr_t thread = GetThreadHandle(platform_data());
MOZ_ASSERT(thread);
+#endif
void* pc_array[1000];
PCArray array = {
pc_array,
mozilla::ArrayLength(pc_array),
0
};
+#ifdef XP_MACOSX
+ nsresult rv = FramePointerStackWalk(StackWalkCallback, 1, &array, reinterpret_cast<void**>(fp));
+#else
nsresult rv = NS_StackWalk(StackWalkCallback, 0, &array, thread);
+#endif
if (NS_SUCCEEDED(rv)) {
aProfile.addTag(ProfileEntry('s', "(root)", 0));
@@ -539,7 +548,7 @@ void TableTicker::Tick(TickSample* sample)
#if defined(USE_BACKTRACE) || defined(USE_NS_STACKWALK)
if (mUseStackWalk) {
- doBacktrace(mProfile);
+ doBacktrace(mProfile, sample->fp);
} else {
doSampleStackTrace(mStack, mProfile, sample);
}
Oops, something went wrong.

0 comments on commit 32cebed

Please sign in to comment.