From 003bd0368c178fe5447df6b032c0b79cf9bfe2bc Mon Sep 17 00:00:00 2001 From: Gerald Squelart Date: Tue, 17 Nov 2020 11:38:06 +0000 Subject: [PATCH] Bug 1675409 - Migrated TextMarkerPayload to Markers 2.0 API - r=gregtatum Differential Revision: https://phabricator.services.mozilla.com/D96052 --- dom/base/TimeoutManager.cpp | 22 +++++--- dom/base/nsDOMNavigationTiming.cpp | 55 ++++++++++++------- dom/ipc/ContentParent.cpp | 19 +++---- dom/media/MediaDecoderStateMachine.cpp | 15 ++--- dom/media/MediaFormatReader.cpp | 13 +---- dom/media/platforms/wmf/WMFDecoderModule.cpp | 16 ++---- .../platforms/wmf/WMFMediaDataDecoder.cpp | 13 +---- .../platforms/wrappers/MediaChangeMonitor.cpp | 27 +++------ dom/script/ScriptLoader.cpp | 16 +++--- js/xpconnect/src/XPCJSContext.cpp | 7 +-- tools/profiler/core/platform.cpp | 42 ++++---------- tools/profiler/tests/gtest/GeckoProfiler.cpp | 28 +--------- 12 files changed, 97 insertions(+), 176 deletions(-) diff --git a/dom/base/TimeoutManager.cpp b/dom/base/TimeoutManager.cpp index b1936ddf4c0e..c20f89e6b345 100644 --- a/dom/base/TimeoutManager.cpp +++ b/dom/base/TimeoutManager.cpp @@ -154,10 +154,13 @@ void TimeoutManager::MoveIdleToActive() { int(elapsed.ToMilliseconds()), int(target.ToMilliseconds()), int(delta.ToMilliseconds())); // don't have end before start... - PROFILER_ADD_MARKER_WITH_PAYLOAD( - "setTimeout deferred release", DOM, TextMarkerPayload, - (marker, delta.ToMilliseconds() >= 0 ? timeout->When() : now, now, - Some(mWindow.WindowID()))); + PROFILER_MARKER_TEXT( + "setTimeout deferred release", DOM, + MarkerOptions( + MarkerTiming::Interval( + delta.ToMilliseconds() >= 0 ? timeout->When() : now, now), + MarkerInnerWindowId(mWindow.WindowID())), + marker); } #endif num++; @@ -905,10 +908,13 @@ void TimeoutManager::RunTimeout(const TimeStamp& aNow, int(elapsed.ToMilliseconds()), int(target.ToMilliseconds()), int(delta.ToMilliseconds()), int(runtime.ToMilliseconds())); // don't have end before start... - PROFILER_ADD_MARKER_WITH_PAYLOAD( - "setTimeout", DOM, TextMarkerPayload, - (marker, delta.ToMilliseconds() >= 0 ? timeout->When() : now, now, - Some(mWindow.WindowID()))); + PROFILER_MARKER_TEXT( + "setTimeout", DOM, + MarkerOptions( + MarkerTiming::Interval( + delta.ToMilliseconds() >= 0 ? timeout->When() : now, now), + MarkerInnerWindowId(mWindow.WindowID())), + marker); } #endif diff --git a/dom/base/nsDOMNavigationTiming.cpp b/dom/base/nsDOMNavigationTiming.cpp index c5032bee35f1..9fe7820f0b41 100644 --- a/dom/base/nsDOMNavigationTiming.cpp +++ b/dom/base/nsDOMNavigationTiming.cpp @@ -179,10 +179,13 @@ void nsDOMNavigationTiming::NotifyLoadEventEnd() { "Document %s loaded after %dms, load event duration %dms", spec.get(), int(elapsed.ToMilliseconds()), int(duration.ToMilliseconds())); PAGELOAD_LOG(("%s", marker.get())); - PROFILER_ADD_MARKER_WITH_PAYLOAD( - "DocumentLoad", DOM, TextMarkerPayload, - (marker, mNavigationStart, mLoadEventEnd, - profiler_get_inner_window_id_from_docshell(mDocShell))); + PROFILER_MARKER_TEXT( + "DocumentLoad", DOM, + MarkerOptions( + MarkerTiming::Interval(mNavigationStart, mLoadEventEnd), + MarkerInnerWindowId( + profiler_get_inner_window_id_from_docshell(mDocShell))), + marker); } #endif TimeStamp loadEventEnd = TimeStamp::Now(); @@ -377,10 +380,13 @@ void nsDOMNavigationTiming::TTITimeout(nsITimer* aTimer) { int(elapsed.ToMilliseconds()), int(elapsedLongTask.ToMilliseconds()), spec.get()); - PROFILER_ADD_MARKER_WITH_PAYLOAD( - "TimeToFirstInteractive (TTFI)", DOM, TextMarkerPayload, - (marker, mNavigationStart, mTTFI, - profiler_get_inner_window_id_from_docshell(mDocShell))); + PROFILER_MARKER_TEXT( + "TimeToFirstInteractive (TTFI)", DOM, + MarkerOptions( + MarkerTiming::Interval(mNavigationStart, mTTFI), + MarkerInnerWindowId( + profiler_get_inner_window_id_from_docshell(mDocShell))), + marker); } #endif } @@ -410,10 +416,13 @@ void nsDOMNavigationTiming::NotifyNonBlankPaintForRootContentDocument() { : "this tab was inactive some of the time between navigation start " "and first non-blank paint"); PAGELOAD_LOG(("%s", marker.get())); - PROFILER_ADD_MARKER_WITH_PAYLOAD( - "FirstNonBlankPaint", DOM, TextMarkerPayload, - (marker, mNavigationStart, mNonBlankPaint, - profiler_get_inner_window_id_from_docshell(mDocShell))); + PROFILER_MARKER_TEXT( + "FirstNonBlankPaint", DOM, + MarkerOptions( + MarkerTiming::Interval(mNavigationStart, mNonBlankPaint), + MarkerInnerWindowId( + profiler_get_inner_window_id_from_docshell(mDocShell))), + marker); } #endif @@ -459,10 +468,13 @@ void nsDOMNavigationTiming::NotifyContentfulPaintForRootContentDocument( : "this tab was inactive some of the time between navigation start " "and first non-blank paint"); PAGELOAD_LOG(("%s", marker.get())); - PROFILER_ADD_MARKER_WITH_PAYLOAD( - "FirstContentfulPaint", DOM, TextMarkerPayload, - (marker, mNavigationStart, mContentfulPaint, - profiler_get_inner_window_id_from_docshell(mDocShell))); + PROFILER_MARKER_TEXT( + "FirstContentfulPaint", DOM, + MarkerOptions( + MarkerTiming::Interval(mNavigationStart, mContentfulPaint), + MarkerInnerWindowId( + profiler_get_inner_window_id_from_docshell(mDocShell))), + marker); } #endif @@ -508,10 +520,13 @@ void nsDOMNavigationTiming::NotifyDOMContentFlushedForRootContentDocument() { : "this tab was inactive some of the time between navigation start " "and DOMContentFlushed"); PAGELOAD_LOG(("%s", marker.get())); - PROFILER_ADD_MARKER_WITH_PAYLOAD( - "DOMContentFlushed", DOM, TextMarkerPayload, - (marker, mNavigationStart, mDOMContentFlushed, - profiler_get_inner_window_id_from_docshell(mDocShell))); + PROFILER_MARKER_TEXT( + "DOMContentFlushed", DOM, + MarkerOptions( + MarkerTiming::Interval(mNavigationStart, mDOMContentFlushed), + MarkerInnerWindowId( + profiler_get_inner_window_id_from_docshell(mDocShell))), + marker); } #endif } diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index b798b4e044ed..135f92f6fc06 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -918,9 +918,7 @@ already_AddRefed ContentParent::GetUsedBrowserProcess( if (profiler_thread_is_being_profiled()) { nsPrintfCString marker("Reused process %u", (unsigned int)retval->ChildID()); - TimeStamp now = TimeStamp::Now(); - PROFILER_ADD_MARKER_WITH_PAYLOAD("Process", DOM, TextMarkerPayload, - (marker, now, now)); + PROFILER_MARKER_TEXT("Process", DOM, {}, marker); } #endif MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, @@ -959,9 +957,7 @@ already_AddRefed ContentParent::GetUsedBrowserProcess( if (profiler_thread_is_being_profiled()) { nsPrintfCString marker("Recycled process %u (%p)", (unsigned int)recycled->ChildID(), recycled.get()); - TimeStamp now = TimeStamp::Now(); - PROFILER_ADD_MARKER_WITH_PAYLOAD("Process", DOM, TextMarkerPayload, - (marker, now, now)); + PROFILER_MARKER_TEXT("Process", DOM, {}, marker); } #endif MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, @@ -984,9 +980,7 @@ already_AddRefed ContentParent::GetUsedBrowserProcess( if (profiler_thread_is_being_profiled()) { nsPrintfCString marker("Assigned preallocated process %u", (unsigned int)preallocated->ChildID()); - TimeStamp now = TimeStamp::Now(); - PROFILER_ADD_MARKER_WITH_PAYLOAD("Process", DOM, TextMarkerPayload, - (marker, now, now)); + PROFILER_MARKER_TEXT("Process", DOM, {}, marker); } #endif MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug, @@ -2423,9 +2417,10 @@ bool ContentParent::LaunchSubprocessResolve(bool aIsSync, nsPrintfCString marker("Process start%s for %u", mIsAPreallocBlocker ? " (immediate)" : "", (unsigned int)ChildID()); - PROFILER_ADD_MARKER_WITH_PAYLOAD( - mIsAPreallocBlocker ? "Process Immediate Launch" : "Process Launch", - DOM, TextMarkerPayload, (marker, mLaunchTS, launchResumeTS)); + PROFILER_MARKER_TEXT( + mIsAPreallocBlocker ? ProfilerString8View("Process Immediate Launch") + : ProfilerString8View("Process Launch"), + DOM, MarkerTiming::Interval(mLaunchTS, launchResumeTS), marker); } #endif diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp index dc49d4103a3a..6105bac69160 100644 --- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -15,7 +15,6 @@ #include "mozilla/Logging.h" #include "mozilla/MathAlgorithms.h" #include "mozilla/NotNull.h" -#include "mozilla/ProfilerMarkerTypes.h" #include "mozilla/SharedThreadPool.h" #include "mozilla/Sprintf.h" #include "mozilla/StaticPrefs_media.h" @@ -28,6 +27,7 @@ #include "AudioSegment.h" #include "DOMMediaStream.h" #include "ImageContainer.h" +#include "GeckoProfiler.h" #include "MediaDecoder.h" #include "MediaDecoderStateMachine.h" #include "MediaShutdownManager.h" @@ -39,13 +39,8 @@ #include "VideoUtils.h" #ifdef MOZ_GECKO_PROFILER -# include "ProfilerMarkerPayload.h" -# define MDSM_ERROR_MARKER(tag, error, markerTime) \ - PROFILER_ADD_MARKER_WITH_PAYLOAD(tag, MEDIA_PLAYBACK, TextMarkerPayload, \ - (error, markerTime)) -#else -# define MDSM_ERROR_MARKER(tag, error, markerTime) -#endif +# include "mozilla/ProfilerMarkerTypes.h" +#endif // MOZ_GECKO_PROFILER namespace mozilla { @@ -3468,8 +3463,8 @@ bool MediaDecoderStateMachine::HasLowBufferedData(const TimeUnit& aThreshold) { void MediaDecoderStateMachine::DecodeError(const MediaResult& aError) { MOZ_ASSERT(OnTaskQueue()); LOGE("Decode error: %s", aError.Description().get()); - MDSM_ERROR_MARKER("MDSM::DecodeError", aError.Description(), - TimeStamp::NowUnfuzzed()); + PROFILER_MARKER_TEXT("MDSM::DecodeError", MEDIA_PLAYBACK, {}, + aError.Description()); // Notify the decode error and MediaDecoder will shut down MDSM. mOnPlaybackErrorEvent.Notify(aError); } diff --git a/dom/media/MediaFormatReader.cpp b/dom/media/MediaFormatReader.cpp index 1304b1186e88..aeeec6c7fe54 100644 --- a/dom/media/MediaFormatReader.cpp +++ b/dom/media/MediaFormatReader.cpp @@ -42,15 +42,6 @@ mozilla::LazyLogModule gMediaDemuxerLog("MediaDemuxer"); DDMOZ_LOG(sFormatDecoderLog, mozilla::LogLevel::Verbose, "::%s: " arg, \ __func__, ##__VA_ARGS__) -#ifdef MOZ_GECKO_PROFILER -# include "ProfilerMarkerPayload.h" -# define MEDIA_FORMAT_READER_STATUS_MARKER(tag, text, markerTime) \ - PROFILER_ADD_MARKER_WITH_PAYLOAD(tag, MEDIA_PLAYBACK, TextMarkerPayload, \ - (text, markerTime)) -#else -# define MEDIA_FORMAT_READER_STATUS_MARKER(tag, text, markerTime) -#endif - #define NS_DispatchToMainThread(...) CompileError_UseAbstractMainThreadInstead namespace mozilla { @@ -1933,8 +1924,7 @@ void MediaFormatReader::HandleDemuxedSamples( nsPrintfCString markerString( "%s stream id changed from:%" PRIu32 " to:%" PRIu32, TrackTypeToStr(aTrack), decoder.mLastStreamSourceID, info->GetID()); - MEDIA_FORMAT_READER_STATUS_MARKER("StreamID Change", markerString, - TimeStamp::NowUnfuzzed()); + PROFILER_MARKER_TEXT("StreamID Change", MEDIA_PLAYBACK, {}, markerString); LOG("%s", markerString.get()); if (aTrack == TrackInfo::kVideoTrack) { @@ -3152,6 +3142,5 @@ void MediaFormatReader::OnFirstDemuxFailed(TrackInfo::TrackType aType, } // namespace mozilla #undef NS_DispatchToMainThread -#undef MEDIA_FORMAT_READER_STATUS_MARKER #undef LOGV #undef LOG diff --git a/dom/media/platforms/wmf/WMFDecoderModule.cpp b/dom/media/platforms/wmf/WMFDecoderModule.cpp index a12e193e4ade..9d53030ff75f 100644 --- a/dom/media/platforms/wmf/WMFDecoderModule.cpp +++ b/dom/media/platforms/wmf/WMFDecoderModule.cpp @@ -27,6 +27,7 @@ #include "mozilla/WindowsVersion.h" #include "mozilla/gfx/gfxVars.h" #include "mozilla/mscom/EnsureMTA.h" +#include "mozilla/ProfilerMarkers.h" #include "nsComponentManagerUtils.h" #include "nsIXULRuntime.h" #include "nsIXULRuntime.h" // for BrowserTabsRemoteAutostart @@ -36,28 +37,19 @@ #define LOG(...) MOZ_LOG(sPDMLog, mozilla::LogLevel::Debug, (__VA_ARGS__)) -#ifdef MOZ_GECKO_PROFILER -# include "ProfilerMarkerPayload.h" -# define WFM_DECODER_MODULE_STATUS_MARKER(tag, text, markerTime) \ - PROFILER_ADD_MARKER_WITH_PAYLOAD(tag, MEDIA_PLAYBACK, TextMarkerPayload, \ - (text, markerTime)) -#else -# define WFM_DECODER_MODULE_STATUS_MARKER(tag, text, markerTime) -#endif - extern const GUID CLSID_WebmMfVpxDec; namespace mozilla { // Helper function to add a profile marker and log at the same time. static void MOZ_FORMAT_PRINTF(2, 3) - WmfDeocderModuleMarkerAndLog(const char* aTag, const char* aFormat, ...) { + WmfDeocderModuleMarkerAndLog(const ProfilerString8View& aMarkerTag, + const char* aFormat, ...) { va_list ap; va_start(ap, aFormat); const nsVprintfCString markerString(aFormat, ap); va_end(ap); - WFM_DECODER_MODULE_STATUS_MARKER(aTag, markerString, - TimeStamp::NowUnfuzzed()); + PROFILER_MARKER_TEXT(aMarkerTag, MEDIA_PLAYBACK, {}, markerString); LOG("%s", markerString.get()); } diff --git a/dom/media/platforms/wmf/WMFMediaDataDecoder.cpp b/dom/media/platforms/wmf/WMFMediaDataDecoder.cpp index 7b84f2a71d63..47f2b1726ef6 100644 --- a/dom/media/platforms/wmf/WMFMediaDataDecoder.cpp +++ b/dom/media/platforms/wmf/WMFMediaDataDecoder.cpp @@ -9,6 +9,7 @@ #include "VideoUtils.h" #include "WMFUtils.h" #include "mozilla/Logging.h" +#include "mozilla/ProfilerMarkers.h" #include "mozilla/SyncRunnable.h" #include "mozilla/TaskQueue.h" #include "mozilla/Telemetry.h" @@ -16,15 +17,6 @@ #define LOG(...) MOZ_LOG(sPDMLog, mozilla::LogLevel::Debug, (__VA_ARGS__)) -#ifdef MOZ_GECKO_PROFILER -# include "ProfilerMarkerPayload.h" -# define WFM_MEDIA_DATA_DECODER_STATUS_MARKER(tag, text, markerTime) \ - PROFILER_ADD_MARKER_WITH_PAYLOAD(tag, MEDIA_PLAYBACK, TextMarkerPayload, \ - (text, markerTime)) -#else -# define WFM_MEDIA_DATA_DECODER_STATUS_MARKER(tag, text, markerTime) -#endif - namespace mozilla { WMFMediaDataDecoder::WMFMediaDataDecoder(MFTManager* aMFTManager) @@ -102,8 +94,7 @@ RefPtr WMFMediaDataDecoder::ProcessError( "reason: %s", GetDescriptionName().get(), aReason); LOG(markerString.get()); - WFM_MEDIA_DATA_DECODER_STATUS_MARKER("WMFDecoder Error", markerString, - TimeStamp::NowUnfuzzed()); + PROFILER_MARKER_TEXT("WMFDecoder Error", MEDIA_PLAYBACK, {}, markerString); // TODO: For the error DXGI_ERROR_DEVICE_RESET, we could return // NS_ERROR_DOM_MEDIA_NEED_NEW_DECODER to get the latest device. Maybe retry diff --git a/dom/media/platforms/wrappers/MediaChangeMonitor.cpp b/dom/media/platforms/wrappers/MediaChangeMonitor.cpp index 351cbcb7bca5..0edd0d8c4863 100644 --- a/dom/media/platforms/wrappers/MediaChangeMonitor.cpp +++ b/dom/media/platforms/wrappers/MediaChangeMonitor.cpp @@ -13,18 +13,10 @@ #include "MediaInfo.h" #include "PDMFactory.h" #include "VPXDecoder.h" +#include "mozilla/ProfilerMarkers.h" #include "mozilla/StaticPrefs_media.h" #include "mozilla/TaskQueue.h" -#ifdef MOZ_GECKO_PROFILER -# include "ProfilerMarkerPayload.h" -# define MEDIA_CHANGE_MONITOR_STATUS_MARKER(tag, text, markerTime) \ - PROFILER_ADD_MARKER_WITH_PAYLOAD(tag, MEDIA_PLAYBACK, TextMarkerPayload, \ - (text, markerTime)) -#else -# define MEDIA_CHANGE_MONITOR_STATUS_MARKER(tag, text, markerTime) -#endif - namespace mozilla { // H264ChangeMonitor is used to ensure that only AVCC or AnnexB is fed to the @@ -98,11 +90,9 @@ class H264ChangeMonitor : public MediaChangeMonitor::CodecChangeMonitor { mPreviousExtraData = aSample->mExtraData; UpdateConfigFromExtraData(extra_data); - MEDIA_CHANGE_MONITOR_STATUS_MARKER( - "H264 Stream Change", - "H264ChangeMonitor::CheckForChange has detected a change in the " - "stream and will request a new decoder"_ns, - TimeStamp::NowUnfuzzed()); + PROFILER_MARKER_TEXT("H264 Stream Change", MEDIA_PLAYBACK, {}, + "H264ChangeMonitor::CheckForChange has detected a " + "change in the stream and will request a new decoder"); return NS_ERROR_DOM_MEDIA_NEED_NEW_DECODER; } @@ -204,11 +194,10 @@ class VPXChangeMonitor : public MediaChangeMonitor::CodecChangeMonitor { mCurrentConfig.SetImageRect( gfx::IntRect(0, 0, info.mImage.width, info.mImage.height)); - MEDIA_CHANGE_MONITOR_STATUS_MARKER( - "VPX Stream Change", + PROFILER_MARKER_TEXT( + "VPX Stream Change", MEDIA_PLAYBACK, {}, "VPXChangeMonitor::CheckForChange has detected a change in the " - "stream and will request a new decoder"_ns, - TimeStamp::NowUnfuzzed()); + "stream and will request a new decoder"); rv = NS_ERROR_DOM_MEDIA_NEED_NEW_DECODER; } mInfo = Some(info); @@ -755,5 +744,3 @@ void MediaChangeMonitor::FlushThenShutdownDecoder( } } // namespace mozilla - -#undef MEDIA_CHANGE_MONITOR_STATUS_MARKER diff --git a/dom/script/ScriptLoader.cpp b/dom/script/ScriptLoader.cpp index 032d762911ce..319a026eb622 100644 --- a/dom/script/ScriptLoader.cpp +++ b/dom/script/ScriptLoader.cpp @@ -24,6 +24,7 @@ #include "js/SourceText.h" #include "js/Utility.h" #include "xpcpublic.h" +#include "GeckoProfiler.h" #include "nsCycleCollectionParticipant.h" #include "nsIContent.h" #include "nsJSUtils.h" @@ -83,10 +84,6 @@ #include "nsIScriptError.h" #include "nsIAsyncOutputStream.h" -#ifdef MOZ_GECKO_PROFILER -# include "ProfilerMarkerPayload.h" -#endif - using JS::SourceText; using mozilla::Telemetry::LABELS_DOM_SCRIPT_PRELOAD_RESULT; @@ -2180,7 +2177,7 @@ NotifyOffThreadScriptLoadCompletedRunnable::Run() { #ifdef MOZ_GECKO_PROFILER if (profiler_is_active()) { - const char* scriptSourceString; + ProfilerString8View scriptSourceString; if (request->IsTextSource()) { scriptSourceString = "ScriptCompileOffThread"; } else if (request->IsBinASTSource()) { @@ -2192,10 +2189,11 @@ NotifyOffThreadScriptLoadCompletedRunnable::Run() { nsAutoCString profilerLabelString; GetProfilerLabelForRequest(request, profilerLabelString); - PROFILER_ADD_MARKER_WITH_PAYLOAD( - scriptSourceString, JS, TextMarkerPayload, - (profilerLabelString, request->mOffThreadParseStartTime, - request->mOffThreadParseStopTime)); + PROFILER_MARKER_TEXT( + scriptSourceString, JS, + MarkerTiming::Interval(request->mOffThreadParseStartTime, + request->mOffThreadParseStopTime), + profilerLabelString); } #endif diff --git a/js/xpconnect/src/XPCJSContext.cpp b/js/xpconnect/src/XPCJSContext.cpp index e6cc40ccc394..28f2882acbd8 100644 --- a/js/xpconnect/src/XPCJSContext.cpp +++ b/js/xpconnect/src/XPCJSContext.cpp @@ -63,9 +63,6 @@ #include "nsIXULRuntime.h" #include "nsJSPrincipals.h" #include "ExpandedPrincipal.h" -#ifdef MOZ_GECKO_PROFILER -# include "ProfilerMarkerPayload.h" -#endif #if defined(XP_LINUX) && !defined(ANDROID) // For getrlimit and min/max. @@ -591,9 +588,7 @@ bool XPCJSContext::InterruptCallback(JSContext* cx) { if (const char* file = scriptFilename.get()) { filename.Assign(file, strlen(file)); } - PROFILER_ADD_MARKER_WITH_PAYLOAD("JS::InterruptCallback", JS, - TextMarkerPayload, - (filename, TimeStamp::Now())); + PROFILER_MARKER_TEXT("JS::InterruptCallback", JS, {}, filename); } #endif diff --git a/tools/profiler/core/platform.cpp b/tools/profiler/core/platform.cpp index b3be356857d5..06c871e685fd 100644 --- a/tools/profiler/core/platform.cpp +++ b/tools/profiler/core/platform.cpp @@ -2783,19 +2783,15 @@ static void CollectJavaThreadProfileData(ProfileBuffer& aProfileBuffer) { if (!text) { // This marker doesn't have a text. - StoreMarker(aProfileBuffer.UnderlyingChunkedBuffer(), threadId, - markerName.get(), timing, - JS::ProfilingCategoryPair::JAVA_ANDROID, nullptr); + AddMarkerToBuffer(aProfileBuffer.UnderlyingChunkedBuffer(), markerName, + geckoprofiler::category::JAVA_ANDROID, + {MarkerThreadId(threadId), std::move(timing)}); } else { // This marker has a text. - nsCString textString = text->ToCString(); - const TextMarkerPayload payload(textString, startTime, endTime, Nothing(), - nullptr); - - // Put the marker inside the buffer. - StoreMarker(aProfileBuffer.UnderlyingChunkedBuffer(), threadId, - markerName.get(), timing, - JS::ProfilingCategoryPair::JAVA_ANDROID, &payload); + AddMarkerToBuffer(aProfileBuffer.UnderlyingChunkedBuffer(), markerName, + geckoprofiler::category::JAVA_ANDROID, + {MarkerThreadId(threadId), std::move(timing)}, + geckoprofiler::markers::Text{}, text->ToCString()); } } } @@ -5109,10 +5105,8 @@ ProfilingStack* profiler_register_thread(const char* aName, text.AppendLiteral("\" attempted to re-register as \""); text.AppendASCII(aName); text.AppendLiteral("\""); - maybelocked_profiler_add_marker_for_thread( - profiler_main_thread_id(), JS::ProfilingCategoryPair::OTHER_Profiling, - "profiler_register_thread again", - TextMarkerPayload(text, TimeStamp::NowUnfuzzed()), &lock); + PROFILER_MARKER_TEXT("profiler_register_thread again", OTHER_Profiling, + MarkerThreadId::MainThread(), text); return &thread->RacyRegisteredThread().ProfilingStack(); } @@ -5192,10 +5186,8 @@ void profiler_unregister_thread() { tid != profiler_main_thread_id()) { nsCString threadIdString; threadIdString.AppendInt(tid); - maybelocked_profiler_add_marker_for_thread( - profiler_main_thread_id(), JS::ProfilingCategoryPair::OTHER_Profiling, - "profiler_unregister_thread again", - TextMarkerPayload(threadIdString, TimeStamp::NowUnfuzzed()), &lock); + PROFILER_MARKER_TEXT("profiler_unregister_thread again", OTHER_Profiling, + MarkerThreadId::MainThread(), threadIdString); } } } @@ -5804,18 +5796,6 @@ void profiler_tracing_marker(const char* aCategoryString, aInnerWindowID, std::move(aCause))); } -void profiler_add_text_marker(const char* aMarkerName, const nsACString& aText, - JS::ProfilingCategoryPair aCategoryPair, - const mozilla::TimeStamp& aStartTime, - const mozilla::TimeStamp& aEndTime, - const mozilla::Maybe& aInnerWindowID, - UniqueProfilerBacktrace aCause) { - AUTO_PROFILER_STATS(add_marker_with_TextMarkerPayload); - profiler_add_marker(aMarkerName, aCategoryPair, - TextMarkerPayload(aText, aStartTime, aEndTime, - aInnerWindowID, std::move(aCause))); -} - void profiler_set_js_context(JSContext* aCx) { MOZ_ASSERT(aCx); diff --git a/tools/profiler/tests/gtest/GeckoProfiler.cpp b/tools/profiler/tests/gtest/GeckoProfiler.cpp index 9e1ff3454d61..a3989e9b827a 100644 --- a/tools/profiler/tests/gtest/GeckoProfiler.cpp +++ b/tools/profiler/tests/gtest/GeckoProfiler.cpp @@ -829,15 +829,10 @@ TEST(GeckoProfiler, Markers) /* const mozilla::Maybe& aContentType = mozilla::Nothing() */); - PROFILER_ADD_MARKER_WITH_PAYLOAD("TextMarkerPayload marker 1", OTHER, - TextMarkerPayload, ("text"_ns, ts1)); - - PROFILER_ADD_MARKER_WITH_PAYLOAD("TextMarkerPayload marker 2", OTHER, - TextMarkerPayload, ("text"_ns, ts1, ts2)); - MOZ_RELEASE_ASSERT(profiler_add_marker( "Text in main thread with stack", geckoprofiler::category::OTHER, - MarkerStack::Capture(), geckoprofiler::markers::Text{}, "")); + {MarkerStack::Capture(), MarkerTiming::Interval(ts1, ts2)}, + geckoprofiler::markers::Text{}, "")); MOZ_RELEASE_ASSERT(profiler_add_marker( "Text from main thread with stack", geckoprofiler::category::OTHER, MarkerOptions(MarkerThreadId::MainThread(), MarkerStack::Capture()), @@ -932,8 +927,6 @@ TEST(GeckoProfiler, Markers) S_NetworkMarkerPayload_start, S_NetworkMarkerPayload_stop, S_NetworkMarkerPayload_redirect, - S_TextMarkerPayload1, - S_TextMarkerPayload2, S_TextWithStack, S_TextToMTWithStack, S_RegThread_TextToMTWithStack, @@ -1319,27 +1312,12 @@ TEST(GeckoProfiler, Markers) "http://example.com/"); EXPECT_TRUE(payload["contentType"].isNull()); - } else if (nameString == "TextMarkerPayload marker 1") { - EXPECT_EQ(state, S_TextMarkerPayload1); - state = State(S_TextMarkerPayload1 + 1); - EXPECT_EQ(typeString, "Text"); - EXPECT_TIMING_INSTANT_AT(ts1Double); - EXPECT_TRUE(payload["stack"].isNull()); - EXPECT_EQ_JSON(payload["name"], String, "text"); - - } else if (nameString == "TextMarkerPayload marker 2") { - EXPECT_EQ(state, S_TextMarkerPayload2); - state = State(S_TextMarkerPayload2 + 1); - EXPECT_EQ(typeString, "Text"); - EXPECT_TIMING_INTERVAL_AT(ts1Double, ts2Double); - EXPECT_TRUE(payload["stack"].isNull()); - EXPECT_EQ_JSON(payload["name"], String, "text"); - } else if (nameString == "Text in main thread with stack") { EXPECT_EQ(state, S_TextWithStack); state = State(S_TextWithStack + 1); EXPECT_EQ(typeString, "Text"); EXPECT_FALSE(payload["stack"].isNull()); + EXPECT_TIMING_INTERVAL_AT(ts1Double, ts2Double); EXPECT_EQ_JSON(payload["name"], String, ""); } else if (nameString == "Text from main thread with stack") {