Bug 1559000 - mozglue's AutoProfilerLabel doesn't need to know about ProfilingStack - r=mstange
authorGerald Squelart <gsquelart@mozilla.com>
Thu, 04 Jul 2019 04:38:16 +0000
changeset 481230 8fed7bc35767fdfab4bac0908ae9b21c08f49e1f
parent 481229 cc6fbf8afb48a0e3e3cc9c2db7a91b5906fb0a8b
child 481231 c9da4cd2c6f56a3b6034c41fb208e583ba0cbcd3
push id89173
push usergsquelart@mozilla.com
push dateThu, 04 Jul 2019 09:01:43 +0000
treeherderautoland@c52f0346e630 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1559000
milestone69.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 1559000 - mozglue's AutoProfilerLabel doesn't need to know about ProfilingStack - r=mstange `ProfilingStack*` happens to be the information that the current Gecko Profiler entry function wants to forward to the exit function, but AutoProfilerLabel does not really need to know about that. Changing it to `void*`, so that we can later use different entry/exit functions that use different context types. Differential Revision: https://phabricator.services.mozilla.com/D34806
mozglue/misc/AutoProfilerLabel.cpp
mozglue/misc/AutoProfilerLabel.h
tools/profiler/core/platform.cpp
--- a/mozglue/misc/AutoProfilerLabel.cpp
+++ b/mozglue/misc/AutoProfilerLabel.cpp
@@ -17,18 +17,18 @@ void RegisterProfilerLabelEnterExit(Prof
   sExit = aExit;
 }
 
 AutoProfilerLabel::AutoProfilerLabel(
     const char* aLabel,
     const char* aDynamicString MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL) {
   MOZ_GUARD_OBJECT_NOTIFIER_INIT;
 
-  mProfilingStack = sEnter ? sEnter(aLabel, aDynamicString, this) : nullptr;
+  mEntryContext = sEnter ? sEnter(aLabel, aDynamicString, this) : nullptr;
 }
 
 AutoProfilerLabel::~AutoProfilerLabel() {
-  if (sExit && mProfilingStack) {
-    sExit(mProfilingStack);
+  if (sExit && mEntryContext) {
+    sExit(mEntryContext);
   }
 }
 
 }  // namespace mozilla
--- a/mozglue/misc/AutoProfilerLabel.h
+++ b/mozglue/misc/AutoProfilerLabel.h
@@ -20,22 +20,22 @@
 //
 // Note that this class is slightly slower than the other AutoProfilerLabel,
 // and it lacks the macro wrappers. It also is effectively hardwired to use
 // JS::ProfilingCategory::OTHER as the category pair, because that's what
 // the callbacks provided by the profiler use. (Specifying the categories in
 // this file would require #including ProfilingCategory.h in mozglue, which we
 // don't want to do.)
 
-class ProfilingStack;
-
 namespace mozilla {
 
-typedef ProfilingStack* (*ProfilerLabelEnter)(const char*, const char*, void*);
-typedef void (*ProfilerLabelExit)(ProfilingStack*);
+// Enter should return a pointer that will be given to Exit.
+typedef void* (*ProfilerLabelEnter)(const char* aLabel,
+                                    const char* aDynamicString, void* aSp);
+typedef void (*ProfilerLabelExit)(void* EntryContext);
 
 // Register callbacks that do the entry/exit work involving sProfilingStack.
 MFBT_API void RegisterProfilerLabelEnterExit(ProfilerLabelEnter aEnter,
                                              ProfilerLabelExit aExit);
 
 // This #ifdef prevents this AutoProfilerLabel from being defined in libxul,
 // which would conflict with the one in the profiler.
 #ifdef IMPL_MFBT
@@ -43,16 +43,16 @@ MFBT_API void RegisterProfilerLabelEnter
 class MOZ_RAII AutoProfilerLabel {
  public:
   AutoProfilerLabel(const char* aLabel,
                     const char* aDynamicString MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
   ~AutoProfilerLabel();
 
  private:
   MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
-  ProfilingStack* mProfilingStack;
+  void* mEntryContext;
 };
 
 #endif
 
 }  // namespace mozilla
 
 #endif  // mozilla_AutoProfilerLabel_h
--- a/tools/profiler/core/platform.cpp
+++ b/tools/profiler/core/platform.cpp
@@ -2837,30 +2837,30 @@ static void NotifyProfilerStarted(const 
 }
 
 static void locked_profiler_start(PSLockRef aLock, PowerOfTwo32 aCapacity,
                                   double aInterval, uint32_t aFeatures,
                                   const char** aFilters, uint32_t aFilterCount,
                                   const Maybe<double>& aDuration);
 
 // This basically duplicates AutoProfilerLabel's constructor.
-ProfilingStack* MozGlueLabelEnter(const char* aLabel,
-                                  const char* aDynamicString, void* aSp) {
+static void* MozGlueLabelEnter(const char* aLabel, const char* aDynamicString,
+                               void* aSp) {
   ProfilingStack* profilingStack = AutoProfilerLabel::sProfilingStack.get();
   if (profilingStack) {
     profilingStack->pushLabelFrame(aLabel, aDynamicString, aSp,
                                    JS::ProfilingCategoryPair::OTHER);
   }
   return profilingStack;
 }
 
 // This basically duplicates AutoProfilerLabel's destructor.
-void MozGlueLabelExit(ProfilingStack* sProfilingStack) {
+static void MozGlueLabelExit(void* sProfilingStack) {
   if (sProfilingStack) {
-    sProfilingStack->pop();
+    reinterpret_cast<ProfilingStack*>(sProfilingStack)->pop();
   }
 }
 
 static Vector<const char*> SplitAtCommas(const char* aString,
                                          UniquePtr<char[]>& aStorage) {
   size_t len = strlen(aString);
   aStorage = MakeUnique<char[]>(len + 1);
   PodCopy(aStorage.get(), aString, len + 1);