Bug 1499507 - Add AUTO_PROFILER_LABEL_DYNAMIC_FAST which allows specifying flags. r=njn
☠☠ backed out by ccf46ccf3519 ☠ ☠
authorMarkus Stange <mstange@themasta.com>
Mon, 05 Nov 2018 20:57:30 +0000
changeset 444475 9254e6c721b32580fea698c20c8cb262770c85ac
parent 444474 cf40b044af3f441382a691ad3afa92d9b963e029
child 444476 35d05a53e0a988dbfba29bd3b56918010b5f20a4
push id34996
push userrgurzau@mozilla.com
push dateTue, 06 Nov 2018 09:53:23 +0000
treeherdermozilla-central@e160f0a60e4f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1499507 - Add AUTO_PROFILER_LABEL_DYNAMIC_FAST which allows specifying flags. r=njn Depends on D9203 Differential Revision: https://phabricator.services.mozilla.com/D9204
--- a/js/public/ProfilingStack.h
+++ b/js/public/ProfilingStack.h
@@ -259,25 +259,26 @@ class ProfilingStackFrame
     void setLabel(const char* aLabel) { label_ = aLabel; }
     const char* label() const { return label_; }
     const char* dynamicString() const { return dynamicString_; }
     void initLabelFrame(const char* aLabel, const char* aDynamicString, void* sp,
-                        Category aCategory)
+                        Category aCategory, uint32_t aFlags)
         label_ = aLabel;
         dynamicString_ = aDynamicString;
         spOrScript = sp;
         // pcOffsetIfJS_ is not set and must not be used on label frames.
         flagsAndCategory_ =
             uint32_t(Flags::IS_LABEL_FRAME) |
-            (uint32_t(aCategory) << uint32_t(Flags::FLAGS_BITCOUNT));
+            (uint32_t(aCategory) << uint32_t(Flags::FLAGS_BITCOUNT)) |
+            aFlags;
     void initSpMarkerFrame(void* sp)
         label_ = "";
         dynamicString_ = nullptr;
         spOrScript = sp;
@@ -386,23 +387,25 @@ class ProfilingStack final
       : stackPointer(0)
     void pushLabelFrame(const char* label, const char* dynamicString, void* sp,
-                        js::ProfilingStackFrame::Category category) {
+                        js::ProfilingStackFrame::Category category,
+                        uint32_t flags = 0) {
         uint32_t oldStackPointer = stackPointer;
         if (MOZ_UNLIKELY(oldStackPointer >= capacity)) {
-        frames[oldStackPointer].initLabelFrame(label, dynamicString, sp, category);
+        frames[oldStackPointer].initLabelFrame(label, dynamicString, sp,
+                                               category, flags);
         // This must happen at the end! The compiler will not reorder this
         // update because stackPointer is Atomic<..., ReleaseAcquire>, so any
         // the writes above will not be reordered below the stackPointer store.
         // Do the read and the write as two separate statements, in order to
         // make it clear that we don't need an atomic increment, which would be
         // more expensive on x86 than the separate operations done here.
         // This thread is the only one that ever changes the value of
--- a/tools/profiler/public/GeckoProfiler.h
+++ b/tools/profiler/public/GeckoProfiler.h
@@ -41,16 +41,17 @@
 #define AUTO_PROFILER_LABEL(label, category)
 #define AUTO_PROFILER_LABEL_DYNAMIC_CSTR(label, category, cStr)
 #define AUTO_PROFILER_LABEL_DYNAMIC_NSCSTRING(label, category, nsCStr)
 #define AUTO_PROFILER_LABEL_FAST(label, category, ctx)
+#define AUTO_PROFILER_LABEL_DYNAMIC_FAST(label, dynamicString, category, ctx, flags)
 #define PROFILER_ADD_MARKER(markerName)
 #define PROFILER_ADD_NETWORK_MARKER(uri, pri, channel, type, start, end, count, timings, redirect)
 #define PROFILER_TRACING(category, markerName, kind)
 #define AUTO_PROFILER_TRACING(category, markerName)
@@ -537,16 +538,24 @@ mozilla::Maybe<ProfilerBufferInfo> profi
 // Used to annotate functions for which overhead in the range of nanoseconds is
 // noticeable. It avoids overhead from the TLS lookup because it can get the
 // ProfilingStack from the JS context, and avoids almost all overhead in the case
 // where the profiler is disabled.
 #define AUTO_PROFILER_LABEL_FAST(label, category, ctx) \
   mozilla::AutoProfilerLabel PROFILER_RAII(ctx, label, nullptr, \
+// Similar to AUTO_PROFILER_LABEL_FAST, but also takes an extra string and an
+// additional set of flags. The flags parameter should carry values from the
+// js::ProfilingStackFrame::Flags enum.
+#define AUTO_PROFILER_LABEL_DYNAMIC_FAST(label, dynamicString, category, ctx, flags) \
+  mozilla::AutoProfilerLabel PROFILER_RAII(ctx, label, dynamicString, \
+                                           js::ProfilingStackFrame::Category::category, \
+                                           flags)
 // Insert a marker in the profile timeline. This is useful to delimit something
 // 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 label stack, markers will always be recorded in the profile buffer.
 // aMarkerName is copied, so the caller does not need to ensure it lives for a
 // certain length of time. A no-op if the profiler is inactive or in privacy
 // mode.
 #define PROFILER_ADD_MARKER(markerName) \
@@ -727,33 +736,36 @@ public:
     // Get the ProfilingStack from TLS.
     Push(sProfilingStack.get(), aLabel, aDynamicString, aCategory);
   // This is the AUTO_PROFILER_LABEL_FAST variant. It retrieves the ProfilingStack
   // from the JSContext and does nothing if the profiler is inactive.
   AutoProfilerLabel(JSContext* aJSContext,
                     const char* aLabel, const char* aDynamicString,
-                    js::ProfilingStackFrame::Category aCategory
+                    js::ProfilingStackFrame::Category aCategory,
+                    uint32_t aFlags
-         aLabel, aDynamicString, aCategory);
+         aLabel, aDynamicString, aCategory, aFlags);
   void Push(ProfilingStack* aProfilingStack,
             const char* aLabel, const char* aDynamicString,
-            js::ProfilingStackFrame::Category aCategory)
+            js::ProfilingStackFrame::Category aCategory,
+            uint32_t aFlags = 0)
     // This function runs both on and off the main thread.
     mProfilingStack = aProfilingStack;
     if (mProfilingStack) {
-      mProfilingStack->pushLabelFrame(aLabel, aDynamicString, this, aCategory);
+      mProfilingStack->pushLabelFrame(aLabel, aDynamicString, this, aCategory,
+                                      aFlags);
     // This function runs both on and off the main thread.
     if (mProfilingStack) {