Bug 1403868 - Only include GeckoProfiler.h in xpcom/threads ifdef MOZ_GECKO_PROFILER. r?mstange
The header should be included and used only if MOZ_GECKO_PROFILER is defined.
The gecko-media crate has to define MOZ_INTERNAL_API in order to make strings
work, and we'd like to avoid the Gecko profiler, so we'd like to switch the
profiler to being included based on its existing define rather than re-using
MOZ_INTERAL_API.
MozReview-Commit-ID: GbUQHdc8Yq3
--- a/toolkit/components/startup/StartupTimeline.h
+++ b/toolkit/components/startup/StartupTimeline.h
@@ -26,17 +26,17 @@ mozilla_StartupTimeline_Event(PROFILE_BE
#else
#ifndef mozilla_StartupTimeline
#define mozilla_StartupTimeline
#include "mozilla/TimeStamp.h"
#include "nscore.h"
-#ifdef MOZILLA_INTERNAL_API
+#ifdef MOZ_GECKO_PROFILER
#include "GeckoProfiler.h"
#endif
namespace mozilla {
void RecordShutdownEndTimeStamp();
void RecordShutdownStartTimeStamp();
@@ -52,17 +52,17 @@ public:
static TimeStamp Get(Event ev) {
return sStartupTimeline[ev];
}
static const char *Describe(Event ev) {
return sStartupTimelineDesc[ev];
}
-#ifdef MOZILLA_INTERNAL_API
+#ifdef MOZ_GECKO_PROFILER
static void Record(Event ev) {
profiler_add_marker(Describe(ev));
Record(ev, TimeStamp::Now());
}
static void Record(Event ev, TimeStamp when) {
sStartupTimeline[ev] = when;
}
--- a/xpcom/threads/CondVar.h
+++ b/xpcom/threads/CondVar.h
@@ -6,19 +6,19 @@
#ifndef mozilla_CondVar_h
#define mozilla_CondVar_h
#include "mozilla/BlockingResourceBase.h"
#include "mozilla/PlatformConditionVariable.h"
#include "mozilla/Mutex.h"
-#ifdef MOZILLA_INTERNAL_API
+#ifdef MOZ_GECKO_PROFILER
#include "GeckoProfiler.h"
-#endif //MOZILLA_INTERNAL_API
+#endif //MOZ_GECKO_PROFILER
namespace mozilla {
/**
* CondVar
* Vanilla condition variable. Please don't use this unless you have a
* compelling reason --- Monitor provides a simpler API.
@@ -56,19 +56,19 @@ public:
#ifndef DEBUG
/**
* Wait
* @see prcvar.h
**/
nsresult Wait(PRIntervalTime aInterval = PR_INTERVAL_NO_TIMEOUT)
{
-#ifdef MOZILLA_INTERNAL_API
+#ifdef MOZ_GECKO_PROFILER
AutoProfilerThreadSleep sleep;
-#endif //MOZILLA_INTERNAL_API
+#endif //MOZ_GECKO_PROFILER
if (aInterval == PR_INTERVAL_NO_TIMEOUT) {
mImpl.wait(*mLock);
} else {
mImpl.wait_for(*mLock, TimeDuration::FromMilliseconds(double(aInterval)));
}
return NS_OK;
}
#else
--- a/xpcom/threads/ReentrantMonitor.h
+++ b/xpcom/threads/ReentrantMonitor.h
@@ -4,19 +4,19 @@
* 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 mozilla_ReentrantMonitor_h
#define mozilla_ReentrantMonitor_h
#include "prmon.h"
-#ifdef MOZILLA_INTERNAL_API
+#ifdef MOZ_GECKO_PROFILER
#include "GeckoProfiler.h"
-#endif //MOZILLA_INTERNAL_API
+#endif //MOZ_GECKO_PROFILER
#include "mozilla/BlockingResourceBase.h"
//
// Provides:
//
// - ReentrantMonitor, a Java-like monitor
// - ReentrantMonitorAutoEnter, an RAII class for ensuring that
@@ -80,19 +80,19 @@ public:
void Exit() { PR_ExitMonitor(mReentrantMonitor); }
/**
* Wait
* @see prmon.h
**/
nsresult Wait(PRIntervalTime aInterval = PR_INTERVAL_NO_TIMEOUT)
{
-#ifdef MOZILLA_INTERNAL_API
+#ifdef MOZ_GECKO_PROFILER
AutoProfilerThreadSleep sleep;
-#endif //MOZILLA_INTERNAL_API
+#endif //MOZ_GECKO_PROFILER
return PR_Wait(mReentrantMonitor, aInterval) == PR_SUCCESS ?
NS_OK : NS_ERROR_FAILURE;
}
#else // ifndef DEBUG
void Enter();
void Exit();
nsresult Wait(PRIntervalTime aInterval = PR_INTERVAL_NO_TIMEOUT);
--- a/xpcom/threads/nsTimerImpl.cpp
+++ b/xpcom/threads/nsTimerImpl.cpp
@@ -5,27 +5,30 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsTimerImpl.h"
#include "TimerThread.h"
#include "nsAutoPtr.h"
#include "nsThreadManager.h"
#include "nsThreadUtils.h"
#include "pratom.h"
-#include "GeckoProfiler.h"
#include "mozilla/Atomics.h"
#include "mozilla/IntegerPrintfMacros.h"
#include "mozilla/Logging.h"
#include "mozilla/Move.h"
#include "mozilla/Mutex.h"
#ifdef MOZ_TASK_TRACER
#include "GeckoTaskTracerImpl.h"
using namespace mozilla::tasktracer;
#endif
+#ifdef MOZ_GECKO_PROFILER
+#include "GeckoProfiler.h"
+#endif
+
#ifdef XP_WIN
#include <process.h>
#ifndef getpid
#define getpid _getpid
#endif
#else
#include <unistd.h>
#endif
@@ -478,17 +481,19 @@ nsTimerImpl::Fire(int32_t aGeneration)
oldDelay = mDelay.ToMilliseconds();
oldTimeout = mTimeout;
// Ensure that the nsITimer does not unhook from the nsTimerImpl during
// Fire; this will cause null pointer crashes if the user of the timer drops
// its reference, and then uses the nsITimer* passed in the callback.
kungFuDeathGrip = mITimer;
}
+#ifdef MOZ_GECKO_PROFILER
AUTO_PROFILER_LABEL("nsTimerImpl::Fire", OTHER);
+#endif
TimeStamp now = TimeStamp::Now();
if (MOZ_LOG_TEST(GetTimerLog(), LogLevel::Debug)) {
TimeDuration delta = now - oldTimeout;
int32_t d = delta.ToMilliseconds(); // delta in ms
sDeltaSum += abs(d);
sDeltaSumSquared += double(d) * double(d);
sDeltaNum++;