Bug 1332577 (part 9) - Remove all mozilla_sampler_*() functions. r=mstange.
authorNicholas Nethercote <nnethercote@mozilla.com>
Fri, 20 Jan 2017 15:05:16 +1100
changeset 375611 5267191b229f425a34f26f0d7a96fd5391f3105d
parent 375610 0cdd083de64d2c7d9cf742ca15546a00e80ec989
child 375612 6328f5d01711068b42ec2d61e04a3f899d4c84d4
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1332577
milestone53.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 1332577 (part 9) - Remove all mozilla_sampler_*() functions. r=mstange. There are lots of profiler_*() functions that simply call onto equivalent or nearly-equivalent mozilla_sampler_*() functions. This patch removes the unnecessary indirection by removing the mozilla_sampler_*() functions. The most important changes: - In platform.cpp, all the mozilla_sampler_*() definitions are renamed as profiler_*(). - In GeckoProfiler.h, the new PROFILER_FUNC{,_VOID} macros provide a neat way to declare the functions that must be present whether the profiler is enabled or not. - In GeckoProfiler.h, all the mozilla_sampler_*() declarations are removed, as are all the profiler_*() definitions that corresponded to a mozilla_sampler_*() function. Other things of note: - profiler_log(const char* str) is now defined in platform.cpp, instead of in GeckoProfiler.h, for consistency with all the other profiler_*() functions. Likewise with profiler_js_operation_callback() and profiler_in_privacy_mode(). - ProfilerBacktraceDestructor::operator() is treated slightly different to all the profiler_*() functions. - Both variants of profiler_tracing() got some early-return conditions moved into them from GeckoProfiler.h. - There were some cases where the profiler_*() and mozilla_sampler_*() name didn't quite match. Specifically: * mozilla_sampler_get_profile_data() and profiler_get_profiler_jsobject(): name mismatch. Kept the latter. * mozilla_sampler_get_profile_data_async() and profiler_get_profile_jsobject_async(): name mismatch. Kept the latter. * mozilla_sampler_register_thread() and profiler_register_thread(): return type mismatch. Changed to void. * mozilla_sampler_frame_number() and profiler_set_frame_number(): name mismatch. Kept the latter. * mozilla_sampler_save_profile_to_file() and profile_sampler_save_profile_to_file(): the former was 'extern "C"' so it could be called from a debugger easily. The latter now is 'extern "C"'. - profiler_get_buffer_info() didn't fit the patterns handled by PROFILER_FUNC{,VOID}, so the patch makes it call onto the new function profiler_get_buffer_info_helper(), which does fit the pattern.
tools/profiler/core/platform.cpp
tools/profiler/public/GeckoProfiler.h
--- a/tools/profiler/core/platform.cpp
+++ b/tools/profiler/core/platform.cpp
@@ -458,17 +458,23 @@ bool is_main_thread_name(const char* aNa
 #define VARARGS_ASSIGN(foo, bar)        VA_COPY(foo,bar)
 #elif defined(HAVE_VA_LIST_AS_ARRAY)
 #define VARARGS_ASSIGN(foo, bar)     foo[0] = bar[0]
 #else
 #define VARARGS_ASSIGN(foo, bar)     (foo) = (bar)
 #endif
 
 void
-mozilla_sampler_log(const char *fmt, va_list args)
+profiler_log(const char* str)
+{
+  profiler_tracing("log", str, TRACING_EVENT);
+}
+
+void
+profiler_log(const char* fmt, va_list args)
 {
   if (profiler_is_active()) {
     // nsAutoCString AppendPrintf would be nicer but
     // this is mozilla external code
     char buf[2048];
     va_list argsCpy;
     VARARGS_ASSIGN(argsCpy, args);
     int required = VsprintfLiteral(buf, fmt, argsCpy);
@@ -491,28 +497,29 @@ mozilla_sampler_log(const char *fmt, va_
       delete[] heapBuf;
     }
   }
 }
 
 ////////////////////////////////////////////////////////////////////////
 // BEGIN externally visible functions
 
-void mozilla_sampler_init(void* stackTop)
+void
+profiler_init(void* stackTop)
 {
   sInitCount++;
 
   if (stack_key_initialized)
     return;
 
 #ifdef MOZ_TASK_TRACER
   mozilla::tasktracer::InitTaskTracer();
 #endif
 
-  LOG("BEGIN mozilla_sampler_init");
+  LOG("BEGIN profiler_init");
   if (!tlsPseudoStack.init() || !tlsTicker.init()) {
     LOG("Failed to init.");
     return;
   }
   bool ignore;
   sStartTime = mozilla::TimeStamp::ProcessCreation(ignore);
 
   stack_key_initialized = true;
@@ -529,17 +536,17 @@ void mozilla_sampler_init(void* stackTop
 
   // Read interval settings from MOZ_PROFILER_INTERVAL and stack-scan
   // threshhold from MOZ_PROFILER_STACK_SCAN.
   read_profiler_env_vars();
 
   // platform specific initialization
   OS::Startup();
 
-  set_stderr_callback(mozilla_sampler_log);
+  set_stderr_callback(profiler_log);
 
 #if defined(SPS_OS_android) && !defined(MOZ_WIDGET_GONK)
   if (mozilla::jni::IsFennec()) {
     GeckoJavaSampler::Init();
   }
 #endif
 
   // We can't open pref so we use an environment variable
@@ -563,20 +570,21 @@ void mozilla_sampler_init(void* stackTop
 #endif
                          };
 
   const char* threadFilters[] = { "GeckoMain", "Compositor" };
 
   profiler_start(PROFILE_DEFAULT_ENTRY, PROFILE_DEFAULT_INTERVAL,
                          features, MOZ_ARRAY_LENGTH(features),
                          threadFilters, MOZ_ARRAY_LENGTH(threadFilters));
-  LOG("END   mozilla_sampler_init");
+  LOG("END   profiler_init");
 }
 
-void mozilla_sampler_shutdown()
+void
+profiler_shutdown()
 {
   sInitCount--;
 
   if (sInitCount > 0)
     return;
 
   // Save the profile on shutdown if requested.
   GeckoSampler *t = tlsTicker.get();
@@ -602,65 +610,69 @@ void mozilla_sampler_shutdown()
   stack->deref();
   tlsPseudoStack.set(nullptr);
 
 #ifdef MOZ_TASK_TRACER
   mozilla::tasktracer::ShutdownTaskTracer();
 #endif
 }
 
-mozilla::UniquePtr<char[]> mozilla_sampler_get_profile(double aSinceTime)
+mozilla::UniquePtr<char[]>
+profiler_get_profile(double aSinceTime)
 {
   GeckoSampler *t = tlsTicker.get();
   if (!t) {
     return nullptr;
   }
 
   return t->ToJSON(aSinceTime);
 }
 
-JSObject *mozilla_sampler_get_profile_data(JSContext *aCx, double aSinceTime)
+JSObject*
+profiler_get_profile_jsobject(JSContext *aCx, double aSinceTime)
 {
   GeckoSampler *t = tlsTicker.get();
   if (!t) {
     return nullptr;
   }
 
   return t->ToJSObject(aCx, aSinceTime);
 }
 
-void mozilla_sampler_get_profile_data_async(double aSinceTime,
-                                            mozilla::dom::Promise* aPromise)
+void
+profiler_get_profile_jsobject_async(double aSinceTime,
+                                    mozilla::dom::Promise* aPromise)
 {
   GeckoSampler *t = tlsTicker.get();
   if (NS_WARN_IF(!t)) {
     return;
   }
 
   t->ToJSObjectAsync(aSinceTime, aPromise);
 }
 
-void mozilla_sampler_save_profile_to_file_async(double aSinceTime,
-                                                const char* aFileName)
+void
+profiler_save_profile_to_file_async(double aSinceTime, const char* aFileName)
 {
   nsCString filename(aFileName);
   NS_DispatchToMainThread(NS_NewRunnableFunction([=] () {
     GeckoSampler *t = tlsTicker.get();
     if (NS_WARN_IF(!t)) {
       return;
     }
 
     t->ToFileAsync(filename, aSinceTime);
   }));
 }
 
-void mozilla_sampler_get_profiler_start_params(int* aEntrySize,
-                                               double* aInterval,
-                                               mozilla::Vector<const char*>* aFilters,
-                                               mozilla::Vector<const char*>* aFeatures)
+void
+profiler_get_start_params(int* aEntrySize,
+                          double* aInterval,
+                          mozilla::Vector<const char*>* aFilters,
+                          mozilla::Vector<const char*>* aFeatures)
 {
   if (NS_WARN_IF(!aEntrySize) || NS_WARN_IF(!aInterval) ||
       NS_WARN_IF(!aFilters) || NS_WARN_IF(!aFeatures)) {
     return;
   }
 
   GeckoSampler *t = tlsTicker.get();
   if (NS_WARN_IF(!t)) {
@@ -678,17 +690,18 @@ void mozilla_sampler_get_profiler_start_
 
   const FeatureList& featureList = t->Features();
   MOZ_ALWAYS_TRUE(aFeatures->resize(featureList.length()));
   for (size_t i = 0; i < featureList.length(); ++i) {
     (*aFeatures)[i] = featureList[i].c_str();
   }
 }
 
-void mozilla_sampler_get_gatherer(nsISupports** aRetVal)
+void
+profiler_get_gatherer(nsISupports** aRetVal)
 {
   if (!aRetVal) {
     return;
   }
 
   if (NS_WARN_IF(!profiler_is_active())) {
     *aRetVal = nullptr;
     return;
@@ -698,17 +711,18 @@ void mozilla_sampler_get_gatherer(nsISup
   if (NS_WARN_IF(!t)) {
     *aRetVal = nullptr;
     return;
   }
 
   t->GetGatherer(aRetVal);
 }
 
-void mozilla_sampler_save_profile_to_file(const char* aFilename)
+void
+profiler_save_profile_to_file(const char* aFilename)
 {
   GeckoSampler *t = tlsTicker.get();
   if (!t) {
     return;
   }
 
   std::ofstream stream;
   stream.open(aFilename);
@@ -716,18 +730,18 @@ void mozilla_sampler_save_profile_to_fil
     t->ToStreamAsJSON(stream);
     stream.close();
     LOGF("Saved to %s", aFilename);
   } else {
     LOG("Fail to open profile log file.");
   }
 }
 
-
-const char** mozilla_sampler_get_features()
+const char**
+profiler_get_features()
 {
   static const char* features[] = {
 #if defined(MOZ_PROFILING) && defined(HAVE_NATIVE_UNWIND)
     // Walk the C++ stack.
     "stackwalk",
 #endif
 #if defined(ENABLE_SPS_LEAF_DATA)
     // Include the C++ leaf node if not stackwalking. DevTools
@@ -763,40 +777,42 @@ const char** mozilla_sampler_get_feature
     "tasktracer",
 #endif
     nullptr
   };
 
   return features;
 }
 
-void mozilla_sampler_get_buffer_info(uint32_t *aCurrentPosition, uint32_t *aTotalSize,
-                                     uint32_t *aGeneration)
+void
+profiler_get_buffer_info_helper(uint32_t *aCurrentPosition,
+                                uint32_t *aTotalSize,
+                                uint32_t *aGeneration)
 {
-  *aCurrentPosition = 0;
-  *aTotalSize = 0;
-  *aGeneration = 0;
+  // This function is called by profiler_get_buffer_info(), which has already
+  // zeroed the outparams.
 
   if (!stack_key_initialized)
     return;
 
   GeckoSampler *t = tlsTicker.get();
   if (!t)
     return;
 
   t->GetBufferInfo(aCurrentPosition, aTotalSize, aGeneration);
 }
 
 // Values are only honored on the first start
-void mozilla_sampler_start(int aProfileEntries, double aInterval,
-                           const char** aFeatures, uint32_t aFeatureCount,
-                           const char** aThreadNameFilters, uint32_t aFilterCount)
+void
+profiler_start(int aProfileEntries, double aInterval,
+               const char** aFeatures, uint32_t aFeatureCount,
+               const char** aThreadNameFilters, uint32_t aFilterCount)
 
 {
-  LOG("BEGIN mozilla_sampler_start");
+  LOG("BEGIN profiler_start");
 
   if (!stack_key_initialized)
     profiler_init(nullptr);
 
   /* If the sampling interval was set using env vars, use that
      in preference to anything else. */
   if (sUnwindInterval > 0)
     aInterval = sUnwindInterval;
@@ -882,29 +898,30 @@ void mozilla_sampler_start(int aProfileE
       nsCOMPtr<nsIProfilerStartParams> params =
         new nsProfilerStartParams(aProfileEntries, aInterval, featuresArray,
                                   threadNameFiltersArray);
 
       os->NotifyObservers(params, "profiler-started", nullptr);
     }
   }
 
-  LOG("END   mozilla_sampler_start");
+  LOG("END   profiler_start");
 }
 
-void mozilla_sampler_stop()
+void
+profiler_stop()
 {
-  LOG("BEGIN mozilla_sampler_stop");
+  LOG("BEGIN profiler_stop");
 
   if (!stack_key_initialized)
     return;
 
   GeckoSampler *t = tlsTicker.get();
   if (!t) {
-    LOG("END   mozilla_sampler_stop-early");
+    LOG("END   profiler_stop-early");
     return;
   }
 
   bool disableJS = t->ProfileJS();
 
   t->Stop();
   delete t;
   tlsTicker.set(nullptr);
@@ -926,50 +943,57 @@ void mozilla_sampler_stop()
   sIsRestyleProfiling = false;
 
   if (Sampler::CanNotifyObservers()) {
     nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
     if (os)
       os->NotifyObservers(nullptr, "profiler-stopped", nullptr);
   }
 
-  LOG("END   mozilla_sampler_stop");
+  LOG("END   profiler_stop");
 }
 
-bool mozilla_sampler_is_paused() {
+bool
+profiler_is_paused()
+{
   if (Sampler::GetActiveSampler()) {
     return Sampler::GetActiveSampler()->IsPaused();
   } else {
     return false;
   }
 }
 
-void mozilla_sampler_pause() {
+void
+profiler_pause()
+{
   if (Sampler::GetActiveSampler()) {
     Sampler::GetActiveSampler()->SetPaused(true);
     if (Sampler::CanNotifyObservers()) {
       nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
       if (os)
         os->NotifyObservers(nullptr, "profiler-paused", nullptr);
     }
   }
 }
 
-void mozilla_sampler_resume() {
+void
+profiler_resume()
+{
   if (Sampler::GetActiveSampler()) {
     Sampler::GetActiveSampler()->SetPaused(false);
     if (Sampler::CanNotifyObservers()) {
       nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
       if (os)
         os->NotifyObservers(nullptr, "profiler-resumed", nullptr);
     }
   }
 }
 
-bool mozilla_sampler_feature_active(const char* aName)
+bool
+profiler_feature_active(const char* aName)
 {
   if (!profiler_is_active()) {
     return false;
   }
 
   if (strcmp(aName, "gpu") == 0) {
     return sIsGPUProfiling;
   }
@@ -984,70 +1008,77 @@ bool mozilla_sampler_feature_active(cons
 
   if (strcmp(aName, "restyle") == 0) {
     return sIsRestyleProfiling;
   }
 
   return false;
 }
 
-bool mozilla_sampler_is_active()
+bool
+profiler_is_active()
 {
   return sIsProfiling;
 }
 
-void mozilla_sampler_responsiveness(const mozilla::TimeStamp& aTime)
+void
+profiler_responsiveness(const mozilla::TimeStamp& aTime)
 {
   sLastTracerEvent = aTime;
 }
 
-void mozilla_sampler_frame_number(int frameNumber)
+void
+profiler_set_frame_number(int frameNumber)
 {
   sFrameNumber = frameNumber;
 }
 
-void mozilla_sampler_lock()
+void
+profiler_lock()
 {
   profiler_stop();
   nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
   if (os)
     os->NotifyObservers(nullptr, "profiler-locked", nullptr);
 }
 
-void mozilla_sampler_unlock()
+void
+profiler_unlock()
 {
   nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
   if (os)
     os->NotifyObservers(nullptr, "profiler-unlocked", nullptr);
 }
 
-bool mozilla_sampler_register_thread(const char* aName, void* aGuessStackTop)
+void
+profiler_register_thread(const char* aName, void* aGuessStackTop)
 {
   if (sInitCount == 0) {
-    return false;
+    return;
   }
 
 #if defined(MOZ_WIDGET_GONK) && !defined(MOZ_PROFILING)
   // The only way to profile secondary threads on b2g
   // is to build with profiling OR have the profiler
   // running on startup.
   if (!profiler_is_active()) {
-    return false;
+    return;
   }
 #endif
 
   MOZ_ASSERT(tlsPseudoStack.get() == nullptr);
   PseudoStack* stack = PseudoStack::create();
   tlsPseudoStack.set(stack);
   bool isMainThread = is_main_thread_name(aName);
   void* stackTop = GetStackTop(aGuessStackTop);
-  return Sampler::RegisterCurrentThread(aName, stack, isMainThread, stackTop);
+  Sampler::RegisterCurrentThread(aName, stack, isMainThread, stackTop);
 }
 
-void mozilla_sampler_unregister_thread()
+void
+profiler_unregister_thread()
 {
   // Don't check sInitCount count here -- we may be unregistering the
   // thread after the sampler was shut down.
   if (!stack_key_initialized) {
     return;
   }
 
   PseudoStack *stack = tlsPseudoStack.get();
@@ -1055,63 +1086,93 @@ void mozilla_sampler_unregister_thread()
     return;
   }
   stack->deref();
   tlsPseudoStack.set(nullptr);
 
   Sampler::UnregisterCurrentThread();
 }
 
-void mozilla_sampler_sleep_start() {
+void
+profiler_sleep_start()
+{
   if (sInitCount == 0) {
     return;
   }
 
   PseudoStack *stack = tlsPseudoStack.get();
   if (stack == nullptr) {
     return;
   }
   stack->setSleeping(1);
 }
 
-void mozilla_sampler_sleep_end() {
+void
+profiler_sleep_end()
+{
   if (sInitCount == 0) {
     return;
   }
 
   PseudoStack *stack = tlsPseudoStack.get();
   if (stack == nullptr) {
     return;
   }
   stack->setSleeping(0);
 }
 
-bool mozilla_sampler_is_sleeping() {
+bool
+profiler_is_sleeping()
+{
   if (sInitCount == 0) {
     return false;
   }
   PseudoStack *stack = tlsPseudoStack.get();
   if (stack == nullptr) {
     return false;
   }
   return stack->isSleeping();
 }
 
-double mozilla_sampler_time(const mozilla::TimeStamp& aTime)
+void
+profiler_js_operation_callback()
+{
+  PseudoStack *stack = tlsPseudoStack.get();
+  if (!stack) {
+    return;
+  }
+
+  stack->jsOperationCallback();
+}
+
+double
+profiler_time(const mozilla::TimeStamp& aTime)
 {
   mozilla::TimeDuration delta = aTime - sStartTime;
   return delta.ToMilliseconds();
 }
 
-double mozilla_sampler_time()
+double
+profiler_time()
 {
-  return mozilla_sampler_time(mozilla::TimeStamp::Now());
+  return profiler_time(mozilla::TimeStamp::Now());
 }
 
-UniqueProfilerBacktrace mozilla_sampler_get_backtrace()
+bool
+profiler_in_privacy_mode()
+{
+  PseudoStack *stack = tlsPseudoStack.get();
+  if (!stack) {
+    return false;
+  }
+  return stack->mPrivacyMode;
+}
+
+UniqueProfilerBacktrace
+profiler_get_backtrace()
 {
   if (!stack_key_initialized)
     return nullptr;
 
   // Don't capture a stack if we're not profiling
   if (!profiler_is_active()) {
     return nullptr;
   }
@@ -1133,17 +1194,18 @@ void
 ProfilerBacktraceDestructor::operator()(ProfilerBacktrace* aBacktrace)
 {
   delete aBacktrace;
 }
 
 // Fill the output buffer with the following pattern:
 // "Lable 1" "\0" "Label 2" "\0" ... "Label N" "\0" "\0"
 // TODO: use the unwinder instead of pseudo stack.
-void mozilla_sampler_get_backtrace_noalloc(char *output, size_t outputSize)
+void
+profiler_get_backtrace_noalloc(char *output, size_t outputSize)
 {
   MOZ_ASSERT(outputSize >= 2);
   char *bound = output + outputSize - 2;
   output[0] = output[1] = '\0';
   PseudoStack *pseudoStack = tlsPseudoStack.get();
   if (!pseudoStack) {
     return;
   }
@@ -1157,31 +1219,45 @@ void mozilla_sampler_get_backtrace_noall
       break;
     strcpy(output, pseudoFrames[i].label());
     output += len;
     *output++ = '\0';
     *output = '\0';
   }
 }
 
-void mozilla_sampler_tracing(const char* aCategory, const char* aInfo,
-                             TracingMetadata aMetaData)
+void
+profiler_tracing(const char* aCategory, const char* aInfo,
+                 TracingMetadata aMetaData)
 {
-  mozilla_sampler_add_marker(aInfo, new ProfilerMarkerTracing(aCategory, aMetaData));
+  // Don't insert a marker if we're not profiling, to avoid the heap copy
+  // (malloc).
+  if (!stack_key_initialized || !profiler_is_active()) {
+    return;
+  }
+
+  profiler_add_marker(aInfo, new ProfilerMarkerTracing(aCategory, aMetaData));
 }
 
-void mozilla_sampler_tracing(const char* aCategory, const char* aInfo,
-                             UniqueProfilerBacktrace aCause,
-                             TracingMetadata aMetaData)
+void
+profiler_tracing(const char* aCategory, const char* aInfo,
+                 UniqueProfilerBacktrace aCause, TracingMetadata aMetaData)
 {
-  mozilla_sampler_add_marker(aInfo, new ProfilerMarkerTracing(aCategory, aMetaData,
-                                                              mozilla::Move(aCause)));
+  // Don't insert a marker if we're not profiling, to avoid the heap copy
+  // (malloc).
+  if (!stack_key_initialized || !profiler_is_active()) {
+    return;
+  }
+
+  profiler_add_marker(aInfo, new ProfilerMarkerTracing(aCategory, aMetaData,
+                                                       mozilla::Move(aCause)));
 }
 
-void mozilla_sampler_add_marker(const char *aMarker, ProfilerMarkerPayload *aPayload)
+void
+profiler_add_marker(const char *aMarker, ProfilerMarkerPayload *aPayload)
 {
   // Note that aPayload may be allocated by the caller, so we need to make sure
   // that we free it at some point.
   mozilla::UniquePtr<ProfilerMarkerPayload> payload(aPayload);
 
   if (!stack_key_initialized)
     return;
 
--- a/tools/profiler/public/GeckoProfiler.h
+++ b/tools/profiler/public/GeckoProfiler.h
@@ -85,16 +85,23 @@ struct ProfilerBacktraceDestructor
 {
   void operator()(ProfilerBacktrace*);
 };
 using UniqueProfilerBacktrace =
   mozilla::UniquePtr<ProfilerBacktrace, ProfilerBacktraceDestructor>;
 
 #if !defined(MOZ_ENABLE_PROFILER_SPS)
 
+// Use these for functions below that must be visible whether the profiler is
+// enabled or not. When the profiler is disabled they are static inline
+// functions (with a simple return value if they are non-void) that should be
+// optimized away during compilation.
+#define PROFILER_FUNC(decl, rv)  static inline decl { return rv; }
+#define PROFILER_FUNC_VOID(decl) static inline void decl {}
+
 // 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, category) do {} while (0)
 
 // Similar to PROFILER_LABEL, PROFILER_LABEL_FUNC will push/pop the enclosing
 // functon name as the pseudostack label.
 #define PROFILER_LABEL_FUNC(category) do {} while (0)
@@ -107,151 +114,187 @@ using UniqueProfilerBacktrace =
 
 // 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.
 #define PROFILER_MARKER(info) do {} while (0)
 #define PROFILER_MARKER_PAYLOAD(info, payload) do { mozilla::UniquePtr<ProfilerMarkerPayload> payloadDeletor(payload); } while (0)
 
-static inline void profiler_tracing(const char* aCategory, const char* aInfo,
-                                    TracingMetadata metaData = TRACING_DEFAULT) {}
-static inline void profiler_tracing(const char* aCategory, const char* aInfo,
+#else   // defined(MOZ_ENABLE_PROFILER_SPS)
+
+#define PROFILER_FUNC(decl, rv)  decl;
+#define PROFILER_FUNC_VOID(decl) void decl;
+
+// 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
+
+#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_FUNC(category) MOZ_PLATFORM_TRACING(SAMPLE_FUNCTION_NAME) mozilla::SamplerStackFrameRAII SAMPLER_APPEND_LINE_NUMBER(sampler_raii)(SAMPLE_FUNCTION_NAME, 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) profiler_add_marker(info)
+#define PROFILER_MARKER_PAYLOAD(info, payload) profiler_add_marker(info, payload)
+
+#endif  // defined(MOZ_ENABLE_PROFILER_SPS)
+
+// These functions are defined whether the profiler is enabled or not.
+
+PROFILER_FUNC_VOID(profiler_tracing(const char* aCategory, const char* aInfo,
+                                    TracingMetadata metaData = TRACING_DEFAULT))
+PROFILER_FUNC_VOID(profiler_tracing(const char* aCategory, const char* aInfo,
                                     UniqueProfilerBacktrace aCause,
-                                    TracingMetadata metaData = TRACING_DEFAULT) {}
+                                    TracingMetadata metaData = TRACING_DEFAULT))
 
 // Initilize the profiler TLS, signal handlers on linux. If MOZ_PROFILER_STARTUP
 // is set the profiler will be started. This call must happen before any other
 // sampler calls. Particularly sampler_label/sampler_marker.
-static inline void profiler_init(void* stackTop) {};
+PROFILER_FUNC_VOID(profiler_init(void* stackTop))
 
 // Clean up the profiler module, stopping it if required. This function may
 // also save a shutdown profile if requested. No profiler calls should happen
 // after this point and all pseudo labels should have been popped.
-static inline void profiler_shutdown() {};
+PROFILER_FUNC_VOID(profiler_shutdown())
 
 // Start the profiler with the selected options. The samples will be
 // recorded in a circular buffer.
 //   "aProfileEntries" is an abstract size indication of how big
 //       the profile's circular buffer should be. Multiply by 4
 //       words to get the cost.
 //   "aInterval" the sampling interval. The profiler will do its
 //       best to sample at this interval. The profiler visualization
 //       should represent the actual sampling accuracy.
-static inline void profiler_start(int aProfileEntries, double aInterval,
+PROFILER_FUNC_VOID(profiler_start(int aProfileEntries, double aInterval,
                               const char** aFeatures, uint32_t aFeatureCount,
-                              const char** aThreadNameFilters, uint32_t aFilterCount) {}
+                              const char** aThreadNameFilters, uint32_t aFilterCount))
 
 // Stop the profiler and discard the profile. Call 'profiler_save' before this
 // to retrieve the profile.
-static inline void profiler_stop() {}
+PROFILER_FUNC_VOID(profiler_stop())
 
 // These functions pause and resume the profiler. While paused the profile will not
 // take any samples and will not record any data into its buffers. The profiler
 // remains fully initialized in this state. Timeline markers will still be stored.
 // This feature will keep javascript profiling enabled, thus allowing toggling the
 // profiler without invalidating the JIT.
-static inline bool profiler_is_paused() { return false; }
-static inline void profiler_pause() {}
-static inline void profiler_resume() {}
-
+PROFILER_FUNC(bool profiler_is_paused(), false)
+PROFILER_FUNC_VOID(profiler_pause())
+PROFILER_FUNC_VOID(profiler_resume())
 
 // Immediately capture the current thread's call stack and return it
-static inline UniqueProfilerBacktrace profiler_get_backtrace() { return nullptr; }
-static inline void profiler_get_backtrace_noalloc(char *output, size_t outputSize) { return; }
+PROFILER_FUNC(UniqueProfilerBacktrace profiler_get_backtrace(), nullptr)
+PROFILER_FUNC_VOID(profiler_get_backtrace_noalloc(char *output,
+                                                  size_t outputSize))
 
 // Free a ProfilerBacktrace returned by profiler_get_backtrace()
+#if !defined(MOZ_ENABLE_PROFILER_SPS)
 inline void ProfilerBacktraceDestructor::operator()(ProfilerBacktrace* aBacktrace) {}
+#endif
 
-static inline bool profiler_is_active() { return false; }
+PROFILER_FUNC(bool profiler_is_active(), false)
 
 // Check if an external profiler feature is active.
 // Supported:
 //  * gpu
-static inline bool profiler_feature_active(const char*) { return false; }
+PROFILER_FUNC(bool profiler_feature_active(const char*), false)
 
 // Internal-only. Used by the event tracer.
-static inline void profiler_responsiveness(const mozilla::TimeStamp& aTime) {}
+PROFILER_FUNC_VOID(profiler_responsiveness(const mozilla::TimeStamp& aTime))
 
 // Internal-only.
-static inline void profiler_set_frame_number(int frameNumber) {}
+PROFILER_FUNC_VOID(profiler_set_frame_number(int frameNumber))
 
 // Get the profile encoded as a JSON string.
-static inline mozilla::UniquePtr<char[]> profiler_get_profile(double aSinceTime = 0) {
-  return nullptr;
-}
+PROFILER_FUNC(mozilla::UniquePtr<char[]> profiler_get_profile(double aSinceTime = 0),
+              nullptr)
 
 // Get the profile encoded as a JSON object.
-static inline JSObject* profiler_get_profile_jsobject(JSContext* aCx,
-                                                      double aSinceTime = 0) {
-  return nullptr;
-}
+PROFILER_FUNC(JSObject* profiler_get_profile_jsobject(JSContext* aCx,
+                                                       double aSinceTime = 0),
+	       nullptr)
 
 // Get the profile encoded as a JSON object.
-static inline void profiler_get_profile_jsobject_async(double aSinceTime = 0,
-                                                       mozilla::dom::Promise* = 0) {}
-static inline void profiler_get_start_params(int* aEntrySize,
+PROFILER_FUNC_VOID(profiler_get_profile_jsobject_async(double aSinceTime = 0,
+                                                       mozilla::dom::Promise* = 0))
+
+PROFILER_FUNC_VOID(profiler_get_start_params(int* aEntrySize,
                                              double* aInterval,
                                              mozilla::Vector<const char*>* aFilters,
-                                             mozilla::Vector<const char*>* aFeatures) {}
+                                             mozilla::Vector<const char*>* aFeatures))
 
-// Get the profile and write it into a file
-static inline void profiler_save_profile_to_file(char* aFilename) { }
+// Get the profile and write it into a file. It is 'extern "C"' so that it is
+// easily callable from a debugger in a build without debugging information
+// (work around http://llvm.org/bugs/show_bug.cgi?id=22211).
+extern "C" {
+PROFILER_FUNC_VOID(profiler_save_profile_to_file(const char* aFilename))
+}
 
 // Get the features supported by the profiler that are accepted by profiler_init.
 // Returns a null terminated char* array.
-static inline char** profiler_get_features() { return nullptr; }
+PROFILER_FUNC(const char** profiler_get_features(), nullptr)
+
+PROFILER_FUNC_VOID(profiler_get_buffer_info_helper(uint32_t* aCurrentPosition,
+                                                   uint32_t* aTotalSize,
+                                                   uint32_t* aGeneration))
 
 // Get information about the current buffer status.
 // Retursn (using outparams) the current write position in the buffer,
 // the total size of the buffer, and the generation of the buffer.
 // This information may be useful to a user-interface displaying the
 // current status of the profiler, allowing the user to get a sense
 // for how fast the buffer is being written to, and how much
 // data is visible.
-static inline void profiler_get_buffer_info(uint32_t *aCurrentPosition,
-                                            uint32_t *aTotalSize,
-                                            uint32_t *aGeneration)
+static inline void profiler_get_buffer_info(uint32_t* aCurrentPosition,
+                                            uint32_t* aTotalSize,
+                                            uint32_t* aGeneration)
 {
   *aCurrentPosition = 0;
   *aTotalSize = 0;
   *aGeneration = 0;
+
+  profiler_get_buffer_info_helper(aCurrentPosition, aTotalSize, aGeneration);
 }
 
-// Discard the profile, throw away the profile and notify 'profiler-locked'.
-// This function is to be used when entering private browsing to prevent
-// the profiler from collecting sensitive data.
-static inline void profiler_lock() {}
+// Lock the profiler. When locked the profiler is (1) stopped,
+// (2) profile data is cleared, (3) 'profiler-locked' is fired.
+// This is used to lock down the profiler during private browsing.
+PROFILER_FUNC_VOID(profiler_lock())
 
-// Re-enable the profiler and notify 'profiler-unlocked'.
-static inline void profiler_unlock() {}
+// Unlock the profiler, leaving it stopped, and fire 'profiler-unlocked'.
+PROFILER_FUNC_VOID(profiler_unlock())
 
-static inline void profiler_register_thread(const char* name, void* guessStackTop) {}
-static inline void profiler_unregister_thread() {}
+// Register/unregister threads with the profiler.
+PROFILER_FUNC_VOID(profiler_register_thread(const char* name,
+                                            void* guessStackTop))
+PROFILER_FUNC_VOID(profiler_unregister_thread())
 
 // These functions tell the profiler that a thread went to sleep so that we can avoid
 // sampling it while it's sleeping. Calling profiler_sleep_start() twice without
 // profiler_sleep_end() is an error.
-static inline void profiler_sleep_start() {}
-static inline void profiler_sleep_end() {}
-static inline bool profiler_is_sleeping() { return false; }
+PROFILER_FUNC_VOID(profiler_sleep_start())
+PROFILER_FUNC_VOID(profiler_sleep_end())
+PROFILER_FUNC(bool profiler_is_sleeping(), false)
 
 // Call by the JSRuntime's operation callback. This is used to enable
 // profiling on auxilerary threads.
-static inline void profiler_js_operation_callback() {}
+PROFILER_FUNC_VOID(profiler_js_operation_callback())
 
-static inline double profiler_time() { return 0; }
-static inline double profiler_time(const mozilla::TimeStamp& aTime) { return 0; }
+PROFILER_FUNC(double profiler_time(), 0)
+PROFILER_FUNC(double profiler_time(const mozilla::TimeStamp& aTime), 0)
+
+PROFILER_FUNC(bool profiler_in_privacy_mode(), false)
 
-static inline bool profiler_in_privacy_mode() { return false; }
+PROFILER_FUNC_VOID(profiler_log(const char *str))
+PROFILER_FUNC_VOID(profiler_log(const char *fmt, va_list args))
 
-static inline void profiler_log(const char *str) {}
-static inline void profiler_log(const char *fmt, va_list args) {}
+// End of the functions defined whether the profiler is enabled or not.
 
-#else
+#if defined(MOZ_ENABLE_PROFILER_SPS)
 
 #include <stdlib.h>
 #include <signal.h>
 #include "js/ProfilingStack.h"
 #include "mozilla/Sprintf.h"
 #include "mozilla/ThreadLocal.h"
 #include "nscore.h"
 #include "PseudoStack.h"
@@ -261,45 +304,36 @@ static inline void profiler_log(const ch
 #ifdef min
 #undef min
 #endif
 
 class GeckoSampler;
 class nsISupports;
 class ProfilerMarkerPayload;
 
-namespace mozilla {
-class TimeStamp;
-
-namespace dom {
-class Promise;
-} // namespace dom
-} // namespace mozilla
-
-
 extern MOZ_THREAD_LOCAL(PseudoStack *) tlsPseudoStack;
 extern MOZ_THREAD_LOCAL(GeckoSampler *) tlsTicker;
 extern bool stack_key_initialized;
 
 #ifndef SAMPLE_FUNCTION_NAME
 # ifdef __GNUC__
 #  define SAMPLE_FUNCTION_NAME __FUNCTION__
 # elif defined(_MSC_VER)
 #  define SAMPLE_FUNCTION_NAME __FUNCTION__
 # else
 #  define SAMPLE_FUNCTION_NAME __func__  // defined in C99, supported in various C++ compilers. Just raw function name.
 # endif
 #endif
 
 // 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,
-                           js::ProfileEntry::Category aCategory,
-                           void *aFrameAddress, bool aCopy, uint32_t line)
+static inline void*
+profiler_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.
   if (!stack_key_initialized)
     return nullptr;
 
   PseudoStack *stack = tlsPseudoStack.get();
   // we can't infer whether 'stack' has been initialized
@@ -314,342 +348,33 @@ mozilla_sampler_call_enter(const char *a
   // The handle is meant to support future changes
   // but for now it is simply use to save a call to
   // pthread_getspecific on exit. It also supports the
   // case where the sampler is initialized between
   // enter and exit.
   return stack;
 }
 
-inline void
-mozilla_sampler_call_exit(void *aHandle)
+static inline void
+profiler_call_exit(void* aHandle)
 {
   if (!aHandle)
     return;
 
   PseudoStack *stack = (PseudoStack*)aHandle;
   stack->popAndMaybeDelete();
 }
 
-void mozilla_sampler_add_marker(const char *aMarker,
-                                ProfilerMarkerPayload *aPayload = nullptr);
-
-void mozilla_sampler_start(int aEntries, double aInterval,
-                           const char** aFeatures, uint32_t aFeatureCount,
-                           const char** aThreadNameFilters, uint32_t aFilterCount);
-
-void mozilla_sampler_stop();
-
-bool mozilla_sampler_is_paused();
-void mozilla_sampler_pause();
-void mozilla_sampler_resume();
-
-UniqueProfilerBacktrace mozilla_sampler_get_backtrace();
-void mozilla_sampler_get_backtrace_noalloc(char *output, size_t outputSize);
-
-bool mozilla_sampler_is_active();
-
-bool mozilla_sampler_feature_active(const char* aName);
-
-void mozilla_sampler_responsiveness(const mozilla::TimeStamp& time);
-
-void mozilla_sampler_frame_number(int frameNumber);
-
-mozilla::UniquePtr<char[]> mozilla_sampler_get_profile(double aSinceTime);
-
-JSObject *mozilla_sampler_get_profile_data(JSContext* aCx, double aSinceTime);
-void mozilla_sampler_get_profile_data_async(double aSinceTime,
-                                            mozilla::dom::Promise* aPromise);
-MOZ_EXPORT
-void mozilla_sampler_save_profile_to_file_async(double aSinceTime,
-                                                const char* aFileName);
-void mozilla_sampler_get_profiler_start_params(int* aEntrySize,
-                                               double* aInterval,
-                                               mozilla::Vector<const char*>* aFilters,
-                                               mozilla::Vector<const char*>* aFeatures);
-void mozilla_sampler_get_gatherer(nsISupports** aRetVal);
-
-// Make this function easily callable from a debugger in a build without
-// debugging information (work around http://llvm.org/bugs/show_bug.cgi?id=22211)
-extern "C" {
-  void mozilla_sampler_save_profile_to_file(const char* aFilename);
-}
-
-const char** mozilla_sampler_get_features();
-
-void mozilla_sampler_get_buffer_info(uint32_t *aCurrentPosition, uint32_t *aTotalSize,
-                                     uint32_t *aGeneration);
-
-void mozilla_sampler_init(void* stackTop);
-
-void mozilla_sampler_shutdown();
-
-// Lock the profiler. When locked the profiler is (1) stopped,
-// (2) profile data is cleared, (3) profiler-locked is fired.
-// This is used to lock down the profiler during private browsing
-void mozilla_sampler_lock();
-
-// Unlock the profiler, leaving it stopped and fires profiler-unlocked.
-void mozilla_sampler_unlock();
-
-// Register/unregister threads with the profiler
-bool mozilla_sampler_register_thread(const char* name, void* stackTop);
-void mozilla_sampler_unregister_thread();
-
-void mozilla_sampler_sleep_start();
-void mozilla_sampler_sleep_end();
-bool mozilla_sampler_is_sleeping();
-
-double mozilla_sampler_time();
-double mozilla_sampler_time(const mozilla::TimeStamp& aTime);
-
-void mozilla_sampler_tracing(const char* aCategory, const char* aInfo,
-                             TracingMetadata aMetaData);
-
-void mozilla_sampler_tracing(const char* aCategory, const char* aInfo,
-                             UniqueProfilerBacktrace aCause,
-                             TracingMetadata aMetaData);
-
-void mozilla_sampler_log(const char *fmt, va_list args);
-
-static inline
-void profiler_init(void* stackTop)
-{
-  mozilla_sampler_init(stackTop);
-}
-
-static inline
-void profiler_shutdown()
-{
-  mozilla_sampler_shutdown();
-}
-
-static inline
-void profiler_start(int aProfileEntries, double aInterval,
-                    const char** aFeatures, uint32_t aFeatureCount,
-                    const char** aThreadNameFilters, uint32_t aFilterCount)
-{
-  mozilla_sampler_start(aProfileEntries, aInterval, aFeatures, aFeatureCount, aThreadNameFilters, aFilterCount);
-}
-
-static inline
-void profiler_stop()
-{
-  mozilla_sampler_stop();
-}
-
-static inline
-bool profiler_is_paused()
-{
-  return mozilla_sampler_is_paused();
-}
-
-static inline
-void profiler_pause()
-{
-  mozilla_sampler_pause();
-}
-
-static inline
-void profiler_resume()
-{
-  mozilla_sampler_resume();
-}
-
-static inline
-UniqueProfilerBacktrace profiler_get_backtrace()
-{
-  return mozilla_sampler_get_backtrace();
-}
-
-static inline
-void profiler_get_backtrace_noalloc(char *output, size_t outputSize)
-{
-  return mozilla_sampler_get_backtrace_noalloc(output, outputSize);
-}
-
-static inline
-bool profiler_is_active()
-{
-  return mozilla_sampler_is_active();
-}
-
-static inline
-bool profiler_feature_active(const char* aName)
-{
-  return mozilla_sampler_feature_active(aName);
-}
-
-static inline
-void profiler_responsiveness(const mozilla::TimeStamp& aTime)
-{
-  mozilla_sampler_responsiveness(aTime);
-}
+void profiler_add_marker(const char *aMarker,
+                         ProfilerMarkerPayload *aPayload = nullptr);
 
-static inline
-void profiler_set_frame_number(int frameNumber)
-{
-  return mozilla_sampler_frame_number(frameNumber);
-}
-
-static inline
-mozilla::UniquePtr<char[]> profiler_get_profile(double aSinceTime = 0)
-{
-  return mozilla_sampler_get_profile(aSinceTime);
-}
-
-static inline
-JSObject* profiler_get_profile_jsobject(JSContext* aCx, double aSinceTime = 0)
-{
-  return mozilla_sampler_get_profile_data(aCx, aSinceTime);
-}
-
-static inline
-void profiler_get_profile_jsobject_async(double aSinceTime = 0,
-                                         mozilla::dom::Promise* aPromise = 0)
-{
-  mozilla_sampler_get_profile_data_async(aSinceTime, aPromise);
-}
-
-static inline
-void profiler_get_start_params(int* aEntrySize,
-                               double* aInterval,
-                               mozilla::Vector<const char*>* aFilters,
-                               mozilla::Vector<const char*>* aFeatures)
-{
-  mozilla_sampler_get_profiler_start_params(aEntrySize, aInterval, aFilters, aFeatures);
-}
-
-static inline
-void profiler_get_gatherer(nsISupports** aRetVal)
-{
-  mozilla_sampler_get_gatherer(aRetVal);
-}
-
-static inline
-void profiler_save_profile_to_file(const char* aFilename)
-{
-  return mozilla_sampler_save_profile_to_file(aFilename);
-}
-
-static inline
-const char** profiler_get_features()
-{
-  return mozilla_sampler_get_features();
-}
-
-static inline
-void profiler_get_buffer_info(uint32_t *aCurrentPosition, uint32_t *aTotalSize,
-                              uint32_t *aGeneration)
-{
-  return mozilla_sampler_get_buffer_info(aCurrentPosition, aTotalSize, aGeneration);
-}
-
-static inline
-void profiler_lock()
-{
-  return mozilla_sampler_lock();
-}
-
-static inline
-void profiler_unlock()
-{
-  return mozilla_sampler_unlock();
-}
-
-static inline
-void profiler_register_thread(const char* name, void* guessStackTop)
-{
-  mozilla_sampler_register_thread(name, guessStackTop);
-}
-
-static inline
-void profiler_unregister_thread()
-{
-  mozilla_sampler_unregister_thread();
-}
-
-static inline
-void profiler_sleep_start()
-{
-  mozilla_sampler_sleep_start();
-}
-
-static inline
-void profiler_sleep_end()
-{
-  mozilla_sampler_sleep_end();
-}
-
-static inline
-bool profiler_is_sleeping()
-{
-  return mozilla_sampler_is_sleeping();
-}
-
-static inline
-void profiler_js_operation_callback()
-{
-  PseudoStack *stack = tlsPseudoStack.get();
-  if (!stack) {
-    return;
-  }
-
-  stack->jsOperationCallback();
-}
-
-static inline
-double profiler_time()
-{
-  return mozilla_sampler_time();
-}
-
-static inline
-double profiler_time(const mozilla::TimeStamp& aTime)
-{
-  return mozilla_sampler_time(aTime);
-}
-
-static inline
-bool profiler_in_privacy_mode()
-{
-  PseudoStack *stack = tlsPseudoStack.get();
-  if (!stack) {
-    return false;
-  }
-  return stack->mPrivacyMode;
-}
-
-static inline void profiler_tracing(const char* aCategory, const char* aInfo,
-                                    UniqueProfilerBacktrace aCause,
-                                    TracingMetadata aMetaData = TRACING_DEFAULT)
-{
-  // Don't insert a marker if we're not profiling to avoid
-  // the heap copy (malloc).
-  if (!stack_key_initialized || !profiler_is_active()) {
-    return;
-  }
-
-  mozilla_sampler_tracing(aCategory, aInfo, mozilla::Move(aCause), aMetaData);
-}
-
-static inline void profiler_tracing(const char* aCategory, const char* aInfo,
-                                    TracingMetadata aMetaData = TRACING_DEFAULT)
-{
-  if (!stack_key_initialized)
-    return;
-
-  // Don't insert a marker if we're not profiling to avoid
-  // the heap copy (malloc).
-  if (!profiler_is_active()) {
-    return;
-  }
-
-  mozilla_sampler_tracing(aCategory, aInfo, aMetaData);
-}
+MOZ_EXPORT  // XXX: should this be 'extern "C"' as well?
+void profiler_save_profile_to_file_async(double aSinceTime,
+                                         const char* aFileName);
+void profiler_get_gatherer(nsISupports** aRetVal);
 
 #define SAMPLER_APPEND_LINE_NUMBER_PASTE(id, line) id ## line
 #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__)
 
 // Uncomment this to turn on systrace or build with
 // ac_add_options --enable-systace
 //#define MOZ_USE_SYSTRACE
@@ -675,28 +400,16 @@ static inline void profiler_tracing(cons
 # ifdef REMOVE_HAVE_ANDROID_OS
 #  undef HAVE_ANDROID_OS
 #  undef REMOVE_HAVE_ANDROID_OS
 # endif
 #else
 # define MOZ_PLATFORM_TRACING(name)
 #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
-
-#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_FUNC(category) MOZ_PLATFORM_TRACING(SAMPLE_FUNCTION_NAME) mozilla::SamplerStackFrameRAII SAMPLER_APPEND_LINE_NUMBER(sampler_raii)(SAMPLE_FUNCTION_NAME, 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)
-
 /* FIXME/bug 789667: memory constraints wouldn't much of a problem for
  * this small a sample buffer size, except that serializing the
  * profile data is extremely, unnecessarily memory intensive. */
 #ifdef MOZ_WIDGET_GONK
 # define PLATFORM_LIKELY_MEMORY_CONSTRAINED
 #endif
 
 #if !defined(PLATFORM_LIKELY_MEMORY_CONSTRAINED) && !defined(ARCH_ARMV6)
@@ -738,20 +451,20 @@ namespace mozilla {
 class MOZ_RAII 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,
     js::ProfileEntry::Category aCategory, uint32_t line
     MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
   {
     MOZ_GUARD_OBJECT_NOTIFIER_INIT;
-    mHandle = mozilla_sampler_call_enter(aInfo, aCategory, this, false, line);
+    mHandle = profiler_call_enter(aInfo, aCategory, this, false, line);
   }
   ~SamplerStackFrameRAII() {
-    mozilla_sampler_call_exit(mHandle);
+    profiler_call_exit(mHandle);
   }
 private:
   MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
   void* mHandle;
 };
 
 static const int SAMPLER_MAX_STRING = 128;
 class MOZ_RAII SamplerStackFramePrintfRAII {
@@ -766,53 +479,41 @@ public:
       va_start(args, aFormat);
       char buff[SAMPLER_MAX_STRING];
 
       // We have to use seperate printf's because we're using
       // the vargs.
       VsprintfLiteral(buff, aFormat, args);
       SprintfLiteral(mDest, "%s %s", aInfo, buff);
 
-      mHandle = mozilla_sampler_call_enter(mDest, aCategory, this, true, line);
+      mHandle = profiler_call_enter(mDest, aCategory, this, true, line);
       va_end(args);
     } else {
-      mHandle = mozilla_sampler_call_enter(aInfo, aCategory, this, false, line);
+      mHandle = profiler_call_enter(aInfo, aCategory, this, false, line);
     }
   }
   ~SamplerStackFramePrintfRAII() {
-    mozilla_sampler_call_exit(mHandle);
+    profiler_call_exit(mHandle);
   }
 private:
   char mDest[SAMPLER_MAX_STRING];
   void* mHandle;
 };
 
 } // namespace mozilla
 
 inline PseudoStack*
 profiler_get_pseudo_stack(void)
 {
   if (!stack_key_initialized)
     return nullptr;
   return tlsPseudoStack.get();
 }
 
-static inline
-void profiler_log(const char *str)
-{
-  profiler_tracing("log", str, TRACING_EVENT);
-}
-
-static inline
-void profiler_log(const char *fmt, va_list args)
-{
-  mozilla_sampler_log(fmt, args);
-}
-
-#endif
+#endif  // defined(MOZ_ENABLE_PROFILER_SPS)
 
 namespace mozilla {
 
 class MOZ_RAII GeckoProfilerInitRAII {
 public:
   explicit GeckoProfilerInitRAII(void* stackTop) {
     profiler_init(stackTop);
   }