From 2e9e2ccdd2c7213155e4d452ebf099c16d5ab00e Mon Sep 17 00:00:00 2001 From: Julien Wajsberg Date: Fri, 11 Mar 2022 09:18:31 +0000 Subject: [PATCH] Bug 1752861 - [profiler] Expose GC and CC operations to the JS view r=sfink,smaug Differential Revision: https://phabricator.services.mozilla.com/D140390 --- dom/base/nsJSEnvironment.cpp | 5 +++-- js/xpconnect/src/XPCJSRuntime.cpp | 1 + xpcom/base/nsCycleCollector.cpp | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index 0e7d71722834..82db36d86cba 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -1081,6 +1081,7 @@ void nsJSContext::GarbageCollectNow(JS::GCReason aReason, void nsJSContext::RunIncrementalGCSlice(JS::GCReason aReason, IsShrinking aShrinking, js::SliceBudget& aBudget) { + AUTO_PROFILER_LABEL_RELEVANT_FOR_JS("Incremental GC", GCCC); GarbageCollectImpl(aReason, aShrinking, aBudget); } @@ -1415,8 +1416,6 @@ void nsJSContext::RunCycleCollectorSlice(CCReason aReason, AUTO_PROFILER_MARKER_TEXT("CCSlice", GCCC, {}, aDeadline.IsNull() ? ""_ns : "(idle)"_ns); - AUTO_PROFILER_LABEL("nsJSContext::RunCycleCollectorSlice", GCCC); - PrepareForCycleCollectionSlice(aReason, aDeadline); // Decide how long we want to budget for this slice. @@ -1529,6 +1528,8 @@ void nsJSContext::EndCycleCollectionCallback(CycleCollectorResults& aResults) { /* static */ bool CCGCScheduler::CCRunnerFired(TimeStamp aDeadline) { + AUTO_PROFILER_LABEL_RELEVANT_FOR_JS("Incremental CC", GCCC); + bool didDoWork = false; // The CC/GC scheduler (sScheduler) decides what action(s) to take during diff --git a/js/xpconnect/src/XPCJSRuntime.cpp b/js/xpconnect/src/XPCJSRuntime.cpp index 5b3d1d259314..1cfd467a96d0 100644 --- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -140,6 +140,7 @@ const char* const XPCJSRuntime::mStrings[] = { class AsyncFreeSnowWhite : public Runnable { public: NS_IMETHOD Run() override { + AUTO_PROFILER_LABEL_RELEVANT_FOR_JS("Incremental CC", GCCC); AUTO_PROFILER_LABEL("AsyncFreeSnowWhite::Run", GCCC_FreeSnowWhite); TimeStamp start = TimeStamp::Now(); diff --git a/xpcom/base/nsCycleCollector.cpp b/xpcom/base/nsCycleCollector.cpp index cb2f650da6e6..c6350e2e802c 100644 --- a/xpcom/base/nsCycleCollector.cpp +++ b/xpcom/base/nsCycleCollector.cpp @@ -3370,6 +3370,8 @@ bool nsCycleCollector::Collect(CCReason aReason, ccIsManual aIsManual, SliceBudget& aBudget, nsICycleCollectorListener* aManualListener, bool aPreferShorterSlices) { + AUTO_PROFILER_LABEL_RELEVANT_FOR_JS("Incremental CC", GCCC); + CheckThreadSafety(); // This can legitimately happen in a few cases. See bug 383651. @@ -3854,8 +3856,6 @@ void nsCycleCollector_forgetSkippable(js::SliceBudget& aBudget, MOZ_ASSERT(data); MOZ_ASSERT(data->mCollector); - AUTO_PROFILER_LABEL("nsCycleCollector_forgetSkippable", GCCC); - TimeLog timeLog; data->mCollector->ForgetSkippable(aBudget, aRemoveChildlessNodes, aAsyncSnowWhiteFreeing);