From dc05eb93fd1587cb7e10963aaf226bdff9efd91f Mon Sep 17 00:00:00 2001 From: Markus Stange Date: Sat, 8 Apr 2017 16:00:30 -0400 Subject: [PATCH] Bug 1329114 - Put profiles from other processes into a 'processes' array, not into the threads array, and don't stringify them. r=njn MozReview-Commit-ID: Ccl6JIbRMyX --HG-- extra : rebase_source : 1b9a5bbff6da5b1dbfb907630900526e95981a28 extra : histedit_source : 8c830a0178c14fdb044dea2c7323025d3892454b --- tools/profiler/core/platform.cpp | 43 +++++++++++++++++--------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/tools/profiler/core/platform.cpp b/tools/profiler/core/platform.cpp index f9f1b97f246a..857e77de3c5e 100644 --- a/tools/profiler/core/platform.cpp +++ b/tools/profiler/core/platform.cpp @@ -1222,7 +1222,7 @@ StreamMetaJSCustomObject(PS::LockRef aLock, SpliceableJSONWriter& aWriter) { MOZ_RELEASE_ASSERT(NS_IsMainThread()); - aWriter.IntProperty("version", 4); + aWriter.IntProperty("version", 5); aWriter.DoubleProperty("interval", gPS->Interval(aLock)); aWriter.IntProperty("stackwalk", gPS->FeatureStackWalk(aLock)); @@ -1309,8 +1309,9 @@ SubProcessCallback(const char* aProfile, void* aClosure) // Called by the observer to get their profile data included as a sub profile. SubprocessClosure* closure = (SubprocessClosure*)aClosure; - // Add the string profile into the profile. - closure->mWriter->StringElement(aProfile); + // Add the subprocess profile into the profile, as an element in the + // "processes" array. + closure->mWriter->Splice(aProfile); } #if defined(PROFILE_JAVA) @@ -1420,23 +1421,6 @@ StreamJSON(PS::LockRef aLock, SpliceableJSONWriter& aWriter, double aSinceTime) aSinceTime); } - // When notifying observers in other places in this file we are careful - // to do it when gPSMutex is unlocked, to avoid deadlocks. But that's not - // necessary here, because "profiler-subprocess" observers just call back - // into SubprocessCallback, which is simple and doesn't lock gPSMutex. - if (CanNotifyObservers()) { - // Send a event asking any subprocesses (plugins) to - // give us their information - SubprocessClosure closure(&aWriter); - nsCOMPtr os = - mozilla::services::GetObserverService(); - if (os) { - RefPtr pse = - new ProfileSaveEvent(SubProcessCallback, &closure); - os->NotifyObservers(pse, "profiler-subprocess", nullptr); - } - } - #if defined(PROFILE_JAVA) if (gPS->FeatureJava(aLock)) { java::GeckoJavaSampler::Pause(); @@ -1454,6 +1438,25 @@ StreamJSON(PS::LockRef aLock, SpliceableJSONWriter& aWriter, double aSinceTime) gPS->SetIsPaused(aLock, false); } aWriter.EndArray(); + + aWriter.StartArrayProperty("processes"); + // When notifying observers in other places in this file we are careful + // to do it when gPSMutex is unlocked, to avoid deadlocks. But that's not + // necessary here, because "profiler-subprocess" observers just call back + // into SubprocessCallback, which is simple and doesn't lock gPSMutex. + if (CanNotifyObservers()) { + // Send a event asking any subprocesses (plugins) to + // give us their information + SubprocessClosure closure(&aWriter); + nsCOMPtr os = + mozilla::services::GetObserverService(); + if (os) { + RefPtr pse = + new ProfileSaveEvent(SubProcessCallback, &closure); + os->NotifyObservers(pse, "profiler-subprocess", nullptr); + } + } + aWriter.EndArray(); } aWriter.End(); }