зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1007203 - Set the categories as flags on profile entries, r=djvj
This commit is contained in:
Родитель
9ce7e9c089
Коммит
ebedad1bb5
|
@ -8,6 +8,7 @@
|
|||
#define js_ProfilingStack_h
|
||||
|
||||
#include "mozilla/NullPtr.h"
|
||||
#include "mozilla/TypedEnum.h"
|
||||
|
||||
#include "jsbytecode.h"
|
||||
#include "jstypes.h"
|
||||
|
@ -63,17 +64,20 @@ class ProfileEntry
|
|||
FRAME_LABEL_COPY = 0x02
|
||||
};
|
||||
|
||||
enum class Category {
|
||||
MOZ_BEGIN_NESTED_ENUM_CLASS(Category, uint32_t)
|
||||
OTHER = 0x04,
|
||||
CSS = 0x08,
|
||||
JS = 0x16,
|
||||
GC = 0x32,
|
||||
CC = 0x64,
|
||||
NETWORK = 0x128,
|
||||
GRAPHICS = 0x256,
|
||||
STORAGE = 0x512,
|
||||
EVENTS = 0x1024
|
||||
};
|
||||
JS = 0x10,
|
||||
GC = 0x20,
|
||||
CC = 0x40,
|
||||
NETWORK = 0x80,
|
||||
GRAPHICS = 0x100,
|
||||
STORAGE = 0x200,
|
||||
EVENTS = 0x400,
|
||||
|
||||
FIRST = OTHER,
|
||||
LAST = EVENTS
|
||||
MOZ_END_NESTED_ENUM_CLASS(Category)
|
||||
|
||||
// All of these methods are marked with the 'volatile' keyword because SPS's
|
||||
// representation of the stack is stored such that all ProfileEntry
|
||||
|
@ -99,15 +103,15 @@ class ProfileEntry
|
|||
lineOrPc = aLine;
|
||||
}
|
||||
|
||||
void setFlag(Flags flag) volatile {
|
||||
void setFlag(uint32_t flag) volatile {
|
||||
MOZ_ASSERT(flag != IS_CPP_ENTRY);
|
||||
flags |= flag;
|
||||
}
|
||||
void unsetFlag(Flags flag) volatile {
|
||||
void unsetFlag(uint32_t flag) volatile {
|
||||
MOZ_ASSERT(flag != IS_CPP_ENTRY);
|
||||
flags &= ~flag;
|
||||
}
|
||||
bool hasFlag(Flags flag) const volatile {
|
||||
bool hasFlag(uint32_t flag) const volatile {
|
||||
return bool(flags & uint32_t(flag));
|
||||
}
|
||||
|
||||
|
|
|
@ -71,13 +71,13 @@ enum TracingMetadata {
|
|||
// Insert a RAII in this scope to active a pseudo label. Any samples collected
|
||||
// in this scope will contain this annotation. For dynamic strings use
|
||||
// PROFILER_LABEL_PRINTF. Arguments must be string literals.
|
||||
#define PROFILER_LABEL(name_space, info) do {} while (0)
|
||||
#define PROFILER_LABEL(name_space, info, category) do {} while (0)
|
||||
|
||||
// Format a dynamic string as a pseudo label. These labels will a considerable
|
||||
// storage size in the circular buffer compared to regular labels. This function
|
||||
// can be used to annotate custom information such as URL for the resource being
|
||||
// decoded or the size of the paint.
|
||||
#define PROFILER_LABEL_PRINTF(name_space, info, format, ...) do {} while (0)
|
||||
#define PROFILER_LABEL_PRINTF(name_space, info, category, format, ...) do {} while (0)
|
||||
|
||||
// Insert a marker in the profile timeline. This is useful to delimit something
|
||||
// important happening such as the first paint. Unlike profiler_label that are
|
||||
|
@ -87,8 +87,8 @@ enum TracingMetadata {
|
|||
#define PROFILER_MARKER_PAYLOAD(info, payload) do {} while (0)
|
||||
|
||||
// Main thread specilization to avoid TLS lookup for performance critical use.
|
||||
#define PROFILER_MAIN_THREAD_LABEL(name_space, info) do {} while (0)
|
||||
#define PROFILER_MAIN_THREAD_LABEL_PRINTF(name_space, info, format, ...) do {} while (0)
|
||||
#define PROFILER_MAIN_THREAD_LABEL(name_space, info, category) do {} while (0)
|
||||
#define PROFILER_MAIN_THREAD_LABEL_PRINTF(name_space, info, category, format, ...) do {} while (0)
|
||||
|
||||
static inline void profiler_tracing(const char* aCategory, const char* aInfo,
|
||||
TracingMetadata metaData = TRACING_DEFAULT) {}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "mozilla/NullPtr.h"
|
||||
#include "js/TypeDecls.h"
|
||||
#include "js/ProfilingStack.h"
|
||||
#include <stdint.h>
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -23,9 +24,12 @@ class ProfilerMarkerPayload;
|
|||
|
||||
// Returns a handle to pass on exit. This can check that we are popping the
|
||||
// correct callstack.
|
||||
inline void* mozilla_sampler_call_enter(const char *aInfo, void *aFrameAddress = nullptr,
|
||||
bool aCopy = false, uint32_t line = 0);
|
||||
inline void* mozilla_sampler_call_enter(const char *aInfo, js::ProfileEntry::Category aCategory,
|
||||
void *aFrameAddress = nullptr, bool aCopy = false,
|
||||
uint32_t line = 0);
|
||||
|
||||
inline void mozilla_sampler_call_exit(void* handle);
|
||||
|
||||
void mozilla_sampler_add_marker(const char *aInfo,
|
||||
ProfilerMarkerPayload *aPayload = nullptr);
|
||||
|
||||
|
|
|
@ -310,15 +310,15 @@ static inline void profiler_tracing(const char* aCategory, const char* aInfo,
|
|||
#define SAMPLER_APPEND_LINE_NUMBER_EXPAND(id, line) SAMPLER_APPEND_LINE_NUMBER_PASTE(id, line)
|
||||
#define SAMPLER_APPEND_LINE_NUMBER(id) SAMPLER_APPEND_LINE_NUMBER_EXPAND(id, __LINE__)
|
||||
|
||||
#define PROFILER_LABEL(name_space, info) MOZ_PLATFORM_TRACING(name_space "::" info) mozilla::SamplerStackFrameRAII SAMPLER_APPEND_LINE_NUMBER(sampler_raii)(name_space "::" info, __LINE__)
|
||||
#define PROFILER_LABEL_PRINTF(name_space, info, ...) MOZ_PLATFORM_TRACING(name_space "::" info) mozilla::SamplerStackFramePrintfRAII SAMPLER_APPEND_LINE_NUMBER(sampler_raii)(name_space "::" info, __LINE__, __VA_ARGS__)
|
||||
#define PROFILER_LABEL(name_space, info, category) MOZ_PLATFORM_TRACING(name_space "::" info) mozilla::SamplerStackFrameRAII SAMPLER_APPEND_LINE_NUMBER(sampler_raii)(name_space "::" info, category, __LINE__)
|
||||
#define PROFILER_LABEL_PRINTF(name_space, info, category, ...) MOZ_PLATFORM_TRACING(name_space "::" info) mozilla::SamplerStackFramePrintfRAII SAMPLER_APPEND_LINE_NUMBER(sampler_raii)(name_space "::" info, category, __LINE__, __VA_ARGS__)
|
||||
|
||||
#define PROFILER_MARKER(info) mozilla_sampler_add_marker(info)
|
||||
#define PROFILER_MARKER_PAYLOAD(info, payload) mozilla_sampler_add_marker(info, payload)
|
||||
#define PROFILER_MAIN_THREAD_MARKER(info) MOZ_ASSERT(NS_IsMainThread(), "This can only be called on the main thread"); mozilla_sampler_add_marker(info)
|
||||
|
||||
#define PROFILER_MAIN_THREAD_LABEL(name_space, info) MOZ_ASSERT(NS_IsMainThread(), "This can only be called on the main thread"); mozilla::SamplerStackFrameRAII SAMPLER_APPEND_LINE_NUMBER(sampler_raii)(name_space "::" info, __LINE__)
|
||||
#define PROFILER_MAIN_THREAD_LABEL_PRINTF(name_space, info, ...) MOZ_ASSERT(NS_IsMainThread(), "This can only be called on the main thread"); mozilla::SamplerStackFramePrintfRAII SAMPLER_APPEND_LINE_NUMBER(sampler_raii)(name_space "::" info, __LINE__, __VA_ARGS__)
|
||||
#define PROFILER_MAIN_THREAD_LABEL(name_space, info, category) MOZ_ASSERT(NS_IsMainThread(), "This can only be called on the main thread"); mozilla::SamplerStackFrameRAII SAMPLER_APPEND_LINE_NUMBER(sampler_raii)(name_space "::" info, category, __LINE__)
|
||||
#define PROFILER_MAIN_THREAD_LABEL_PRINTF(name_space, info, category, ...) MOZ_ASSERT(NS_IsMainThread(), "This can only be called on the main thread"); mozilla::SamplerStackFramePrintfRAII SAMPLER_APPEND_LINE_NUMBER(sampler_raii)(name_space "::" info, category, __LINE__, __VA_ARGS__)
|
||||
|
||||
|
||||
/* FIXME/bug 789667: memory constraints wouldn't much of a problem for
|
||||
|
@ -367,8 +367,10 @@ namespace mozilla {
|
|||
class MOZ_STACK_CLASS SamplerStackFrameRAII {
|
||||
public:
|
||||
// we only copy the strings at save time, so to take multiple parameters we'd need to copy them then.
|
||||
SamplerStackFrameRAII(const char *aInfo, uint32_t line) {
|
||||
mHandle = mozilla_sampler_call_enter(aInfo, this, false, line);
|
||||
SamplerStackFrameRAII(const char *aInfo,
|
||||
js::ProfileEntry::Category aCategory, uint32_t line)
|
||||
{
|
||||
mHandle = mozilla_sampler_call_enter(aInfo, aCategory, this, false, line);
|
||||
}
|
||||
~SamplerStackFrameRAII() {
|
||||
mozilla_sampler_call_exit(mHandle);
|
||||
|
@ -381,7 +383,9 @@ static const int SAMPLER_MAX_STRING = 128;
|
|||
class MOZ_STACK_CLASS SamplerStackFramePrintfRAII {
|
||||
public:
|
||||
// we only copy the strings at save time, so to take multiple parameters we'd need to copy them then.
|
||||
SamplerStackFramePrintfRAII(const char *aDefault, uint32_t line, const char *aFormat, ...) {
|
||||
SamplerStackFramePrintfRAII(const char *aInfo,
|
||||
js::ProfileEntry::Category aCategory, uint32_t line, const char *aFormat, ...)
|
||||
{
|
||||
if (profiler_is_active() && !profiler_in_privacy_mode()) {
|
||||
va_list args;
|
||||
va_start(args, aFormat);
|
||||
|
@ -391,15 +395,15 @@ public:
|
|||
// the vargs.
|
||||
#if _MSC_VER
|
||||
_vsnprintf(buff, SAMPLER_MAX_STRING, aFormat, args);
|
||||
_snprintf(mDest, SAMPLER_MAX_STRING, "%s %s", aDefault, buff);
|
||||
_snprintf(mDest, SAMPLER_MAX_STRING, "%s %s", aInfo, buff);
|
||||
#else
|
||||
::vsnprintf(buff, SAMPLER_MAX_STRING, aFormat, args);
|
||||
::snprintf(mDest, SAMPLER_MAX_STRING, "%s %s", aDefault, buff);
|
||||
::snprintf(mDest, SAMPLER_MAX_STRING, "%s %s", aInfo, buff);
|
||||
#endif
|
||||
mHandle = mozilla_sampler_call_enter(mDest, this, true, line);
|
||||
mHandle = mozilla_sampler_call_enter(mDest, aCategory, this, true, line);
|
||||
va_end(args);
|
||||
} else {
|
||||
mHandle = mozilla_sampler_call_enter(aDefault, this, false, line);
|
||||
mHandle = mozilla_sampler_call_enter(aInfo, aCategory, this, false, line);
|
||||
}
|
||||
}
|
||||
~SamplerStackFramePrintfRAII() {
|
||||
|
@ -419,8 +423,8 @@ inline PseudoStack* mozilla_get_pseudo_stack(void)
|
|||
return tlsPseudoStack.get();
|
||||
}
|
||||
|
||||
inline void* mozilla_sampler_call_enter(const char *aInfo, void *aFrameAddress,
|
||||
bool aCopy, uint32_t line)
|
||||
inline void* mozilla_sampler_call_enter(const char *aInfo,
|
||||
js::ProfileEntry::Category aCategory, void *aFrameAddress, bool aCopy, uint32_t line)
|
||||
{
|
||||
// check if we've been initialized to avoid calling pthread_getspecific
|
||||
// with a null tlsStack which will return undefined results.
|
||||
|
@ -435,7 +439,7 @@ inline void* mozilla_sampler_call_enter(const char *aInfo, void *aFrameAddress,
|
|||
if (!stack) {
|
||||
return stack;
|
||||
}
|
||||
stack->push(aInfo, aFrameAddress, aCopy, line);
|
||||
stack->push(aInfo, aCategory, aFrameAddress, aCopy, line);
|
||||
|
||||
// The handle is meant to support future changes
|
||||
// but for now it is simply use to save a call to
|
||||
|
|
|
@ -343,12 +343,13 @@ public:
|
|||
return mPendingMarkers.getPendingMarkers();
|
||||
}
|
||||
|
||||
void push(const char *aName, uint32_t line)
|
||||
void push(const char *aName, js::ProfileEntry::Category aCategory, uint32_t line)
|
||||
{
|
||||
push(aName, nullptr, false, line);
|
||||
push(aName, aCategory, nullptr, false, line);
|
||||
}
|
||||
|
||||
void push(const char *aName, void *aStackAddress, bool aCopy, uint32_t line)
|
||||
void push(const char *aName, js::ProfileEntry::Category aCategory,
|
||||
void *aStackAddress, bool aCopy, uint32_t line)
|
||||
{
|
||||
if (size_t(mStackPointer) >= mozilla::ArrayLength(mStack)) {
|
||||
mStackPointer++;
|
||||
|
@ -362,6 +363,13 @@ public:
|
|||
entry.setLabel(aName);
|
||||
entry.setCppFrame(aStackAddress, line);
|
||||
|
||||
uint32_t uint_category = static_cast<uint32_t>(aCategory);
|
||||
MOZ_ASSERT(
|
||||
uint_category >= static_cast<uint32_t>(js::ProfileEntry::Category::FIRST) &&
|
||||
uint_category <= static_cast<uint32_t>(js::ProfileEntry::Category::LAST));
|
||||
|
||||
entry.setFlag(uint_category);
|
||||
|
||||
// Track if mLabel needs a copy.
|
||||
if (aCopy)
|
||||
entry.setFlag(js::ProfileEntry::FRAME_LABEL_COPY);
|
||||
|
|
Загрузка…
Ссылка в новой задаче