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
This commit is contained in:
Markus Stange 2020-05-05 21:42:21 +00:00
Родитель fa240018c6
Коммит 1bb0550030
2 изменённых файлов: 35 добавлений и 0 удалений

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

@ -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<ProfilerBufferInfo> 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

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

@ -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 <typename... Args>
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<Traits, void> : public Method<Traits, bool> {
public:
template <typename... Args>
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<Traits, typename Traits::ReturnType> {
template <typename... Args>
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);