Bug 1492121 - Added "BASE" to all public macros - r=njn

E.g., AUTO_PROFILER_INIT -> AUTO_BASE_PROFILER_INIT.
This will allow #including BaseProfiler.h anywhere as needed, without clashing
with Gecko Profiler macros.

Differential Revision: https://phabricator.services.mozilla.com/D31929

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Gerald Squelart 2019-06-05 23:41:01 +00:00
Родитель bf5eeb02e8
Коммит bdd55c576d
7 изменённых файлов: 238 добавлений и 228 удалений

Просмотреть файл

@ -27,9 +27,9 @@ namespace JS {
name, name,
#define SUBCATEGORY_ENUMS_END_CATEGORY \ #define SUBCATEGORY_ENUMS_END_CATEGORY \
}; };
PROFILING_CATEGORY_LIST(SUBCATEGORY_ENUMS_BEGIN_CATEGORY, BASE_PROFILING_CATEGORY_LIST(SUBCATEGORY_ENUMS_BEGIN_CATEGORY,
SUBCATEGORY_ENUMS_SUBCATEGORY, SUBCATEGORY_ENUMS_SUBCATEGORY,
SUBCATEGORY_ENUMS_END_CATEGORY) SUBCATEGORY_ENUMS_END_CATEGORY)
#undef SUBCATEGORY_ENUMS_BEGIN_CATEGORY #undef SUBCATEGORY_ENUMS_BEGIN_CATEGORY
#undef SUBCATEGORY_ENUMS_SUBCATEGORY #undef SUBCATEGORY_ENUMS_SUBCATEGORY
#undef SUBCATEGORY_ENUMS_END_CATEGORY #undef SUBCATEGORY_ENUMS_END_CATEGORY
@ -44,9 +44,9 @@ PROFILING_CATEGORY_LIST(SUBCATEGORY_ENUMS_BEGIN_CATEGORY,
uint32_t(ProfilingSubcategory_##category::name), labelAsString}, uint32_t(ProfilingSubcategory_##category::name), labelAsString},
#define CATEGORY_INFO_END_CATEGORY #define CATEGORY_INFO_END_CATEGORY
const ProfilingCategoryPairInfo sProfilingCategoryPairInfo[] = { const ProfilingCategoryPairInfo sProfilingCategoryPairInfo[] = {
PROFILING_CATEGORY_LIST(CATEGORY_INFO_BEGIN_CATEGORY, BASE_PROFILING_CATEGORY_LIST(CATEGORY_INFO_BEGIN_CATEGORY,
CATEGORY_INFO_SUBCATEGORY, CATEGORY_INFO_SUBCATEGORY,
CATEGORY_INFO_END_CATEGORY) CATEGORY_INFO_END_CATEGORY)
}; };
#undef CATEGORY_INFO_BEGIN_CATEGORY #undef CATEGORY_INFO_BEGIN_CATEGORY
#undef CATEGORY_INFO_SUBCATEGORY #undef CATEGORY_INFO_SUBCATEGORY

Просмотреть файл

@ -162,7 +162,7 @@ static uint32_t AvailableFeatures() {
ProfilerFeature::Set##Name_(features); ProfilerFeature::Set##Name_(features);
// Add all the possible features. // Add all the possible features.
PROFILER_FOR_EACH_FEATURE(ADD_FEATURE) BASE_PROFILER_FOR_EACH_FEATURE(ADD_FEATURE)
# undef ADD_FEATURE # undef ADD_FEATURE
@ -593,7 +593,7 @@ class ActivePS {
return ProfilerFeature::Has##Name_(sInstance->mFeatures); \ return ProfilerFeature::Has##Name_(sInstance->mFeatures); \
} }
PROFILER_FOR_EACH_FEATURE(PS_GET_FEATURE) BASE_PROFILER_FOR_EACH_FEATURE(PS_GET_FEATURE)
# undef PS_GET_FEATURE # undef PS_GET_FEATURE
@ -1504,8 +1504,9 @@ static void StreamCategories(SpliceableJSONWriter& aWriter) {
# define CATEGORY_JSON_SUBCATEGORY(category, name, labelAsString) # define CATEGORY_JSON_SUBCATEGORY(category, name, labelAsString)
# define CATEGORY_JSON_END_CATEGORY aWriter.EndObject(); # define CATEGORY_JSON_END_CATEGORY aWriter.EndObject();
PROFILING_CATEGORY_LIST(CATEGORY_JSON_BEGIN_CATEGORY, BASE_PROFILING_CATEGORY_LIST(CATEGORY_JSON_BEGIN_CATEGORY,
CATEGORY_JSON_SUBCATEGORY, CATEGORY_JSON_END_CATEGORY) CATEGORY_JSON_SUBCATEGORY,
CATEGORY_JSON_END_CATEGORY)
# undef CATEGORY_JSON_BEGIN_CATEGORY # undef CATEGORY_JSON_BEGIN_CATEGORY
# undef CATEGORY_JSON_SUBCATEGORY # undef CATEGORY_JSON_SUBCATEGORY
@ -1731,17 +1732,18 @@ static void PrintUsageThenExit(int aExitCode) {
" Features: (x=unavailable, D/d=default/unavailable,\n" " Features: (x=unavailable, D/d=default/unavailable,\n"
" S/s=MOZ_BASE_PROFILER_STARTUP extra " " S/s=MOZ_BASE_PROFILER_STARTUP extra "
"default/unavailable)\n", "default/unavailable)\n",
unsigned(PROFILER_DEFAULT_ENTRIES), unsigned(BASE_PROFILER_DEFAULT_ENTRIES),
unsigned(PROFILER_DEFAULT_STARTUP_ENTRIES), sizeof(ProfileBufferEntry), unsigned(BASE_PROFILER_DEFAULT_STARTUP_ENTRIES),
sizeof(ProfileBufferEntry) * PROFILER_DEFAULT_ENTRIES, sizeof(ProfileBufferEntry),
sizeof(ProfileBufferEntry) * PROFILER_DEFAULT_STARTUP_ENTRIES); sizeof(ProfileBufferEntry) * BASE_PROFILER_DEFAULT_ENTRIES,
sizeof(ProfileBufferEntry) * BASE_PROFILER_DEFAULT_STARTUP_ENTRIES);
# define PRINT_FEATURE(n_, str_, Name_, desc_) \ # define PRINT_FEATURE(n_, str_, Name_, desc_) \
printf(" %c %5u: \"%s\" (%s)\n", \ printf(" %c %5u: \"%s\" (%s)\n", \
FeatureCategory(ProfilerFeature::Name_), ProfilerFeature::Name_, \ FeatureCategory(ProfilerFeature::Name_), ProfilerFeature::Name_, \
str_, desc_); str_, desc_);
PROFILER_FOR_EACH_FEATURE(PRINT_FEATURE) BASE_PROFILER_FOR_EACH_FEATURE(PRINT_FEATURE)
# undef PRINT_FEATURE # undef PRINT_FEATURE
@ -2067,7 +2069,7 @@ static uint32_t ParseFeature(const char* aFeature, bool aIsStartup) {
return ProfilerFeature::Name_; \ return ProfilerFeature::Name_; \
} }
PROFILER_FOR_EACH_FEATURE(PARSE_FEATURE_BIT) BASE_PROFILER_FOR_EACH_FEATURE(PARSE_FEATURE_BIT)
# undef PARSE_FEATURE_BIT # undef PARSE_FEATURE_BIT
@ -2182,9 +2184,9 @@ void profiler_init(void* aStackTop) {
Vector<const char*> filters; Vector<const char*> filters;
MOZ_RELEASE_ASSERT(filters.append(kMainThreadName)); MOZ_RELEASE_ASSERT(filters.append(kMainThreadName));
uint32_t capacity = PROFILER_DEFAULT_ENTRIES; uint32_t capacity = BASE_PROFILER_DEFAULT_ENTRIES;
Maybe<double> duration = Nothing(); Maybe<double> duration = Nothing();
double interval = PROFILER_DEFAULT_INTERVAL; double interval = BASE_PROFILER_DEFAULT_INTERVAL;
{ {
PSAutoLock lock; PSAutoLock lock;
@ -2212,7 +2214,7 @@ void profiler_init(void* aStackTop) {
LOG("- MOZ_BASE_PROFILER_STARTUP is set"); LOG("- MOZ_BASE_PROFILER_STARTUP is set");
// Startup default capacity may be different. // Startup default capacity may be different.
capacity = PROFILER_DEFAULT_STARTUP_ENTRIES; capacity = BASE_PROFILER_DEFAULT_STARTUP_ENTRIES;
const char* startupCapacity = getenv("MOZ_BASE_PROFILER_STARTUP_ENTRIES"); const char* startupCapacity = getenv("MOZ_BASE_PROFILER_STARTUP_ENTRIES");
if (startupCapacity && startupCapacity[0] != '\0') { if (startupCapacity && startupCapacity[0] != '\0') {
@ -2585,7 +2587,7 @@ static void locked_profiler_start(PSLockRef aLock, uint32_t aCapacity,
LOG("- feature = %s", str_); \ LOG("- feature = %s", str_); \
} }
PROFILER_FOR_EACH_FEATURE(LOG_FEATURE) BASE_PROFILER_FOR_EACH_FEATURE(LOG_FEATURE)
# undef LOG_FEATURE # undef LOG_FEATURE
@ -2601,13 +2603,13 @@ static void locked_profiler_start(PSLockRef aLock, uint32_t aCapacity,
# endif # endif
// Fall back to the default values if the passed-in values are unreasonable. // Fall back to the default values if the passed-in values are unreasonable.
uint32_t capacity = aCapacity > 0 ? aCapacity : PROFILER_DEFAULT_ENTRIES; uint32_t capacity = aCapacity > 0 ? aCapacity : BASE_PROFILER_DEFAULT_ENTRIES;
Maybe<double> duration = aDuration; Maybe<double> duration = aDuration;
if (aDuration && *aDuration <= 0) { if (aDuration && *aDuration <= 0) {
duration = Nothing(); duration = Nothing();
} }
double interval = aInterval > 0 ? aInterval : PROFILER_DEFAULT_INTERVAL; double interval = aInterval > 0 ? aInterval : BASE_PROFILER_DEFAULT_INTERVAL;
ActivePS::Create(aLock, capacity, interval, aFeatures, aFilters, aFilterCount, ActivePS::Create(aLock, capacity, interval, aFeatures, aFilters, aFilterCount,
duration); duration);

Просмотреть файл

@ -45,36 +45,37 @@
// following macros, which encapsulate the most common operations and thus // following macros, which encapsulate the most common operations and thus
// avoid the need for many #ifdefs. // avoid the need for many #ifdefs.
# define AUTO_PROFILER_INIT # define AUTO_BASE_PROFILER_INIT
# define PROFILER_REGISTER_THREAD(name) # define BASE_PROFILER_REGISTER_THREAD(name)
# define PROFILER_UNREGISTER_THREAD() # define BASE_PROFILER_UNREGISTER_THREAD()
# define AUTO_PROFILER_REGISTER_THREAD(name) # define AUTO_BASE_PROFILER_REGISTER_THREAD(name)
# define AUTO_PROFILER_THREAD_SLEEP # define AUTO_BASE_PROFILER_THREAD_SLEEP
# define AUTO_PROFILER_THREAD_WAKE # define AUTO_BASE_PROFILER_THREAD_WAKE
# define AUTO_PROFILER_LABEL(label, categoryPair) # define AUTO_BASE_PROFILER_LABEL(label, categoryPair)
# define AUTO_PROFILER_LABEL_CATEGORY_PAIR(categoryPair) # define AUTO_BASE_PROFILER_LABEL_CATEGORY_PAIR(categoryPair)
# define AUTO_PROFILER_LABEL_DYNAMIC_CSTR(label, categoryPair, cStr) # define AUTO_BASE_PROFILER_LABEL_DYNAMIC_CSTR(label, categoryPair, cStr)
# define AUTO_PROFILER_LABEL_DYNAMIC_STRING(label, categoryPair, str) # define AUTO_BASE_PROFILER_LABEL_DYNAMIC_STRING(label, categoryPair, str)
# define AUTO_PROFILER_LABEL_FAST(label, categoryPair, ctx) # define AUTO_BASE_PROFILER_LABEL_FAST(label, categoryPair, ctx)
# define AUTO_PROFILER_LABEL_DYNAMIC_FAST(label, dynamicString, categoryPair, \ # define AUTO_BASE_PROFILER_LABEL_DYNAMIC_FAST(label, dynamicString, \
ctx, flags) categoryPair, ctx, flags)
# define PROFILER_ADD_MARKER(markerName, categoryPair) # define BASE_PROFILER_ADD_MARKER(markerName, categoryPair)
# define DECLARE_DOCSHELL_AND_HISTORY_ID(docShell) # define MOZDECLARE_DOCSHELL_AND_HISTORY_ID(docShell)
# define PROFILER_TRACING(categoryString, markerName, categoryPair, kind) # define BASE_PROFILER_TRACING(categoryString, markerName, categoryPair, kind)
# define PROFILER_TRACING_DOCSHELL(categoryString, markerName, categoryPair, \ # define BASE_PROFILER_TRACING_DOCSHELL(categoryString, markerName, \
kind, docshell) categoryPair, kind, docshell)
# define AUTO_PROFILER_TRACING(categoryString, markerName, categoryPair) # define AUTO_BASE_PROFILER_TRACING(categoryString, markerName, categoryPair)
# define AUTO_PROFILER_TRACING_DOCSHELL(categoryString, markerName, \ # define AUTO_BASE_PROFILER_TRACING_DOCSHELL(categoryString, markerName, \
categoryPair, docShell) categoryPair, docShell)
# define AUTO_PROFILER_TEXT_MARKER_CAUSE(markerName, text, categoryPair, cause) # define AUTO_BASE_PROFILER_TEXT_MARKER_CAUSE(markerName, text, categoryPair, \
# define AUTO_PROFILER_TEXT_MARKER_DOCSHELL(markerName, text, categoryPair, \ cause)
docShell) # define AUTO_BASE_PROFILER_TEXT_MARKER_DOCSHELL(markerName, text, \
# define AUTO_PROFILER_TEXT_MARKER_DOCSHELL_CAUSE( \ categoryPair, docShell)
# define AUTO_BASE_PROFILER_TEXT_MARKER_DOCSHELL_CAUSE( \
markerName, text, categoryPair, docShell, cause) markerName, text, categoryPair, docShell, cause)
#else // !MOZ_BASE_PROFILER #else // !MOZ_BASE_PROFILER
@ -104,10 +105,10 @@ template <class T, size_t MinInlineCapacity, class AllocPolicy>
class Vector; class Vector;
} // namespace mozilla } // namespace mozilla
// Macros used by the AUTO_PROFILER_* macros below. // Macros used by the AUTO_BASE_PROFILER_* macros below.
# define PROFILER_RAII_PASTE(id, line) id##line # define BASE_PROFILER_RAII_PASTE(id, line) id##line
# define PROFILER_RAII_EXPAND(id, line) PROFILER_RAII_PASTE(id, line) # define BASE_PROFILER_RAII_EXPAND(id, line) BASE_PROFILER_RAII_PASTE(id, line)
# define PROFILER_RAII PROFILER_RAII_EXPAND(raiiObject, __LINE__) # define BASE_PROFILER_RAII BASE_PROFILER_RAII_EXPAND(raiiObject, __LINE__)
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Profiler features // Profiler features
@ -118,7 +119,7 @@ class Vector;
// values are used internally only and so can be changed without consequence. // values are used internally only and so can be changed without consequence.
// Any changes to this list should also be applied to the feature list in // Any changes to this list should also be applied to the feature list in
// toolkit/components/extensions/schemas/geckoProfiler.json. // toolkit/components/extensions/schemas/geckoProfiler.json.
# define PROFILER_FOR_EACH_FEATURE(MACRO) \ # define BASE_PROFILER_FOR_EACH_FEATURE(MACRO) \
MACRO(0, "java", Java, "Profile Java code, Android only") \ MACRO(0, "java", Java, "Profile Java code, Android only") \
\ \
MACRO(1, "js", JS, \ MACRO(1, "js", JS, \
@ -171,7 +172,7 @@ struct ProfilerFeature {
} }
// Define a bitfield constant, a getter, and two setters for each feature. // Define a bitfield constant, a getter, and two setters for each feature.
PROFILER_FOR_EACH_FEATURE(DECLARE) BASE_PROFILER_FOR_EACH_FEATURE(DECLARE)
# undef DECLARE # undef DECLARE
}; };
@ -207,7 +208,7 @@ class RacyFeatures {
# define NO_OVERLAP(n_, str_, Name_, desc_) \ # define NO_OVERLAP(n_, str_, Name_, desc_) \
static_assert(ProfilerFeature::Name_ != Active, "bad Active value"); static_assert(ProfilerFeature::Name_ != Active, "bad Active value");
PROFILER_FOR_EACH_FEATURE(NO_OVERLAP); BASE_PROFILER_FOR_EACH_FEATURE(NO_OVERLAP);
# undef NO_OVERLAP # undef NO_OVERLAP
@ -230,7 +231,7 @@ MFBT_API bool IsThreadBeingProfiled();
// Start and stop the profiler // Start and stop the profiler
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
static constexpr uint32_t PROFILER_DEFAULT_ENTRIES = static constexpr uint32_t BASE_PROFILER_DEFAULT_ENTRIES =
# if !defined(ARCH_ARMV6) # if !defined(ARCH_ARMV6)
1u << 20; // 1'048'576 1u << 20; // 1'048'576
# else # else
@ -239,15 +240,15 @@ static constexpr uint32_t PROFILER_DEFAULT_ENTRIES =
// Startup profiling usually need to capture more data, especially on slow // Startup profiling usually need to capture more data, especially on slow
// systems. // systems.
static constexpr uint32_t PROFILER_DEFAULT_STARTUP_ENTRIES = static constexpr uint32_t BASE_PROFILER_DEFAULT_STARTUP_ENTRIES =
# if !defined(ARCH_ARMV6) # if !defined(ARCH_ARMV6)
1u << 22; // 4'194'304 1u << 22; // 4'194'304
# else # else
1u << 17; // 131'072 1u << 17; // 131'072
# endif # endif
# define PROFILER_DEFAULT_DURATION 20 # define BASE_PROFILER_DEFAULT_DURATION 20
# define PROFILER_DEFAULT_INTERVAL 1 # define BASE_PROFILER_DEFAULT_INTERVAL 1
// Initialize the profiler. If MOZ_BASE_PROFILER_STARTUP is set the profiler // Initialize the profiler. If MOZ_BASE_PROFILER_STARTUP is set the profiler
// will also be started. This call must happen before any other profiler calls // will also be started. This call must happen before any other profiler calls
@ -255,7 +256,7 @@ static constexpr uint32_t PROFILER_DEFAULT_STARTUP_ENTRIES =
// already run). // already run).
MFBT_API void profiler_init(void* stackTop); MFBT_API void profiler_init(void* stackTop);
# define AUTO_PROFILER_INIT mozilla::AutoProfilerInit PROFILER_RAII # define AUTO_BASE_PROFILER_INIT mozilla::AutoProfilerInit BASE_PROFILER_RAII
// Clean up the profiler module, stopping it if required. This function may // Clean up the profiler module, stopping it if required. This function may
// also save a shutdown profile if requested. No profiler calls should happen // also save a shutdown profile if requested. No profiler calls should happen
@ -303,12 +304,12 @@ MFBT_API void profiler_ensure_started(
// Register/unregister threads with the profiler. Both functions operate the // Register/unregister threads with the profiler. Both functions operate the
// same whether the profiler is active or inactive. // same whether the profiler is active or inactive.
# define PROFILER_REGISTER_THREAD(name) \ # define BASE_PROFILER_REGISTER_THREAD(name) \
do { \ do { \
char stackTop; \ char stackTop; \
profiler_register_thread(name, &stackTop); \ profiler_register_thread(name, &stackTop); \
} while (0) } while (0)
# define PROFILER_UNREGISTER_THREAD() profiler_unregister_thread() # define BASE_PROFILER_UNREGISTER_THREAD() profiler_unregister_thread()
MFBT_API ProfilingStack* profiler_register_thread(const char* name, MFBT_API ProfilingStack* profiler_register_thread(const char* name,
void* guessStackTop); void* guessStackTop);
MFBT_API void profiler_unregister_thread(); MFBT_API void profiler_unregister_thread();
@ -348,8 +349,8 @@ MFBT_API void profiler_add_sampled_counter(BaseProfilerCount* aCounter);
MFBT_API void profiler_remove_sampled_counter(BaseProfilerCount* aCounter); MFBT_API void profiler_remove_sampled_counter(BaseProfilerCount* aCounter);
// Register and unregister a thread within a scope. // Register and unregister a thread within a scope.
# define AUTO_PROFILER_REGISTER_THREAD(name) \ # define AUTO_BASE_PROFILER_REGISTER_THREAD(name) \
mozilla::AutoProfilerRegisterThread PROFILER_RAII(name) mozilla::AutoProfilerRegisterThread BASE_PROFILER_RAII(name)
// Pause and resume the profiler. No-ops if the profiler is inactive. While // Pause and resume the profiler. No-ops if the profiler is inactive. While
// paused the profile will not take any samples and will not record any data // paused the profile will not take any samples and will not record any data
@ -368,10 +369,10 @@ MFBT_API void profiler_thread_sleep();
MFBT_API void profiler_thread_wake(); MFBT_API void profiler_thread_wake();
// Mark a thread as asleep/awake within a scope. // Mark a thread as asleep/awake within a scope.
# define AUTO_PROFILER_THREAD_SLEEP \ # define AUTO_BASE_PROFILER_THREAD_SLEEP \
mozilla::AutoProfilerThreadSleep PROFILER_RAII mozilla::AutoProfilerThreadSleep BASE_PROFILER_RAII
# define AUTO_PROFILER_THREAD_WAKE \ # define AUTO_BASE_PROFILER_THREAD_WAKE \
mozilla::AutoProfilerThreadWake PROFILER_RAII mozilla::AutoProfilerThreadWake BASE_PROFILER_RAII
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Get information from the profiler // Get information from the profiler
@ -514,28 +515,30 @@ MFBT_API mozilla::Maybe<ProfilerBufferInfo> profiler_get_buffer_info();
// name.) If the label applies to only part of a function, you can qualify it // name.) If the label applies to only part of a function, you can qualify it
// like this: "ClassName::FunctionName:PartName". // like this: "ClassName::FunctionName:PartName".
// //
// Use AUTO_PROFILER_LABEL_DYNAMIC_* if you want to add additional / dynamic // Use AUTO_BASE_PROFILER_LABEL_DYNAMIC_* if you want to add additional /
// information to the label stack frame. // dynamic information to the label stack frame.
# define AUTO_PROFILER_LABEL(label, categoryPair) \ # define AUTO_BASE_PROFILER_LABEL(label, categoryPair) \
mozilla::AutoProfilerLabel PROFILER_RAII( \ mozilla::AutoProfilerLabel BASE_PROFILER_RAII( \
label, nullptr, JS::ProfilingCategoryPair::categoryPair) label, nullptr, JS::ProfilingCategoryPair::categoryPair)
// Similar to AUTO_PROFILER_LABEL, but with only one argument: the category // Similar to AUTO_BASE_PROFILER_LABEL, but with only one argument: the category
// pair. The label string is taken from the category pair. This is convenient // pair. The label string is taken from the category pair. This is convenient
// for labels like AUTO_PROFILER_LABEL_CATEGORY_PAIR(GRAPHICS_LayerBuilding) // for labels like
// which would otherwise just repeat the string. // AUTO_BASE_PROFILER_LABEL_CATEGORY_PAIR(GRAPHICS_LayerBuilding) which would
# define AUTO_PROFILER_LABEL_CATEGORY_PAIR(categoryPair) \ // otherwise just repeat the string.
mozilla::AutoProfilerLabel PROFILER_RAII( \ # define AUTO_BASE_PROFILER_LABEL_CATEGORY_PAIR(categoryPair) \
"", nullptr, JS::ProfilingCategoryPair::categoryPair, \ mozilla::AutoProfilerLabel BASE_PROFILER_RAII( \
uint32_t(js::ProfilingStackFrame::Flags:: \ "", nullptr, JS::ProfilingCategoryPair::categoryPair, \
uint32_t(js::ProfilingStackFrame::Flags:: \
LABEL_DETERMINED_BY_CATEGORY_PAIR)) LABEL_DETERMINED_BY_CATEGORY_PAIR))
// Similar to AUTO_PROFILER_LABEL, but with an additional string. The inserted // Similar to AUTO_BASE_PROFILER_LABEL, but with an additional string. The
// RAII object stores the cStr pointer in a field; it does not copy the string. // inserted RAII object stores the cStr pointer in a field; it does not copy the
// string.
// //
// WARNING: This means that the string you pass to this macro needs to live at // WARNING: This means that the string you pass to this macro needs to live at
// least until the end of the current scope. Be careful using this macro with // least until the end of the current scope. Be careful using this macro with
// ns[C]String; the other AUTO_PROFILER_LABEL_DYNAMIC_* macros below are // ns[C]String; the other AUTO_BASE_PROFILER_LABEL_DYNAMIC_* macros below are
// preferred because they avoid this problem. // preferred because they avoid this problem.
// //
// If the profiler samples the current thread and walks the label stack while // If the profiler samples the current thread and walks the label stack while
@ -543,49 +546,48 @@ MFBT_API mozilla::Maybe<ProfilerBufferInfo> profiler_get_buffer_info();
// profile buffer. So there's one string copy operation, and it happens at // profile buffer. So there's one string copy operation, and it happens at
// sample time. // sample time.
// //
// Compare this to the plain AUTO_PROFILER_LABEL macro, which only accepts // Compare this to the plain AUTO_BASE_PROFILER_LABEL macro, which only accepts
// literal strings: When the label stack frames generated by // literal strings: When the label stack frames generated by
// AUTO_PROFILER_LABEL are sampled, no string copy needs to be made because the // AUTO_BASE_PROFILER_LABEL are sampled, no string copy needs to be made because
// profile buffer can just store the raw pointers to the literal strings. // the profile buffer can just store the raw pointers to the literal strings.
// Consequently, AUTO_PROFILER_LABEL frames take up considerably less space in // Consequently, AUTO_BASE_PROFILER_LABEL frames take up considerably less space
// the profile buffer than AUTO_PROFILER_LABEL_DYNAMIC_* frames. // in the profile buffer than AUTO_BASE_PROFILER_LABEL_DYNAMIC_* frames.
# define AUTO_PROFILER_LABEL_DYNAMIC_CSTR(label, categoryPair, cStr) \ # define AUTO_BASE_PROFILER_LABEL_DYNAMIC_CSTR(label, categoryPair, cStr) \
mozilla::AutoProfilerLabel PROFILER_RAII( \ mozilla::AutoProfilerLabel BASE_PROFILER_RAII( \
label, cStr, JS::ProfilingCategoryPair::categoryPair) label, cStr, JS::ProfilingCategoryPair::categoryPair)
// Similar to AUTO_PROFILER_LABEL_DYNAMIC_CSTR, but takes an std::string. // Similar to AUTO_BASE_PROFILER_LABEL_DYNAMIC_CSTR, but takes an std::string.
// //
// Note: The use of the Maybe<>s ensures the scopes for the dynamic string and // Note: The use of the Maybe<>s ensures the scopes for the dynamic string and
// the AutoProfilerLabel are appropriate, while also not incurring the runtime // the AutoProfilerLabel are appropriate, while also not incurring the runtime
// cost of the string assignment unless the profiler is active. Therefore, // cost of the string assignment unless the profiler is active. Therefore,
// unlike AUTO_PROFILER_LABEL and AUTO_PROFILER_LABEL_DYNAMIC_CSTR, this macro // unlike AUTO_BASE_PROFILER_LABEL and AUTO_BASE_PROFILER_LABEL_DYNAMIC_CSTR,
// doesn't push/pop a label when the profiler is inactive. // this macro doesn't push/pop a label when the profiler is inactive.
# define AUTO_PROFILER_LABEL_DYNAMIC_STRING(label, categoryPair, str) \ # define AUTO_BASE_PROFILER_LABEL_DYNAMIC_STRING(label, categoryPair, str) \
mozilla::Maybe<std::string> autoStr; \ mozilla::Maybe<std::string> autoStr; \
mozilla::Maybe<mozilla::AutoProfilerLabel> raiiObjectString; \ mozilla::Maybe<mozilla::AutoProfilerLabel> raiiObjectString; \
if (profiler_is_active()) { \ if (profiler_is_active()) { \
autoStr.emplace(str); \ autoStr.emplace(str); \
raiiObjectString.emplace(label, autoStr->c_str(), \ raiiObjectString.emplace(label, autoStr->c_str(), \
JS::ProfilingCategoryPair::categoryPair); \ JS::ProfilingCategoryPair::categoryPair); \
} }
// Similar to AUTO_PROFILER_LABEL, but accepting a JSContext* parameter, and a // Similar to AUTO_BASE_PROFILER_LABEL, but accepting a JSContext* parameter,
// no-op if the profiler is disabled. // and a no-op if the profiler is disabled. Used to annotate functions for which
// Used to annotate functions for which overhead in the range of nanoseconds is // overhead in the range of nanoseconds is noticeable. It avoids overhead from
// noticeable. It avoids overhead from the TLS lookup because it can get the // the TLS lookup because it can get the ProfilingStack from the JS context, and
// ProfilingStack from the JS context, and avoids almost all overhead in the // avoids almost all overhead in the case where the profiler is disabled.
// case where the profiler is disabled. # define AUTO_BASE_PROFILER_LABEL_FAST(label, categoryPair, ctx) \
# define AUTO_PROFILER_LABEL_FAST(label, categoryPair, ctx) \ mozilla::AutoProfilerLabel BASE_PROFILER_RAII( \
mozilla::AutoProfilerLabel PROFILER_RAII( \
ctx, label, nullptr, JS::ProfilingCategoryPair::categoryPair) ctx, label, nullptr, JS::ProfilingCategoryPair::categoryPair)
// Similar to AUTO_PROFILER_LABEL_FAST, but also takes an extra string and an // Similar to AUTO_BASE_PROFILER_LABEL_FAST, but also takes an extra string and
// additional set of flags. The flags parameter should carry values from the // an additional set of flags. The flags parameter should carry values from the
// js::ProfilingStackFrame::Flags enum. // js::ProfilingStackFrame::Flags enum.
# define AUTO_PROFILER_LABEL_DYNAMIC_FAST(label, dynamicString, categoryPair, \ # define AUTO_BASE_PROFILER_LABEL_DYNAMIC_FAST(label, dynamicString, \
ctx, flags) \ categoryPair, ctx, flags) \
mozilla::AutoProfilerLabel PROFILER_RAII( \ mozilla::AutoProfilerLabel BASE_PROFILER_RAII( \
ctx, label, dynamicString, JS::ProfilingCategoryPair::categoryPair, \ ctx, label, dynamicString, JS::ProfilingCategoryPair::categoryPair, \
flags) flags)
// Insert a marker in the profile timeline. This is useful to delimit something // Insert a marker in the profile timeline. This is useful to delimit something
@ -596,7 +598,7 @@ MFBT_API mozilla::Maybe<ProfilerBufferInfo> profiler_get_buffer_info();
// certain length of time. A no-op if the profiler is inactive or in privacy // certain length of time. A no-op if the profiler is inactive or in privacy
// mode. // mode.
# define PROFILER_ADD_MARKER(markerName, categoryPair) \ # define BASE_PROFILER_ADD_MARKER(markerName, categoryPair) \
profiler_add_marker(markerName, JS::ProfilingCategoryPair::categoryPair) profiler_add_marker(markerName, JS::ProfilingCategoryPair::categoryPair)
MFBT_API void profiler_add_marker(const char* aMarkerName, MFBT_API void profiler_add_marker(const char* aMarkerName,
@ -619,7 +621,7 @@ enum TracingKind {
}; };
// Helper macro to retrieve DocShellId and DocShellHistoryId from docShell // Helper macro to retrieve DocShellId and DocShellHistoryId from docShell
# define DECLARE_DOCSHELL_AND_HISTORY_ID(docShell) \ # define MOZDECLARE_DOCSHELL_AND_HISTORY_ID(docShell) \
mozilla::Maybe<std::string> docShellId; \ mozilla::Maybe<std::string> docShellId; \
mozilla::Maybe<uint32_t> docShellHistoryId; \ mozilla::Maybe<uint32_t> docShellHistoryId; \
if (docShell) { \ if (docShell) { \
@ -639,14 +641,15 @@ enum TracingKind {
// Adds a tracing marker to the profile. A no-op if the profiler is inactive or // Adds a tracing marker to the profile. A no-op if the profiler is inactive or
// in privacy mode. // in privacy mode.
# define PROFILER_TRACING(categoryString, markerName, categoryPair, kind) \ # define BASE_PROFILER_TRACING(categoryString, markerName, categoryPair, \
profiler_tracing(categoryString, markerName, \ kind) \
profiler_tracing(categoryString, markerName, \
JS::ProfilingCategoryPair::categoryPair, kind) JS::ProfilingCategoryPair::categoryPair, kind)
# define PROFILER_TRACING_DOCSHELL(categoryString, markerName, categoryPair, \ # define BASE_PROFILER_TRACING_DOCSHELL(categoryString, markerName, \
kind, docShell) \ categoryPair, kind, docShell) \
DECLARE_DOCSHELL_AND_HISTORY_ID(docShell); \ MOZDECLARE_DOCSHELL_AND_HISTORY_ID(docShell); \
profiler_tracing(categoryString, markerName, \ profiler_tracing(categoryString, markerName, \
JS::ProfilingCategoryPair::categoryPair, kind, \ JS::ProfilingCategoryPair::categoryPair, kind, \
docShellId, docShellHistoryId) docShellId, docShellHistoryId)
MFBT_API void profiler_tracing( MFBT_API void profiler_tracing(
@ -662,14 +665,14 @@ MFBT_API void profiler_tracing(
const mozilla::Maybe<uint32_t>& aDocShellHistoryId = mozilla::Nothing()); const mozilla::Maybe<uint32_t>& aDocShellHistoryId = mozilla::Nothing());
// Adds a START/END pair of tracing markers. // Adds a START/END pair of tracing markers.
# define AUTO_PROFILER_TRACING(categoryString, markerName, categoryPair) \ # define AUTO_BASE_PROFILER_TRACING(categoryString, markerName, categoryPair) \
mozilla::AutoProfilerTracing PROFILER_RAII( \ mozilla::AutoProfilerTracing BASE_PROFILER_RAII( \
categoryString, markerName, JS::ProfilingCategoryPair::categoryPair, \ categoryString, markerName, JS::ProfilingCategoryPair::categoryPair, \
mozilla::Nothing(), mozilla::Nothing()) mozilla::Nothing(), mozilla::Nothing())
# define AUTO_PROFILER_TRACING_DOCSHELL(categoryString, markerName, \ # define AUTO_BASE_PROFILER_TRACING_DOCSHELL(categoryString, markerName, \
categoryPair, docShell) \ categoryPair, docShell) \
DECLARE_DOCSHELL_AND_HISTORY_ID(docShell); \ MOZDECLARE_DOCSHELL_AND_HISTORY_ID(docShell); \
mozilla::AutoProfilerTracing PROFILER_RAII( \ mozilla::AutoProfilerTracing BASE_PROFILER_RAII( \
categoryString, markerName, JS::ProfilingCategoryPair::categoryPair, \ categoryString, markerName, JS::ProfilingCategoryPair::categoryPair, \
docShellId, docShellHistoryId) docShellId, docShellHistoryId)
@ -722,23 +725,23 @@ class MOZ_RAII AutoProfilerTextMarker {
const mozilla::Maybe<uint32_t> mDocShellHistoryId; const mozilla::Maybe<uint32_t> mDocShellHistoryId;
}; };
# define AUTO_PROFILER_TEXT_MARKER_CAUSE(markerName, text, categoryPair, \ # define AUTO_BASE_PROFILER_TEXT_MARKER_CAUSE(markerName, text, categoryPair, \
cause) \ cause) \
AutoProfilerTextMarker PROFILER_RAII( \ AutoProfilerTextMarker BASE_PROFILER_RAII( \
markerName, text, JS::ProfilingCategoryPair::categoryPair, \ markerName, text, JS::ProfilingCategoryPair::categoryPair, \
mozilla::Nothing(), mozilla::Nothing(), cause) mozilla::Nothing(), mozilla::Nothing(), cause)
# define AUTO_PROFILER_TEXT_MARKER_DOCSHELL(markerName, text, categoryPair, \ # define AUTO_BASE_PROFILER_TEXT_MARKER_DOCSHELL(markerName, text, \
docShell) \ categoryPair, docShell) \
DECLARE_DOCSHELL_AND_HISTORY_ID(docShell); \ MOZDECLARE_DOCSHELL_AND_HISTORY_ID(docShell); \
AutoProfilerTextMarker PROFILER_RAII( \ AutoProfilerTextMarker BASE_PROFILER_RAII( \
markerName, text, JS::ProfilingCategoryPair::categoryPair, docShellId, \ markerName, text, JS::ProfilingCategoryPair::categoryPair, docShellId, \
docShellHistoryId) docShellHistoryId)
# define AUTO_PROFILER_TEXT_MARKER_DOCSHELL_CAUSE( \ # define AUTO_BASE_PROFILER_TEXT_MARKER_DOCSHELL_CAUSE( \
markerName, text, categoryPair, docShell, cause) \ markerName, text, categoryPair, docShell, cause) \
DECLARE_DOCSHELL_AND_HISTORY_ID(docShell); \ MOZDECLARE_DOCSHELL_AND_HISTORY_ID(docShell); \
AutoProfilerTextMarker PROFILER_RAII( \ AutoProfilerTextMarker BASE_PROFILER_RAII( \
markerName, text, JS::ProfilingCategoryPair::categoryPair, docShellId, \ markerName, text, JS::ProfilingCategoryPair::categoryPair, docShellId, \
docShellHistoryId, cause) docShellHistoryId, cause)
@ -847,7 +850,8 @@ class MOZ_RAII AutoProfilerThreadWake {
// be used after the ProfilingStack is destroyed. // be used after the ProfilingStack is destroyed.
class MOZ_RAII AutoProfilerLabel { class MOZ_RAII AutoProfilerLabel {
public: public:
// This is the AUTO_PROFILER_LABEL and AUTO_PROFILER_LABEL_DYNAMIC variant. // This is the AUTO_BASE_PROFILER_LABEL and AUTO_BASE_PROFILER_LABEL_DYNAMIC
// variant.
AutoProfilerLabel(const char* aLabel, const char* aDynamicString, AutoProfilerLabel(const char* aLabel, const char* aDynamicString,
JS::ProfilingCategoryPair aCategoryPair, JS::ProfilingCategoryPair aCategoryPair,
uint32_t aFlags = 0 MOZ_GUARD_OBJECT_NOTIFIER_PARAM) { uint32_t aFlags = 0 MOZ_GUARD_OBJECT_NOTIFIER_PARAM) {

Просмотреть файл

@ -9,12 +9,13 @@
#ifndef MOZ_BASE_PROFILER #ifndef MOZ_BASE_PROFILER
# define PROFILER_DEFINE_COUNT_TOTAL(label, category, description) # define BASE_PROFILER_DEFINE_COUNT_TOTAL(label, category, description)
# define PROFILER_DEFINE_COUNT(label, category, description) # define BASE_PROFILER_DEFINE_COUNT(label, category, description)
# define PROFILER_DEFINE_STATIC_COUNT_TOTAL(label, category, description) # define BASE_PROFILER_DEFINE_STATIC_COUNT_TOTAL(label, category, description)
# define AUTO_PROFILER_TOTAL(label, count) # define AUTO_BASE_PROFILER_COUNT_TOTAL(label, count)
# define AUTO_PROFILER_COUNT(label) # define AUTO_BASE_PROFILER_COUNT(label)
# define AUTO_PROFILER_STATIC_COUNT(label, count) # define AUTO_BASE_PROFILER_STATIC_COUNT(label, count)
# define AUTO_BASE_PROFILER_FORCE_ALLOCATION(label)
#else #else
@ -189,24 +190,25 @@ class ProfilerCounterTotal final : public BaseProfilerCount {
// independent Atomics, there is a possiblity that count will not include // independent Atomics, there is a possiblity that count will not include
// the last call, but number of uses will. I think this is not worth // the last call, but number of uses will. I think this is not worth
// worrying about // worrying about
# define PROFILER_DEFINE_COUNT_TOTAL(label, category, description) \ # define BASE_PROFILER_DEFINE_COUNT_TOTAL(label, category, description) \
ProfilerAtomicSigned profiler_count_##label(0); \ ProfilerAtomicSigned profiler_count_##label(0); \
ProfilerAtomicUnsigned profiler_number_##label(0); \ ProfilerAtomicUnsigned profiler_number_##label(0); \
const char profiler_category_##label[] = category; \ const char profiler_category_##label[] = category; \
const char profiler_description_##label[] = description; \ const char profiler_description_##label[] = description; \
mozilla::UniquePtr<BaseProfilerCount> AutoCount_##label; mozilla::UniquePtr<BaseProfilerCount> AutoCount_##label;
// This counts, but doesn't keep track of the number of calls to // This counts, but doesn't keep track of the number of calls to
// AUTO_PROFILER_COUNT() // AUTO_PROFILER_COUNT()
# define PROFILER_DEFINE_COUNT(label, category, description) \ # define BASE_PROFILER_DEFINE_COUNT(label, category, description) \
ProfilerAtomicSigned profiler_count_##label(0); \ ProfilerAtomicSigned profiler_count_##label(0); \
const char profiler_category_##label[] = category; \ const char profiler_category_##label[] = category; \
const char profiler_description_##label[] = description; \ const char profiler_description_##label[] = description; \
mozilla::UniquePtr<BaseProfilerCount> AutoCount_##label; mozilla::UniquePtr<BaseProfilerCount> AutoCount_##label;
// This will create a static initializer if used, but avoids a possible // This will create a static initializer if used, but avoids a possible
// allocation. // allocation.
# define PROFILER_DEFINE_STATIC_COUNT_TOTAL(label, category, description) \ # define BASE_PROFILER_DEFINE_STATIC_COUNT_TOTAL(label, category, \
description) \
ProfilerAtomicSigned profiler_count_##label(0); \ ProfilerAtomicSigned profiler_count_##label(0); \
ProfilerAtomicUnsigned profiler_number_##label(0); \ ProfilerAtomicUnsigned profiler_number_##label(0); \
BaseProfilerCount AutoCount_##label(#label, &profiler_count_##label, \ BaseProfilerCount AutoCount_##label(#label, &profiler_count_##label, \
@ -218,7 +220,7 @@ class ProfilerCounterTotal final : public BaseProfilerCount {
// XXX It would be better to do this without the if() and without the // XXX It would be better to do this without the if() and without the
// theoretical race to set the UniquePtr (i.e. possible leak). // theoretical race to set the UniquePtr (i.e. possible leak).
# define AUTO_PROFILER_COUNT_TOTAL(label, count) \ # define AUTO_BASE_PROFILER_COUNT_TOTAL(label, count) \
do { \ do { \
profiler_number_##label++; /* do this first*/ \ profiler_number_##label++; /* do this first*/ \
profiler_count_##label += count; \ profiler_count_##label += count; \
@ -233,7 +235,7 @@ class ProfilerCounterTotal final : public BaseProfilerCount {
} \ } \
} while (0) } while (0)
# define AUTO_PROFILER_COUNT(label, count) \ # define AUTO_BASE_PROFILER_COUNT(label, count) \
do { \ do { \
profiler_count_##label += count; /* do this first*/ \ profiler_count_##label += count; /* do this first*/ \
if (!AutoCount_##label) { \ if (!AutoCount_##label) { \
@ -247,14 +249,14 @@ class ProfilerCounterTotal final : public BaseProfilerCount {
} \ } \
} while (0) } while (0)
# define AUTO_PROFILER_STATIC_COUNT(label, count) \ # define AUTO_BASE_PROFILER_STATIC_COUNT(label, count) \
do { \ do { \
profiler_number_##label++; /* do this first*/ \ profiler_number_##label++; /* do this first*/ \
profiler_count_##label += count; \ profiler_count_##label += count; \
} while (0) } while (0)
// if we need to force the allocation // if we need to force the allocation
# define AUTO_PROFILER_FORCE_ALLOCATION(label) \ # define AUTO_BASE_PROFILER_FORCE_ALLOCATION(label) \
do { \ do { \
if (!AutoCount_##label) { \ if (!AutoCount_##label) { \
/* Ignore that we could call this twice in theory, and that we leak \ /* Ignore that we could call this twice in theory, and that we leak \

Просмотреть файл

@ -84,7 +84,7 @@ class ProfilerMarkerPayload {
mozilla::Maybe<uint32_t> mDocShellHistoryId; mozilla::Maybe<uint32_t> mDocShellHistoryId;
}; };
#define DECL_STREAM_PAYLOAD \ #define DECL_BASE_STREAM_PAYLOAD \
virtual void StreamPayload(SpliceableJSONWriter& aWriter, \ virtual void StreamPayload(SpliceableJSONWriter& aWriter, \
const mozilla::TimeStamp& aProcessStartTime, \ const mozilla::TimeStamp& aProcessStartTime, \
UniqueStacks& aUniqueStacks) override; UniqueStacks& aUniqueStacks) override;
@ -106,7 +106,7 @@ class TracingMarkerPayload : public ProfilerMarkerPayload {
SetDocShellHistoryId(aDocShellHistoryId); SetDocShellHistoryId(aDocShellHistoryId);
} }
DECL_STREAM_PAYLOAD DECL_BASE_STREAM_PAYLOAD
private: private:
const char* mCategory; const char* mCategory;
@ -128,7 +128,7 @@ class FileIOMarkerPayload : public ProfilerMarkerPayload {
MOZ_ASSERT(aSource); MOZ_ASSERT(aSource);
} }
DECL_STREAM_PAYLOAD DECL_BASE_STREAM_PAYLOAD
private: private:
const char* mSource; const char* mSource;
@ -161,7 +161,7 @@ class UserTimingMarkerPayload : public ProfilerMarkerPayload {
mStartMark(aStartMark), mStartMark(aStartMark),
mEndMark(aEndMark) {} mEndMark(aEndMark) {}
DECL_STREAM_PAYLOAD DECL_BASE_STREAM_PAYLOAD
private: private:
// Either "mark" or "measure". // Either "mark" or "measure".
@ -177,7 +177,7 @@ class HangMarkerPayload : public ProfilerMarkerPayload {
const mozilla::TimeStamp& aEndTime) const mozilla::TimeStamp& aEndTime)
: ProfilerMarkerPayload(aStartTime, aEndTime) {} : ProfilerMarkerPayload(aStartTime, aEndTime) {}
DECL_STREAM_PAYLOAD DECL_BASE_STREAM_PAYLOAD
private: private:
}; };
@ -187,7 +187,7 @@ class LongTaskMarkerPayload : public ProfilerMarkerPayload {
const mozilla::TimeStamp& aEndTime) const mozilla::TimeStamp& aEndTime)
: ProfilerMarkerPayload(aStartTime, aEndTime) {} : ProfilerMarkerPayload(aStartTime, aEndTime) {}
DECL_STREAM_PAYLOAD DECL_BASE_STREAM_PAYLOAD
}; };
class TextMarkerPayload : public ProfilerMarkerPayload { class TextMarkerPayload : public ProfilerMarkerPayload {
@ -219,7 +219,7 @@ class TextMarkerPayload : public ProfilerMarkerPayload {
aDocShellHistoryId, std::move(aCause)), aDocShellHistoryId, std::move(aCause)),
mText(aText) {} mText(aText) {}
DECL_STREAM_PAYLOAD DECL_BASE_STREAM_PAYLOAD
private: private:
std::string mText; std::string mText;
@ -233,7 +233,7 @@ class LogMarkerPayload : public ProfilerMarkerPayload {
mModule(aModule), mModule(aModule),
mText(aText) {} mText(aText) {}
DECL_STREAM_PAYLOAD DECL_BASE_STREAM_PAYLOAD
private: private:
std::string mModule; // longest known LazyLogModule name is ~24 std::string mModule; // longest known LazyLogModule name is ~24

Просмотреть файл

@ -21,7 +21,7 @@
// This higher-order macro lists all categories with their subcategories. // This higher-order macro lists all categories with their subcategories.
// //
// PROFILING_CATEGORY_LIST(BEGIN_CATEGORY, SUBCATEGORY, END_CATEGORY) // BASE_PROFILING_CATEGORY_LIST(BEGIN_CATEGORY, SUBCATEGORY, END_CATEGORY)
// BEGIN_CATEGORY(name, labelAsString, colorAsString) // BEGIN_CATEGORY(name, labelAsString, colorAsString)
// SUBCATEGORY(category, name, labelAsString) // SUBCATEGORY(category, name, labelAsString)
// END_CATEGORY // END_CATEGORY
@ -38,46 +38,47 @@
// chosen in such a way that every possible stack can be mapped to a single // chosen in such a way that every possible stack can be mapped to a single
// category unambiguously. // category unambiguously.
#define PROFILING_CATEGORY_LIST(BEGIN_CATEGORY, SUBCATEGORY, END_CATEGORY) \ #define BASE_PROFILING_CATEGORY_LIST(BEGIN_CATEGORY, SUBCATEGORY, \
BEGIN_CATEGORY(IDLE, "Idle", "transparent") \ END_CATEGORY) \
SUBCATEGORY(IDLE, IDLE, "Other") \ BEGIN_CATEGORY(IDLE, "Idle", "transparent") \
END_CATEGORY \ SUBCATEGORY(IDLE, IDLE, "Other") \
BEGIN_CATEGORY(OTHER, "Other", "grey") \ END_CATEGORY \
SUBCATEGORY(OTHER, OTHER, "Other") \ BEGIN_CATEGORY(OTHER, "Other", "grey") \
END_CATEGORY \ SUBCATEGORY(OTHER, OTHER, "Other") \
BEGIN_CATEGORY(LAYOUT, "Layout", "purple") \ END_CATEGORY \
SUBCATEGORY(LAYOUT, LAYOUT, "Other") \ BEGIN_CATEGORY(LAYOUT, "Layout", "purple") \
SUBCATEGORY(LAYOUT, LAYOUT_FrameConstruction, "Frame construction") \ SUBCATEGORY(LAYOUT, LAYOUT, "Other") \
SUBCATEGORY(LAYOUT, LAYOUT_Reflow, "Reflow") \ SUBCATEGORY(LAYOUT, LAYOUT_FrameConstruction, "Frame construction") \
SUBCATEGORY(LAYOUT, LAYOUT_CSSParsing, "CSS parsing") \ SUBCATEGORY(LAYOUT, LAYOUT_Reflow, "Reflow") \
SUBCATEGORY(LAYOUT, LAYOUT_SelectorQuery, "Selector query") \ SUBCATEGORY(LAYOUT, LAYOUT_CSSParsing, "CSS parsing") \
SUBCATEGORY(LAYOUT, LAYOUT_StyleComputation, "Style computation") \ SUBCATEGORY(LAYOUT, LAYOUT_SelectorQuery, "Selector query") \
END_CATEGORY \ SUBCATEGORY(LAYOUT, LAYOUT_StyleComputation, "Style computation") \
BEGIN_CATEGORY(JS, "JavaScript", "yellow") \ END_CATEGORY \
SUBCATEGORY(JS, JS, "Other") \ BEGIN_CATEGORY(JS, "JavaScript", "yellow") \
SUBCATEGORY(JS, JS_Parsing, "JS Parsing") \ SUBCATEGORY(JS, JS, "Other") \
SUBCATEGORY(JS, JS_IonCompilation, "Ion JIT Compilation") \ SUBCATEGORY(JS, JS_Parsing, "JS Parsing") \
SUBCATEGORY(JS, JS_BaselineCompilation, "Baseline JIT Compilation") \ SUBCATEGORY(JS, JS_IonCompilation, "Ion JIT Compilation") \
END_CATEGORY \ SUBCATEGORY(JS, JS_BaselineCompilation, "Baseline JIT Compilation") \
BEGIN_CATEGORY(GCCC, "GC / CC", "orange") \ END_CATEGORY \
SUBCATEGORY(GCCC, GCCC, "Other") \ BEGIN_CATEGORY(GCCC, "GC / CC", "orange") \
END_CATEGORY \ SUBCATEGORY(GCCC, GCCC, "Other") \
BEGIN_CATEGORY(NETWORK, "Network", "lightblue") \ END_CATEGORY \
SUBCATEGORY(NETWORK, NETWORK, "Other") \ BEGIN_CATEGORY(NETWORK, "Network", "lightblue") \
END_CATEGORY \ SUBCATEGORY(NETWORK, NETWORK, "Other") \
BEGIN_CATEGORY(GRAPHICS, "Graphics", "green") \ END_CATEGORY \
SUBCATEGORY(GRAPHICS, GRAPHICS, "Other") \ BEGIN_CATEGORY(GRAPHICS, "Graphics", "green") \
SUBCATEGORY(GRAPHICS, GRAPHICS, "Other") \
SUBCATEGORY(GRAPHICS, GRAPHICS_DisplayListBuilding, "DisplayList building") \ SUBCATEGORY(GRAPHICS, GRAPHICS_DisplayListBuilding, "DisplayList building") \
SUBCATEGORY(GRAPHICS, GRAPHICS_DisplayListMerging, "DisplayList merging") \ SUBCATEGORY(GRAPHICS, GRAPHICS_DisplayListMerging, "DisplayList merging") \
SUBCATEGORY(GRAPHICS, GRAPHICS_LayerBuilding, "Layer building") \ SUBCATEGORY(GRAPHICS, GRAPHICS_LayerBuilding, "Layer building") \
SUBCATEGORY(GRAPHICS, GRAPHICS_TileAllocation, "Tile allocation") \ SUBCATEGORY(GRAPHICS, GRAPHICS_TileAllocation, "Tile allocation") \
SUBCATEGORY(GRAPHICS, GRAPHICS_WRDisplayList, "WebRender display list") \ SUBCATEGORY(GRAPHICS, GRAPHICS_WRDisplayList, "WebRender display list") \
SUBCATEGORY(GRAPHICS, GRAPHICS_Rasterization, "Rasterization") \ SUBCATEGORY(GRAPHICS, GRAPHICS_Rasterization, "Rasterization") \
SUBCATEGORY(GRAPHICS, GRAPHICS_FlushingAsyncPaints, "Flushing async paints") \ SUBCATEGORY(GRAPHICS, GRAPHICS_FlushingAsyncPaints, "Flushing async paints") \
SUBCATEGORY(GRAPHICS, GRAPHICS_ImageDecoding, "Image decoding") \ SUBCATEGORY(GRAPHICS, GRAPHICS_ImageDecoding, "Image decoding") \
END_CATEGORY \ END_CATEGORY \
BEGIN_CATEGORY(DOM, "DOM", "blue") \ BEGIN_CATEGORY(DOM, "DOM", "blue") \
SUBCATEGORY(DOM, DOM, "Other") \ SUBCATEGORY(DOM, DOM, "Other") \
END_CATEGORY END_CATEGORY
namespace JS { namespace JS {
@ -90,9 +91,9 @@ namespace JS {
#define CATEGORY_ENUM_SUBCATEGORY(supercategory, name, labelAsString) name, #define CATEGORY_ENUM_SUBCATEGORY(supercategory, name, labelAsString) name,
#define CATEGORY_ENUM_END_CATEGORY #define CATEGORY_ENUM_END_CATEGORY
enum class ProfilingCategoryPair : uint32_t { enum class ProfilingCategoryPair : uint32_t {
PROFILING_CATEGORY_LIST(CATEGORY_ENUM_BEGIN_CATEGORY, BASE_PROFILING_CATEGORY_LIST(CATEGORY_ENUM_BEGIN_CATEGORY,
CATEGORY_ENUM_SUBCATEGORY, CATEGORY_ENUM_SUBCATEGORY,
CATEGORY_ENUM_END_CATEGORY) CATEGORY_ENUM_END_CATEGORY)
COUNT, COUNT,
LAST = COUNT - 1, LAST = COUNT - 1,
}; };
@ -105,9 +106,9 @@ enum class ProfilingCategoryPair : uint32_t {
#define SUPERCATEGORY_ENUM_SUBCATEGORY(supercategory, name, labelAsString) #define SUPERCATEGORY_ENUM_SUBCATEGORY(supercategory, name, labelAsString)
#define SUPERCATEGORY_ENUM_END_CATEGORY #define SUPERCATEGORY_ENUM_END_CATEGORY
enum class ProfilingCategory : uint32_t { enum class ProfilingCategory : uint32_t {
PROFILING_CATEGORY_LIST(SUPERCATEGORY_ENUM_BEGIN_CATEGORY, BASE_PROFILING_CATEGORY_LIST(SUPERCATEGORY_ENUM_BEGIN_CATEGORY,
SUPERCATEGORY_ENUM_SUBCATEGORY, SUPERCATEGORY_ENUM_SUBCATEGORY,
SUPERCATEGORY_ENUM_END_CATEGORY) SUPERCATEGORY_ENUM_END_CATEGORY)
COUNT, COUNT,
LAST = COUNT - 1, LAST = COUNT - 1,
}; };

Просмотреть файл

@ -42,7 +42,7 @@ MOZ_NEVER_INLINE unsigned long long Fibonacci(unsigned long long n) {
} }
unsigned long long f2 = Fibonacci<NextDepth(DEPTH)>(n - 2); unsigned long long f2 = Fibonacci<NextDepth(DEPTH)>(n - 2);
if (DEPTH == 0) { if (DEPTH == 0) {
PROFILER_ADD_MARKER("Half-way through Fibonacci", OTHER); BASE_PROFILER_ADD_MARKER("Half-way through Fibonacci", OTHER);
} }
unsigned long long f1 = Fibonacci<NextDepth(DEPTH)>(n - 1); unsigned long long f1 = Fibonacci<NextDepth(DEPTH)>(n - 1);
return f2 + f1; return f2 + f1;
@ -74,7 +74,7 @@ void TestProfiler() {
{ {
printf("profiler_init()...\n"); printf("profiler_init()...\n");
AUTO_PROFILER_INIT; AUTO_BASE_PROFILER_INIT;
MOZ_RELEASE_ASSERT(!profiler_is_active()); MOZ_RELEASE_ASSERT(!profiler_is_active());
MOZ_RELEASE_ASSERT(!profiler_thread_is_being_profiled()); MOZ_RELEASE_ASSERT(!profiler_thread_is_being_profiled());
@ -87,26 +87,27 @@ void TestProfiler() {
const uint32_t features = ProfilerFeature::Leaf | const uint32_t features = ProfilerFeature::Leaf |
ProfilerFeature::StackWalk | ProfilerFeature::StackWalk |
ProfilerFeature::Threads; ProfilerFeature::Threads;
profiler_start(PROFILER_DEFAULT_ENTRIES, PROFILER_DEFAULT_INTERVAL, profiler_start(BASE_PROFILER_DEFAULT_ENTRIES,
features, filters.begin(), filters.length()); BASE_PROFILER_DEFAULT_INTERVAL, features, filters.begin(),
filters.length());
MOZ_RELEASE_ASSERT(profiler_is_active()); MOZ_RELEASE_ASSERT(profiler_is_active());
MOZ_RELEASE_ASSERT(profiler_thread_is_being_profiled()); MOZ_RELEASE_ASSERT(profiler_thread_is_being_profiled());
MOZ_RELEASE_ASSERT(!profiler_thread_is_sleeping()); MOZ_RELEASE_ASSERT(!profiler_thread_is_sleeping());
{ {
AUTO_PROFILER_TEXT_MARKER_CAUSE("fibonacci", "First leaf call", OTHER, AUTO_BASE_PROFILER_TEXT_MARKER_CAUSE("fibonacci", "First leaf call",
nullptr); OTHER, nullptr);
static const unsigned long long fibStart = 40; static const unsigned long long fibStart = 40;
printf("Fibonacci(%llu)...\n", fibStart); printf("Fibonacci(%llu)...\n", fibStart);
AUTO_PROFILER_LABEL("Label around Fibonacci", OTHER); AUTO_BASE_PROFILER_LABEL("Label around Fibonacci", OTHER);
unsigned long long f = Fibonacci(fibStart); unsigned long long f = Fibonacci(fibStart);
printf("Fibonacci(%llu) = %llu\n", fibStart, f); printf("Fibonacci(%llu) = %llu\n", fibStart, f);
} }
printf("Sleep 1s...\n"); printf("Sleep 1s...\n");
{ {
AUTO_PROFILER_THREAD_SLEEP; AUTO_BASE_PROFILER_THREAD_SLEEP;
SleepMilli(1000); SleepMilli(1000);
} }
@ -133,14 +134,14 @@ void TestProfiler() {
void TestProfiler() { void TestProfiler() {
// These don't need to make sense, we just want to know that they're defined // These don't need to make sense, we just want to know that they're defined
// and don't do anything. // and don't do anything.
AUTO_PROFILER_INIT; AUTO_BASE_PROFILER_INIT;
// This wouldn't build if the macro did output its arguments. // This wouldn't build if the macro did output its arguments.
AUTO_PROFILER_TEXT_MARKER_CAUSE(catch, catch, catch, catch); AUTO_BASE_PROFILER_TEXT_MARKER_CAUSE(catch, catch, catch, catch);
AUTO_PROFILER_LABEL(catch, catch); AUTO_BASE_PROFILER_LABEL(catch, catch);
AUTO_PROFILER_THREAD_SLEEP; AUTO_BASE_PROFILER_THREAD_SLEEP;
} }
#endif // MOZ_BASE_PROFILER else #endif // MOZ_BASE_PROFILER else