Bug 1520357 - Rename the JSON formatting entry points r=jonco
authorPaul Bone <pbone@mozilla.com>
Thu, 17 Jan 2019 14:08:30 +1100
changeset 514393 fc81c4dfe73377001915d843a25be594f08979ba
parent 514392 e0f21f574d36309f94a832c8985223e4b46a0dd2
child 514394 5f582bf6aa5c3f3e70e4463d4eac73187902d083
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs1520357
milestone66.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 1520357 - Rename the JSON formatting entry points r=jonco I'm always forgetting which code path is which. So give both these functions clearer names that say if they're used by profiling or telemetry.
dom/base/nsJSEnvironment.cpp
js/public/GCAPI.h
js/src/gc/GC.cpp
js/src/jsapi-tests/testGCHooks.cpp
xpcom/base/CycleCollectedJSRuntime.cpp
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -2169,17 +2169,17 @@ static void DOMGCSliceCallback(JSContext
           cs->LogStringMessage(msg.get());
         }
       }
 
       if (!sShuttingDown) {
         if (StaticPrefs::javascript_options_mem_notify() ||
             Telemetry::CanRecordExtended()) {
           nsString json;
-          json.Adopt(aDesc.formatJSON(aCx, PR_Now()));
+          json.Adopt(aDesc.formatJSONTelemetry(aCx, PR_Now()));
           RefPtr<NotifyGCEndRunnable> notify =
               new NotifyGCEndRunnable(std::move(json));
           SystemGroup::Dispatch(TaskCategory::GarbageCollection,
                                 notify.forget());
         }
       }
 
       sCCLockedOut = false;
--- a/js/public/GCAPI.h
+++ b/js/public/GCAPI.h
@@ -629,25 +629,26 @@ struct JS_PUBLIC_API GCDescription {
                 gcreason::Reason reason)
       : isZone_(isZone),
         isComplete_(isComplete),
         invocationKind_(kind),
         reason_(reason) {}
 
   char16_t* formatSliceMessage(JSContext* cx) const;
   char16_t* formatSummaryMessage(JSContext* cx) const;
-  char16_t* formatJSON(JSContext* cx, uint64_t timestamp) const;
 
   mozilla::TimeStamp startTime(JSContext* cx) const;
   mozilla::TimeStamp endTime(JSContext* cx) const;
   mozilla::TimeStamp lastSliceStart(JSContext* cx) const;
   mozilla::TimeStamp lastSliceEnd(JSContext* cx) const;
 
-  JS::UniqueChars sliceToJSON(JSContext* cx) const;
-  JS::UniqueChars summaryToJSON(JSContext* cx) const;
+  char16_t* formatJSONTelemetry(JSContext* cx, uint64_t timestamp) const;
+
+  JS::UniqueChars sliceToJSONProfiler(JSContext* cx) const;
+  JS::UniqueChars formatJSONProfiler(JSContext* cx) const;
 
   JS::dbg::GarbageCollectionEvent::Ptr toGCEvent(JSContext* cx) const;
 };
 
 extern JS_PUBLIC_API UniqueChars MinorGcToJSON(JSContext* cx);
 
 typedef void (*GCSliceCallback)(JSContext* cx, GCProgress progress,
                                 const GCDescription& desc);
--- a/js/src/gc/GC.cpp
+++ b/js/src/gc/GC.cpp
@@ -8587,18 +8587,18 @@ char16_t* JS::GCDescription::formatSumma
 
 JS::dbg::GarbageCollectionEvent::Ptr JS::GCDescription::toGCEvent(
     JSContext* cx) const {
   return JS::dbg::GarbageCollectionEvent::Create(
       cx->runtime(), cx->runtime()->gc.stats(),
       cx->runtime()->gc.majorGCCount());
 }
 
-char16_t* JS::GCDescription::formatJSON(JSContext* cx,
-                                        uint64_t timestamp) const {
+char16_t* JS::GCDescription::formatJSONTelemetry(JSContext* cx,
+                                                 uint64_t timestamp) const {
   UniqueChars cstr = cx->runtime()->gc.stats().renderJsonMessage(timestamp);
 
   size_t nchars = strlen(cstr.get());
   UniqueTwoByteChars out(js_pod_malloc<char16_t>(nchars + 1));
   if (!out) {
     return nullptr;
   }
   out.get()[nchars] = 0;
@@ -8618,23 +8618,23 @@ TimeStamp JS::GCDescription::endTime(JSC
 TimeStamp JS::GCDescription::lastSliceStart(JSContext* cx) const {
   return cx->runtime()->gc.stats().slices().back().start;
 }
 
 TimeStamp JS::GCDescription::lastSliceEnd(JSContext* cx) const {
   return cx->runtime()->gc.stats().slices().back().end;
 }
 
-JS::UniqueChars JS::GCDescription::sliceToJSON(JSContext* cx) const {
+JS::UniqueChars JS::GCDescription::sliceToJSONProfiler(JSContext* cx) const {
   size_t slices = cx->runtime()->gc.stats().slices().length();
   MOZ_ASSERT(slices > 0);
   return cx->runtime()->gc.stats().renderJsonSlice(slices - 1);
 }
 
-JS::UniqueChars JS::GCDescription::summaryToJSON(JSContext* cx) const {
+JS::UniqueChars JS::GCDescription::formatJSONProfiler(JSContext* cx) const {
   return cx->runtime()->gc.stats().renderJsonMessage(0, false);
 }
 
 JS_PUBLIC_API JS::UniqueChars JS::MinorGcToJSON(JSContext* cx) {
   JSRuntime* rt = cx->runtime();
   return rt->gc.stats().renderNurseryJson(rt);
 }
 
--- a/js/src/jsapi-tests/testGCHooks.cpp
+++ b/js/src/jsapi-tests/testGCHooks.cpp
@@ -19,17 +19,17 @@ static void NonIncrementalGCSliceCallbac
   MOZ_RELEASE_ASSERT(gSliceCallbackCount < mozilla::ArrayLength(expect));
   MOZ_RELEASE_ASSERT(progress == expect[gSliceCallbackCount++]);
   MOZ_RELEASE_ASSERT(desc.isZone_ == false);
   MOZ_RELEASE_ASSERT(desc.invocationKind_ == GC_NORMAL);
   MOZ_RELEASE_ASSERT(desc.reason_ == JS::gcreason::API);
   if (progress == GC_CYCLE_END) {
     mozilla::UniquePtr<char16_t> summary(desc.formatSummaryMessage(cx));
     mozilla::UniquePtr<char16_t> message(desc.formatSliceMessage(cx));
-    mozilla::UniquePtr<char16_t> json(desc.formatJSON(cx, 0));
+    mozilla::UniquePtr<char16_t> json(desc.formatJSONTelemetry(cx, 0));
   }
 }
 
 BEGIN_TEST(testGCSliceCallback) {
   gSliceCallbackCount = 0;
   JS::SetGCSliceCallback(cx, NonIncrementalGCSliceCallback);
   JS_GC(cx);
   JS::SetGCSliceCallback(cx, nullptr);
--- a/xpcom/base/CycleCollectedJSRuntime.cpp
+++ b/xpcom/base/CycleCollectedJSRuntime.cpp
@@ -795,22 +795,22 @@ void CycleCollectedJSRuntime::TraverseNa
   MOZ_ASSERT(CycleCollectedJSContext::Get()->Context() == aContext);
 
 #ifdef MOZ_GECKO_PROFILER
   if (profiler_thread_is_being_profiled()) {
     if (aProgress == JS::GC_CYCLE_END) {
       profiler_add_marker(
           "GCMajor", MakeUnique<GCMajorMarkerPayload>(
                          aDesc.startTime(aContext), aDesc.endTime(aContext),
-                         aDesc.summaryToJSON(aContext)));
+                         aDesc.formatJSONProfiler(aContext)));
     } else if (aProgress == JS::GC_SLICE_END) {
       profiler_add_marker("GCSlice", MakeUnique<GCSliceMarkerPayload>(
                                          aDesc.lastSliceStart(aContext),
                                          aDesc.lastSliceEnd(aContext),
-                                         aDesc.sliceToJSON(aContext)));
+                                         aDesc.sliceToJSONProfiler(aContext)));
     }
   }
 #endif
 
   if (aProgress == JS::GC_CYCLE_END &&
       JS::dbg::FireOnGarbageCollectionHookRequired(aContext)) {
     JS::gcreason::Reason reason = aDesc.reason_;
     Unused << NS_WARN_IF(