Bug 1375776 (part 4) - Allow ProfilerMarkerPayload.h to be #included unconditionally. r=mstange.
authorNicholas Nethercote <nnethercote@mozilla.com>
Fri, 23 Jun 2017 16:24:15 +1000
changeset 416058 cf412ab85156a34b36f60a9bba6d8f2a6ecc06f7
parent 416057 e2c80991b84d16a20d5f49322639b699b417f162
child 416059 9adcd10aa3a94ee89812fd48661598f99a0ed65c
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1375776
milestone56.0a1
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 1375776 (part 4) - Allow ProfilerMarkerPayload.h to be #included unconditionally. r=mstange. This requires: - Moving the constructors of ProfilerMarkerPayload and its subclasses into the .h file so they are visible even when ProfilerMarkerPayload.cpp isn't compiled. - Similarly, using a macro to make StreamPayload() a crashing no-op when the profiler isn't enabled. (It is never called in that case.)
dom/events/EventListenerManager.cpp
dom/performance/Performance.cpp
gfx/layers/composite/ContainerLayerComposite.cpp
gfx/layers/ipc/CompositorBridgeParent.cpp
gfx/thebes/ContextStateTracker.cpp
tools/profiler/core/ProfilerMarkerPayload.cpp
tools/profiler/moz.build
tools/profiler/public/ProfilerMarkerPayload.h
widget/VsyncDispatcher.cpp
xpcom/base/CycleCollectedJSRuntime.cpp
--- a/dom/events/EventListenerManager.cpp
+++ b/dom/events/EventListenerManager.cpp
@@ -28,19 +28,17 @@
 #include "mozilla/dom/EventTargetBinding.h"
 #include "mozilla/dom/TouchEvent.h"
 #include "mozilla/TimelineConsumers.h"
 #include "mozilla/EventTimelineMarker.h"
 #include "mozilla/TimeStamp.h"
 
 #include "EventListenerService.h"
 #include "GeckoProfiler.h"
-#ifdef MOZ_GECKO_PROFILER
 #include "ProfilerMarkerPayload.h"
-#endif
 #include "nsCOMArray.h"
 #include "nsCOMPtr.h"
 #include "nsContentUtils.h"
 #include "nsDOMCID.h"
 #include "nsError.h"
 #include "nsGkAtoms.h"
 #include "nsIContent.h"
 #include "nsIContentSecurityPolicy.h"
@@ -1283,17 +1281,16 @@ EventListenerManager::HandleEventInterna
               // called again inside the listener.
               listenerHolder.emplace(Move(*listener));
               listener = listenerHolder.ptr();
               hasRemovedListener = true;
             }
 
             nsresult rv = NS_OK;
             if (profiler_is_active()) {
-#ifdef MOZ_GECKO_PROFILER
               // Add a profiler label and a profiler marker for the actual
               // dispatch of the event.
               // This is a very hot code path, so we need to make sure not to
               // do this extra work when we're not profiling.
               nsAutoString typeStr;
               (*aDOMEvent)->GetType(typeStr);
               NS_LossyConvertUTF16toASCII typeCStr(typeStr);
               AUTO_PROFILER_LABEL_DYNAMIC(
@@ -1305,17 +1302,16 @@ EventListenerManager::HandleEventInterna
 
               TimeStamp endTime = TimeStamp::Now();
               uint16_t phase;
               (*aDOMEvent)->GetEventPhase(&phase);
               profiler_add_marker(
                 "DOMEvent",
                 MakeUnique<DOMEventMarkerPayload>(typeStr, phase,
                                                   startTime, endTime));
-#endif
             } else {
               rv = HandleEventSubType(listener, *aDOMEvent, aCurrentTarget);
             }
 
             if (NS_FAILED(rv)) {
               aEvent->mFlags.mExceptionWasRaised = true;
             }
             aEvent->mFlags.mInPassiveListener = false;
--- a/dom/performance/Performance.cpp
+++ b/dom/performance/Performance.cpp
@@ -3,19 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "Performance.h"
 
 #include "GeckoProfiler.h"
 #include "nsRFPService.h"
-#ifdef MOZ_GECKO_PROFILER
 #include "ProfilerMarkerPayload.h"
-#endif
 #include "PerformanceEntry.h"
 #include "PerformanceMainThread.h"
 #include "PerformanceMark.h"
 #include "PerformanceMeasure.h"
 #include "PerformanceObserver.h"
 #include "PerformanceResourceTiming.h"
 #include "PerformanceService.h"
 #include "PerformanceWorker.h"
@@ -292,23 +290,21 @@ Performance::Mark(const nsAString& aName
     aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
     return;
   }
 
   RefPtr<PerformanceMark> performanceMark =
     new PerformanceMark(GetAsISupports(), aName, Now());
   InsertUserEntry(performanceMark);
 
-#ifdef MOZ_GECKO_PROFILER
   if (profiler_is_active()) {
     profiler_add_marker(
       "UserTiming",
       MakeUnique<UserTimingMarkerPayload>(aName, TimeStamp::Now()));
   }
-#endif
 }
 
 void
 Performance::ClearMarks(const Optional<nsAString>& aName)
 {
   ClearUserEntries(aName, NS_LITERAL_STRING("mark"));
 }
 
@@ -386,27 +382,25 @@ Performance::Measure(const nsAString& aN
   } else {
     endTime = Now();
   }
 
   RefPtr<PerformanceMeasure> performanceMeasure =
     new PerformanceMeasure(GetAsISupports(), aName, startTime, endTime);
   InsertUserEntry(performanceMeasure);
 
-#ifdef MOZ_GECKO_PROFILER
   if (profiler_is_active()) {
     TimeStamp startTimeStamp = CreationTimeStamp() +
                                TimeDuration::FromMilliseconds(startTime);
     TimeStamp endTimeStamp = CreationTimeStamp() +
                              TimeDuration::FromMilliseconds(endTime);
     profiler_add_marker(
       "UserTiming",
       MakeUnique<UserTimingMarkerPayload>(aName, startTimeStamp, endTimeStamp));
   }
-#endif
 }
 
 void
 Performance::ClearMeasures(const Optional<nsAString>& aName)
 {
   ClearUserEntries(aName, NS_LITERAL_STRING("measure"));
 }
 
--- a/gfx/layers/composite/ContainerLayerComposite.cpp
+++ b/gfx/layers/composite/ContainerLayerComposite.cpp
@@ -30,19 +30,17 @@
 #include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
 #include "nsISupportsUtils.h"           // for NS_ADDREF, NS_RELEASE
 #include "nsRegion.h"                   // for nsIntRegion
 #include "nsTArray.h"                   // for AutoTArray
 #include <stack>
 #include "TextRenderer.h"               // for TextRenderer
 #include <vector>
 #include "GeckoProfiler.h"              // for GeckoProfiler
-#ifdef MOZ_GECKO_PROFILER
 #include "ProfilerMarkerPayload.h"      // for LayerTranslationMarkerPayload
-#endif
 
 #define CULLING_LOG(...)
 // #define CULLING_LOG(...) printf_stderr("CULLING: " __VA_ARGS__)
 
 #define DUMP(...) do { if (gfxEnv::DumpDebug()) { printf_stderr(__VA_ARGS__); } } while(0)
 #define XYWH(k)  (k).x, (k).y, (k).width, (k).height
 #define XY(k)    (k).x, (k).y
 #define WH(k)    (k).width, (k).height
@@ -78,17 +76,16 @@ DrawLayerInfo(const RenderTargetIntRect&
     topLeft,
     aLayer->GetEffectiveTransform(), 16,
     maxWidth);
 }
 
 static void
 PrintUniformityInfo(Layer* aLayer)
 {
-#ifdef MOZ_GECKO_PROFILER
   if (!profiler_is_active()) {
     return;
   }
 
   // Don't want to print a log for smaller layers
   if (aLayer->GetLocalVisibleRegion().GetBounds().width < 300 ||
       aLayer->GetLocalVisibleRegion().GetBounds().height < 300) {
     return;
@@ -98,17 +95,16 @@ PrintUniformityInfo(Layer* aLayer)
   if (!transform.Is2D()) {
     return;
   }
 
   Point translation = transform.As2D().GetTranslation();
   profiler_add_marker(
     "LayerTranslation",
     MakeUnique<LayerTranslationMarkerPayload>(aLayer, translation));
-#endif
 }
 
 static Maybe<gfx::Polygon>
 SelectLayerGeometry(const Maybe<gfx::Polygon>& aParentGeometry,
                     const Maybe<gfx::Polygon>& aChildGeometry)
 {
   // Both the parent and the child layer were split.
   if (aParentGeometry && aChildGeometry) {
--- a/gfx/layers/ipc/CompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CompositorBridgeParent.cpp
@@ -78,19 +78,17 @@
 #endif
 #include "GeckoProfiler.h"
 #include "mozilla/ipc/ProtocolTypes.h"
 #include "mozilla/Unused.h"
 #include "mozilla/Hal.h"
 #include "mozilla/HalTypes.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/Telemetry.h"
-#ifdef MOZ_GECKO_PROFILER
 #include "ProfilerMarkerPayload.h"
-#endif
 #include "mozilla/VsyncDispatcher.h"
 #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
 #include "VsyncSource.h"
 #endif
 #include "mozilla/widget/CompositorWidget.h"
 #ifdef MOZ_WIDGET_SUPPORTS_OOP_COMPOSITING
 # include "mozilla/widget/CompositorWidgetParent.h"
 #endif
@@ -1839,22 +1837,20 @@ CompositorBridgeParent::GetAPZCTreeManag
                                    ? lts->mParent->mApzcTreeManager.get()
                                    : nullptr;
   return apzctm.forget();
 }
 
 static void
 InsertVsyncProfilerMarker(TimeStamp aVsyncTimestamp)
 {
-#ifdef MOZ_GECKO_PROFILER
   MOZ_ASSERT(CompositorThreadHolder::IsInCompositorThread());
   profiler_add_marker(
     "VsyncTimestamp",
     MakeUnique<VsyncMarkerPayload>(aVsyncTimestamp));
-#endif
 }
 
 /*static */ void
 CompositorBridgeParent::PostInsertVsyncProfilerMarker(TimeStamp aVsyncTimestamp)
 {
   // Called in the vsync thread
   if (profiler_is_active() && CompositorThreadHolder::IsActive()) {
     CompositorLoop()->PostTask(
--- a/gfx/thebes/ContextStateTracker.cpp
+++ b/gfx/thebes/ContextStateTracker.cpp
@@ -1,19 +1,17 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "ContextStateTracker.h"
 #include "GLContext.h"
 #include "GeckoProfiler.h"
-#ifdef MOZ_GECKO_PROFILER
 #include "ProfilerMarkerPayload.h"
-#endif
 
 namespace mozilla {
 
 void
 ContextStateTrackerOGL::PushOGLSection(GLContext* aGL, const char* aSectionName)
 {
   if (!profiler_feature_active(ProfilerFeature::GPU)) {
     return;
@@ -106,23 +104,23 @@ ContextStateTrackerOGL::Flush(GLContext*
       break;
     }
 
     GLuint gpuTime = 0;
     aGL->fGetQueryObjectuiv(handle, LOCAL_GL_QUERY_RESULT, &gpuTime);
 
     aGL->fDeleteQueries(1, &handle);
 
-#ifdef MOZ_GECKO_PROFILER
-    profiler_add_marker(
-      "gpu_timer_query",
-      MakeUnique<GPUMarkerPayload>(mCompletedSections[0].mCpuTimeStart,
-                                   mCompletedSections[0].mCpuTimeEnd,
-                                   0, gpuTime));
-#endif
+    if (profiler_is_active()) {
+      profiler_add_marker(
+        "gpu_timer_query",
+        MakeUnique<GPUMarkerPayload>(mCompletedSections[0].mCpuTimeStart,
+                                     mCompletedSections[0].mCpuTimeEnd,
+                                     0, gpuTime));
+    }
 
     mCompletedSections.RemoveElementAt(0);
   }
 }
 
 void
 ContextStateTrackerOGL::DestroyOGL(GLContext* aGL)
 {
--- a/tools/profiler/core/ProfilerMarkerPayload.cpp
+++ b/tools/profiler/core/ProfilerMarkerPayload.cpp
@@ -7,28 +7,16 @@
 #include "ProfilerBacktrace.h"
 #include "ProfilerMarkerPayload.h"
 #include "gfxASurface.h"
 #include "Layers.h"
 #include "mozilla/Sprintf.h"
 
 using namespace mozilla;
 
-ProfilerMarkerPayload::ProfilerMarkerPayload(UniqueProfilerBacktrace aStack)
-  : mStack(Move(aStack))
-{}
-
-ProfilerMarkerPayload::ProfilerMarkerPayload(const TimeStamp& aStartTime,
-                                             const TimeStamp& aEndTime,
-                                             UniqueProfilerBacktrace aStack)
-  : mStartTime(aStartTime)
-  , mEndTime(aEndTime)
-  , mStack(Move(aStack))
-{}
-
 void
 ProfilerMarkerPayload::StreamCommonProps(const char* aMarkerType,
                                          SpliceableJSONWriter& aWriter,
                                          const TimeStamp& aProcessStartTime,
                                          UniqueStacks& aUniqueStacks)
 {
   MOZ_ASSERT(aMarkerType);
   aWriter.StringProperty("type", aMarkerType);
@@ -44,27 +32,16 @@ ProfilerMarkerPayload::StreamCommonProps
     aWriter.StartObjectProperty("stack");
     {
       mStack->StreamJSON(aWriter, aProcessStartTime, aUniqueStacks);
     }
     aWriter.EndObject();
   }
 }
 
-TracingMarkerPayload::TracingMarkerPayload(const char* aCategory,
-                                           TracingKind aKind,
-                                           UniqueProfilerBacktrace aCause)
-  : mCategory(aCategory)
-  , mKind(aKind)
-{
-  if (aCause) {
-    SetStack(Move(aCause));
-  }
-}
-
 void
 TracingMarkerPayload::StreamPayload(SpliceableJSONWriter& aWriter,
                                     const TimeStamp& aProcessStartTime,
                                     UniqueStacks& aUniqueStacks)
 {
   StreamCommonProps("tracing", aWriter, aProcessStartTime, aUniqueStacks);
 
   if (mCategory) {
@@ -73,144 +50,79 @@ TracingMarkerPayload::StreamPayload(Spli
 
   if (mKind == TRACING_INTERVAL_START) {
     aWriter.StringProperty("interval", "start");
   } else if (mKind == TRACING_INTERVAL_END) {
     aWriter.StringProperty("interval", "end");
   }
 }
 
-GPUMarkerPayload::GPUMarkerPayload(
-  const TimeStamp& aCpuTimeStart,
-  const TimeStamp& aCpuTimeEnd,
-  uint64_t aGpuTimeStart,
-  uint64_t aGpuTimeEnd)
-
-  : ProfilerMarkerPayload(aCpuTimeStart, aCpuTimeEnd)
-  , mCpuTimeStart(aCpuTimeStart)
-  , mCpuTimeEnd(aCpuTimeEnd)
-  , mGpuTimeStart(aGpuTimeStart)
-  , mGpuTimeEnd(aGpuTimeEnd)
-{ }
-
 void
 GPUMarkerPayload::StreamPayload(SpliceableJSONWriter& aWriter,
                                 const TimeStamp& aProcessStartTime,
                                 UniqueStacks& aUniqueStacks)
 {
   StreamCommonProps("gpu_timer_query", aWriter, aProcessStartTime,
                     aUniqueStacks);
 
   aWriter.DoubleProperty("cpustart",
                          (mCpuTimeStart - aProcessStartTime).ToMilliseconds());
   aWriter.DoubleProperty("cpuend",
                          (mCpuTimeEnd - aProcessStartTime).ToMilliseconds());
   aWriter.IntProperty("gpustart", (int)mGpuTimeStart);
   aWriter.IntProperty("gpuend", (int)mGpuTimeEnd);
 }
 
-IOMarkerPayload::IOMarkerPayload(const char* aSource,
-                                 const char* aFilename,
-                                 const TimeStamp& aStartTime,
-                                 const TimeStamp& aEndTime,
-                                 UniqueProfilerBacktrace aStack)
-  : ProfilerMarkerPayload(aStartTime, aEndTime, Move(aStack))
-  , mSource(aSource)
-  , mFilename(aFilename ? strdup(aFilename) : nullptr)
-{
-  MOZ_ASSERT(aSource);
-}
-
 void
 IOMarkerPayload::StreamPayload(SpliceableJSONWriter& aWriter,
                                const TimeStamp& aProcessStartTime,
                                UniqueStacks& aUniqueStacks)
 {
   StreamCommonProps("io", aWriter, aProcessStartTime, aUniqueStacks);
   aWriter.StringProperty("source", mSource);
   if (mFilename) {
     aWriter.StringProperty("filename", mFilename.get());
   }
 }
 
-UserTimingMarkerPayload::UserTimingMarkerPayload(const nsAString& aName,
-                                                 const TimeStamp& aStartTime)
-  : ProfilerMarkerPayload(aStartTime, aStartTime, nullptr)
-  , mEntryType("mark")
-  , mName(aName)
-{
-}
-
-UserTimingMarkerPayload::UserTimingMarkerPayload(const nsAString& aName,
-                                                 const TimeStamp& aStartTime,
-                                                 const TimeStamp& aEndTime)
-  : ProfilerMarkerPayload(aStartTime, aEndTime, nullptr)
-  , mEntryType("measure")
-  , mName(aName)
-{
-}
-
 void
 UserTimingMarkerPayload::StreamPayload(SpliceableJSONWriter& aWriter,
                                        const TimeStamp& aProcessStartTime,
                                        UniqueStacks& aUniqueStacks)
 {
   StreamCommonProps("UserTiming", aWriter, aProcessStartTime, aUniqueStacks);
   aWriter.StringProperty("name", NS_ConvertUTF16toUTF8(mName).get());
   aWriter.StringProperty("entryType", mEntryType);
 }
 
-DOMEventMarkerPayload::DOMEventMarkerPayload(const nsAString& aType, uint16_t aPhase,
-                                             const TimeStamp& aStartTime,
-                                             const TimeStamp& aEndTime)
-  : ProfilerMarkerPayload(aStartTime, aEndTime, nullptr)
-  , mType(aType)
-  , mPhase(aPhase)
-{
-}
-
 void
 DOMEventMarkerPayload::StreamPayload(SpliceableJSONWriter& aWriter,
                                      const TimeStamp& aProcessStartTime,
                                      UniqueStacks& aUniqueStacks)
 {
   StreamCommonProps("DOMEvent", aWriter, aProcessStartTime, aUniqueStacks);
   aWriter.StringProperty("type", NS_ConvertUTF16toUTF8(mType).get());
   aWriter.IntProperty("phase", mPhase);
 }
 
-LayerTranslationMarkerPayload::LayerTranslationMarkerPayload(layers::Layer* aLayer,
-                                                             gfx::Point aPoint)
-  : ProfilerMarkerPayload(TimeStamp::Now(), TimeStamp::Now(), nullptr)
-  , mLayer(aLayer)
-  , mPoint(aPoint)
-{
-}
-
 void
 LayerTranslationMarkerPayload::StreamPayload(SpliceableJSONWriter& aWriter,
                                              const TimeStamp& aProcessStartTime,
                                              UniqueStacks& aUniqueStacks)
 {
   const size_t bufferSize = 32;
   char buffer[bufferSize];
   SprintfLiteral(buffer, "%p", mLayer);
 
   aWriter.StringProperty("layer", buffer);
   aWriter.IntProperty("x", mPoint.x);
   aWriter.IntProperty("y", mPoint.y);
   aWriter.StringProperty("category", "LayerTranslation");
 }
 
-VsyncMarkerPayload::VsyncMarkerPayload(TimeStamp aVsyncTimestamp)
-  : ProfilerMarkerPayload(aVsyncTimestamp, aVsyncTimestamp, nullptr)
-  , mVsyncTimestamp(aVsyncTimestamp)
-{
-}
-
 void
 VsyncMarkerPayload::StreamPayload(SpliceableJSONWriter& aWriter,
                                   const TimeStamp& aProcessStartTime,
                                   UniqueStacks& aUniqueStacks)
 {
   aWriter.DoubleProperty("vsync",
                          (mVsyncTimestamp - aProcessStartTime).ToMilliseconds());
   aWriter.StringProperty("category", "VsyncTimestamp");
--- a/tools/profiler/moz.build
+++ b/tools/profiler/moz.build
@@ -7,17 +7,16 @@
 if CONFIG['MOZ_GECKO_PROFILER']:
     XPIDL_MODULE = 'profiler'
     XPIDL_SOURCES += [
         'gecko/nsIProfiler.idl',
     ]
     EXPORTS += [
         'public/ChildProfilerController.h',
         'public/ProfilerChild.h',
-        'public/ProfilerMarkerPayload.h',
         'public/ProfilerParent.h',
         'public/shared-libraries.h',
     ]
     UNIFIED_SOURCES += [
         'core/platform.cpp',
         'core/ProfileBuffer.cpp',
         'core/ProfileBufferEntry.cpp',
         'core/ProfileJSONWriter.cpp',
@@ -115,16 +114,17 @@ IPDL_SOURCES += [
     'gecko/ProfilerTypes.ipdlh',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 EXPORTS += [
     'public/GeckoProfiler.h',
     'public/GeckoProfilerReporter.h',
+    'public/ProfilerMarkerPayload.h',
 ]
 
 if CONFIG['MOZ_TASK_TRACER']:
     EXPORTS += [
         'tasktracer/GeckoTaskTracer.h',
         'tasktracer/GeckoTaskTracerImpl.h',
         'tasktracer/SourceEventTypeMap.h',
         'tasktracer/TracedTaskCommon.h',
--- a/tools/profiler/public/ProfilerMarkerPayload.h
+++ b/tools/profiler/public/ProfilerMarkerPayload.h
@@ -30,20 +30,27 @@ class UniqueStacks;
 // This is an abstract class that can be implemented to supply data to be
 // attached with a profiler marker.
 //
 // When subclassing this, note that the destructor can be called on any thread,
 // i.e. not necessarily on the thread that created the object.
 class ProfilerMarkerPayload
 {
 public:
-  explicit ProfilerMarkerPayload(UniqueProfilerBacktrace aStack = nullptr);
+  explicit ProfilerMarkerPayload(UniqueProfilerBacktrace aStack = nullptr)
+    : mStack(Move(aStack))
+  {}
+
   ProfilerMarkerPayload(const mozilla::TimeStamp& aStartTime,
                         const mozilla::TimeStamp& aEndTime,
-                        UniqueProfilerBacktrace aStack = nullptr);
+                        UniqueProfilerBacktrace aStack = nullptr)
+    : mStartTime(aStartTime)
+    , mEndTime(aEndTime)
+    , mStack(Move(aStack))
+  {}
 
   virtual ~ProfilerMarkerPayload() {}
 
   virtual void StreamPayload(SpliceableJSONWriter& aWriter,
                              const mozilla::TimeStamp& aProcessStartTime,
                              UniqueStacks& aUniqueStacks) = 0;
 
   mozilla::TimeStamp GetStartTime() const { return mStartTime; }
@@ -60,182 +67,214 @@ protected:
   }
 
 private:
   mozilla::TimeStamp mStartTime;
   mozilla::TimeStamp mEndTime;
   UniqueProfilerBacktrace mStack;
 };
 
+#define DECL_STREAM_PAYLOAD_BASE  \
+  virtual void StreamPayload(SpliceableJSONWriter& aWriter, \
+                             const mozilla::TimeStamp& aProcessStartTime, \
+                             UniqueStacks& aUniqueStacks) override
+
+// If the profiler is disabled then StreamPayload() will never be called.
+#ifdef MOZ_GECKO_PROFILER
+# define DECL_STREAM_PAYLOAD DECL_STREAM_PAYLOAD_BASE ;
+#else
+# define DECL_STREAM_PAYLOAD DECL_STREAM_PAYLOAD_BASE { MOZ_CRASH(); }
+#endif
+
 class TracingMarkerPayload : public ProfilerMarkerPayload
 {
 public:
   TracingMarkerPayload(const char* aCategory, TracingKind aKind,
-                       UniqueProfilerBacktrace aCause = nullptr);
+                       UniqueProfilerBacktrace aCause = nullptr)
+    : mCategory(aCategory)
+    , mKind(aKind)
+  {
+    if (aCause) {
+      SetStack(Move(aCause));
+    }
+  }
 
-  virtual void StreamPayload(SpliceableJSONWriter& aWriter,
-                             const mozilla::TimeStamp& aProcessStartTime,
-                             UniqueStacks& aUniqueStacks) override;
+  DECL_STREAM_PAYLOAD
 
 private:
   const char *mCategory;
   TracingKind mKind;
 };
 
 class IOMarkerPayload : public ProfilerMarkerPayload
 {
 public:
   IOMarkerPayload(const char* aSource, const char* aFilename,
                   const mozilla::TimeStamp& aStartTime,
                   const mozilla::TimeStamp& aEndTime,
-                  UniqueProfilerBacktrace aStack);
+                  UniqueProfilerBacktrace aStack)
+    : ProfilerMarkerPayload(aStartTime, aEndTime, Move(aStack))
+    , mSource(aSource)
+    , mFilename(aFilename ? strdup(aFilename) : nullptr)
+  {
+    MOZ_ASSERT(aSource);
+  }
 
-  virtual void StreamPayload(SpliceableJSONWriter& aWriter,
-                             const mozilla::TimeStamp& aProcessStartTime,
-                             UniqueStacks& aUniqueStacks) override;
+  DECL_STREAM_PAYLOAD
 
 private:
   const char* mSource;
   mozilla::UniqueFreePtr<char> mFilename;
 };
 
 class DOMEventMarkerPayload : public ProfilerMarkerPayload
 {
 public:
   DOMEventMarkerPayload(const nsAString& aType, uint16_t aPhase,
                         const mozilla::TimeStamp& aStartTime,
-                        const mozilla::TimeStamp& aEndTime);
+                        const mozilla::TimeStamp& aEndTime)
+    : ProfilerMarkerPayload(aStartTime, aEndTime)
+    , mType(aType)
+    , mPhase(aPhase)
+  {}
 
-  virtual void StreamPayload(SpliceableJSONWriter& aWriter,
-                             const mozilla::TimeStamp& aProcessStartTime,
-                             UniqueStacks& aUniqueStacks) override;
+  DECL_STREAM_PAYLOAD
 
 private:
   nsString mType;
   uint16_t mPhase;
 };
 
 class UserTimingMarkerPayload : public ProfilerMarkerPayload
 {
 public:
   UserTimingMarkerPayload(const nsAString& aName,
-                          const mozilla::TimeStamp& aStartTime);
+                          const mozilla::TimeStamp& aStartTime)
+    : ProfilerMarkerPayload(aStartTime, aStartTime)
+    , mEntryType("mark")
+    , mName(aName)
+  {}
+
   UserTimingMarkerPayload(const nsAString& aName,
                           const mozilla::TimeStamp& aStartTime,
-                          const mozilla::TimeStamp& aEndTime);
+                          const mozilla::TimeStamp& aEndTime)
+    : ProfilerMarkerPayload(aStartTime, aEndTime)
+    , mEntryType("measure")
+    , mName(aName)
+  {}
 
-  virtual void StreamPayload(SpliceableJSONWriter& aWriter,
-                             const mozilla::TimeStamp& aProcessStartTime,
-                             UniqueStacks& aUniqueStacks) override;
+  DECL_STREAM_PAYLOAD
 
 private:
   // Either "mark" or "measure".
   const char* mEntryType;
   nsString mName;
 };
 
 // Contains the translation applied to a 2d layer so we can track the layer
 // position at each frame.
 class LayerTranslationMarkerPayload : public ProfilerMarkerPayload
 {
 public:
   LayerTranslationMarkerPayload(mozilla::layers::Layer* aLayer,
-                                mozilla::gfx::Point aPoint);
+                                mozilla::gfx::Point aPoint)
+    : ProfilerMarkerPayload(mozilla::TimeStamp::Now(),
+                            mozilla::TimeStamp::Now())
+    , mLayer(aLayer)
+    , mPoint(aPoint)
+  {}
 
-  virtual void StreamPayload(SpliceableJSONWriter& aWriter,
-                             const mozilla::TimeStamp& aProcessStartTime,
-                             UniqueStacks& aUniqueStacks) override;
+  DECL_STREAM_PAYLOAD
 
 private:
   mozilla::layers::Layer* mLayer;
   mozilla::gfx::Point mPoint;
 };
 
 #include "Units.h"    // For ScreenIntPoint
 
 // Tracks when a vsync occurs according to the HardwareComposer.
 class VsyncMarkerPayload : public ProfilerMarkerPayload
 {
 public:
-  explicit VsyncMarkerPayload(mozilla::TimeStamp aVsyncTimestamp);
+  explicit VsyncMarkerPayload(mozilla::TimeStamp aVsyncTimestamp)
+    : ProfilerMarkerPayload(aVsyncTimestamp, aVsyncTimestamp)
+    , mVsyncTimestamp(aVsyncTimestamp)
+  {}
 
-  virtual void StreamPayload(SpliceableJSONWriter& aWriter,
-                             const mozilla::TimeStamp& aProcessStartTime,
-                             UniqueStacks& aUniqueStacks) override;
+  DECL_STREAM_PAYLOAD
 
 private:
   mozilla::TimeStamp mVsyncTimestamp;
 };
 
 class GPUMarkerPayload : public ProfilerMarkerPayload
 {
 public:
   GPUMarkerPayload(const mozilla::TimeStamp& aCpuTimeStart,
                    const mozilla::TimeStamp& aCpuTimeEnd,
                    uint64_t aGpuTimeStart,
-                   uint64_t aGpuTimeEnd);
+                   uint64_t aGpuTimeEnd)
+    : ProfilerMarkerPayload(aCpuTimeStart, aCpuTimeEnd)
+    , mCpuTimeStart(aCpuTimeStart)
+    , mCpuTimeEnd(aCpuTimeEnd)
+    , mGpuTimeStart(aGpuTimeStart)
+    , mGpuTimeEnd(aGpuTimeEnd)
+  {}
 
-  virtual void StreamPayload(SpliceableJSONWriter& aWriter,
-                             const mozilla::TimeStamp& aProcessStartTime,
-                             UniqueStacks& aUniqueStacks) override;
+  DECL_STREAM_PAYLOAD
 
 private:
   mozilla::TimeStamp mCpuTimeStart;
   mozilla::TimeStamp mCpuTimeEnd;
   uint64_t mGpuTimeStart;
   uint64_t mGpuTimeEnd;
 };
 
 class GCSliceMarkerPayload : public ProfilerMarkerPayload
 {
 public:
   GCSliceMarkerPayload(const mozilla::TimeStamp& aStartTime,
                        const mozilla::TimeStamp& aEndTime,
                        JS::UniqueChars&& aTimingJSON)
-   : ProfilerMarkerPayload(aStartTime, aEndTime, nullptr),
+   : ProfilerMarkerPayload(aStartTime, aEndTime),
      mTimingJSON(mozilla::Move(aTimingJSON))
   {}
 
-  void StreamPayload(SpliceableJSONWriter& aWriter,
-                     const mozilla::TimeStamp& aProcessStartTime,
-                     UniqueStacks& aUniqueStacks) override;
+  DECL_STREAM_PAYLOAD
 
 private:
   JS::UniqueChars mTimingJSON;
 };
 
 class GCMajorMarkerPayload : public ProfilerMarkerPayload
 {
 public:
   GCMajorMarkerPayload(const mozilla::TimeStamp& aStartTime,
                        const mozilla::TimeStamp& aEndTime,
                        JS::UniqueChars&& aTimingJSON)
-   : ProfilerMarkerPayload(aStartTime, aEndTime, nullptr),
+   : ProfilerMarkerPayload(aStartTime, aEndTime),
      mTimingJSON(mozilla::Move(aTimingJSON))
   {}
 
-  void StreamPayload(SpliceableJSONWriter& aWriter,
-                     const mozilla::TimeStamp& aProcessStartTime,
-                     UniqueStacks& aUniqueStacks) override;
+  DECL_STREAM_PAYLOAD
 
 private:
   JS::UniqueChars mTimingJSON;
 };
 
 class GCMinorMarkerPayload : public ProfilerMarkerPayload
 {
 public:
   GCMinorMarkerPayload(const mozilla::TimeStamp& aStartTime,
                        const mozilla::TimeStamp& aEndTime,
                        JS::UniqueChars&& aTimingData)
-   : ProfilerMarkerPayload(aStartTime, aEndTime, nullptr),
+   : ProfilerMarkerPayload(aStartTime, aEndTime),
      mTimingData(mozilla::Move(aTimingData))
   {}
 
-  void StreamPayload(SpliceableJSONWriter& aWriter,
-                     const mozilla::TimeStamp& aProcessStartTime,
-                     UniqueStacks& aUniqueStacks) override;
+  DECL_STREAM_PAYLOAD
 
 private:
   JS::UniqueChars mTimingData;
 };
 
 #endif // ProfilerMarkerPayload_h
--- a/widget/VsyncDispatcher.cpp
+++ b/widget/VsyncDispatcher.cpp
@@ -28,19 +28,17 @@ CompositorVsyncDispatcher::~CompositorVs
   MOZ_ASSERT(XRE_IsParentProcess());
   // We auto remove this vsync dispatcher from the vsync source in the nsBaseWidget
 }
 
 void
 CompositorVsyncDispatcher::NotifyVsync(TimeStamp aVsyncTimestamp)
 {
   // In vsync thread
-#ifdef MOZ_GECKO_PROFILER
   layers::CompositorBridgeParent::PostInsertVsyncProfilerMarker(aVsyncTimestamp);
-#endif
 
   MutexAutoLock lock(mCompositorObserverLock);
   if (mCompositorVsyncObserver) {
     mCompositorVsyncObserver->NotifyVsync(aVsyncTimestamp);
   }
 }
 
 void
--- a/xpcom/base/CycleCollectedJSRuntime.cpp
+++ b/xpcom/base/CycleCollectedJSRuntime.cpp
@@ -80,19 +80,17 @@
 #include "nsCycleCollectionNoteRootCallback.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsCycleCollector.h"
 #include "nsDOMJSUtils.h"
 #include "nsJSUtils.h"
 #include "nsWrapperCache.h"
 #include "nsStringBuffer.h"
 #include "GeckoProfiler.h"
-#ifdef MOZ_GECKO_PROFILER
 #include "ProfilerMarkerPayload.h"
-#endif
 
 #ifdef MOZ_CRASHREPORTER
 #include "nsExceptionHandler.h"
 #endif
 
 #include "nsIException.h"
 #include "nsIPlatformInfo.h"
 #include "nsThread.h"
@@ -829,33 +827,31 @@ CycleCollectedJSRuntime::GCCallback(JSCo
 /* static */ void
 CycleCollectedJSRuntime::GCSliceCallback(JSContext* aContext,
                                          JS::GCProgress aProgress,
                                          const JS::GCDescription& aDesc)
 {
   CycleCollectedJSRuntime* self = CycleCollectedJSRuntime::Get();
   MOZ_ASSERT(CycleCollectedJSContext::Get()->Context() == aContext);
 
-#ifdef MOZ_GECKO_PROFILER
   if (profiler_is_active()) {
     if (aProgress == JS::GC_CYCLE_END) {
       profiler_add_marker(
         "GCMajor",
         MakeUnique<GCMajorMarkerPayload>(aDesc.startTime(aContext),
                                          aDesc.endTime(aContext),
                                          aDesc.summaryToJSON(aContext)));
     } else if (aProgress == JS::GC_SLICE_END) {
       profiler_add_marker(
         "GCSlice",
         MakeUnique<GCSliceMarkerPayload>(aDesc.lastSliceStart(aContext),
                                          aDesc.lastSliceEnd(aContext),
                                          aDesc.sliceToJSON(aContext)));
     }
   }
-#endif
 
   if (aProgress == JS::GC_CYCLE_END) {
     JS::gcreason::Reason reason = aDesc.reason_;
     Unused <<
       NS_WARN_IF(NS_FAILED(DebuggerOnGCRunnable::Enqueue(aContext, aDesc)) &&
                  reason != JS::gcreason::SHUTDOWN_CC &&
                  reason != JS::gcreason::DESTROY_RUNTIME &&
                  reason != JS::gcreason::XPCONNECT_SHUTDOWN);
@@ -930,23 +926,21 @@ CycleCollectedJSRuntime::GCNurseryCollec
     timelines->AddMarkerForAllObservedDocShells(abstractMarker);
   }
 
   if (aProgress == JS::GCNurseryProgress::GC_NURSERY_COLLECTION_START) {
     self->mLatestNurseryCollectionStart = TimeStamp::Now();
   } else if ((aProgress == JS::GCNurseryProgress::GC_NURSERY_COLLECTION_END) &&
              profiler_is_active())
   {
-#ifdef MOZ_GECKO_PROFILER
     profiler_add_marker(
       "GCMinor",
       MakeUnique<GCMinorMarkerPayload>(self->mLatestNurseryCollectionStart,
                                        TimeStamp::Now(),
                                        JS::MinorGcToJSON(aContext)));
-#endif
   }
 
   if (self->mPrevGCNurseryCollectionCallback) {
     self->mPrevGCNurseryCollectionCallback(aContext, aProgress, aReason);
   }
 }