diff --git a/dom/base/nsDOMNavigationTiming.cpp b/dom/base/nsDOMNavigationTiming.cpp index 30c21921fa62..678c91fd22f0 100644 --- a/dom/base/nsDOMNavigationTiming.cpp +++ b/dom/base/nsDOMNavigationTiming.cpp @@ -80,7 +80,7 @@ nsDOMNavigationTiming::NotifyNavigationStart(DocShellState aDocShellState) mNavigationStartHighRes = (double)PR_Now() / PR_USEC_PER_MSEC; mNavigationStartTimeStamp = TimeStamp::Now(); mDocShellHasBeenActiveSinceNavigationStart = (aDocShellState == DocShellState::eActive); - PROFILER_MARKER("Navigation::Start"); + profiler_add_marker("Navigation::Start"); } void @@ -169,7 +169,7 @@ nsDOMNavigationTiming::NotifyDOMLoading(nsIURI* aURI) mDOMLoading = DurationFromStart(); mDOMLoadingSet = true; - PROFILER_MARKER("Navigation::DOMLoading"); + profiler_add_marker("Navigation::DOMLoading"); if (IsTopLevelContentDocument()) { Telemetry::AccumulateTimeDelta(Telemetry::TIME_TO_DOM_LOADING_MS, @@ -186,7 +186,7 @@ nsDOMNavigationTiming::NotifyDOMInteractive(nsIURI* aURI) mDOMInteractive = DurationFromStart(); mDOMInteractiveSet = true; - PROFILER_MARKER("Navigation::DOMInteractive"); + profiler_add_marker("Navigation::DOMInteractive"); if (IsTopLevelContentDocument()) { Telemetry::AccumulateTimeDelta(Telemetry::TIME_TO_DOM_INTERACTIVE_MS, @@ -203,7 +203,7 @@ nsDOMNavigationTiming::NotifyDOMComplete(nsIURI* aURI) mDOMComplete = DurationFromStart(); mDOMCompleteSet = true; - PROFILER_MARKER("Navigation::DOMComplete"); + profiler_add_marker("Navigation::DOMComplete"); if (IsTopLevelContentDocument()) { Telemetry::AccumulateTimeDelta(Telemetry::TIME_TO_DOM_COMPLETE_MS, @@ -267,7 +267,7 @@ nsDOMNavigationTiming::NotifyNonBlankPaintForRootContentDocument() nsPrintfCString marker("Non-blank paint after %dms for URL %s, %s", int(elapsed.ToMilliseconds()), spec.get(), mDocShellHasBeenActiveSinceNavigationStart ? "foreground tab" : "this tab was inactive some of the time between navigation start and first non-blank paint"); - PROFILER_MARKER(marker.get()); + profiler_add_marker(marker.get()); } if (mDocShellHasBeenActiveSinceNavigationStart) { diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 7f21ba9830a0..12cbf4139a2a 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -3394,7 +3394,7 @@ PrepareForFullscreenChange(nsIPresShell* aPresShell, const nsSize& aSize, NS_IMETHODIMP nsDOMWindowUtils::HandleFullscreenRequests(bool* aRetVal) { - PROFILER_MARKER("Enter fullscreen"); + profiler_add_marker("Enter fullscreen"); nsCOMPtr doc = GetDocument(); NS_ENSURE_STATE(doc); @@ -3417,7 +3417,7 @@ nsDOMWindowUtils::HandleFullscreenRequests(bool* aRetVal) nsresult nsDOMWindowUtils::ExitFullscreen() { - PROFILER_MARKER("Exit fullscreen"); + profiler_add_marker("Exit fullscreen"); nsCOMPtr doc = GetDocument(); NS_ENSURE_STATE(doc); diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 2f9d77e9597b..f663dc8b2915 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -6972,12 +6972,12 @@ FullscreenTransitionTask::Run() return NS_OK; } if (stage == eBeforeToggle) { - PROFILER_MARKER("Fullscreen transition start"); + profiler_add_marker("Fullscreen transition start"); mWidget->PerformFullscreenTransition(nsIWidget::eBeforeFullscreenToggle, mDuration.mFadeIn, mTransitionData, this); } else if (stage == eToggleFullscreen) { - PROFILER_MARKER("Fullscreen toggle start"); + profiler_add_marker("Fullscreen toggle start"); mFullscreenChangeStartTime = TimeStamp::Now(); if (MOZ_UNLIKELY(mWindow->mFullScreen != mFullscreen)) { // This could happen in theory if several fullscreen requests in @@ -7021,7 +7021,7 @@ FullscreenTransitionTask::Run() mDuration.mFadeOut, mTransitionData, this); } else if (stage == eEnd) { - PROFILER_MARKER("Fullscreen transition end"); + profiler_add_marker("Fullscreen transition end"); } return NS_OK; } @@ -7042,7 +7042,7 @@ FullscreenTransitionTask::Observer::Observe(nsISupports* aSubject, // The paint notification arrives first. Cancel the timer. mTask->mTimer->Cancel(); shouldContinue = true; - PROFILER_MARKER("Fullscreen toggle end"); + profiler_add_marker("Fullscreen toggle end"); } } else { #ifdef DEBUG @@ -7053,7 +7053,7 @@ FullscreenTransitionTask::Observer::Observe(nsISupports* aSubject, "Should only trigger this with the timer the task created"); #endif shouldContinue = true; - PROFILER_MARKER("Fullscreen toggle timeout"); + profiler_add_marker("Fullscreen toggle timeout"); } if (shouldContinue) { nsCOMPtr obs = mozilla::services::GetObserverService(); diff --git a/dom/events/EventListenerManager.cpp b/dom/events/EventListenerManager.cpp index cf22a4a89a42..afc222848338 100644 --- a/dom/events/EventListenerManager.cpp +++ b/dom/events/EventListenerManager.cpp @@ -1305,7 +1305,7 @@ EventListenerManager::HandleEventInternal(nsPresContext* aPresContext, TimeStamp endTime = TimeStamp::Now(); uint16_t phase; (*aDOMEvent)->GetEventPhase(&phase); - PROFILER_MARKER_PAYLOAD( + profiler_add_marker( "DOMEvent", MakeUnique(typeStr, phase, startTime, endTime)); diff --git a/dom/indexedDB/ProfilerHelpers.h b/dom/indexedDB/ProfilerHelpers.h index aec65c4e75b1..3ce8b348e134 100644 --- a/dom/indexedDB/ProfilerHelpers.h +++ b/dom/indexedDB/ProfilerHelpers.h @@ -305,7 +305,7 @@ LoggingHelper(bool aUseProfiler, const char* aFmt, ...) MOZ_LOG(logModule, logLevel, ("%s", message.get())); if (aUseProfiler) { - PROFILER_MARKER(message.get()); + profiler_add_marker(message.get()); } } } diff --git a/dom/performance/Performance.cpp b/dom/performance/Performance.cpp index 95bfe933af9a..dfeee6c3d02d 100644 --- a/dom/performance/Performance.cpp +++ b/dom/performance/Performance.cpp @@ -299,7 +299,7 @@ Performance::Mark(const nsAString& aName, ErrorResult& aRv) #ifdef MOZ_GECKO_PROFILER if (profiler_is_active()) { - PROFILER_MARKER_PAYLOAD( + profiler_add_marker( "UserTiming", MakeUnique(aName, TimeStamp::Now())); } @@ -397,7 +397,7 @@ Performance::Measure(const nsAString& aName, TimeDuration::FromMilliseconds(startTime); TimeStamp endTimeStamp = CreationTimeStamp() + TimeDuration::FromMilliseconds(endTime); - PROFILER_MARKER_PAYLOAD( + profiler_add_marker( "UserTiming", MakeUnique(aName, startTimeStamp, endTimeStamp)); } diff --git a/gfx/layers/composite/ContainerLayerComposite.cpp b/gfx/layers/composite/ContainerLayerComposite.cpp index 9ecb33b21fd6..83e080a9e7f8 100755 --- a/gfx/layers/composite/ContainerLayerComposite.cpp +++ b/gfx/layers/composite/ContainerLayerComposite.cpp @@ -100,7 +100,7 @@ PrintUniformityInfo(Layer* aLayer) } Point translation = transform.As2D().GetTranslation(); - PROFILER_MARKER_PAYLOAD( + profiler_add_marker( "LayerTranslation", MakeUnique(aLayer, translation)); #endif diff --git a/gfx/layers/ipc/CompositorBench.cpp b/gfx/layers/ipc/CompositorBench.cpp index 945adafc1829..5c02f9f695c0 100644 --- a/gfx/layers/ipc/CompositorBench.cpp +++ b/gfx/layers/ipc/CompositorBench.cpp @@ -286,7 +286,7 @@ static void RunCompositorBench(Compositor* aCompositor, const gfx::Rect& aScreen BenchTest* test = tests[i]; std::vector results; int testsOverThreshold = 0; - PROFILER_MARKER(test->ToString()); + profiler_add_marker(test->ToString()); for (size_t j = 0; j < TEST_STEPS; j++) { test->Setup(aCompositor, j); diff --git a/gfx/layers/ipc/CompositorBridgeParent.cpp b/gfx/layers/ipc/CompositorBridgeParent.cpp index 0ae259c98ff5..d78bb72e71f2 100644 --- a/gfx/layers/ipc/CompositorBridgeParent.cpp +++ b/gfx/layers/ipc/CompositorBridgeParent.cpp @@ -1763,7 +1763,7 @@ InsertVsyncProfilerMarker(TimeStamp aVsyncTimestamp) { #ifdef MOZ_GECKO_PROFILER MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread()); - PROFILER_MARKER_PAYLOAD( + profiler_add_marker( "VsyncTimestamp", MakeUnique(aVsyncTimestamp)); #endif diff --git a/gfx/thebes/ContextStateTracker.cpp b/gfx/thebes/ContextStateTracker.cpp index 4273ea93ace1..525695fa3bc0 100644 --- a/gfx/thebes/ContextStateTracker.cpp +++ b/gfx/thebes/ContextStateTracker.cpp @@ -112,7 +112,7 @@ ContextStateTrackerOGL::Flush(GLContext* aGL) aGL->fDeleteQueries(1, &handle); #ifdef MOZ_GECKO_PROFILER - PROFILER_MARKER_PAYLOAD( + profiler_add_marker( "gpu_timer_query", MakeUnique(mCompletedSections[0].mCpuTimeStart, mCompletedSections[0].mCpuTimeEnd, diff --git a/toolkit/components/startup/StartupTimeline.h b/toolkit/components/startup/StartupTimeline.h index f5280eda101c..da57a1ebe943 100644 --- a/toolkit/components/startup/StartupTimeline.h +++ b/toolkit/components/startup/StartupTimeline.h @@ -71,7 +71,7 @@ public: #ifdef MOZILLA_INTERNAL_API static void Record(Event ev) { - PROFILER_MARKER(Describe(ev)); + profiler_add_marker(Describe(ev)); Record(ev, TimeStamp::Now()); } diff --git a/toolkit/components/startup/nsAppStartup.cpp b/toolkit/components/startup/nsAppStartup.cpp index e824e91dedaf..5b982f6a9781 100644 --- a/toolkit/components/startup/nsAppStartup.cpp +++ b/toolkit/components/startup/nsAppStartup.cpp @@ -382,7 +382,7 @@ nsAppStartup::Quit(uint32_t aMode) } } - PROFILER_MARKER("Shutdown start"); + profiler_add_marker("Shutdown start"); mozilla::RecordShutdownStartTimeStamp(); mShuttingDown = true; if (!mRestart) { diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index d5f439ab61b5..f9ccd6054de6 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -1460,7 +1460,7 @@ ScopedXPCOMStartup::~ScopedXPCOMStartup() appStartup->DestroyHiddenWindow(); gDirServiceProvider->DoShutdown(); - PROFILER_MARKER("Shutdown early"); + profiler_add_marker("Shutdown early"); WriteConsoleLog(); diff --git a/tools/profiler/core/ProfilerMarkerPayload.cpp b/tools/profiler/core/ProfilerMarkerPayload.cpp index 9c7f7f36ea62..7de1321d69f6 100644 --- a/tools/profiler/core/ProfilerMarkerPayload.cpp +++ b/tools/profiler/core/ProfilerMarkerPayload.cpp @@ -203,7 +203,7 @@ DOMEventMarkerPayload::StreamPayload(SpliceableJSONWriter& aWriter, void ProfilerJSEventMarker(const char *event) { - PROFILER_MARKER(event); + profiler_add_marker(event); } LayerTranslationMarkerPayload::LayerTranslationMarkerPayload(layers::Layer* aLayer, diff --git a/tools/profiler/gecko/ProfilerIOInterposeObserver.cpp b/tools/profiler/gecko/ProfilerIOInterposeObserver.cpp index 3c4b8c5327bd..f766a3edf01e 100644 --- a/tools/profiler/gecko/ProfilerIOInterposeObserver.cpp +++ b/tools/profiler/gecko/ProfilerIOInterposeObserver.cpp @@ -21,7 +21,7 @@ void ProfilerIOInterposeObserver::Observe(Observation& aObservation) filename = NS_ConvertUTF16toUTF8(aObservation.Filename()); } - PROFILER_MARKER_PAYLOAD( + profiler_add_marker( aObservation.ObservedOperationString(), MakeUnique(aObservation.Reference(), filename.get(), aObservation.Start(), aObservation.End(), diff --git a/tools/profiler/gecko/nsProfiler.cpp b/tools/profiler/gecko/nsProfiler.cpp index d9e3a77f341f..af12ce35eb48 100644 --- a/tools/profiler/gecko/nsProfiler.cpp +++ b/tools/profiler/gecko/nsProfiler.cpp @@ -168,7 +168,7 @@ nsProfiler::ResumeSampling() NS_IMETHODIMP nsProfiler::AddMarker(const char *aMarker) { - PROFILER_MARKER(aMarker); + profiler_add_marker(aMarker); return NS_OK; } diff --git a/tools/profiler/public/GeckoProfiler.h b/tools/profiler/public/GeckoProfiler.h index 2e85e32720f4..47a5fffd74b7 100644 --- a/tools/profiler/public/GeckoProfiler.h +++ b/tools/profiler/public/GeckoProfiler.h @@ -112,16 +112,6 @@ using UniqueProfilerBacktrace = PROFILER_APPEND_LINE_NUMBER(profiler_raii)(name_space "::" info, dynamicStr, \ __LINE__, category) -// 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 pseudostack, markers will always be recorded in the profile buffer. -#define PROFILER_MARKER(marker_name) profiler_add_marker(marker_name) - -// Like PROFILER_MARKER, but with an additional payload. -#define PROFILER_MARKER_PAYLOAD(marker_name, payload) \ - profiler_add_marker(marker_name, payload) - // Higher-order macro containing all the feature info in one place. Define // |macro| appropriately to extract the relevant parts. Note that the number // values are used internally only and so can be changed without consequence. @@ -376,8 +366,11 @@ PROFILER_FUNC_VOID(profiler_suspend_and_sample_thread(int aThreadId, const std::function& aCallback, bool aSampleNative = true)) -// Adds a marker to the PseudoStack. A no-op if the profiler is inactive or in -// privacy mode. +// 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 pseudostack, markers will always be recorded in the profile buffer. +// A no-op if the profiler is inactive or in privacy mode. PROFILER_FUNC_VOID(profiler_add_marker(const char* aMarkerName)) PROFILER_FUNC_VOID(profiler_add_marker(const char* aMarkerName, mozilla::UniquePtr aPayload)) diff --git a/tools/profiler/tests/gtest/GeckoProfiler.cpp b/tools/profiler/tests/gtest/GeckoProfiler.cpp index 97d42cb07ef3..85bb644ea0d9 100644 --- a/tools/profiler/tests/gtest/GeckoProfiler.cpp +++ b/tools/profiler/tests/gtest/GeckoProfiler.cpp @@ -381,14 +381,14 @@ TEST(GeckoProfiler, Markers) profiler_add_marker("M1"); profiler_add_marker("M2", MakeUnique("C", TRACING_EVENT)); - PROFILER_MARKER("M3"); - PROFILER_MARKER_PAYLOAD( + profiler_add_marker("M3"); + profiler_add_marker( "M4", MakeUnique("C", TRACING_EVENT, profiler_get_backtrace())); for (int i = 0; i < 10; i++) { - PROFILER_MARKER_PAYLOAD("M5", MakeUnique(i)); + profiler_add_marker("M5", MakeUnique(i)); } // Sleep briefly to ensure a sample is taken and the pending markers are @@ -417,7 +417,7 @@ TEST(GeckoProfiler, Markers) ASSERT_TRUE(GTestMarkerPayload::sNumDestroyed == 10); for (int i = 0; i < 10; i++) { - PROFILER_MARKER_PAYLOAD("M5", MakeUnique(i)); + profiler_add_marker("M5", MakeUnique(i)); } profiler_start(PROFILER_DEFAULT_ENTRIES, PROFILER_DEFAULT_INTERVAL, diff --git a/xpcom/base/CycleCollectedJSRuntime.cpp b/xpcom/base/CycleCollectedJSRuntime.cpp index efe5d64bb679..5feff032f1b6 100644 --- a/xpcom/base/CycleCollectedJSRuntime.cpp +++ b/xpcom/base/CycleCollectedJSRuntime.cpp @@ -837,13 +837,13 @@ CycleCollectedJSRuntime::GCSliceCallback(JSContext* aContext, #ifdef MOZ_GECKO_PROFILER if (profiler_is_active()) { if (aProgress == JS::GC_CYCLE_END) { - PROFILER_MARKER_PAYLOAD( + profiler_add_marker( "GCMajor", MakeUnique(aDesc.startTime(aContext), aDesc.endTime(aContext), aDesc.summaryToJSON(aContext))); } else if (aProgress == JS::GC_SLICE_END) { - PROFILER_MARKER_PAYLOAD( + profiler_add_marker( "GCSlice", MakeUnique(aDesc.lastSliceStart(aContext), aDesc.lastSliceEnd(aContext), @@ -936,7 +936,7 @@ CycleCollectedJSRuntime::GCNurseryCollectionCallback(JSContext* aContext, profiler_is_active()) { #ifdef MOZ_GECKO_PROFILER - PROFILER_MARKER_PAYLOAD( + profiler_add_marker( "GCMinor", MakeUnique(self->mLatestNurseryCollectionStart, TimeStamp::Now(), diff --git a/xpcom/build/XPCOMInit.cpp b/xpcom/build/XPCOMInit.cpp index b0eb5dec5a4a..7d011cd70f07 100644 --- a/xpcom/build/XPCOMInit.cpp +++ b/xpcom/build/XPCOMInit.cpp @@ -986,7 +986,7 @@ ShutdownXPCOM(nsIServiceManager* aServMgr) #endif nsCycleCollector_shutdown(shutdownCollect); - PROFILER_MARKER("Shutdown xpcom"); + profiler_add_marker("Shutdown xpcom"); // If we are doing any shutdown checks, poison writes. if (gShutdownChecks != SCM_NOTHING) { #ifdef XP_MACOSX