Bug 1663543 - Convert PROFILER_ADD_MARKER and 2-arg profiler_add_marker to PROFILER_MARKER_UNTYPED - r=gregtatum

Mostly mechanical change, with some extra work where non-literal names are provided.
Also, when this is the only profiler call in a file, `#include "GeckoProfiler.h"` can be changed to `#include "mozilla/ProfilerMarkers.h"`.

Differential Revision: https://phabricator.services.mozilla.com/D89415
This commit is contained in:
Gerald Squelart 2020-09-10 03:02:36 +00:00
parent 6c2997d6a8
commit 5f9ff13253
26 changed files with 70 additions and 102 deletions

View File

@ -777,7 +777,7 @@ nsresult Accessible::HandleAccEvent(AccEvent* aEvent) {
nsAutoCString strMarker;
strMarker.AppendLiteral("A11y Event - ");
strMarker.Append(strEventType);
PROFILER_ADD_MARKER(strMarker.get(), OTHER);
PROFILER_MARKER_UNTYPED(strMarker, OTHER);
}
#endif

View File

@ -85,7 +85,7 @@ void nsDOMNavigationTiming::NotifyNavigationStart(
mNavigationStart = TimeStamp::Now();
mDocShellHasBeenActiveSinceNavigationStart =
(aDocShellState == DocShellState::eActive);
PROFILER_ADD_MARKER("Navigation::Start", DOM);
PROFILER_MARKER_UNTYPED("Navigation::Start", DOM);
}
void nsDOMNavigationTiming::NotifyFetchStart(nsIURI* aURI,
@ -200,7 +200,7 @@ void nsDOMNavigationTiming::NotifyDOMLoading(nsIURI* aURI) {
mLoadedURI = aURI;
mDOMLoading = TimeStamp::Now();
PROFILER_ADD_MARKER("Navigation::DOMLoading", DOM);
PROFILER_MARKER_UNTYPED("Navigation::DOMLoading", DOM);
}
void nsDOMNavigationTiming::NotifyDOMInteractive(nsIURI* aURI) {
@ -210,7 +210,7 @@ void nsDOMNavigationTiming::NotifyDOMInteractive(nsIURI* aURI) {
mLoadedURI = aURI;
mDOMInteractive = TimeStamp::Now();
PROFILER_ADD_MARKER("Navigation::DOMInteractive", DOM);
PROFILER_MARKER_UNTYPED("Navigation::DOMInteractive", DOM);
}
void nsDOMNavigationTiming::NotifyDOMComplete(nsIURI* aURI) {
@ -220,7 +220,7 @@ void nsDOMNavigationTiming::NotifyDOMComplete(nsIURI* aURI) {
mLoadedURI = aURI;
mDOMComplete = TimeStamp::Now();
PROFILER_ADD_MARKER("Navigation::DOMComplete", DOM);
PROFILER_MARKER_UNTYPED("Navigation::DOMComplete", DOM);
}
void nsDOMNavigationTiming::NotifyDOMContentLoadedStart(nsIURI* aURI) {

View File

@ -3211,7 +3211,7 @@ static void PrepareForFullscreenChange(nsIDocShell* aDocShell,
NS_IMETHODIMP
nsDOMWindowUtils::HandleFullscreenRequests(bool* aRetVal) {
PROFILER_ADD_MARKER("Enter fullscreen", DOM);
PROFILER_MARKER_UNTYPED("Enter fullscreen", DOM);
nsCOMPtr<Document> doc = GetDocument();
NS_ENSURE_STATE(doc);
@ -3232,7 +3232,7 @@ nsDOMWindowUtils::HandleFullscreenRequests(bool* aRetVal) {
}
nsresult nsDOMWindowUtils::ExitFullscreen() {
PROFILER_ADD_MARKER("Exit fullscreen", DOM);
PROFILER_MARKER_UNTYPED("Exit fullscreen", DOM);
nsCOMPtr<Document> doc = GetDocument();
NS_ENSURE_STATE(doc);

View File

@ -190,6 +190,7 @@
#include "nsFrameLoaderOwner.h"
#include "nsXPCOMCID.h"
#include "mozilla/Logging.h"
#include "mozilla/ProfilerMarkers.h"
#include "prenv.h"
#include "mozilla/dom/IDBFactory.h"
@ -4416,12 +4417,12 @@ FullscreenTransitionTask::Run() {
return NS_OK;
}
if (stage == eBeforeToggle) {
PROFILER_ADD_MARKER("Fullscreen transition start", DOM);
PROFILER_MARKER_UNTYPED("Fullscreen transition start", DOM);
mWidget->PerformFullscreenTransition(nsIWidget::eBeforeFullscreenToggle,
mDuration.mFadeIn, mTransitionData,
this);
} else if (stage == eToggleFullscreen) {
PROFILER_ADD_MARKER("Fullscreen toggle start", DOM);
PROFILER_MARKER_UNTYPED("Fullscreen toggle start", DOM);
mFullscreenChangeStartTime = TimeStamp::Now();
if (MOZ_UNLIKELY(mWindow->mFullscreen != mFullscreen)) {
// This could happen in theory if several fullscreen requests in
@ -4465,7 +4466,7 @@ FullscreenTransitionTask::Run() {
mDuration.mFadeOut, mTransitionData,
this);
} else if (stage == eEnd) {
PROFILER_ADD_MARKER("Fullscreen transition end", DOM);
PROFILER_MARKER_UNTYPED("Fullscreen transition end", DOM);
mWidget->CleanupFullscreenTransition();
}
return NS_OK;
@ -4486,7 +4487,7 @@ FullscreenTransitionTask::Observer::Observe(nsISupports* aSubject,
// The paint notification arrives first. Cancel the timer.
mTask->mTimer->Cancel();
shouldContinue = true;
PROFILER_ADD_MARKER("Fullscreen toggle end", DOM);
PROFILER_MARKER_UNTYPED("Fullscreen toggle end", DOM);
}
} else {
#ifdef DEBUG
@ -4497,7 +4498,7 @@ FullscreenTransitionTask::Observer::Observe(nsISupports* aSubject,
"Should only trigger this with the timer the task created");
#endif
shouldContinue = true;
PROFILER_ADD_MARKER("Fullscreen toggle timeout", DOM);
PROFILER_MARKER_UNTYPED("Fullscreen toggle timeout", DOM);
}
if (shouldContinue) {
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();

View File

@ -51,7 +51,7 @@ void LoggingHelper(bool aUseProfiler, const char* aFmt, va_list args) {
MOZ_LOG(logModule, logLevel, ("%s", message.get()));
if (aUseProfiler) {
PROFILER_ADD_MARKER(message.get(), DOM);
PROFILER_MARKER_UNTYPED(message, DOM);
}
}
}

View File

@ -392,7 +392,7 @@ class MediaDecoderStateMachine::DormantState
explicit DormantState(Master* aPtr) : StateObject(aPtr) {}
void Enter() {
PROFILER_ADD_MARKER("MDSM::EnterDormantState", MEDIA_PLAYBACK);
PROFILER_MARKER_UNTYPED("MDSM::EnterDormantState", MEDIA_PLAYBACK);
if (mMaster->IsPlaying()) {
mMaster->StopPlayback();
}
@ -1401,7 +1401,7 @@ class MediaDecoderStateMachine::AccurateSeekingState
"] target=%" PRId64,
aVideo->mTime.ToMicroseconds(),
aVideo->GetEndTime().ToMicroseconds(), target.ToMicroseconds());
PROFILER_ADD_MARKER("MDSM::DropVideoUpToSeekTarget", MEDIA_PLAYBACK);
PROFILER_MARKER_UNTYPED("MDSM::DropVideoUpToSeekTarget", MEDIA_PLAYBACK);
mFirstVideoFrameAfterSeek = aVideo;
} else {
if (target >= aVideo->mTime && aVideo->GetEndTime() >= target) {
@ -1880,7 +1880,7 @@ class MediaDecoderStateMachine::BufferingState
explicit BufferingState(Master* aPtr) : StateObject(aPtr) {}
void Enter() {
PROFILER_ADD_MARKER("MDSM::EnterBufferingState", MEDIA_PLAYBACK);
PROFILER_MARKER_UNTYPED("MDSM::EnterBufferingState", MEDIA_PLAYBACK);
if (mMaster->IsPlaying()) {
mMaster->StopPlayback();
}
@ -2629,7 +2629,7 @@ void MediaDecoderStateMachine::BufferingState::HandleEndOfVideo() {
}
RefPtr<ShutdownPromise> MediaDecoderStateMachine::ShutdownState::Enter() {
PROFILER_ADD_MARKER("MDSM::EnterShutdownState", MEDIA_PLAYBACK);
PROFILER_MARKER_UNTYPED("MDSM::EnterShutdownState", MEDIA_PLAYBACK);
auto master = mMaster;
master->mDelayedScheduler.Reset();
@ -3158,7 +3158,7 @@ void MediaDecoderStateMachine::BufferedRangeUpdated() {
RefPtr<MediaDecoder::SeekPromise> MediaDecoderStateMachine::Seek(
const SeekTarget& aTarget) {
AUTO_PROFILER_LABEL("MediaDecoderStateMachine::Seek", MEDIA_PLAYBACK);
PROFILER_ADD_MARKER("MDSM::Seek", MEDIA_PLAYBACK);
PROFILER_MARKER_UNTYPED("MDSM::Seek", MEDIA_PLAYBACK);
MOZ_ASSERT(OnTaskQueue());
// We need to be able to seek in some way

View File

@ -2503,7 +2503,7 @@ void MediaFormatReader::SkipVideoDemuxToNextKeyFrame(TimeUnit aTimeThreshold) {
}
void MediaFormatReader::VideoSkipReset(uint32_t aSkipped) {
PROFILER_ADD_MARKER("SkippedVideoDecode", MEDIA_PLAYBACK);
PROFILER_MARKER_UNTYPED("SkippedVideoDecode", MEDIA_PLAYBACK);
MOZ_ASSERT(OnTaskQueue());
// Some frames may have been output by the decoder since we initiated the

View File

@ -48,7 +48,7 @@ void ProfilerScreenshots::SubmitScreenshot(
bool succeeded = aPopulateSurface(backingSurface);
if (!succeeded) {
PROFILER_ADD_MARKER(
PROFILER_MARKER_UNTYPED(
"NoCompositorScreenshot because aPopulateSurface callback failed",
GRAPHICS);
ReturnSurface(backingSurface);

View File

@ -93,8 +93,8 @@ void ScreenshotGrabber::MaybeProcessQueue() {
void ScreenshotGrabber::NotifyEmptyFrame() {
#ifdef MOZ_GECKO_PROFILER
PROFILER_ADD_MARKER("NoCompositorScreenshot because nothing changed",
GRAPHICS);
PROFILER_MARKER_UNTYPED("NoCompositorScreenshot because nothing changed",
GRAPHICS);
#endif
}
@ -147,7 +147,7 @@ void ScreenshotGrabberImpl::GrabScreenshot(Window& aWindow) {
RefPtr<RenderSource> windowRenderSource = aWindow.GetWindowContents();
if (!windowRenderSource) {
PROFILER_ADD_MARKER(
PROFILER_MARKER_UNTYPED(
"NoCompositorScreenshot because of unsupported compositor "
"configuration",
GRAPHICS);
@ -162,7 +162,7 @@ void ScreenshotGrabberImpl::GrabScreenshot(Window& aWindow) {
aWindow, scaledSize, windowRenderSource, 0);
if (!scaledTarget) {
PROFILER_ADD_MARKER(
PROFILER_MARKER_UNTYPED(
"NoCompositorScreenshot because ScaleDownWindowRenderSourceToSize "
"failed",
GRAPHICS);
@ -171,7 +171,7 @@ void ScreenshotGrabberImpl::GrabScreenshot(Window& aWindow) {
RefPtr<AsyncReadbackBuffer> buffer = TakeNextBuffer(aWindow);
if (!buffer) {
PROFILER_ADD_MARKER(
PROFILER_MARKER_UNTYPED(
"NoCompositorScreenshot because AsyncReadbackBuffer creation failed",
GRAPHICS);
return;

View File

@ -10,10 +10,10 @@
# include "mozilla/gfx/2D.h"
# include "mozilla/layers/Compositor.h"
# include "mozilla/layers/Effects.h"
# include "mozilla/ProfilerMarkers.h"
# include "mozilla/StaticPrefs_layers.h"
# include "mozilla/TimeStamp.h"
# include <math.h>
# include "GeckoProfiler.h"
# define TEST_STEPS 1000
# define DURATION_THRESHOLD 30
@ -294,7 +294,9 @@ static void RunCompositorBench(Compositor* aCompositor,
BenchTest* test = tests[i];
std::vector<TimeDuration> results;
int testsOverThreshold = 0;
PROFILER_ADD_MARKER(test->ToString(), GRAPHICS);
PROFILER_MARKER_UNTYPED(
ProfilerString8View::WrapNullTerminatedString(test->ToString()),
GRAPHICS);
for (size_t j = 0; j < TEST_STEPS; j++) {
test->Setup(aCompositor, j);

View File

@ -13,7 +13,7 @@
#include "mozilla/layers/ProfilerScreenshots.h"
#include "mozilla/gfx/Point.h"
#include "mozilla/gfx/Swizzle.h"
#include "GeckoProfiler.h"
#include "mozilla/ProfilerMarkers.h"
#include "SharedBufferMLGPU.h"
#include "ShaderDefinitionsMLGPU.h"
#include "nsTArray.h"
@ -104,8 +104,8 @@ void MLGPUScreenshotGrabber::MaybeProcessQueue() {
void MLGPUScreenshotGrabber::NotifyEmptyFrame() {
#ifdef MOZ_GECKO_PROFILER
PROFILER_ADD_MARKER("NoCompositorScreenshot because nothing changed",
GRAPHICS);
PROFILER_MARKER_UNTYPED("NoCompositorScreenshot because nothing changed",
GRAPHICS);
#endif
}
@ -251,7 +251,7 @@ void MLGPUScreenshotGrabberImpl::GrabScreenshot(MLGDevice* aDevice,
ScaleDownWindowTargetToSize(aDevice, scaledSize, windowTexture, 0);
if (!scaledTarget) {
PROFILER_ADD_MARKER(
PROFILER_MARKER_UNTYPED(
"NoCompositorScreenshot because ScaleDownWindowTargetToSize failed",
GRAPHICS);
return;
@ -259,7 +259,7 @@ void MLGPUScreenshotGrabberImpl::GrabScreenshot(MLGDevice* aDevice,
RefPtr<MLGTexture> readbackTexture = TakeNextReadbackTexture(aDevice);
if (!readbackTexture) {
PROFILER_ADD_MARKER(
PROFILER_MARKER_UNTYPED(
"NoCompositorScreenshot because AsyncReadbackReadbackTexture creation "
"failed",
GRAPHICS);

View File

@ -1931,7 +1931,7 @@ void nsRefreshDriver::Tick(VsyncId aId, TimeStamp aNowTime) {
// We're currently suspended waiting for earlier Tick's to
// be completed (on the Compositor). Mark that we missed the paint
// and keep waiting.
PROFILER_ADD_MARKER("nsRefreshDriver::Tick waiting for paint", LAYOUT);
PROFILER_MARKER_UNTYPED("nsRefreshDriver::Tick waiting for paint", LAYOUT);
return;
}

View File

@ -3648,16 +3648,11 @@ void profiler_add_marker(const char* aMarkerName,
racy_profiler_add_marker(aMarkerName, aCategoryPair, &aPayload);
}
void profiler_add_marker(const char* aMarkerName,
ProfilingCategoryPair aCategoryPair) {
racy_profiler_add_marker(aMarkerName, aCategoryPair, nullptr);
}
// This is a simplified version of profiler_add_marker that can be easily passed
// into the JS engine.
void profiler_add_js_marker(const char* aMarkerName) {
AUTO_PROFILER_STATS(base_add_marker);
profiler_add_marker(aMarkerName, ProfilingCategoryPair::JS);
BASE_PROFILER_MARKER_UNTYPED(
ProfilerString8View::WrapNullTerminatedString(aMarkerName), JS);
}
static void maybelocked_profiler_add_marker_for_thread(

View File

@ -53,7 +53,6 @@
# define AUTO_BASE_PROFILER_LABEL_DYNAMIC_FAST(label, dynamicString, \
categoryPair, ctx, flags)
# define BASE_PROFILER_ADD_MARKER(markerName, categoryPair)
# define BASE_PROFILER_ADD_MARKER_WITH_PAYLOAD( \
markerName, categoryPair, PayloadType, parenthesizedPayloadArgs)
@ -808,24 +807,6 @@ namespace baseprofiler {
ctx, label, dynamicString, \
::mozilla::baseprofiler::ProfilingCategoryPair::categoryPair, flags)
// Insert a marker in the profile timeline. This is useful to delimit something
// important happening such as the first paint. Unlike labels, which are only
// recorded in the profile buffer if a sample is collected while the label is
// on the label stack, markers will always be recorded in the profile buffer.
// aMarkerName is copied, so the caller does not need to ensure it lives for a
// certain length of time. A no-op if the profiler is inactive.
# define BASE_PROFILER_ADD_MARKER(markerName, categoryPair) \
do { \
AUTO_PROFILER_STATS(base_add_marker); \
::mozilla::baseprofiler::profiler_add_marker( \
markerName, \
::mozilla::baseprofiler::ProfilingCategoryPair::categoryPair); \
} while (false)
MFBT_API void profiler_add_marker(const char* aMarkerName,
ProfilingCategoryPair aCategoryPair);
// `PayloadType` is a sub-class of BaseMarkerPayload, `parenthesizedPayloadArgs`
// is the argument list used to construct that `PayloadType`. E.g.:
// `BASE_PROFILER_ADD_MARKER_WITH_PAYLOAD("Load", DOM, TextMarkerPayload,

View File

@ -4,6 +4,11 @@
* 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/. */
// Markers are useful to delimit something important happening such as the first
// paint. Unlike labels, which are only recorded in the profile buffer if a
// sample is collected while the label is on the label stack, markers will
// always be recorded in the profile buffer.
//
// This header contains basic definitions necessary to create marker types, and
// to add markers to the profiler buffers.
//
@ -85,14 +90,14 @@ inline void WritePropertyTime(JSONWriter& aWriter, const char* aName,
# define BASE_PROFILER_MARKER_UNTYPED(markerName, options) \
do { \
AUTO_PROFILER_STATS(base_add_marker_v2); \
AUTO_PROFILER_STATS(BASE_PROFILER_MARKER_UNTYPED); \
::mozilla::baseprofiler::AddMarker<>( \
markerName, ::mozilla::baseprofiler::category::options); \
} while (false)
# define BASE_PROFILER_MARKER(markerName, options, MarkerType, ...) \
do { \
AUTO_PROFILER_STATS(base_add_marker_v2_with_##MarkerType); \
AUTO_PROFILER_STATS(BASE_PROFILER_MARKER_with_##MarkerType); \
::mozilla::baseprofiler::AddMarker< \
::mozilla::baseprofiler::markers::MarkerType>( \
markerName, ::mozilla::baseprofiler::category::options, \

View File

@ -3336,7 +3336,7 @@ MOZ_NEVER_INLINE unsigned long long Fibonacci(unsigned long long n) {
static constexpr size_t MAX_MARKER_DEPTH = 10;
unsigned long long f2 = Fibonacci<NextDepth(DEPTH)>(n - 2);
if (DEPTH == 0) {
BASE_PROFILER_ADD_MARKER("Half-way through Fibonacci", OTHER);
BASE_PROFILER_MARKER_UNTYPED("Half-way through Fibonacci", OTHER);
}
unsigned long long f1 = Fibonacci<NextDepth(DEPTH)>(n - 1);
if (DEPTH < MAX_MARKER_DEPTH) {

View File

@ -36,6 +36,7 @@
#include "nsJSEnvironment.h"
#include "mozilla/dom/Document.h"
#include "mozilla/dom/DebuggerUtilsBinding.h"
#include "mozilla/ProfilerMarkers.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -120,7 +121,7 @@ class nsHtml5ExecutorFlusher : public Runnable {
nsCOMPtr<nsIRunnable> flusher = this;
if (NS_SUCCEEDED(
doc->Dispatch(TaskCategory::Network, flusher.forget()))) {
PROFILER_ADD_MARKER("HighPrio blocking parser flushing(1)", DOM);
PROFILER_MARKER_UNTYPED("HighPrio blocking parser flushing(1)", DOM);
return NS_OK;
}
}

View File

@ -63,7 +63,7 @@ class nsHtml5ExecutorReflusher : public Runnable {
nsCOMPtr<nsIRunnable> flusher = this;
if (NS_SUCCEEDED(
doc->Dispatch(TaskCategory::Network, flusher.forget()))) {
PROFILER_ADD_MARKER("HighPrio blocking parser flushing(2)", DOM);
PROFILER_MARKER_UNTYPED("HighPrio blocking parser flushing(2)", DOM);
return NS_OK;
}
}

View File

@ -38,7 +38,7 @@
# include "nscore.h"
# ifdef MOZILLA_INTERNAL_API
# include "GeckoProfiler.h"
# include "mozilla/ProfilerMarkers.h"
# endif
namespace mozilla {
@ -61,7 +61,8 @@ class StartupTimeline {
# ifdef MOZILLA_INTERNAL_API
static void Record(Event ev) {
PROFILER_ADD_MARKER(Describe(ev), OTHER);
PROFILER_MARKER_UNTYPED(
ProfilerString8View::WrapNullTerminatedString(Describe(ev)), OTHER);
Record(ev, TimeStamp::Now());
}

View File

@ -24,9 +24,9 @@
#include "nsString.h"
#include "mozilla/AppShutdown.h"
#include "mozilla/Preferences.h"
#include "mozilla/ProfilerMarkers.h"
#include "mozilla/ResultExtensions.h"
#include "mozilla/Unused.h"
#include "GeckoProfiler.h"
#include "prprf.h"
#include "nsIInterfaceRequestorUtils.h"
@ -363,7 +363,7 @@ nsAppStartup::Quit(uint32_t aMode, bool* aUserAllowedQuit) {
}
}
PROFILER_ADD_MARKER("Shutdown start", OTHER);
PROFILER_MARKER_UNTYPED("Shutdown start", OTHER);
mozilla::RecordShutdownStartTimeStamp();
*aUserAllowedQuit = true;

View File

@ -1284,7 +1284,7 @@ ScopedXPCOMStartup::~ScopedXPCOMStartup() {
if (appStartup) appStartup->DestroyHiddenWindow();
gDirServiceProvider->DoShutdown();
PROFILER_ADD_MARKER("Shutdown early", OTHER);
PROFILER_MARKER_UNTYPED("Shutdown early", OTHER);
WriteConsoleLog();

View File

@ -5428,16 +5428,11 @@ void profiler_add_marker(const char* aMarkerName,
racy_profiler_add_marker(aMarkerName, aCategoryPair, &aPayload);
}
void profiler_add_marker(const char* aMarkerName,
JS::ProfilingCategoryPair aCategoryPair) {
racy_profiler_add_marker(aMarkerName, aCategoryPair, nullptr);
}
// This is a simplified version of profiler_add_marker that can be easily passed
// into the JS engine.
void profiler_add_js_marker(const char* aMarkerName) {
AUTO_PROFILER_STATS(add_marker);
profiler_add_marker(aMarkerName, JS::ProfilingCategoryPair::JS);
PROFILER_MARKER_UNTYPED(
ProfilerString8View::WrapNullTerminatedString(aMarkerName), JS);
}
void profiler_add_js_allocation_marker(JS::RecordAllocationInfo&& info) {

View File

@ -62,7 +62,6 @@
# define AUTO_PROFILER_LABEL_DYNAMIC_FAST(label, dynamicString, categoryPair, \
ctx, flags)
# define PROFILER_ADD_MARKER(markerName, categoryPair)
# define PROFILER_ADD_MARKER_WITH_PAYLOAD(markerName, categoryPair, \
PayloadType, payloadArgs)
# define PROFILER_ADD_TEXT_MARKER(markerName, text, categoryPair, startTime, \
@ -889,23 +888,6 @@ mozilla::Maybe<ProfilerBufferInfo> profiler_get_buffer_info();
ctx, label, dynamicString, JS::ProfilingCategoryPair::categoryPair, \
flags)
// Insert a marker in the profile timeline. This is useful to delimit something
// important happening such as the first paint. Unlike labels, which are only
// recorded in the profile buffer if a sample is collected while the label is
// on the label stack, markers will always be recorded in the profile buffer.
// aMarkerName is copied, so the caller does not need to ensure it lives for a
// certain length of time. A no-op if the profiler is inactive.
# define PROFILER_ADD_MARKER(markerName, categoryPair) \
do { \
AUTO_PROFILER_STATS(add_marker); \
::profiler_add_marker(markerName, \
::JS::ProfilingCategoryPair::categoryPair); \
} while (false)
void profiler_add_marker(const char* aMarkerName,
JS::ProfilingCategoryPair aCategoryPair);
// `PayloadType` is a sub-class of MarkerPayload, `parenthesizedPayloadArgs` is
// the argument list used to construct that `PayloadType`. E.g.:
// `PROFILER_ADD_MARKER_WITH_PAYLOAD("Load", DOM, TextMarkerPayload,

View File

@ -4,6 +4,11 @@
* 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/. */
// Markers are useful to delimit something important happening such as the first
// paint. Unlike labels, which are only recorded in the profile buffer if a
// sample is collected while the label is on the label stack, markers will
// always be recorded in the profile buffer.
//
// This header contains definitions necessary to add markers to the Gecko
// Profiler buffer.
//
@ -73,13 +78,13 @@ mozilla::ProfileBufferBlockIndex profiler_add_marker(
# define PROFILER_MARKER_UNTYPED(markerName, options) \
do { \
AUTO_PROFILER_STATS(add_marker_v2); \
AUTO_PROFILER_STATS(PROFILER_MARKER_UNTYPED); \
::profiler_add_marker<>(markerName, ::geckoprofiler::category::options); \
} while (false)
# define PROFILER_MARKER(markerName, options, MarkerType, ...) \
do { \
AUTO_PROFILER_STATS(add_marker_v2_with_##MarkerType); \
AUTO_PROFILER_STATS(PROFILER_MARKER_with_##MarkerType); \
::profiler_add_marker<::geckoprofiler::markers::MarkerType>( \
markerName, ::geckoprofiler::category::options, ##__VA_ARGS__); \
} while (false)

View File

@ -523,7 +523,7 @@ TEST(GeckoProfiler, Pause)
// Check that we are writing markers while not paused.
info1 = profiler_get_buffer_info();
PROFILER_ADD_MARKER("Not paused", OTHER);
PROFILER_MARKER_UNTYPED("Not paused", OTHER);
info2 = profiler_get_buffer_info();
ASSERT_TRUE(info1->mRangeEnd != info2->mRangeEnd);
@ -540,7 +540,7 @@ TEST(GeckoProfiler, Pause)
// Check that we are now writing markers while paused.
info1 = profiler_get_buffer_info();
PROFILER_ADD_MARKER("Paused", OTHER);
PROFILER_MARKER_UNTYPED("Paused", OTHER);
info2 = profiler_get_buffer_info();
ASSERT_TRUE(info1->mRangeEnd == info2->mRangeEnd);
PROFILER_MARKER_UNTYPED("Paused v2", OTHER);
@ -649,10 +649,10 @@ TEST(GeckoProfiler, Markers)
{ AUTO_PROFILER_TRACING_MARKER("C", "auto tracing", OTHER); }
PROFILER_ADD_MARKER("M1", OTHER);
PROFILER_MARKER_UNTYPED("M1", OTHER);
PROFILER_ADD_MARKER_WITH_PAYLOAD("M2", OTHER, TracingMarkerPayload,
("C", TRACING_EVENT, ts0));
PROFILER_ADD_MARKER("M3", OTHER);
PROFILER_MARKER_UNTYPED("M3", OTHER);
PROFILER_ADD_MARKER_WITH_PAYLOAD(
"M4", OTHER, TracingMarkerPayload,
("C", TRACING_EVENT, ts0, mozilla::Nothing(), profiler_get_backtrace()));
@ -2047,7 +2047,7 @@ TEST(GeckoProfiler, BaseProfilerHandOff)
// Add at least a marker, which should go straight into the buffer.
Maybe<baseprofiler::ProfilerBufferInfo> info0 =
baseprofiler::profiler_get_buffer_info();
BASE_PROFILER_ADD_MARKER("Marker from base profiler", OTHER);
BASE_PROFILER_MARKER_UNTYPED("Marker from base profiler", OTHER);
Maybe<baseprofiler::ProfilerBufferInfo> info1 =
baseprofiler::profiler_get_buffer_info();
ASSERT_GT(info1->mRangeEnd, info0->mRangeEnd);

View File

@ -728,7 +728,7 @@ nsresult ShutdownXPCOM(nsIServiceManager* aServMgr) {
mozilla::scache::StartupCache::DeleteSingleton();
PROFILER_ADD_MARKER("Shutdown xpcom", OTHER);
PROFILER_MARKER_UNTYPED("Shutdown xpcom", OTHER);
// Shutdown xpcom. This will release all loaders and cause others holding
// a refcount to the component manager to release it.