Bug 1717991 - Profiler headers should declare all the marker related functions even when MOZ_GECKO_PROFILER is not defined, r=gerald.

Differential Revision: https://phabricator.services.mozilla.com/D118679
This commit is contained in:
Florian Quèze 2021-06-25 13:28:01 +00:00
parent 75b303b538
commit c87b4eb7b7
13 changed files with 168 additions and 195 deletions

View File

@ -13,9 +13,7 @@ if CONFIG["MOZ_GECKO_PROFILER"]:
DEFINES["IMPL_MFBT"] = True
EXPORTS += [
"public/BaseProfilerSharedLibraries.h",
"public/BaseProfilingCategory.h",
"public/BaseProfilingStack.h",
"public/ProfilingCategoryList.h",
]
UNIFIED_SOURCES += [
"core/PageInformation.cpp",
@ -72,6 +70,8 @@ if CONFIG["MOZ_GECKO_PROFILER"]:
EXPORTS += [
"public/BaseProfiler.h",
"public/BaseProfilingCategory.h",
"public/ProfilingCategoryList.h",
]
EXPORTS.mozilla += [

View File

@ -50,9 +50,6 @@
// Function stubs for when MOZ_GECKO_PROFILER is not defined.
namespace mozilla {
// This won't be used, it's just there to allow the empty definition of
// `profiler_capture_backtrace`.
class ProfileChunkedBuffer {};
namespace baseprofiler {
// This won't be used, it's just there to allow the empty definition of

View File

@ -13,15 +13,15 @@
#include "mozilla/Maybe.h"
#include "mozilla/PlatformMutex.h"
#ifndef MOZ_GECKO_PROFILER
# error Do not #include this header when MOZ_GECKO_PROFILER is not #defined.
#endif
namespace mozilla {
namespace baseprofiler {
#ifdef MOZ_GECKO_PROFILER
// Implemented in platform.cpp
MFBT_API int profiler_current_thread_id();
#else
inline int profiler_current_thread_id() { return 0; }
#endif // MOZ_GECKO_PROFILER
namespace detail {

View File

@ -25,8 +25,6 @@
#include "mozilla/BaseProfilerMarkers.h"
#ifdef MOZ_GECKO_PROFILER
namespace mozilla::baseprofiler::markers {
struct MediaSampleMarker {
@ -64,6 +62,4 @@ struct ContentBuildMarker {
} // namespace mozilla::baseprofiler::markers
#endif // MOZ_GECKO_PROFILER
#endif // BaseProfilerMarkerTypes_h

View File

@ -32,28 +32,17 @@
#define BaseProfilerMarkers_h
#include "mozilla/BaseProfilerMarkersDetail.h"
#include "mozilla/BaseProfilerLabels.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/Unused.h"
#ifndef MOZ_GECKO_PROFILER
# define BASE_PROFILER_MARKER_UNTYPED(markerName, categoryName, ...)
# define BASE_PROFILER_MARKER(markerName, categoryName, options, MarkerType, \
...)
# define BASE_PROFILER_MARKER_TEXT(markerName, categoryName, options, text)
# define AUTO_BASE_PROFILER_MARKER_TEXT(markerName, categoryName, options, \
text)
#else // ndef MOZ_GECKO_PROFILER
# include "mozilla/BaseProfilerLabels.h"
# include "mozilla/TimeStamp.h"
# include "mozilla/Unused.h"
# include <functional>
# include <string>
# include <utility>
#include <functional>
#include <string>
#include <utility>
namespace mozilla::baseprofiler {
#ifdef MOZ_GECKO_PROFILER
// Forward-declaration. TODO: Move to more common header, see bug 1681416.
MFBT_API bool profiler_capture_backtrace_into(
ProfileChunkedBuffer& aChunkedBuffer, StackCaptureOptions aCaptureOptions);
@ -82,6 +71,7 @@ inline ProfileBufferBlockIndex AddMarkerToBuffer(
return AddMarkerToBuffer(aBuffer, aName, aCategory, std::move(aOptions),
markers::NoPayload{});
}
#endif // MOZ_GECKO_PROFILER
// Add a marker to the Base Profiler buffer.
// - aName: Main name of this marker.
@ -96,12 +86,16 @@ ProfileBufferBlockIndex AddMarker(
const ProfilerString8View& aName, const MarkerCategory& aCategory,
MarkerOptions&& aOptions, MarkerType aMarkerType,
const PayloadArguments&... aPayloadArguments) {
#ifndef MOZ_GECKO_PROFILER
return {};
#else
if (!baseprofiler::profiler_can_accept_markers()) {
return {};
}
return ::mozilla::baseprofiler::AddMarkerToBuffer(
base_profiler_markers_detail::CachedBaseCoreBuffer(), aName, aCategory,
std::move(aOptions), aMarkerType, aPayloadArguments...);
#endif
}
// Add a marker (without payload) to the Base Profiler buffer.
@ -115,25 +109,24 @@ inline ProfileBufferBlockIndex AddMarker(const ProfilerString8View& aName,
// Same as `AddMarker()` (without payload). This macro is safe to use even if
// MOZ_GECKO_PROFILER is not #defined.
# define BASE_PROFILER_MARKER_UNTYPED(markerName, categoryName, ...) \
do { \
AUTO_PROFILER_STATS(BASE_PROFILER_MARKER_UNTYPED); \
::mozilla::baseprofiler::AddMarker( \
markerName, ::mozilla::baseprofiler::category::categoryName, \
##__VA_ARGS__); \
} while (false)
#define BASE_PROFILER_MARKER_UNTYPED(markerName, categoryName, ...) \
do { \
AUTO_PROFILER_STATS(BASE_PROFILER_MARKER_UNTYPED); \
::mozilla::baseprofiler::AddMarker( \
markerName, ::mozilla::baseprofiler::category::categoryName, \
##__VA_ARGS__); \
} while (false)
// Same as `AddMarker()` (with payload). This macro is safe to use even if
// MOZ_GECKO_PROFILER is not #defined.
# define BASE_PROFILER_MARKER(markerName, categoryName, options, MarkerType, \
...) \
do { \
AUTO_PROFILER_STATS(BASE_PROFILER_MARKER_with_##MarkerType); \
::mozilla::baseprofiler::AddMarker( \
markerName, ::mozilla::baseprofiler::category::categoryName, \
options, ::mozilla::baseprofiler::markers::MarkerType{}, \
##__VA_ARGS__); \
} while (false)
#define BASE_PROFILER_MARKER(markerName, categoryName, options, MarkerType, \
...) \
do { \
AUTO_PROFILER_STATS(BASE_PROFILER_MARKER_with_##MarkerType); \
::mozilla::baseprofiler::AddMarker( \
markerName, ::mozilla::baseprofiler::category::categoryName, options, \
::mozilla::baseprofiler::markers::MarkerType{}, ##__VA_ARGS__); \
} while (false)
namespace mozilla::baseprofiler::markers {
// Most common marker type. Others are in BaseProfilerMarkerTypes.h.
@ -177,13 +170,13 @@ struct Tracing {
// Add a text marker. This macro is safe to use even if MOZ_GECKO_PROFILER is
// not #defined.
# define BASE_PROFILER_MARKER_TEXT(markerName, categoryName, options, text) \
do { \
AUTO_PROFILER_STATS(BASE_PROFILER_MARKER_TEXT); \
::mozilla::baseprofiler::AddMarker( \
markerName, ::mozilla::baseprofiler::category::categoryName, \
options, ::mozilla::baseprofiler::markers::TextMarker{}, text); \
} while (false)
#define BASE_PROFILER_MARKER_TEXT(markerName, categoryName, options, text) \
do { \
AUTO_PROFILER_STATS(BASE_PROFILER_MARKER_TEXT); \
::mozilla::baseprofiler::AddMarker( \
markerName, ::mozilla::baseprofiler::category::categoryName, options, \
::mozilla::baseprofiler::markers::TextMarker{}, text); \
} while (false)
namespace mozilla::baseprofiler {
@ -220,6 +213,7 @@ class MOZ_RAII AutoProfilerTextMarker {
std::string mText;
};
#ifdef MOZ_GECKO_PROFILER
extern template MFBT_API ProfileBufferBlockIndex
AddMarker(const ProfilerString8View&, const MarkerCategory&, MarkerOptions&&,
markers::TextMarker, const std::string&);
@ -231,17 +225,16 @@ AddMarkerToBuffer(ProfileChunkedBuffer&, const ProfilerString8View&,
extern template MFBT_API ProfileBufferBlockIndex AddMarkerToBuffer(
ProfileChunkedBuffer&, const ProfilerString8View&, const MarkerCategory&,
MarkerOptions&&, markers::TextMarker, const std::string&);
#endif // MOZ_GECKO_PROFILER
} // namespace mozilla::baseprofiler
// Creates an AutoProfilerTextMarker RAII object. This macro is safe to use
// even if MOZ_GECKO_PROFILER is not #defined.
# define AUTO_BASE_PROFILER_MARKER_TEXT(markerName, categoryName, options, \
text) \
::mozilla::baseprofiler::AutoProfilerTextMarker BASE_PROFILER_RAII( \
markerName, ::mozilla::baseprofiler::category::categoryName, options, \
text)
#endif // nfed MOZ_GECKO_PROFILER else
#define AUTO_BASE_PROFILER_MARKER_TEXT(markerName, categoryName, options, \
text) \
::mozilla::baseprofiler::AutoProfilerTextMarker BASE_PROFILER_RAII( \
markerName, ::mozilla::baseprofiler::category::categoryName, options, \
text)
#endif // BaseProfilerMarkers_h

View File

@ -13,18 +13,16 @@
#include "mozilla/BaseProfilerMarkersPrerequisites.h"
#ifdef MOZ_GECKO_PROFILER
// ~~ HERE BE DRAGONS ~~
//
// Everything below is internal implementation detail, you shouldn't need to
// look at it unless working on the profiler code.
# include "mozilla/BaseProfileJSONWriter.h"
# include "mozilla/ProfileBufferEntryKinds.h"
#include "mozilla/BaseProfileJSONWriter.h"
#include "mozilla/ProfileBufferEntryKinds.h"
# include <limits>
# include <tuple>
#include <limits>
#include <tuple>
namespace mozilla::baseprofiler {
// Implemented in platform.cpp
@ -673,6 +671,4 @@ struct ProfileBufferEntryReader::Deserializer<MarkerOptions> {
} // namespace mozilla
#endif // MOZ_GECKO_PROFILER
#endif // BaseProfilerMarkersDetail_h

View File

@ -24,22 +24,20 @@ enum class StackCaptureOptions {
}
#ifdef MOZ_GECKO_PROFILER
#include "BaseProfilingCategory.h"
#include "mozilla/Maybe.h"
#include "mozilla/ProfileChunkedBuffer.h"
#include "mozilla/BaseProfilerState.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/Variant.h"
# include "BaseProfilingCategory.h"
# include "mozilla/Maybe.h"
# include "mozilla/ProfileChunkedBuffer.h"
# include "mozilla/BaseProfilerState.h"
# include "mozilla/TimeStamp.h"
# include "mozilla/UniquePtr.h"
# include "mozilla/Variant.h"
# include <initializer_list>
# include <string_view>
# include <string>
# include <type_traits>
# include <utility>
# include <vector>
#include <initializer_list>
#include <string_view>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>
namespace mozilla {
@ -248,16 +246,16 @@ namespace baseprofiler::category {
// E.g.: mozilla::baseprofiler::category::OTHER_Profiling
// Profiler macros will take the category name alone without namespace.
// E.g.: `PROFILER_MARKER_UNTYPED("name", OTHER_Profiling)`
# define CATEGORY_ENUM_BEGIN_CATEGORY(name, labelAsString, color)
# define CATEGORY_ENUM_SUBCATEGORY(supercategory, name, labelAsString) \
static constexpr MarkerCategory name{ProfilingCategoryPair::name};
# define CATEGORY_ENUM_END_CATEGORY
#define CATEGORY_ENUM_BEGIN_CATEGORY(name, labelAsString, color)
#define CATEGORY_ENUM_SUBCATEGORY(supercategory, name, labelAsString) \
static constexpr MarkerCategory name{ProfilingCategoryPair::name};
#define CATEGORY_ENUM_END_CATEGORY
MOZ_PROFILING_CATEGORY_LIST(CATEGORY_ENUM_BEGIN_CATEGORY,
CATEGORY_ENUM_SUBCATEGORY,
CATEGORY_ENUM_END_CATEGORY)
# undef CATEGORY_ENUM_BEGIN_CATEGORY
# undef CATEGORY_ENUM_SUBCATEGORY
# undef CATEGORY_ENUM_END_CATEGORY
#undef CATEGORY_ENUM_BEGIN_CATEGORY
#undef CATEGORY_ENUM_SUBCATEGORY
#undef CATEGORY_ENUM_END_CATEGORY
// Import `MarkerCategory` into this namespace. This will allow using this type
// dynamically in macros that prepend `::mozilla::baseprofiler::category::` to
@ -535,7 +533,7 @@ class MarkerStack {
// This should be called after every constructor and non-const function.
void AssertInvariants() const {
# ifdef DEBUG
#ifdef DEBUG
if (mCaptureOptions != StackCaptureOptions::NoStack) {
MOZ_ASSERT(!mOptionalChunkedBufferStorage,
"We should not hold a buffer when capture is requested");
@ -552,7 +550,7 @@ class MarkerStack {
"Non-null mChunkedBuffer must not be empty");
}
}
# endif // DEBUG
#endif // DEBUG
}
StackCaptureOptions mCaptureOptions = StackCaptureOptions::NoStack;
@ -624,26 +622,26 @@ class MarkerOptions {
//
// Options can be read by their name (without "Marker"), e.g.: `o.ThreadId()`.
// Add "Ref" for a non-const reference, e.g.: `o.ThreadIdRef() = ...;`
# define FUNCTIONS_ON_MEMBER(NAME) \
MarkerOptions& Set(Marker##NAME&& a##NAME)& { \
m##NAME = std::move(a##NAME); \
return *this; \
} \
\
MarkerOptions&& Set(Marker##NAME&& a##NAME)&& { \
m##NAME = std::move(a##NAME); \
return std::move(*this); \
} \
\
const Marker##NAME& NAME() const { return m##NAME; } \
\
Marker##NAME& NAME##Ref() { return m##NAME; }
#define FUNCTIONS_ON_MEMBER(NAME) \
MarkerOptions& Set(Marker##NAME&& a##NAME)& { \
m##NAME = std::move(a##NAME); \
return *this; \
} \
\
MarkerOptions&& Set(Marker##NAME&& a##NAME)&& { \
m##NAME = std::move(a##NAME); \
return std::move(*this); \
} \
\
const Marker##NAME& NAME() const { return m##NAME; } \
\
Marker##NAME& NAME##Ref() { return m##NAME; }
FUNCTIONS_ON_MEMBER(ThreadId);
FUNCTIONS_ON_MEMBER(Timing);
FUNCTIONS_ON_MEMBER(Stack);
FUNCTIONS_ON_MEMBER(InnerWindowId);
# undef FUNCTIONS_ON_MEMBER
#undef FUNCTIONS_ON_MEMBER
private:
friend ProfileBufferEntryReader::Deserializer<MarkerOptions>;
@ -763,17 +761,17 @@ class MarkerSchema {
// can contain element keys in braces to include data elements streamed by
// `StreamJSONMarkerData()`. E.g.: "This is {text}"
# define LABEL_SETTER(name) \
MarkerSchema& Set##name(std::string a##name) { \
m##name = std::move(a##name); \
return *this; \
}
#define LABEL_SETTER(name) \
MarkerSchema& Set##name(std::string a##name) { \
m##name = std::move(a##name); \
return *this; \
}
LABEL_SETTER(ChartLabel)
LABEL_SETTER(TooltipLabel)
LABEL_SETTER(TableLabel)
# undef LABEL_SETTER
#undef LABEL_SETTER
MarkerSchema& SetAllLabels(std::string aText) {
// Here we set the same text in each label.
@ -868,6 +866,4 @@ class MarkerSchema {
} // namespace mozilla
#endif // MOZ_GECKO_PROFILER
#endif // BaseProfilerMarkersPrerequisites_h

View File

@ -26,6 +26,15 @@
# define AUTO_PROFILER_STATS(name)
namespace mozilla {
namespace baseprofiler {
inline int profiler_main_thread_id() { return 0; }
} // namespace baseprofiler
} // namespace mozilla
#else // !MOZ_GECKO_PROFILER
# include "mozilla/Atomics.h"

View File

@ -7,10 +7,6 @@
#ifndef BaseProfilingCategory_h
#define BaseProfilingCategory_h
#ifndef MOZ_GECKO_PROFILER
# error Do not #include this header when MOZ_GECKO_PROFILER is not #defined.
#endif
#include "mozilla/Types.h"
#include <cstdint>

View File

@ -4379,16 +4379,13 @@ void TestProfiler() {
# endif // AUTO_BASE_PROFILER_INIT
AUTO_BASE_PROFILER_INIT;
// This wouldn't build if the macro did output its arguments.
# ifndef AUTO_BASE_PROFILER_MARKER_TEXT
# error AUTO_BASE_PROFILER_MARKER_TEXT not #defined
# endif // AUTO_BASE_PROFILER_MARKER_TEXT
AUTO_BASE_PROFILER_MARKER_TEXT(catch, catch, catch, catch);
# ifndef AUTO_BASE_PROFILER_LABEL
# error AUTO_BASE_PROFILER_LABEL not #defined
# endif // AUTO_BASE_PROFILER_LABEL
AUTO_BASE_PROFILER_LABEL(catch, catch);
# ifndef AUTO_BASE_PROFILER_THREAD_SLEEP
# error AUTO_BASE_PROFILER_THREAD_SLEEP not #defined
@ -4398,23 +4395,19 @@ void TestProfiler() {
# ifndef BASE_PROFILER_MARKER_UNTYPED
# error BASE_PROFILER_MARKER_UNTYPED not #defined
# endif // BASE_PROFILER_MARKER_UNTYPED
BASE_PROFILER_MARKER_UNTYPED(catch, catch);
BASE_PROFILER_MARKER_UNTYPED(catch, catch, catch);
# ifndef BASE_PROFILER_MARKER
# error BASE_PROFILER_MARKER not #defined
# endif // BASE_PROFILER_MARKER
BASE_PROFILER_MARKER(catch, catch, catch, catch);
BASE_PROFILER_MARKER(catch, catch, catch, catch, catch);
# ifndef BASE_PROFILER_MARKER_TEXT
# error BASE_PROFILER_MARKER_TEXT not #defined
# endif // BASE_PROFILER_MARKER_TEXT
BASE_PROFILER_MARKER_TEXT(catch, catch, catch, catch);
MOZ_RELEASE_ASSERT(!mozilla::baseprofiler::profiler_get_backtrace(),
"profiler_get_backtrace should return nullptr");
mozilla::ProfileChunkedBuffer buffer;
mozilla::ProfileChunkedBuffer buffer(
mozilla::ProfileChunkedBuffer::ThreadSafety::WithoutMutex);
MOZ_RELEASE_ASSERT(!mozilla::baseprofiler::profiler_capture_backtrace_into(
buffer, mozilla::StackCaptureOptions::Full),
"profiler_capture_backtrace_into should return false");

View File

@ -20,13 +20,10 @@
#include "mozilla/BaseProfilerMarkerTypes.h"
#include "mozilla/ProfilerMarkers.h"
#ifdef MOZ_GECKO_PROFILER
# include "js/ProfilingFrameIterator.h"
# include "js/Utility.h"
# include "mozilla/Preferences.h"
# include "mozilla/ServoTraversalStatistics.h"
#include "js/ProfilingFrameIterator.h"
#include "js/Utility.h"
#include "mozilla/Preferences.h"
#include "mozilla/ServoTraversalStatistics.h"
namespace geckoprofiler::markers {
@ -36,6 +33,4 @@ using ContentBuildMarker = mozilla::baseprofiler::markers::ContentBuildMarker;
} // namespace geckoprofiler::markers
#endif // MOZ_GECKO_PROFILER
#endif // ProfilerMarkerTypes_h

View File

@ -34,28 +34,24 @@
#include "mozilla/BaseProfilerMarkers.h"
#include "mozilla/ProfilerMarkersDetail.h"
#ifndef MOZ_GECKO_PROFILER
# define PROFILER_MARKER_UNTYPED(markerName, categoryName, ...)
# define PROFILER_MARKER(markerName, categoryName, options, MarkerType, ...)
# define PROFILER_MARKER_TEXT(markerName, categoryName, options, text)
# define AUTO_PROFILER_MARKER_TEXT(markerName, categoryName, options, text)
# define AUTO_PROFILER_TRACING_MARKER(categoryString, markerName, categoryPair)
# define AUTO_PROFILER_TRACING_MARKER_DOCSHELL(categoryString, markerName, \
categoryPair, docShell)
#else // ndef MOZ_GECKO_PROFILER
# include "mozilla/ProfilerLabels.h"
# include "nsJSUtils.h" // for nsJSUtils::GetCurrentlyRunningCodeInnerWindowID
#include "mozilla/ProfilerLabels.h"
#include "nsJSUtils.h" // for nsJSUtils::GetCurrentlyRunningCodeInnerWindowID
class nsIDocShell;
namespace geckoprofiler::markers::detail {
// Please do not use anything from the detail namespace outside the profiler.
#ifdef MOZ_GECKO_PROFILER
mozilla::Maybe<uint64_t> profiler_get_inner_window_id_from_docshell(
nsIDocShell* aDocshell);
#else
inline mozilla::Maybe<uint64_t> profiler_get_inner_window_id_from_docshell(
nsIDocShell* aDocshell) {
return mozilla::Nothing();
}
#endif // MOZ_GECKO_PROFILER
} // namespace geckoprofiler::markers::detail
// This is a helper function to get the Inner Window ID from DocShell but it's
@ -84,17 +80,18 @@ inline mozilla::MarkerInnerWindowId MarkerInnerWindowIdFromJSContext(
nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(aContext));
}
// Forward-declaration. TODO: Move to more common header, see bug 1681416.
bool profiler_capture_backtrace_into(
mozilla::ProfileChunkedBuffer& aChunkedBuffer,
mozilla::StackCaptureOptions aCaptureOptions);
// Bring category names from Base Profiler into the geckoprofiler::category
// namespace, for consistency with other Gecko Profiler identifiers.
namespace geckoprofiler::category {
using namespace ::mozilla::baseprofiler::category;
}
#ifdef MOZ_GECKO_PROFILER
// Forward-declaration. TODO: Move to more common header, see bug 1681416.
bool profiler_capture_backtrace_into(
mozilla::ProfileChunkedBuffer& aChunkedBuffer,
mozilla::StackCaptureOptions aCaptureOptions);
// Add a marker to a given buffer. `AddMarker()` and related macros should be
// used in most cases, see below for more information about them and the
// paramters; This function may be useful when markers need to be recorded in a
@ -121,6 +118,7 @@ inline mozilla::ProfileBufferBlockIndex AddMarkerToBuffer(
return AddMarkerToBuffer(aBuffer, aName, aCategory, std::move(aOptions),
mozilla::baseprofiler::markers::NoPayload{});
}
#endif
// Add a marker to the Gecko Profiler buffer.
// - aName: Main name of this marker.
@ -135,12 +133,16 @@ mozilla::ProfileBufferBlockIndex profiler_add_marker(
const mozilla::ProfilerString8View& aName,
const mozilla::MarkerCategory& aCategory, mozilla::MarkerOptions&& aOptions,
MarkerType aMarkerType, const PayloadArguments&... aPayloadArguments) {
#ifndef MOZ_GECKO_PROFILER
return {};
#else
if (!profiler_can_accept_markers()) {
return {};
}
return ::AddMarkerToBuffer(profiler_markers_detail::CachedCoreBuffer(), aName,
aCategory, std::move(aOptions), aMarkerType,
aPayloadArguments...);
#endif
}
// Add a marker (without payload) to the Gecko Profiler buffer.
@ -154,22 +156,22 @@ inline mozilla::ProfileBufferBlockIndex profiler_add_marker(
// Same as `profiler_add_marker()` (without payload). This macro is safe to use
// even if MOZ_GECKO_PROFILER is not #defined.
# define PROFILER_MARKER_UNTYPED(markerName, categoryName, ...) \
do { \
AUTO_PROFILER_STATS(PROFILER_MARKER_UNTYPED); \
::profiler_add_marker( \
markerName, ::geckoprofiler::category::categoryName, ##__VA_ARGS__); \
} while (false)
#define PROFILER_MARKER_UNTYPED(markerName, categoryName, ...) \
do { \
AUTO_PROFILER_STATS(PROFILER_MARKER_UNTYPED); \
::profiler_add_marker(markerName, ::geckoprofiler::category::categoryName, \
##__VA_ARGS__); \
} while (false)
// Same as `profiler_add_marker()` (with payload). This macro is safe to use
// even if MOZ_GECKO_PROFILER is not #defined.
# define PROFILER_MARKER(markerName, categoryName, options, MarkerType, ...) \
do { \
AUTO_PROFILER_STATS(PROFILER_MARKER_with_##MarkerType); \
::profiler_add_marker( \
markerName, ::geckoprofiler::category::categoryName, options, \
::geckoprofiler::markers::MarkerType{}, ##__VA_ARGS__); \
} while (false)
#define PROFILER_MARKER(markerName, categoryName, options, MarkerType, ...) \
do { \
AUTO_PROFILER_STATS(PROFILER_MARKER_with_##MarkerType); \
::profiler_add_marker(markerName, ::geckoprofiler::category::categoryName, \
options, ::geckoprofiler::markers::MarkerType{}, \
##__VA_ARGS__); \
} while (false)
namespace geckoprofiler::markers {
// Most common marker types. Others are in ProfilerMarkerTypes.h.
@ -179,13 +181,13 @@ using Tracing = mozilla::baseprofiler::markers::Tracing;
// Add a text marker. This macro is safe to use even if MOZ_GECKO_PROFILER is
// not #defined.
# define PROFILER_MARKER_TEXT(markerName, categoryName, options, text) \
do { \
AUTO_PROFILER_STATS(PROFILER_MARKER_TEXT); \
::profiler_add_marker(markerName, \
::geckoprofiler::category::categoryName, options, \
::geckoprofiler::markers::TextMarker{}, text); \
} while (false)
#define PROFILER_MARKER_TEXT(markerName, categoryName, options, text) \
do { \
AUTO_PROFILER_STATS(PROFILER_MARKER_TEXT); \
::profiler_add_marker(markerName, ::geckoprofiler::category::categoryName, \
options, ::geckoprofiler::markers::TextMarker{}, \
text); \
} while (false)
// RAII object that adds a PROFILER_MARKER_TEXT when destroyed; the marker's
// timing will be the interval from construction (unless an instant or start
@ -226,10 +228,10 @@ class MOZ_RAII AutoProfilerTextMarker {
// Creates an AutoProfilerTextMarker RAII object. This macro is safe to use
// even if MOZ_GECKO_PROFILER is not #defined.
# define AUTO_PROFILER_MARKER_TEXT(markerName, categoryName, options, text) \
AutoProfilerTextMarker PROFILER_RAII( \
markerName, ::mozilla::baseprofiler::category::categoryName, options, \
text)
#define AUTO_PROFILER_MARKER_TEXT(markerName, categoryName, options, text) \
AutoProfilerTextMarker PROFILER_RAII( \
markerName, ::mozilla::baseprofiler::category::categoryName, options, \
text)
class MOZ_RAII AutoProfilerTracing {
public:
@ -289,18 +291,18 @@ class MOZ_RAII AutoProfilerTracing {
};
// Adds a START/END pair of tracing markers.
# define AUTO_PROFILER_TRACING_MARKER(categoryString, markerName, \
categoryPair) \
AutoProfilerTracing PROFILER_RAII(categoryString, markerName, \
geckoprofiler::category::categoryPair, \
mozilla::Nothing())
# define AUTO_PROFILER_TRACING_MARKER_DOCSHELL(categoryString, markerName, \
categoryPair, docShell) \
AutoProfilerTracing PROFILER_RAII( \
categoryString, markerName, geckoprofiler::category::categoryPair, \
geckoprofiler::markers::detail:: \
profiler_get_inner_window_id_from_docshell(docShell))
#define AUTO_PROFILER_TRACING_MARKER(categoryString, markerName, categoryPair) \
AutoProfilerTracing PROFILER_RAII(categoryString, markerName, \
geckoprofiler::category::categoryPair, \
mozilla::Nothing())
#define AUTO_PROFILER_TRACING_MARKER_DOCSHELL(categoryString, markerName, \
categoryPair, docShell) \
AutoProfilerTracing PROFILER_RAII( \
categoryString, markerName, geckoprofiler::category::categoryPair, \
geckoprofiler::markers::detail:: \
profiler_get_inner_window_id_from_docshell(docShell))
#ifdef MOZ_GECKO_PROFILER
extern template mozilla::ProfileBufferBlockIndex AddMarkerToBuffer(
mozilla::ProfileChunkedBuffer&, const mozilla::ProfilerString8View&,
const mozilla::MarkerCategory&, mozilla::MarkerOptions&&,
@ -325,7 +327,6 @@ extern template mozilla::ProfileBufferBlockIndex profiler_add_marker(
const mozilla::ProfilerString8View&, const mozilla::MarkerCategory&,
mozilla::MarkerOptions&&, mozilla::baseprofiler::markers::Tracing,
const mozilla::ProfilerString8View&);
#endif // nfed MOZ_GECKO_PROFILER else
#endif // MOZ_GECKO_PROFILER
#endif // ProfilerMarkers_h

View File

@ -168,6 +168,7 @@ inline bool profiler_thread_is_being_profiled() { return false; }
inline bool profiler_is_active_and_thread_is_registered() { return false; }
inline bool profiler_feature_active(uint32_t aFeature) { return false; }
inline bool profiler_is_locked_on_current_thread() { return false; }
inline int profiler_current_thread_id() { return 0; }
inline void profiler_add_state_change_callback(
ProfilingStateSet aProfilingStateSet,
ProfilingStateChangeCallback&& aCallback, uintptr_t aUniqueIdentifier = 0) {