From 793ed8be234e98ff2efff60e37b66a0485f68bb3 Mon Sep 17 00:00:00 2001 From: Paul Bone Date: Thu, 17 Jan 2019 14:08:30 +1100 Subject: [PATCH] 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. --HG-- extra : rebase_source : 8edcabba510bcf7170b7e071f7cb3a21be23b0e4 --- dom/base/nsJSEnvironment.cpp | 2 +- js/public/GCAPI.h | 7 ++++--- js/src/gc/GC.cpp | 8 ++++---- js/src/jsapi-tests/testGCHooks.cpp | 2 +- xpcom/base/CycleCollectedJSRuntime.cpp | 4 ++-- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index bdd944f53377..18fa634dc597 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -2174,7 +2174,7 @@ static void DOMGCSliceCallback(JSContext* aCx, JS::GCProgress aProgress, 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 notify = new NotifyGCEndRunnable(std::move(json)); SystemGroup::Dispatch(TaskCategory::GarbageCollection, diff --git a/js/public/GCAPI.h b/js/public/GCAPI.h index 4abbc8b5f08f..41c94e3f31d4 100644 --- a/js/public/GCAPI.h +++ b/js/public/GCAPI.h @@ -634,15 +634,16 @@ struct JS_PUBLIC_API GCDescription { 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; }; diff --git a/js/src/gc/GC.cpp b/js/src/gc/GC.cpp index 442478a82bfc..a57edf1dddb7 100644 --- a/js/src/gc/GC.cpp +++ b/js/src/gc/GC.cpp @@ -8592,8 +8592,8 @@ JS::dbg::GarbageCollectionEvent::Ptr JS::GCDescription::toGCEvent( 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()); @@ -8623,13 +8623,13 @@ 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); } diff --git a/js/src/jsapi-tests/testGCHooks.cpp b/js/src/jsapi-tests/testGCHooks.cpp index 9648e74bfdcb..93160f4d5561 100644 --- a/js/src/jsapi-tests/testGCHooks.cpp +++ b/js/src/jsapi-tests/testGCHooks.cpp @@ -24,7 +24,7 @@ static void NonIncrementalGCSliceCallback(JSContext* cx, if (progress == GC_CYCLE_END) { mozilla::UniquePtr summary(desc.formatSummaryMessage(cx)); mozilla::UniquePtr message(desc.formatSliceMessage(cx)); - mozilla::UniquePtr json(desc.formatJSON(cx, 0)); + mozilla::UniquePtr json(desc.formatJSONTelemetry(cx, 0)); } } diff --git a/xpcom/base/CycleCollectedJSRuntime.cpp b/xpcom/base/CycleCollectedJSRuntime.cpp index 901930444eda..83dfde8f2afe 100644 --- a/xpcom/base/CycleCollectedJSRuntime.cpp +++ b/xpcom/base/CycleCollectedJSRuntime.cpp @@ -800,12 +800,12 @@ void CycleCollectedJSRuntime::TraverseNativeRoots( profiler_add_marker( "GCMajor", MakeUnique( aDesc.startTime(aContext), aDesc.endTime(aContext), - aDesc.summaryToJSON(aContext))); + aDesc.formatJSONProfiler(aContext))); } else if (aProgress == JS::GC_SLICE_END) { profiler_add_marker("GCSlice", MakeUnique( aDesc.lastSliceStart(aContext), aDesc.lastSliceEnd(aContext), - aDesc.sliceToJSON(aContext))); + aDesc.sliceToJSONProfiler(aContext))); } } #endif