Bug 1624993 - Add StoreMarker function to unify the marker insertion points. r=gerald

Differential Revision: https://phabricator.services.mozilla.com/D79423
This commit is contained in:
Nazım Can Altınova 2020-06-25 14:28:54 +00:00
parent a74d238798
commit 738659e709

View File

@ -1538,6 +1538,19 @@ void ProfilingStackOwner::DumpStackAndCrash() const {
// The name of the main thread.
static const char* const kMainThreadName = "GeckoMain";
// Add the marker to the given buffer with the given information.
// This is a unified insertion point for all the markers.
template <typename Buffer>
static void StoreMarker(Buffer& aBuffer, int aThreadId, const char* aMarkerName,
JS::ProfilingCategoryPair aCategoryPair,
const ProfilerMarkerPayload* aPayload,
const mozilla::TimeStamp& aTime) {
aBuffer.PutObjects(ProfileBufferEntry::Kind::MarkerData, aThreadId,
WrapProfileBufferUnownedCString(aMarkerName),
static_cast<uint32_t>(aCategoryPair), aPayload,
(aTime - CorePS::ProcessStartTime()).ToMilliseconds());
}
////////////////////////////////////////////////////////////////////////
// BEGIN sampling/unwinding code
@ -4989,11 +5002,8 @@ static void racy_profiler_add_marker(const char* aMarkerName,
TimeStamp origin = (aPayload && !aPayload->GetStartTime().IsNull())
? aPayload->GetStartTime()
: TimeStamp::NowUnfuzzed();
TimeDuration delta = origin - CorePS::ProcessStartTime();
CorePS::CoreBuffer().PutObjects(
ProfileBufferEntry::Kind::MarkerData, racyRegisteredThread->ThreadId(),
WrapProfileBufferUnownedCString(aMarkerName),
static_cast<uint32_t>(aCategoryPair), aPayload, delta.ToMilliseconds());
StoreMarker(CorePS::CoreBuffer(), racyRegisteredThread->ThreadId(),
aMarkerName, aCategoryPair, aPayload, origin);
}
void profiler_add_marker(const char* aMarkerName,
@ -5111,11 +5121,8 @@ static void maybelocked_profiler_add_marker_for_thread(
TimeStamp origin = (!aPayload.GetStartTime().IsNull())
? aPayload.GetStartTime()
: TimeStamp::NowUnfuzzed();
TimeDuration delta = origin - CorePS::ProcessStartTime();
CorePS::CoreBuffer().PutObjects(
ProfileBufferEntry::Kind::MarkerData, aThreadId,
WrapProfileBufferUnownedCString(aMarkerName),
static_cast<uint32_t>(aCategoryPair), &aPayload, delta.ToMilliseconds());
StoreMarker(CorePS::CoreBuffer(), aThreadId, aMarkerName, aCategoryPair,
&aPayload, origin);
}
void profiler_add_marker_for_thread(int aThreadId,