From 1bb0550030fa534701965432f005387c66ca7750 Mon Sep 17 00:00:00 2001 From: Markus Stange Date: Tue, 5 May 2020 21:42:21 +0000 Subject: [PATCH] Bug 1631584 - Add profiler labels for JNI binding method/getter/setter/constructor calls. r=gerald,snorp,geckoview-reviewers Differential Revision: https://phabricator.services.mozilla.com/D71645 --- tools/profiler/public/GeckoProfiler.h | 10 ++++++++++ widget/android/jni/Accessors.h | 25 +++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/tools/profiler/public/GeckoProfiler.h b/tools/profiler/public/GeckoProfiler.h index c0ae11b48a23..c3ed43072a6b 100644 --- a/tools/profiler/public/GeckoProfiler.h +++ b/tools/profiler/public/GeckoProfiler.h @@ -49,6 +49,8 @@ # define AUTO_PROFILER_LABEL_DYNAMIC_CSTR(label, categoryPair, cStr) # define AUTO_PROFILER_LABEL_DYNAMIC_CSTR_NONSENSITIVE(label, categoryPair, \ cStr) +# define AUTO_PROFILER_LABEL_DYNAMIC_CSTR_FLAGS(label, dynamicString, \ + categoryPair, flags) # define AUTO_PROFILER_LABEL_DYNAMIC_NSCSTRING(label, categoryPair, nsCStr) # define AUTO_PROFILER_LABEL_DYNAMIC_NSCSTRING_NONSENSITIVE( \ label, categoryPair, nsCStr) @@ -714,6 +716,14 @@ mozilla::Maybe profiler_get_buffer_info(); label, cStr, JS::ProfilingCategoryPair::categoryPair, \ uint32_t(js::ProfilingStackFrame::Flags::NONSENSITIVE)) +// Like AUTO_PROFILER_LABEL_DYNAMIC_CSTR, but also takes an additional set of +// flags. The flags parameter should carry values from the +// js::ProfilingStackFrame::Flags enum. +# define AUTO_PROFILER_LABEL_DYNAMIC_CSTR_FLAGS(label, dynamicString, \ + categoryPair, flags) \ + mozilla::AutoProfilerLabel PROFILER_RAII( \ + label, dynamicString, JS::ProfilingCategoryPair::categoryPair, flags) + // Similar to AUTO_PROFILER_LABEL_DYNAMIC_CSTR, but takes an nsACString. // // Note: The use of the Maybe<>s ensures the scopes for the dynamic string and diff --git a/widget/android/jni/Accessors.h b/widget/android/jni/Accessors.h index 7496cbcb5a82..5e5207e9f2cc 100644 --- a/widget/android/jni/Accessors.h +++ b/widget/android/jni/Accessors.h @@ -13,6 +13,7 @@ #include "mozilla/jni/Types.h" #include "mozilla/jni/Utils.h" #include "AndroidBridge.h" +#include "GeckoProfiler.h" namespace mozilla { namespace jni { @@ -103,6 +104,11 @@ class Method : public Accessor { template static ReturnType Call(const Context& ctx, nsresult* rv, const Args&... args) { + AUTO_PROFILER_LABEL_DYNAMIC_CSTR_FLAGS( + Traits::Owner::name, Traits::name, OTHER, + uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD) | + uint32_t(js::ProfilingStackFrame::Flags::NONSENSITIVE)); + JNIEnv* const env = ctx.Env(); BeginAccess(ctx); @@ -133,6 +139,11 @@ class Method : public Method { public: template static void Call(const Context& ctx, nsresult* rv, const Args&... args) { + AUTO_PROFILER_LABEL_DYNAMIC_CSTR_FLAGS( + Traits::Owner::name, Traits::name, OTHER, + uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD) | + uint32_t(js::ProfilingStackFrame::Flags::NONSENSITIVE)); + JNIEnv* const env = ctx.Env(); Base::BeginAccess(ctx); @@ -159,6 +170,10 @@ class Constructor : protected Method { template static ReturnType Call(const Context& ctx, nsresult* rv, const Args&... args) { + AUTO_PROFILER_LABEL_DYNAMIC_CSTR_FLAGS( + Traits::Owner::name, "constructor", OTHER, + uint32_t(js::ProfilingStackFrame::Flags::NONSENSITIVE)); + JNIEnv* const env = ctx.Env(); Base::BeginAccess(ctx); @@ -209,6 +224,11 @@ class Field : public Accessor { public: static GetterType Get(const Context& ctx, nsresult* rv) { + AUTO_PROFILER_LABEL_DYNAMIC_CSTR_FLAGS( + Traits::Owner::name, Traits::name, OTHER, + uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_GETTER) | + uint32_t(js::ProfilingStackFrame::Flags::NONSENSITIVE)); + JNIEnv* const env = ctx.Env(); BeginAccess(ctx); @@ -226,6 +246,11 @@ class Field : public Accessor { } static void Set(const Context& ctx, nsresult* rv, SetterType val) { + AUTO_PROFILER_LABEL_DYNAMIC_CSTR_FLAGS( + Traits::Owner::name, Traits::name, OTHER, + uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_SETTER) | + uint32_t(js::ProfilingStackFrame::Flags::NONSENSITIVE)); + JNIEnv* const env = ctx.Env(); BeginAccess(ctx);