зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1374127 (part 4) - Clean up GeckoProfiler.h a bit. r=mstange.
The patch: - Removes some unnecessary forward declarations. - Moves some macros to more logical locations. - Improves and removes some comments. --HG-- extra : rebase_source : 23f1de029bbe4a37d2cc1ebe1df76e9a6aa1b335
This commit is contained in:
Родитель
f8bf8ca8f0
Коммит
376df7b9bd
|
@ -30,20 +30,9 @@ class SpliceableJSONWriter;
|
|||
|
||||
namespace mozilla {
|
||||
class MallocAllocPolicy;
|
||||
class TimeStamp;
|
||||
template <class T,
|
||||
size_t MinInlineCapacity,
|
||||
class AllocPolicy>
|
||||
class Vector;
|
||||
|
||||
namespace dom {
|
||||
class Promise;
|
||||
} // namespace dom
|
||||
|
||||
template <class T, size_t MinInlineCapacity, class AllocPolicy> class Vector;
|
||||
} // namespace mozilla
|
||||
|
||||
class nsIProfilerStartParams;
|
||||
|
||||
enum TracingKind {
|
||||
TRACING_EVENT,
|
||||
TRACING_INTERVAL_START,
|
||||
|
@ -68,6 +57,44 @@ using UniqueProfilerBacktrace =
|
|||
#define PROFILER_FUNC(decl, rv) decl;
|
||||
#define PROFILER_FUNC_VOID(decl) void decl;
|
||||
|
||||
// Uncomment this to turn on systrace or build with
|
||||
// ac_add_options --enable-systace
|
||||
//#define MOZ_USE_SYSTRACE
|
||||
#ifdef MOZ_USE_SYSTRACE
|
||||
# ifndef ATRACE_TAG
|
||||
# define ATRACE_TAG ATRACE_TAG_ALWAYS
|
||||
# endif
|
||||
// We need HAVE_ANDROID_OS to be defined for Trace.h.
|
||||
// If its not set we will set it temporary and remove it.
|
||||
# ifndef HAVE_ANDROID_OS
|
||||
# define HAVE_ANDROID_OS
|
||||
# define REMOVE_HAVE_ANDROID_OS
|
||||
# endif
|
||||
// Android source code will include <cutils/trace.h> before this. There is no
|
||||
// HAVE_ANDROID_OS defined in Firefox OS build at that time. Enabled it globally
|
||||
// will cause other build break. So atrace_begin and atrace_end are not defined.
|
||||
// It will cause a build-break when we include <utils/Trace.h>. Use undef
|
||||
// _LIBS_CUTILS_TRACE_H will force <cutils/trace.h> to define atrace_begin and
|
||||
// atrace_end with defined HAVE_ANDROID_OS again. Then there is no build-break.
|
||||
# undef _LIBS_CUTILS_TRACE_H
|
||||
# include <utils/Trace.h>
|
||||
# define PROFILER_PLATFORM_TRACING(name) \
|
||||
android::ScopedTrace \
|
||||
PROFILER_APPEND_LINE_NUMBER(scopedTrace)(ATRACE_TAG, name);
|
||||
# ifdef REMOVE_HAVE_ANDROID_OS
|
||||
# undef HAVE_ANDROID_OS
|
||||
# undef REMOVE_HAVE_ANDROID_OS
|
||||
# endif
|
||||
#else
|
||||
# define PROFILER_PLATFORM_TRACING(name)
|
||||
#endif
|
||||
|
||||
#define PROFILER_APPEND_LINE_NUMBER_PASTE(id, line) id ## line
|
||||
#define PROFILER_APPEND_LINE_NUMBER_EXPAND(id, line) \
|
||||
PROFILER_APPEND_LINE_NUMBER_PASTE(id, line)
|
||||
#define PROFILER_APPEND_LINE_NUMBER(id) \
|
||||
PROFILER_APPEND_LINE_NUMBER_EXPAND(id, __LINE__)
|
||||
|
||||
#if defined(__GNUC__) || defined(_MSC_VER)
|
||||
# define PROFILER_FUNCTION_NAME __FUNCTION__
|
||||
#else
|
||||
|
@ -75,9 +102,6 @@ using UniqueProfilerBacktrace =
|
|||
# define PROFILER_FUNCTION_NAME __func__
|
||||
#endif
|
||||
|
||||
// we want the class and function name but can't easily get that using preprocessor macros
|
||||
// __func__ doesn't have the class name and __PRETTY_FUNCTION__ has the parameters
|
||||
|
||||
// Insert an RAII object in this scope to enter a pseudo stack frame. Any
|
||||
// samples collected in this scope will contain this label in their pseudo
|
||||
// stack. The name_space and info arguments must be string literals.
|
||||
|
@ -97,16 +121,16 @@ using UniqueProfilerBacktrace =
|
|||
PROFILER_APPEND_LINE_NUMBER(profiler_raii)(PROFILER_FUNCTION_NAME, nullptr, \
|
||||
__LINE__, category)
|
||||
|
||||
// Enter a pseudo stack frame in this scope and associate it with an
|
||||
// additional string.
|
||||
// This macro generates an RAII object. This RAII object stores the dynamicStr
|
||||
// pointer in a field; it does not copy the string. This means that the string
|
||||
// you pass to this macro needs to live at least until the end of the current
|
||||
// scope.
|
||||
// Similar to PROFILER_LABEL, but with an additional string. The inserted RAII
|
||||
// object stores the dynamicStr pointer in a field; it does not copy the string.
|
||||
// This means that the string you pass to this macro needs to live at least
|
||||
// until the end of the current scope.
|
||||
//
|
||||
// If the profiler samples the current thread and walks the pseudo stack while
|
||||
// this RAII object is on the stack, it will copy the supplied string into the
|
||||
// profile buffer. So there's one string copy operation, and it happens at
|
||||
// sample time.
|
||||
//
|
||||
// Compare this to the plain PROFILER_LABEL macro, which only accepts literal
|
||||
// strings: When the pseudo stack frames generated by PROFILER_LABEL are
|
||||
// sampled, no string copy needs to be made because the profile buffer can
|
||||
|
@ -120,9 +144,9 @@ using UniqueProfilerBacktrace =
|
|||
__LINE__, category)
|
||||
|
||||
// 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
|
||||
// only recorded if a sample is collected while it is active, marker will always
|
||||
// be collected.
|
||||
// important happening such as the first paint. Unlike labels, which are only
|
||||
// recorded in the profile buffer if a sample is collected while the label is
|
||||
// on the pseudostack, markers will always be recorded in the profile buffer.
|
||||
#define PROFILER_MARKER(marker_name) profiler_add_marker(marker_name)
|
||||
|
||||
// Like PROFILER_MARKER, but with an additional payload.
|
||||
|
@ -135,9 +159,7 @@ using UniqueProfilerBacktrace =
|
|||
#define PROFILER_FUNC_VOID(decl) static inline void decl {}
|
||||
|
||||
#define PROFILER_LABEL(name_space, info, category) do {} while (0)
|
||||
|
||||
#define PROFILER_LABEL_FUNC(category) do {} while (0)
|
||||
|
||||
#define PROFILER_LABEL_DYNAMIC(name_space, info, category, dynamicStr) \
|
||||
do {} while (0)
|
||||
|
||||
|
@ -415,7 +437,6 @@ PROFILER_FUNC_VOID(profiler_suspend_and_sample_thread(int aThreadId,
|
|||
# undef min
|
||||
#endif
|
||||
|
||||
class nsISupports;
|
||||
class ProfilerMarkerPayload;
|
||||
|
||||
// This exists purely for AutoProfilerLabel. See the comment on the
|
||||
|
@ -428,44 +449,6 @@ void profiler_add_marker(const char* aMarkerName);
|
|||
void profiler_add_marker(const char* aMarkerName,
|
||||
mozilla::UniquePtr<ProfilerMarkerPayload> aPayload);
|
||||
|
||||
#define PROFILER_APPEND_LINE_NUMBER_PASTE(id, line) id ## line
|
||||
#define PROFILER_APPEND_LINE_NUMBER_EXPAND(id, line) \
|
||||
PROFILER_APPEND_LINE_NUMBER_PASTE(id, line)
|
||||
#define PROFILER_APPEND_LINE_NUMBER(id) \
|
||||
PROFILER_APPEND_LINE_NUMBER_EXPAND(id, __LINE__)
|
||||
|
||||
// Uncomment this to turn on systrace or build with
|
||||
// ac_add_options --enable-systace
|
||||
//#define MOZ_USE_SYSTRACE
|
||||
#ifdef MOZ_USE_SYSTRACE
|
||||
# ifndef ATRACE_TAG
|
||||
# define ATRACE_TAG ATRACE_TAG_ALWAYS
|
||||
# endif
|
||||
// We need HAVE_ANDROID_OS to be defined for Trace.h.
|
||||
// If its not set we will set it temporary and remove it.
|
||||
# ifndef HAVE_ANDROID_OS
|
||||
# define HAVE_ANDROID_OS
|
||||
# define REMOVE_HAVE_ANDROID_OS
|
||||
# endif
|
||||
// Android source code will include <cutils/trace.h> before this. There is no
|
||||
// HAVE_ANDROID_OS defined in Firefox OS build at that time. Enabled it globally
|
||||
// will cause other build break. So atrace_begin and atrace_end are not defined.
|
||||
// It will cause a build-break when we include <utils/Trace.h>. Use undef
|
||||
// _LIBS_CUTILS_TRACE_H will force <cutils/trace.h> to define atrace_begin and
|
||||
// atrace_end with defined HAVE_ANDROID_OS again. Then there is no build-break.
|
||||
# undef _LIBS_CUTILS_TRACE_H
|
||||
# include <utils/Trace.h>
|
||||
# define PROFILER_PLATFORM_TRACING(name) \
|
||||
android::ScopedTrace \
|
||||
PROFILER_APPEND_LINE_NUMBER(scopedTrace)(ATRACE_TAG, name);
|
||||
# ifdef REMOVE_HAVE_ANDROID_OS
|
||||
# undef HAVE_ANDROID_OS
|
||||
# undef REMOVE_HAVE_ANDROID_OS
|
||||
# endif
|
||||
#else
|
||||
# define PROFILER_PLATFORM_TRACING(name)
|
||||
#endif
|
||||
|
||||
#if !defined(ARCH_ARMV6)
|
||||
# define PROFILER_DEFAULT_ENTRIES 1000000
|
||||
#else
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/PProfilerParent.h"
|
||||
|
||||
class nsIProfilerStartParams;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class ProfilerParentTracker;
|
||||
|
|
Загрузка…
Ссылка в новой задаче