author | Nicholas Nethercote <nnethercote@mozilla.com> |
Wed, 24 Aug 2016 15:23:45 +1000 | |
changeset 311172 | 7651ea2490e0f0d36757ee238fcf4446b1869d18 |
parent 311171 | 09a27892f811ba6099f85ecbaa3225fb836850be |
child 311173 | e5581710f5c9c2efe6aa032491bf0f9d0c69e5d1 |
push id | 30603 |
push user | kwierso@gmail.com |
push date | Thu, 25 Aug 2016 23:59:44 +0000 |
treeherder | mozilla-central@8f6cbb5a8f4a [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | erahm |
bugs | 1297658 |
milestone | 51.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
|
--- a/dom/base/File.cpp +++ b/dom/base/File.cpp @@ -1076,18 +1076,18 @@ MOZ_DEFINE_MALLOC_SIZE_OF(MemoryFileData class BlobImplMemoryDataOwnerMemoryReporter final : public nsIMemoryReporter { ~BlobImplMemoryDataOwnerMemoryReporter() {} public: NS_DECL_THREADSAFE_ISUPPORTS - NS_IMETHOD CollectReports(nsIMemoryReporterCallback *aCallback, - nsISupports *aClosure, bool aAnonymize) override + NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, + nsISupports* aData, bool aAnonymize) override { typedef BlobImplMemory::DataOwner DataOwner; StaticMutexAutoLock lock(DataOwner::sDataOwnerMutex); if (!DataOwner::sDataOwners) { return NS_OK; } @@ -1108,46 +1108,44 @@ public: uint8_t digest[SHA1Sum::kHashSize]; // SHA1 digests are 20 bytes long. sha1.finish(digest); nsAutoCString digestString; for (size_t i = 0; i < sizeof(digest); i++) { digestString.AppendPrintf("%02x", digest[i]); } - nsresult rv = aCallback->Callback( + aHandleReport->Callback( /* process */ NS_LITERAL_CSTRING(""), nsPrintfCString( "explicit/dom/memory-file-data/large/file(length=%llu, sha1=%s)", owner->mLength, aAnonymize ? "<anonymized>" : digestString.get()), KIND_HEAP, UNITS_BYTES, size, nsPrintfCString( "Memory used to back a memory file of length %llu bytes. The file " "has a sha1 of %s.\n\n" "Note that the allocator may round up a memory file's length -- " "that is, an N-byte memory file may take up more than N bytes of " "memory.", owner->mLength, digestString.get()), - aClosure); - NS_ENSURE_SUCCESS(rv, rv); + aData); } } if (smallObjectsTotal > 0) { - nsresult rv = aCallback->Callback( + aHandleReport->Callback( /* process */ NS_LITERAL_CSTRING(""), NS_LITERAL_CSTRING("explicit/dom/memory-file-data/small"), KIND_HEAP, UNITS_BYTES, smallObjectsTotal, nsPrintfCString( "Memory used to back small memory files (less than %d bytes each).\n\n" "Note that the allocator may round up a memory file's length -- " "that is, an N-byte memory file may take up more than N bytes of " "memory."), - aClosure); - NS_ENSURE_SUCCESS(rv, rv); + aData); } return NS_OK; } }; NS_IMPL_ISUPPORTS(BlobImplMemoryDataOwnerMemoryReporter, nsIMemoryReporter)
--- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -391,20 +391,22 @@ public: { // We don't measure the |EventListenerManager| objects pointed to by the // entries because those references are non-owning. int64_t amount = sEventListenerManagersHash ? sEventListenerManagersHash->ShallowSizeOfIncludingThis( MallocSizeOf) : 0; - return MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "explicit/dom/event-listener-managers-hash", KIND_HEAP, UNITS_BYTES, amount, "Memory used by the event listener manager's hash table."); + + return NS_OK; } }; NS_IMPL_ISUPPORTS(DOMEventListenerManagersHashReporter, nsIMemoryReporter) class EventListenerManagerMapEntry : public PLDHashEntryHdr { public:
--- a/dom/base/nsFrameMessageManager.cpp +++ b/dom/base/nsFrameMessageManager.cpp @@ -1573,30 +1573,28 @@ MessageManagerReporter::CountReferents(n // participate in messages dispatched from parent message manager. for (uint32_t i = 0; i < aMessageManager->mChildManagers.Length(); ++i) { RefPtr<nsFrameMessageManager> mm = static_cast<nsFrameMessageManager*>(aMessageManager->mChildManagers[i]); CountReferents(mm, aReferentCount); } } -static nsresult +static void ReportReferentCount(const char* aManagerType, const MessageManagerReferentCount& aReferentCount, - nsIMemoryReporterCallback* aCb, - nsISupports* aClosure) + nsIHandleReportCallback* aHandleReport, + nsISupports* aData) { -#define REPORT(_path, _amount, _desc) \ - do { \ - nsresult rv; \ - rv = aCb->Callback(EmptyCString(), _path, \ - nsIMemoryReporter::KIND_OTHER, \ - nsIMemoryReporter::UNITS_COUNT, _amount, \ - _desc, aClosure); \ - NS_ENSURE_SUCCESS(rv, rv); \ +#define REPORT(_path, _amount, _desc) \ + do { \ + aHandleReport->Callback(EmptyCString(), _path, \ + nsIMemoryReporter::KIND_OTHER, \ + nsIMemoryReporter::UNITS_COUNT, _amount, \ + _desc, aData); \ } while (0) REPORT(nsPrintfCString("message-manager/referent/%s/strong", aManagerType), aReferentCount.mStrong, nsPrintfCString("The number of strong referents held by the message " "manager in the %s manager.", aManagerType)); REPORT(nsPrintfCString("message-manager/referent/%s/weak/alive", aManagerType), aReferentCount.mWeakAlive, @@ -1617,51 +1615,44 @@ ReportReferentCount(const char* aManager REPORT(nsPrintfCString("message-manager-suspect/%s/referent(message=%s)", aManagerType, suspect.get()), totalReferentCount, nsPrintfCString("A message in the %s message manager with a " "suspiciously large number of referents (symptom " "of a leak).", aManagerType)); } #undef REPORT - - return NS_OK; } NS_IMETHODIMP -MessageManagerReporter::CollectReports(nsIMemoryReporterCallback* aCb, - nsISupports* aClosure, bool aAnonymize) +MessageManagerReporter::CollectReports(nsIHandleReportCallback* aHandleReport, + nsISupports* aData, bool aAnonymize) { - nsresult rv; - if (XRE_IsParentProcess()) { nsCOMPtr<nsIMessageBroadcaster> globalmm = do_GetService("@mozilla.org/globalmessagemanager;1"); if (globalmm) { RefPtr<nsFrameMessageManager> mm = static_cast<nsFrameMessageManager*>(globalmm.get()); MessageManagerReferentCount count; CountReferents(mm, &count); - rv = ReportReferentCount("global-manager", count, aCb, aClosure); - NS_ENSURE_SUCCESS(rv, rv); + ReportReferentCount("global-manager", count, aHandleReport, aData); } } if (nsFrameMessageManager::sParentProcessManager) { MessageManagerReferentCount count; CountReferents(nsFrameMessageManager::sParentProcessManager, &count); - rv = ReportReferentCount("parent-process-manager", count, aCb, aClosure); - NS_ENSURE_SUCCESS(rv, rv); + ReportReferentCount("parent-process-manager", count, aHandleReport, aData); } if (nsFrameMessageManager::sChildProcessManager) { MessageManagerReferentCount count; CountReferents(nsFrameMessageManager::sChildProcessManager, &count); - rv = ReportReferentCount("child-process-manager", count, aCb, aClosure); - NS_ENSURE_SUCCESS(rv, rv); + ReportReferentCount("child-process-manager", count, aHandleReport, aData); } return NS_OK; } } // namespace dom } // namespace mozilla
--- a/dom/base/nsHostObjectProtocolHandler.cpp +++ b/dom/base/nsHostObjectProtocolHandler.cpp @@ -164,21 +164,23 @@ class HostObjectURLsReporter final : pub ~HostObjectURLsReporter() {} public: NS_DECL_ISUPPORTS NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { - return MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "host-object-urls", KIND_OTHER, UNITS_COUNT, gDataTable ? gDataTable->Count() : 0, "The number of host objects stored for access via URLs " "(e.g. blobs passed to URL.createObjectURL)."); + + return NS_OK; } }; NS_IMPL_ISUPPORTS(HostObjectURLsReporter, nsIMemoryReporter) class BlobURLsReporter final : public nsIMemoryReporter { public:
--- a/dom/base/nsScriptNameSpaceManager.cpp +++ b/dom/base/nsScriptNameSpaceManager.cpp @@ -407,20 +407,22 @@ nsScriptNameSpaceManager::Observe(nsISup } MOZ_DEFINE_MALLOC_SIZE_OF(ScriptNameSpaceManagerMallocSizeOf) NS_IMETHODIMP nsScriptNameSpaceManager::CollectReports( nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) { - return MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "explicit/script-namespace-manager", KIND_HEAP, UNITS_BYTES, SizeOfIncludingThis(ScriptNameSpaceManagerMallocSizeOf), "Memory used for the script namespace manager."); + + return NS_OK; } size_t nsScriptNameSpaceManager::SizeOfIncludingThis( mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = 0;
--- a/dom/base/nsWindowMemoryReporter.cpp +++ b/dom/base/nsWindowMemoryReporter.cpp @@ -187,65 +187,65 @@ AppendWindowURI(nsGlobalWindow *aWindow, } } MOZ_DEFINE_MALLOC_SIZE_OF(WindowsMallocSizeOf) // The key is the window ID. typedef nsDataHashtable<nsUint64HashKey, nsCString> WindowPaths; -static nsresult +static void ReportAmount(const nsCString& aBasePath, const char* aPathTail, size_t aAmount, const nsCString& aDescription, uint32_t aKind, uint32_t aUnits, - nsIMemoryReporterCallback* aCb, - nsISupports* aClosure) + nsIHandleReportCallback* aHandleReport, + nsISupports* aData) { if (aAmount == 0) { - return NS_OK; + return; } nsAutoCString path(aBasePath); path += aPathTail; - return aCb->Callback(EmptyCString(), path, aKind, aUnits, - aAmount, aDescription, aClosure); + aHandleReport->Callback( + EmptyCString(), path, aKind, aUnits, aAmount, aDescription, aData); } -static nsresult +static void ReportSize(const nsCString& aBasePath, const char* aPathTail, size_t aAmount, const nsCString& aDescription, - nsIMemoryReporterCallback* aCb, - nsISupports* aClosure) + nsIHandleReportCallback* aHandleReport, + nsISupports* aData) { - return ReportAmount(aBasePath, aPathTail, aAmount, aDescription, - nsIMemoryReporter::KIND_HEAP, - nsIMemoryReporter::UNITS_BYTES, aCb, aClosure); + ReportAmount(aBasePath, aPathTail, aAmount, aDescription, + nsIMemoryReporter::KIND_HEAP, nsIMemoryReporter::UNITS_BYTES, + aHandleReport, aData); } -static nsresult +static void ReportCount(const nsCString& aBasePath, const char* aPathTail, size_t aAmount, const nsCString& aDescription, - nsIMemoryReporterCallback* aCb, - nsISupports* aClosure) + nsIHandleReportCallback* aHandleReport, + nsISupports* aData) { - return ReportAmount(aBasePath, aPathTail, aAmount, aDescription, - nsIMemoryReporter::KIND_OTHER, - nsIMemoryReporter::UNITS_COUNT, aCb, aClosure); + ReportAmount(aBasePath, aPathTail, aAmount, aDescription, + nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_COUNT, + aHandleReport, aData); } -static nsresult +static void CollectWindowReports(nsGlobalWindow *aWindow, amIAddonManager *addonManager, nsWindowSizes *aWindowTotalSizes, nsTHashtable<nsUint64HashKey> *aGhostWindowIDs, WindowPaths *aWindowPaths, WindowPaths *aTopWindowPaths, - nsIMemoryReporterCallback *aCb, - nsISupports *aClosure, + nsIHandleReportCallback *aHandleReport, + nsISupports *aData, bool aAnonymize) { nsAutoCString windowPath("explicit/"); // Avoid calling aWindow->GetTop() if there's no outer window. It will work // just fine, but will spew a lot of warnings. nsGlobalWindow *top = nullptr; nsCOMPtr<nsIURI> location; @@ -297,29 +297,23 @@ CollectWindowReports(nsGlobalWindow *aWi // Use |windowPath|, but replace "explicit/" with "event-counts/". nsCString censusWindowPath(windowPath); censusWindowPath.Replace(0, strlen("explicit"), "event-counts"); // Remember the path for later. aWindowPaths->Put(aWindow->WindowID(), windowPath); -#define REPORT_SIZE(_pathTail, _amount, _desc) \ - do { \ - nsresult rv = ReportSize(windowPath, _pathTail, _amount, \ - NS_LITERAL_CSTRING(_desc), aCb, aClosure); \ - NS_ENSURE_SUCCESS(rv, rv); \ - } while (0) +#define REPORT_SIZE(_pathTail, _amount, _desc) \ + ReportSize(windowPath, _pathTail, _amount, NS_LITERAL_CSTRING(_desc), \ + aHandleReport, aData); -#define REPORT_COUNT(_pathTail, _amount, _desc) \ - do { \ - nsresult rv = ReportCount(censusWindowPath, _pathTail, _amount, \ - NS_LITERAL_CSTRING(_desc), aCb, aClosure); \ - NS_ENSURE_SUCCESS(rv, rv); \ - } while (0) +#define REPORT_COUNT(_pathTail, _amount, _desc) \ + ReportCount(censusWindowPath, _pathTail, _amount, NS_LITERAL_CSTRING(_desc), \ + aHandleReport, aData); nsWindowSizes windowSizes(WindowsMallocSizeOf); aWindow->AddSizeOfIncludingThis(&windowSizes); REPORT_SIZE("/dom/element-nodes", windowSizes.mDOMElementNodesSize, "Memory used by the element nodes in a window's DOM."); aWindowTotalSizes->mDOMElementNodesSize += windowSizes.mDOMElementNodesSize; @@ -434,42 +428,39 @@ CollectWindowReports(nsGlobalWindow *aWi if (frameSundriesSize > 0) { REPORT_SIZE("/layout/frames/sundries", frameSundriesSize, "The sum of all memory used by frames which were too small " "to be shown individually."); } #undef REPORT_SIZE #undef REPORT_COUNT - - return NS_OK; } typedef nsTArray< RefPtr<nsGlobalWindow> > WindowArray; NS_IMETHODIMP -nsWindowMemoryReporter::CollectReports(nsIMemoryReporterCallback* aCb, - nsISupports* aClosure, bool aAnonymize) +nsWindowMemoryReporter::CollectReports(nsIHandleReportCallback* aHandleReport, + nsISupports* aData, bool aAnonymize) { nsGlobalWindow::WindowByIdTable* windowsById = nsGlobalWindow::GetWindowsTable(); NS_ENSURE_TRUE(windowsById, NS_OK); // Hold on to every window in memory so that window objects can't be // destroyed while we're calling the memory reporter callback. WindowArray windows; for (auto iter = windowsById->Iter(); !iter.Done(); iter.Next()) { windows.AppendElement(iter.Data()); } - // Get the IDs of all the "ghost" windows, and call aCb->Callback() for each - // one. + // Get the IDs of all the "ghost" windows, and call aHandleReport->Callback() + // for each one. nsTHashtable<nsUint64HashKey> ghostWindows; CheckForGhostWindows(&ghostWindows); - nsresult rv = NS_OK; for (auto iter = ghostWindows.ConstIter(); !iter.Done(); iter.Next()) { nsGlobalWindow::WindowByIdTable* windowsById = nsGlobalWindow::GetWindowsTable(); if (!windowsById) { NS_WARNING("Couldn't get window-by-id hashtable?"); continue; } @@ -478,62 +469,52 @@ nsWindowMemoryReporter::CollectReports(n NS_WARNING("Could not look up window?"); continue; } nsAutoCString path; path.AppendLiteral("ghost-windows/"); AppendWindowURI(window, path, aAnonymize); - nsresult callbackRv = aCb->Callback( + aHandleReport->Callback( /* process = */ EmptyCString(), path, nsIMemoryReporter::KIND_OTHER, nsIMemoryReporter::UNITS_COUNT, /* amount = */ 1, /* description = */ NS_LITERAL_CSTRING("A ghost window."), - aClosure); - if (NS_FAILED(callbackRv) && NS_SUCCEEDED(rv)) { - rv = callbackRv; - } + aData); } - NS_ENSURE_SUCCESS(rv, rv); WindowPaths windowPaths; WindowPaths topWindowPaths; // Collect window memory usage. nsWindowSizes windowTotalSizes(nullptr); nsCOMPtr<amIAddonManager> addonManager; if (XRE_IsParentProcess()) { // Only try to access the service from the main process. addonManager = do_GetService("@mozilla.org/addons/integration;1"); } for (uint32_t i = 0; i < windows.Length(); i++) { - rv = CollectWindowReports(windows[i], addonManager, - &windowTotalSizes, &ghostWindows, - &windowPaths, &topWindowPaths, aCb, - aClosure, aAnonymize); - NS_ENSURE_SUCCESS(rv, rv); + CollectWindowReports(windows[i], addonManager, + &windowTotalSizes, &ghostWindows, + &windowPaths, &topWindowPaths, aHandleReport, + aData, aAnonymize); } // Report JS memory usage. We do this from here because the JS memory // reporter needs to be passed |windowPaths|. - rv = xpc::JSReporter::CollectReports(&windowPaths, &topWindowPaths, - aCb, aClosure, aAnonymize); - NS_ENSURE_SUCCESS(rv, rv); + xpc::JSReporter::CollectReports(&windowPaths, &topWindowPaths, + aHandleReport, aData, aAnonymize); -#define REPORT(_path, _amount, _desc) \ - do { \ - nsresult rv; \ - rv = aCb->Callback(EmptyCString(), NS_LITERAL_CSTRING(_path), \ - KIND_OTHER, UNITS_BYTES, _amount, \ - NS_LITERAL_CSTRING(_desc), aClosure); \ - NS_ENSURE_SUCCESS(rv, rv); \ - } while (0) +#define REPORT(_path, _amount, _desc) \ + aHandleReport->Callback(EmptyCString(), NS_LITERAL_CSTRING(_path), \ + KIND_OTHER, UNITS_BYTES, _amount, \ + NS_LITERAL_CSTRING(_desc), aData); REPORT("window-objects/dom/element-nodes", windowTotalSizes.mDOMElementNodesSize, "This is the sum of all windows' 'dom/element-nodes' numbers."); REPORT("window-objects/dom/text-nodes", windowTotalSizes.mDOMTextNodesSize, "This is the sum of all windows' 'dom/text-nodes' numbers."); REPORT("window-objects/dom/cdata-nodes", windowTotalSizes.mDOMCDATANodesSize, @@ -640,17 +621,17 @@ nsWindowMemoryReporter::ObserveDOMWindow mDetachedWindows.Put(weakWindow, TimeStamp()); AsyncCheckForGhostWindows(); } // static void -nsWindowMemoryReporter::CheckTimerFired(nsITimer* aTimer, void* aClosure) +nsWindowMemoryReporter::CheckTimerFired(nsITimer* aTimer, void* aData) { if (sWindowReporter) { MOZ_ASSERT(!sWindowReporter->mCycleCollectorIsRunning); sWindowReporter->CheckForGhostWindows(); } } void
--- a/dom/base/nsWindowMemoryReporter.h +++ b/dom/base/nsWindowMemoryReporter.h @@ -175,26 +175,28 @@ private: NS_DECL_ISUPPORTS static int64_t DistinguishedAmount(); NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { - return MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "ghost-windows", KIND_OTHER, UNITS_COUNT, DistinguishedAmount(), "The number of ghost windows present (the number of nodes underneath " "explicit/window-objects/top(none)/ghost, modulo race conditions). A ghost " "window is not shown in any tab, does not share a domain with any non-detached " "windows, and has met these criteria for at least " "memory.ghost_window_timeout_seconds, or has survived a round of " "about:memory's minimize memory usage button.\n\n" "Ghost windows can happen legitimately, but they are often indicative of " "leaks in the browser or add-ons."); + + return NS_OK; } }; // Protect ctor, use Init() instead. nsWindowMemoryReporter(); /** * Get the number of seconds for which a window must satisfy ghost criteria
--- a/dom/bindings/WebIDLGlobalNameHash.cpp +++ b/dom/bindings/WebIDLGlobalNameHash.cpp @@ -118,20 +118,21 @@ public: NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { int64_t amount = sWebIDLGlobalNames ? sWebIDLGlobalNames->ShallowSizeOfIncludingThis(MallocSizeOf) : 0; - return MOZ_COLLECT_REPORT("explicit/dom/webidl-globalnames", KIND_HEAP, - UNITS_BYTES, amount, - "Memory used by the hash table for WebIDL's " - "global names."); + MOZ_COLLECT_REPORT( + "explicit/dom/webidl-globalnames", KIND_HEAP, UNITS_BYTES, amount, + "Memory used by the hash table for WebIDL's global names."); + + return NS_OK; } }; NS_IMPL_ISUPPORTS(WebIDLGlobalNamesHashReporter, nsIMemoryReporter) /* static */ void WebIDLGlobalNameHash::Init()
--- a/dom/canvas/CanvasRenderingContext2D.cpp +++ b/dom/canvas/CanvasRenderingContext2D.cpp @@ -173,21 +173,22 @@ class Canvas2dPixelsReporter final : pub { ~Canvas2dPixelsReporter() {} public: NS_DECL_ISUPPORTS NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { - return MOZ_COLLECT_REPORT( - "canvas-2d-pixels", KIND_OTHER, UNITS_BYTES, - gCanvasAzureMemoryUsed, + MOZ_COLLECT_REPORT( + "canvas-2d-pixels", KIND_OTHER, UNITS_BYTES, gCanvasAzureMemoryUsed, "Memory used by 2D canvases. Each canvas requires " "(width * height * 4) bytes."); + + return NS_OK; } }; NS_IMPL_ISUPPORTS(Canvas2dPixelsReporter, nsIMemoryReporter) class CanvasRadialGradient : public CanvasGradient { public:
--- a/dom/canvas/WebGLMemoryTracker.cpp +++ b/dom/canvas/WebGLMemoryTracker.cpp @@ -12,86 +12,74 @@ #include "WebGLRenderbuffer.h" #include "WebGLShader.h" #include "WebGLTexture.h" #include "WebGLUniformLocation.h" namespace mozilla { NS_IMETHODIMP -WebGLMemoryTracker::CollectReports(nsIHandleReportCallback* handleReport, - nsISupports* data, bool) +WebGLMemoryTracker::CollectReports(nsIHandleReportCallback* aHandleReport, + nsISupports* aData, bool) { -#define REPORT(_path, _kind, _units, _amount, _desc) \ - do { \ - nsresult rv; \ - rv = handleReport->Callback(EmptyCString(), NS_LITERAL_CSTRING(_path), \ - _kind, _units, _amount, \ - NS_LITERAL_CSTRING(_desc), data); \ - NS_ENSURE_SUCCESS(rv, rv); \ - } while (0) + MOZ_COLLECT_REPORT( + "webgl-texture-memory", KIND_OTHER, UNITS_BYTES, GetTextureMemoryUsed(), + "Memory used by WebGL textures. The OpenGL implementation is free to " + "store these textures in either video memory or main memory. This " + "measurement is only a lower bound, actual memory usage may be higher " + "for example if the storage is strided."); + + MOZ_COLLECT_REPORT( + "webgl-texture-count", KIND_OTHER, UNITS_COUNT, GetTextureCount(), + "Number of WebGL textures."); - REPORT("webgl-texture-memory", - KIND_OTHER, UNITS_BYTES, GetTextureMemoryUsed(), - "Memory used by WebGL textures.The OpenGL" - " implementation is free to store these textures in either video" - " memory or main memory. This measurement is only a lower bound," - " actual memory usage may be higher for example if the storage" - " is strided."); + MOZ_COLLECT_REPORT( + "webgl-buffer-memory", KIND_OTHER, UNITS_BYTES, GetBufferMemoryUsed(), + "Memory used by WebGL buffers. The OpenGL implementation is free to " + "store these buffers in either video memory or main memory. This " + "measurement is only a lower bound, actual memory usage may be higher " + "for example if the storage is strided."); - REPORT("webgl-texture-count", - KIND_OTHER, UNITS_COUNT, GetTextureCount(), - "Number of WebGL textures."); - - REPORT("webgl-buffer-memory", - KIND_OTHER, UNITS_BYTES, GetBufferMemoryUsed(), - "Memory used by WebGL buffers. The OpenGL" - " implementation is free to store these buffers in either video" - " memory or main memory. This measurement is only a lower bound," - " actual memory usage may be higher for example if the storage" - " is strided."); + MOZ_COLLECT_REPORT( + "explicit/webgl/buffer-cache-memory", KIND_HEAP, UNITS_BYTES, + GetBufferCacheMemoryUsed(), + "Memory used by WebGL buffer caches. The WebGL implementation caches " + "the contents of element array buffers only. This adds up with the " + "'webgl-buffer-memory' value, but contrary to it, this one represents " + "bytes on the heap, not managed by OpenGL."); - REPORT("explicit/webgl/buffer-cache-memory", - KIND_HEAP, UNITS_BYTES, GetBufferCacheMemoryUsed(), - "Memory used by WebGL buffer caches. The WebGL" - " implementation caches the contents of element array buffers" - " only.This adds up with the webgl-buffer-memory value, but" - " contrary to it, this one represents bytes on the heap," - " not managed by OpenGL."); + MOZ_COLLECT_REPORT( + "webgl-buffer-count", KIND_OTHER, UNITS_COUNT, GetBufferCount(), + "Number of WebGL buffers."); - REPORT("webgl-buffer-count", - KIND_OTHER, UNITS_COUNT, GetBufferCount(), - "Number of WebGL buffers."); + MOZ_COLLECT_REPORT( + "webgl-renderbuffer-memory", KIND_OTHER, UNITS_BYTES, + GetRenderbufferMemoryUsed(), + "Memory used by WebGL renderbuffers. The OpenGL implementation is free " + "to store these renderbuffers in either video memory or main memory. " + "This measurement is only a lower bound, actual memory usage may be " + "higher, for example if the storage is strided."); - REPORT("webgl-renderbuffer-memory", - KIND_OTHER, UNITS_BYTES, GetRenderbufferMemoryUsed(), - "Memory used by WebGL renderbuffers. The OpenGL" - " implementation is free to store these renderbuffers in either" - " video memory or main memory. This measurement is only a lower" - " bound, actual memory usage may be higher for example if the" - " storage is strided."); - - REPORT("webgl-renderbuffer-count", - KIND_OTHER, UNITS_COUNT, GetRenderbufferCount(), - "Number of WebGL renderbuffers."); + MOZ_COLLECT_REPORT( + "webgl-renderbuffer-count", KIND_OTHER, UNITS_COUNT, + GetRenderbufferCount(), + "Number of WebGL renderbuffers."); - REPORT("explicit/webgl/shader", - KIND_HEAP, UNITS_BYTES, GetShaderSize(), - "Combined size of WebGL shader ASCII sources and translation" - " logs cached on the heap."); + MOZ_COLLECT_REPORT( + "explicit/webgl/shader", KIND_HEAP, UNITS_BYTES, GetShaderSize(), + "Combined size of WebGL shader ASCII sources and translation logs " + "cached on the heap."); - REPORT("webgl-shader-count", - KIND_OTHER, UNITS_COUNT, GetShaderCount(), - "Number of WebGL shaders."); + MOZ_COLLECT_REPORT( + "webgl-shader-count", KIND_OTHER, UNITS_COUNT, GetShaderCount(), + "Number of WebGL shaders."); - REPORT("webgl-context-count", - KIND_OTHER, UNITS_COUNT, GetContextCount(), - "Number of WebGL contexts."); - -#undef REPORT + MOZ_COLLECT_REPORT( + "webgl-context-count", KIND_OTHER, UNITS_COUNT, GetContextCount(), + "Number of WebGL contexts."); return NS_OK; } NS_IMPL_ISUPPORTS(WebGLMemoryTracker, nsIMemoryReporter) StaticRefPtr<WebGLMemoryTracker> WebGLMemoryTracker::sUniqueInstance;
--- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -975,73 +975,73 @@ ContentChild::AllocPMemoryReportRequestC const MaybeFileDesc& aDMDFile) { MemoryReportRequestChild *actor = new MemoryReportRequestChild(aAnonymize, aDMDFile); actor->AddRef(); return actor; } -class MemoryReportCallback final : public nsIMemoryReporterCallback +class HandleReportCallback final : public nsIHandleReportCallback { public: NS_DECL_ISUPPORTS - explicit MemoryReportCallback(MemoryReportRequestChild* aActor, + explicit HandleReportCallback(MemoryReportRequestChild* aActor, const nsACString& aProcess) : mActor(aActor) , mProcess(aProcess) { } NS_IMETHOD Callback(const nsACString& aProcess, const nsACString &aPath, int32_t aKind, int32_t aUnits, int64_t aAmount, const nsACString& aDescription, nsISupports* aUnused) override { MemoryReport memreport(mProcess, nsCString(aPath), aKind, aUnits, aAmount, nsCString(aDescription)); mActor->SendReport(memreport); return NS_OK; } private: - ~MemoryReportCallback() {} + ~HandleReportCallback() {} RefPtr<MemoryReportRequestChild> mActor; const nsCString mProcess; }; NS_IMPL_ISUPPORTS( - MemoryReportCallback -, nsIMemoryReporterCallback + HandleReportCallback +, nsIHandleReportCallback ) -class MemoryReportFinishedCallback final : public nsIFinishReportingCallback +class FinishReportingCallback final : public nsIFinishReportingCallback { public: NS_DECL_ISUPPORTS - explicit MemoryReportFinishedCallback(MemoryReportRequestChild* aActor) + explicit FinishReportingCallback(MemoryReportRequestChild* aActor) : mActor(aActor) { } NS_IMETHOD Callback(nsISupports* aUnused) override { bool sent = PMemoryReportRequestChild::Send__delete__(mActor); return sent ? NS_OK : NS_ERROR_FAILURE; } private: - ~MemoryReportFinishedCallback() {} + ~FinishReportingCallback() {} RefPtr<MemoryReportRequestChild> mActor; }; NS_IMPL_ISUPPORTS( - MemoryReportFinishedCallback + FinishReportingCallback , nsIFinishReportingCallback ) bool ContentChild::RecvPMemoryReportRequestConstructor( PMemoryReportRequestChild* aChild, const uint32_t& aGeneration, const bool& aAnonymize, @@ -1071,24 +1071,25 @@ NS_IMETHODIMP MemoryReportRequestChild:: do_GetService("@mozilla.org/memory-reporter-manager;1"); nsCString process; child->GetProcessName(process); child->AppendProcessId(process); // Run the reporters. The callback will turn each measurement into a // MemoryReport. - RefPtr<MemoryReportCallback> cb = - new MemoryReportCallback(this, process); - RefPtr<MemoryReportFinishedCallback> finished = - new MemoryReportFinishedCallback(this); - - return mgr->GetReportsForThisProcessExtended(cb, nullptr, mAnonymize, + RefPtr<HandleReportCallback> handleReport = + new HandleReportCallback(this, process); + RefPtr<FinishReportingCallback> finishReporting = + new FinishReportingCallback(this); + + return mgr->GetReportsForThisProcessExtended(handleReport, nullptr, + mAnonymize, FileDescriptorToFILE(mDMDFile, "wb"), - finished, nullptr); + finishReporting, nullptr); } bool ContentChild::DeallocPMemoryReportRequestChild(PMemoryReportRequestChild* actor) { static_cast<MemoryReportRequestChild*>(actor)->Release(); return true; } @@ -2696,17 +2697,17 @@ ContentChild::RecvNotifyProcessPriorityC bool ContentChild::RecvMinimizeMemoryUsage() { nsCOMPtr<nsIMemoryReporterManager> mgr = do_GetService("@mozilla.org/memory-reporter-manager;1"); NS_ENSURE_TRUE(mgr, true); - mgr->MinimizeMemoryUsage(/* callback = */ nullptr); + Unused << mgr->MinimizeMemoryUsage(/* callback = */ nullptr); return true; } bool ContentChild::RecvNotifyPhoneStateChange(const nsString& aState) { nsCOMPtr<nsIObserverService> os = services::GetObserverService(); if (os) {
--- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -477,19 +477,20 @@ class ContentParentsMemoryReporter final public: NS_DECL_ISUPPORTS NS_DECL_NSIMEMORYREPORTER }; NS_IMPL_ISUPPORTS(ContentParentsMemoryReporter, nsIMemoryReporter) NS_IMETHODIMP -ContentParentsMemoryReporter::CollectReports(nsIMemoryReporterCallback* cb, - nsISupports* aClosure, - bool aAnonymize) +ContentParentsMemoryReporter::CollectReports( + nsIHandleReportCallback* aHandleReport, + nsISupports* aData, + bool aAnonymize) { AutoTArray<ContentParent*, 16> cps; ContentParent::GetAllEvenIfDead(cps); for (uint32_t i = 0; i < cps.Length(); i++) { ContentParent* cp = cps[i]; MessageChannel* channel = cp->GetIPCChannel(); @@ -517,25 +518,19 @@ ContentParentsMemoryReporter::CollectRep static_cast<nsIContentParent*>(cp), refcnt); NS_NAMED_LITERAL_CSTRING(desc, "The number of unset IPC messages held in this ContentParent's " "channel. A large value here might indicate that we're leaking " "messages. Similarly, a ContentParent object for a process that's no " "longer running could indicate that we're leaking ContentParents."); - nsresult rv = cb->Callback(/* process */ EmptyCString(), - path, - KIND_OTHER, - UNITS_COUNT, - numQueuedMessages, - desc, - aClosure); - - NS_ENSURE_SUCCESS(rv, rv); + aHandleReport->Callback(/* process */ EmptyCString(), path, + KIND_OTHER, UNITS_COUNT, + numQueuedMessages, desc, aData); } return NS_OK; } nsDataHashtable<nsStringHashKey, ContentParent*>* ContentParent::sAppContentParents; nsTArray<ContentParent*>* ContentParent::sNonAppContentParents; nsTArray<ContentParent*>* ContentParent::sPrivateContent;
--- a/dom/media/MediaDecoder.cpp +++ b/dom/media/MediaDecoder.cpp @@ -1757,32 +1757,23 @@ MediaMemoryTracker::CollectReports(nsIHa DecodersArray& decoders = Decoders(); for (size_t i = 0; i < decoders.Length(); ++i) { MediaDecoder* decoder = decoders[i]; video += decoder->SizeOfVideoQueue(); audio += decoder->SizeOfAudioQueue(); decoder->AddSizeOfResources(resourceSizes); } -#define REPORT(_path, _amount, _desc) \ - do { \ - nsresult rv; \ - rv = aHandleReport->Callback(EmptyCString(), NS_LITERAL_CSTRING(_path), \ - KIND_HEAP, UNITS_BYTES, _amount, \ - NS_LITERAL_CSTRING(_desc), aData); \ - NS_ENSURE_SUCCESS(rv, rv); \ - } while (0) + MOZ_COLLECT_REPORT( + "explicit/media/decoded/video", KIND_HEAP, UNITS_BYTES, video, + "Memory used by decoded video frames."); - REPORT("explicit/media/decoded/video", video, - "Memory used by decoded video frames."); - - REPORT("explicit/media/decoded/audio", audio, - "Memory used by decoded audio chunks."); - -#undef REPORT + MOZ_COLLECT_REPORT( + "explicit/media/decoded/audio", KIND_HEAP, UNITS_BYTES, audio, + "Memory used by decoded audio chunks."); return NS_OK; } MediaDecoderOwner* MediaDecoder::GetOwner() const { MOZ_ASSERT(NS_IsMainThread());
--- a/dom/media/MediaRecorder.cpp +++ b/dom/media/MediaRecorder.cpp @@ -78,27 +78,19 @@ public: nsISupports* aData, bool aAnonymize) override { int64_t amount = 0; RecordersArray& recorders = GetRecorders(); for (size_t i = 0; i < recorders.Length(); ++i) { amount += recorders[i]->SizeOfExcludingThis(MallocSizeOf); } - #define MEMREPORT(_path, _amount, _desc) \ - do { \ - nsresult rv; \ - rv = aHandleReport->Callback(EmptyCString(), NS_LITERAL_CSTRING(_path), \ - KIND_HEAP, UNITS_BYTES, _amount, \ - NS_LITERAL_CSTRING(_desc), aData); \ - NS_ENSURE_SUCCESS(rv, rv); \ - } while (0) - - MEMREPORT("explicit/media/recorder", amount, - "Memory used by media recorder."); + MOZ_COLLECT_REPORT( + "explicit/media/recorder", KIND_HEAP, UNITS_BYTES, amount, + "Memory used by media recorder."); return NS_OK; } private: MOZ_DEFINE_MALLOC_SIZE_OF(MallocSizeOf) virtual ~MediaRecorderReporter(); static StaticRefPtr<MediaRecorderReporter> sUniqueInstance;
--- a/dom/media/MediaStreamGraph.cpp +++ b/dom/media/MediaStreamGraph.cpp @@ -3493,25 +3493,19 @@ FinishCollectReports(nsIHandleReportCall MOZ_ASSERT(NS_IsMainThread()); nsCOMPtr<nsIMemoryReporterManager> manager = do_GetService("@mozilla.org/memory-reporter-manager;1"); if (!manager) return; -#define REPORT(_path, _amount, _desc) \ - do { \ - nsresult rv; \ - rv = aHandleReport->Callback(EmptyCString(), _path, \ - KIND_HEAP, UNITS_BYTES, _amount, \ - NS_LITERAL_CSTRING(_desc), aData); \ - if (NS_WARN_IF(NS_FAILED(rv))) \ - return; \ - } while (0) +#define REPORT(_path, _amount, _desc) \ + aHandleReport->Callback(EmptyCString(), _path, KIND_HEAP, UNITS_BYTES, \ + _amount, NS_LITERAL_CSTRING(_desc), aData); for (size_t i = 0; i < aAudioStreamSizes.Length(); i++) { const AudioNodeSizes& usage = aAudioStreamSizes[i]; const char* const nodeType = usage.mNodeType ? usage.mNodeType : "<unknown>"; nsPrintfCString enginePath("explicit/webaudio/audio-node/%s/engine-objects", nodeType); @@ -3522,19 +3516,18 @@ FinishCollectReports(nsIHandleReportCall nodeType); REPORT(streamPath, usage.mStream, "Memory used by AudioNode stream objects (Web Audio)."); } size_t hrtfLoaders = WebCore::HRTFDatabaseLoader::sizeOfLoaders(MallocSizeOf); if (hrtfLoaders) { - REPORT(NS_LITERAL_CSTRING( - "explicit/webaudio/audio-node/PannerNode/hrtf-databases"), + "explicit/webaudio/audio-node/PannerNode/hrtf-databases"), hrtfLoaders, "Memory used by PannerNode databases (Web Audio)."); } #undef REPORT manager->EndReport(); }
--- a/dom/media/webaudio/AudioBuffer.cpp +++ b/dom/media/webaudio/AudioBuffer.cpp @@ -136,35 +136,30 @@ AudioBufferMemoryTracker::UnregisterAudi sMutex.AssertCurrentThreadOwns(); mBuffers.RemoveEntry(aAudioBuffer); return mBuffers.Count(); } MOZ_DEFINE_MALLOC_SIZE_OF(AudioBufferMemoryTrackerMallocSizeOf) NS_IMETHODIMP -AudioBufferMemoryTracker::CollectReports(nsIHandleReportCallback* handleReport, - nsISupports* data, bool) +AudioBufferMemoryTracker::CollectReports(nsIHandleReportCallback* aHandleReport, + nsISupports* aData, bool) { - size_t amount = 0; - nsresult rv; - - for (auto iter = mBuffers.Iter(); !iter.Done(); iter.Next()) { - amount += iter.Get()->GetKey()->SizeOfIncludingThis(AudioBufferMemoryTrackerMallocSizeOf); - } + size_t amount = 0; - rv = handleReport->Callback(EmptyCString(), - NS_LITERAL_CSTRING("explicit/webaudio/audiobuffer"), - KIND_HEAP, UNITS_BYTES, amount, - NS_LITERAL_CSTRING("Memory used by AudioBuffer" - " objects (Web Audio)"), - data); - NS_ENSURE_SUCCESS(rv, rv); + for (auto iter = mBuffers.Iter(); !iter.Done(); iter.Next()) { + amount += iter.Get()->GetKey()->SizeOfIncludingThis(AudioBufferMemoryTrackerMallocSizeOf); + } - return NS_OK; + MOZ_COLLECT_REPORT( + "explicit/webaudio/audiobuffer", KIND_HEAP, UNITS_BYTES, amount, + "Memory used by AudioBuffer objects (Web Audio)."); + + return NS_OK; } AudioBuffer::AudioBuffer(AudioContext* aContext, uint32_t aNumberOfChannels, uint32_t aLength, float aSampleRate, already_AddRefed<ThreadSharedFloatArrayBufferList> aInitialContents) : mOwnerWindow(do_GetWeakReference(aContext->GetOwner())), mSharedChannels(aInitialContents),
--- a/dom/media/webaudio/AudioContext.cpp +++ b/dom/media/webaudio/AudioContext.cpp @@ -1140,27 +1140,26 @@ AudioContext::CollectReports(nsIHandleRe { const nsLiteralCString nodeDescription("Memory used by AudioNode DOM objects (Web Audio)."); for (auto iter = mAllNodes.ConstIter(); !iter.Done(); iter.Next()) { AudioNode* node = iter.Get()->GetKey(); int64_t amount = node->SizeOfIncludingThis(MallocSizeOf); nsPrintfCString domNodePath("explicit/webaudio/audio-node/%s/dom-nodes", node->NodeType()); - nsresult rv = - aHandleReport->Callback(EmptyCString(), domNodePath, KIND_HEAP, - UNITS_BYTES, amount, nodeDescription, aData); - if (NS_WARN_IF(NS_FAILED(rv))) - return rv; + aHandleReport->Callback(EmptyCString(), domNodePath, KIND_HEAP, UNITS_BYTES, + amount, nodeDescription, aData); } int64_t amount = SizeOfIncludingThis(MallocSizeOf); - return MOZ_COLLECT_REPORT("explicit/webaudio/audiocontext", - KIND_HEAP, UNITS_BYTES, amount, - "Memory used by AudioContext objects (Web Audio)."); + MOZ_COLLECT_REPORT( + "explicit/webaudio/audiocontext", KIND_HEAP, UNITS_BYTES, amount, + "Memory used by AudioContext objects (Web Audio)."); + + return NS_OK; } BasicWaveFormCache* AudioContext::GetBasicWaveFormCache() { MOZ_ASSERT(NS_IsMainThread()); if (!mBasicWaveFormCache) { mBasicWaveFormCache = new BasicWaveFormCache(SampleRate());
--- a/dom/media/webaudio/AudioContext.h +++ b/dom/media/webaudio/AudioContext.h @@ -321,18 +321,17 @@ public: IMPL_EVENT_HANDLER(mozinterruptend) private: void DisconnectFromWindow(); void RemoveFromDecodeQueue(WebAudioDecodeJob* aDecodeJob); void ShutdownDecoder(); size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; - NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, - nsISupports* aData, bool aAnonymize) override; + NS_DECL_NSIMEMORYREPORTER friend struct ::mozilla::WebAudioDecodeJob; bool CheckClosed(ErrorResult& aRv); nsTArray<MediaStream*> GetAllStreams() const; private:
--- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -2173,18 +2173,18 @@ public: : mMutex(aWorkerPrivate->mMutex), mWorkerPrivate(aWorkerPrivate), mAlreadyMappedToAddon(false) { aWorkerPrivate->AssertIsOnWorkerThread(); } NS_IMETHOD - CollectReports(nsIMemoryReporterCallback* aCallback, - nsISupports* aClosure, bool aAnonymize) override + CollectReports(nsIHandleReportCallback* aHandleReport, + nsISupports* aData, bool aAnonymize) override { AssertIsOnMainThread(); // Assumes that WorkerJSRuntimeStats will hold a reference to |path|, and // not a copy, as TryToMapAddon() may later modify it. nsCString path; WorkerJSRuntimeStats rtStats(path); @@ -2217,19 +2217,19 @@ public: TryToMapAddon(path); if (!mWorkerPrivate->BlockAndCollectRuntimeStats(&rtStats, aAnonymize)) { // Returning NS_OK here will effectively report 0 memory. return NS_OK; } } - return xpc::ReportJSRuntimeExplicitTreeStats(rtStats, path, - aCallback, aClosure, - aAnonymize); + xpc::ReportJSRuntimeExplicitTreeStats(rtStats, path, aHandleReport, aData, + aAnonymize); + return NS_OK; } private: ~MemoryReporter() { } void Disable()
--- a/extensions/spellcheck/hunspell/glue/mozHunspell.cpp +++ b/extensions/spellcheck/hunspell/glue/mozHunspell.cpp @@ -476,19 +476,22 @@ nsresult mozHunspell::ConvertCharset(con return rv; } NS_IMETHODIMP mozHunspell::CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) { - return MOZ_COLLECT_REPORT("explicit/spell-check", KIND_HEAP, UNITS_BYTES, - HunspellAllocator::MemoryAllocated(), - "Memory used by the spell-checking engine."); + MOZ_COLLECT_REPORT( + "explicit/spell-check", KIND_HEAP, UNITS_BYTES, + HunspellAllocator::MemoryAllocated(), + "Memory used by the spell-checking engine."); + + return NS_OK; } NS_IMETHODIMP mozHunspell::Check(const char16_t *aWord, bool *aResult) { NS_ENSURE_ARG_POINTER(aWord); NS_ENSURE_ARG_POINTER(aResult); NS_ENSURE_TRUE(mHunspell, NS_ERROR_FAILURE);
--- a/extensions/spellcheck/hunspell/glue/mozHunspell.h +++ b/extensions/spellcheck/hunspell/glue/mozHunspell.h @@ -96,18 +96,17 @@ public: nsresult Init(); void LoadDictionaryList(bool aNotifyChildProcesses); // helper method for converting a word to the charset of the dictionary nsresult ConvertCharset(const char16_t* aStr, char ** aDst); - NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, - nsISupports* aData, bool aAnonymize) override; + NS_DECL_NSIMEMORYREPORTER protected: virtual ~mozHunspell(); nsCOMPtr<mozIPersonalDictionary> mPersonalDictionary; nsCOMPtr<nsIUnicodeEncoder> mEncoder; nsCOMPtr<nsIUnicodeDecoder> mDecoder;
--- a/gfx/gl/GfxTexturesReporter.h +++ b/gfx/gl/GfxTexturesReporter.h @@ -45,25 +45,31 @@ public: static void UpdateWasteAmount(size_t delta) { sTileWasteAmount += delta; } NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { - MOZ_COLLECT_REPORT("gfx-tiles-waste", KIND_OTHER, UNITS_BYTES, + MOZ_COLLECT_REPORT( + "gfx-tiles-waste", KIND_OTHER, UNITS_BYTES, int64_t(sTileWasteAmount), "Memory lost due to tiles extending past content boundaries"); + MOZ_COLLECT_REPORT( - "gfx-textures", KIND_OTHER, UNITS_BYTES, int64_t(sAmount), + "gfx-textures", KIND_OTHER, UNITS_BYTES, + int64_t(sAmount), "Memory used for storing GL textures."); + MOZ_COLLECT_REPORT( - "gfx-textures-peak", KIND_OTHER, UNITS_BYTES, int64_t(sPeakAmount), + "gfx-textures-peak", KIND_OTHER, UNITS_BYTES, + int64_t(sPeakAmount), "Peak memory used for storing GL textures."); + return NS_OK; } private: static Atomic<size_t> sAmount; static Atomic<size_t> sPeakAmount; // Count the amount of memory lost to tile waste static Atomic<size_t> sTileWasteAmount;
--- a/gfx/layers/ipc/ISurfaceAllocator.h +++ b/gfx/layers/ipc/ISurfaceAllocator.h @@ -263,19 +263,21 @@ public: static void WillFree(void* aPointer) { sAmount -= MallocSizeOfOnFree(aPointer); } NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { - return MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "explicit/gfx/heap-textures", KIND_HEAP, UNITS_BYTES, sAmount, "Heap memory shared between threads by texture clients and hosts."); + + return NS_OK; } private: // Typically we use |size_t| in memory reporters, but in the past this // variable has sometimes gone negative due to missing DidAlloc() calls. // Therefore, we use a signed type so that any such negative values show up // as negative in about:memory, rather than as enormous positive numbers. static mozilla::Atomic<ptrdiff_t> sAmount;
--- a/gfx/layers/ipc/SharedBufferManagerParent.cpp +++ b/gfx/layers/ipc/SharedBufferManagerParent.cpp @@ -48,53 +48,47 @@ public: if (SharedBufferManagerParent::sManagerMonitor) { SharedBufferManagerParent::sManagerMonitor->Lock(); } map<base::ProcessId, SharedBufferManagerParent*>::iterator it; for (it = SharedBufferManagerParent::sManagers.begin(); it != SharedBufferManagerParent::sManagers.end(); it++) { base::ProcessId pid = it->first; SharedBufferManagerParent *mgr = it->second; if (!mgr) { - printf_stderr("GrallocReporter::CollectReports() mgr is nullptr"); + printf_stderr("GrallocReporter::CollectReports(): mgr is nullptr"); continue; } nsAutoCString pidName; LinuxUtils::GetThreadName(pid, pidName); MutexAutoLock lock(mgr->mLock); std::map<int64_t, android::sp<android::GraphicBuffer> >::iterator buf_it; for (buf_it = mgr->mBuffers.begin(); buf_it != mgr->mBuffers.end(); buf_it++) { - nsresult rv; android::sp<android::GraphicBuffer> gb = buf_it->second; int bpp = android::bytesPerPixel(gb->getPixelFormat()); int stride = gb->getStride(); int height = gb->getHeight(); int amount = bpp > 0 ? (stride * height * bpp) // Special case for BSP specific formats (mainly YUV formats, count it as normal YUV buffer). : (stride * height * 3 / 2); nsPrintfCString gpath("gralloc/%s (pid=%d)/buffer(width=%d, height=%d, bpp=%d, stride=%d)", pidName.get(), pid, gb->getWidth(), height, bpp, stride); - rv = aHandleReport->Callback(EmptyCString(), gpath, KIND_OTHER, UNITS_BYTES, amount, - NS_LITERAL_CSTRING( - "Special RAM that can be shared between processes and directly accessed by " - "both the CPU and GPU. Gralloc memory is usually a relatively precious " - "resource, with much less available than generic RAM. When it's exhausted, " - "graphics performance can suffer. This value can be incorrect because of race " - "conditions."), - aData); - if (rv != NS_OK) { - if (SharedBufferManagerParent::sManagerMonitor) { - SharedBufferManagerParent::sManagerMonitor->Unlock(); - } - return rv; - } + aHandleReport->Callback( + EmptyCString(), gpath, KIND_OTHER, UNITS_BYTES, amount, + NS_LITERAL_CSTRING( +"Special RAM that can be shared between processes and directly accessed by " +"both the CPU and GPU. Gralloc memory is usually a relatively precious " +"resource, with much less available than generic RAM. When it's exhausted, " +"graphics performance can suffer. This value can be incorrect because of race " +"conditions."), + aData); } } if (SharedBufferManagerParent::sManagerMonitor) { SharedBufferManagerParent::sManagerMonitor->Unlock(); } return NS_OK; }
--- a/gfx/thebes/gfxASurface.cpp +++ b/gfx/thebes/gfxASurface.cpp @@ -477,38 +477,36 @@ class SurfaceMemoryReporter final : publ public: static void AdjustUsedMemory(gfxSurfaceType aType, int32_t aBytes) { // A read-modify-write operation like += would require a memory barrier // here, which would defeat the purpose of using relaxed memory // ordering. So separate out the read and write operations. sSurfaceMemoryUsed[size_t(aType)] = sSurfaceMemoryUsed[size_t(aType)] + aBytes; }; - + NS_DECL_ISUPPORTS - NS_IMETHOD CollectReports(nsIMemoryReporterCallback *aCb, - nsISupports *aClosure, bool aAnonymize) override + NS_IMETHOD CollectReports(nsIHandleReportCallback *aHandleReport, + nsISupports *aData, bool aAnonymize) override { const size_t len = ArrayLength(sSurfaceMemoryReporterAttrs); for (size_t i = 0; i < len; i++) { int64_t amount = sSurfaceMemoryUsed[i]; if (amount != 0) { const char *path = sSurfaceMemoryReporterAttrs[i].path; const char *desc = sSurfaceMemoryReporterAttrs[i].description; if (!desc) { desc = sDefaultSurfaceDescription; } - nsresult rv = aCb->Callback(EmptyCString(), nsCString(path), - KIND_OTHER, UNITS_BYTES, - amount, - nsCString(desc), aClosure); - NS_ENSURE_SUCCESS(rv, rv); + aHandleReport->Callback( + EmptyCString(), nsCString(path), KIND_OTHER, UNITS_BYTES, + amount, nsCString(desc), aData); } } return NS_OK; } }; Atomic<size_t, Relaxed> SurfaceMemoryReporter::sSurfaceMemoryUsed[size_t(gfxSurfaceType::Max)];
--- a/gfx/thebes/gfxAndroidPlatform.cpp +++ b/gfx/thebes/gfxAndroidPlatform.cpp @@ -64,19 +64,21 @@ public: Realloc(FT_Memory, long cur_size, long new_size, void* p) { return CountingRealloc(p, new_size); } NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { - return MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "explicit/freetype", KIND_HEAP, UNITS_BYTES, MemoryAllocated(), "Memory used by Freetype."); + + return NS_OK; } }; NS_IMPL_ISUPPORTS(FreetypeReporter, nsIMemoryReporter) template<> Atomic<size_t> CountingAllocatorBase<FreetypeReporter>::sAmount(0); static FT_MemoryRec_ sFreetypeMemoryRecord;
--- a/gfx/thebes/gfxFont.cpp +++ b/gfx/thebes/gfxFont.cpp @@ -91,34 +91,32 @@ uint32_t gGlyphExtentsSetupFallBackToTig */ MOZ_DEFINE_MALLOC_SIZE_OF(FontCacheMallocSizeOf) NS_IMPL_ISUPPORTS(gfxFontCache::MemoryReporter, nsIMemoryReporter) NS_IMETHODIMP gfxFontCache::MemoryReporter::CollectReports( - nsIMemoryReporterCallback* aCb, nsISupports* aClosure, bool aAnonymize) + nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) { FontCacheSizes sizes; gfxFontCache::GetCache()->AddSizeOfIncludingThis(&FontCacheMallocSizeOf, &sizes); - aCb->Callback(EmptyCString(), - NS_LITERAL_CSTRING("explicit/gfx/font-cache"), - KIND_HEAP, UNITS_BYTES, sizes.mFontInstances, - NS_LITERAL_CSTRING("Memory used for active font instances."), - aClosure); - - aCb->Callback(EmptyCString(), - NS_LITERAL_CSTRING("explicit/gfx/font-shaped-words"), - KIND_HEAP, UNITS_BYTES, sizes.mShapedWords, - NS_LITERAL_CSTRING("Memory used to cache shaped glyph data."), - aClosure); + MOZ_COLLECT_REPORT( + "explicit/gfx/font-cache", KIND_HEAP, UNITS_BYTES, + sizes.mFontInstances, + "Memory used for active font instances."); + + MOZ_COLLECT_REPORT( + "explicit/gfx/font-shaped-words", KIND_HEAP, UNITS_BYTES, + sizes.mShapedWords, + "Memory used to cache shaped glyph data."); return NS_OK; } NS_IMPL_ISUPPORTS(gfxFontCache::Observer, nsIObserver) NS_IMETHODIMP gfxFontCache::Observer::Observe(nsISupports *aSubject,
--- a/gfx/thebes/gfxPlatformFontList.cpp +++ b/gfx/thebes/gfxPlatformFontList.cpp @@ -135,47 +135,41 @@ gfxFontListPrefObserver::Observe(nsISupp } MOZ_DEFINE_MALLOC_SIZE_OF(FontListMallocSizeOf) NS_IMPL_ISUPPORTS(gfxPlatformFontList::MemoryReporter, nsIMemoryReporter) NS_IMETHODIMP gfxPlatformFontList::MemoryReporter::CollectReports( - nsIMemoryReporterCallback* aCb, nsISupports* aClosure, bool aAnonymize) + nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) { FontListSizes sizes; sizes.mFontListSize = 0; sizes.mFontTableCacheSize = 0; sizes.mCharMapsSize = 0; gfxPlatformFontList::PlatformFontList()->AddSizeOfIncludingThis(&FontListMallocSizeOf, &sizes); - nsresult rv; - rv = aCb->Callback(EmptyCString(), - NS_LITERAL_CSTRING("explicit/gfx/font-list"), - KIND_HEAP, UNITS_BYTES, sizes.mFontListSize, - NS_LITERAL_CSTRING("Memory used to manage the list of font families and faces."), - aClosure); - NS_ENSURE_SUCCESS(rv, rv); + MOZ_COLLECT_REPORT( + "explicit/gfx/font-list", KIND_HEAP, UNITS_BYTES, + sizes.mFontListSize, + "Memory used to manage the list of font families and faces."); - rv = aCb->Callback(EmptyCString(), - NS_LITERAL_CSTRING("explicit/gfx/font-charmaps"), - KIND_HEAP, UNITS_BYTES, sizes.mCharMapsSize, - NS_LITERAL_CSTRING("Memory used to record the character coverage of individual fonts."), - aClosure); - NS_ENSURE_SUCCESS(rv, rv); + MOZ_COLLECT_REPORT( + "explicit/gfx/font-charmaps", KIND_HEAP, UNITS_BYTES, + sizes.mCharMapsSize, + "Memory used to record the character coverage of individual fonts."); if (sizes.mFontTableCacheSize) { - aCb->Callback(EmptyCString(), - NS_LITERAL_CSTRING("explicit/gfx/font-tables"), - KIND_HEAP, UNITS_BYTES, sizes.mFontTableCacheSize, - NS_LITERAL_CSTRING("Memory used for cached font metrics and layout tables."), - aClosure); + MOZ_COLLECT_REPORT( + "explicit/gfx/font-tables", KIND_HEAP, UNITS_BYTES, + sizes.mFontTableCacheSize, + "Memory used for cached font metrics and layout tables."); } return NS_OK; } gfxPlatformFontList::gfxPlatformFontList(bool aNeedFullnamePostscriptNames) : mFontFamilies(64), mOtherFamilyNames(16), mBadUnderlineFamilyNames(8), mSharedCmaps(8),
--- a/gfx/thebes/gfxUserFontSet.cpp +++ b/gfx/thebes/gfxUserFontSet.cpp @@ -1295,20 +1295,19 @@ gfxUserFontSet::UserFontCache::Shutdown( if (sUserFonts) { delete sUserFonts; sUserFonts = nullptr; } } MOZ_DEFINE_MALLOC_SIZE_OF(UserFontsMallocSizeOf) -nsresult -gfxUserFontSet::UserFontCache::Entry::ReportMemory(nsIMemoryReporterCallback* aCb, - nsISupports* aClosure, - bool aAnonymize) +void +gfxUserFontSet::UserFontCache::Entry::ReportMemory( + nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) { MOZ_ASSERT(mFontEntry); nsAutoCString path("explicit/gfx/user-fonts/font("); if (aAnonymize) { path.AppendPrintf("<anonymized-%p>", this); } else { NS_ConvertUTF16toUTF8 familyName(mFontEntry->mFamilyName); @@ -1341,50 +1340,46 @@ gfxUserFontSet::UserFontCache::Entry::Re spec.ReplaceChar('/', '\\'); path.AppendPrintf(", principal=%s", spec.get()); } } } } path.Append(')'); - return aCb-> - Callback(EmptyCString(), path, - nsIMemoryReporter::KIND_HEAP, nsIMemoryReporter::UNITS_BYTES, - mFontEntry->ComputedSizeOfExcludingThis(UserFontsMallocSizeOf), - NS_LITERAL_CSTRING("Memory used by @font-face resource."), - aClosure); + aHandleReport->Callback( + EmptyCString(), path, + nsIMemoryReporter::KIND_HEAP, nsIMemoryReporter::UNITS_BYTES, + mFontEntry->ComputedSizeOfExcludingThis(UserFontsMallocSizeOf), + NS_LITERAL_CSTRING("Memory used by @font-face resource."), + aData); } NS_IMPL_ISUPPORTS(gfxUserFontSet::UserFontCache::MemoryReporter, nsIMemoryReporter) NS_IMETHODIMP gfxUserFontSet::UserFontCache::MemoryReporter::CollectReports( - nsIMemoryReporterCallback* aCb, nsISupports* aClosure, bool aAnonymize) + nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) { if (!sUserFonts) { return NS_OK; } for (auto it = sUserFonts->Iter(); !it.Done(); it.Next()) { - nsresult rv = it.Get()->ReportMemory(aCb, aClosure, aAnonymize); - if (NS_FAILED(rv)) { - return rv; - } + it.Get()->ReportMemory(aHandleReport, aData, aAnonymize); } - return aCb-> - Callback(EmptyCString(), - NS_LITERAL_CSTRING("explicit/gfx/user-fonts/cache-overhead"), - nsIMemoryReporter::KIND_HEAP, nsIMemoryReporter::UNITS_BYTES, - sUserFonts->ShallowSizeOfIncludingThis(UserFontsMallocSizeOf), - NS_LITERAL_CSTRING("Memory used by the @font-face cache, " - "not counting the actual font resources."), - aClosure); + MOZ_COLLECT_REPORT( + "explicit/gfx/user-fonts/cache-overhead", KIND_HEAP, UNITS_BYTES, + sUserFonts->ShallowSizeOfIncludingThis(UserFontsMallocSizeOf), + "Memory used by the @font-face cache, not counting the actual font " + "resources."); + + return NS_OK; } #ifdef DEBUG_USERFONT_CACHE void gfxUserFontSet::UserFontCache::Entry::Dump() { nsresult rv;
--- a/gfx/thebes/gfxUserFontSet.h +++ b/gfx/thebes/gfxUserFontSet.h @@ -443,19 +443,18 @@ public: enum { ALLOW_MEMMOVE = false }; gfxFontEntry* GetFontEntry() const { return mFontEntry; } bool IsPersistent() const { return mPersistence == kPersistent; } bool IsPrivate() const { return mPrivate; } - nsresult ReportMemory(nsIMemoryReporterCallback* aCb, - nsISupports* aClosure, - bool aAnonymize); + void ReportMemory(nsIHandleReportCallback* aHandleReport, + nsISupports* aData, bool aAnonymize); #ifdef DEBUG_USERFONT_CACHE void Dump(); #endif private: static uint32_t HashFeatures(const nsTArray<gfxFontFeature>& aFeatures) {
--- a/gfx/thebes/gfxWindowsPlatform.cpp +++ b/gfx/thebes/gfxWindowsPlatform.cpp @@ -122,29 +122,25 @@ class GfxD2DVramReporter final : public ~GfxD2DVramReporter() {} public: NS_DECL_ISUPPORTS NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { - nsresult rv; - - rv = MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "gfx-d2d-vram-draw-target", KIND_OTHER, UNITS_BYTES, Factory::GetD2DVRAMUsageDrawTarget(), "Video memory used by D2D DrawTargets."); - NS_ENSURE_SUCCESS(rv, rv); - rv = MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "gfx-d2d-vram-source-surface", KIND_OTHER, UNITS_BYTES, Factory::GetD2DVRAMUsageSourceSurface(), "Video memory used by D2D SourceSurfaces."); - NS_ENSURE_SUCCESS(rv, rv); return NS_OK; } }; NS_IMPL_ISUPPORTS(GfxD2DVramReporter, nsIMemoryReporter) #define GFX_USE_CLEARTYPE_ALWAYS "gfx.font_rendering.cleartype.always_use_for_content" @@ -177,18 +173,18 @@ class GPUAdapterReporter final : public } ~GPUAdapterReporter() {} public: NS_DECL_ISUPPORTS NS_IMETHOD - CollectReports(nsIMemoryReporterCallback* aCb, - nsISupports* aClosure, bool aAnonymize) override + CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, + bool aAnonymize) override { HANDLE ProcessHandle = GetCurrentProcess(); int64_t dedicatedBytesUsed = 0; int64_t sharedBytesUsed = 0; int64_t committedBytesUsed = 0; IDXGIAdapter *DXGIAdapter; @@ -259,36 +255,30 @@ public: } } } } } FreeLibrary(gdi32Handle); -#define REPORT(_path, _amount, _desc) \ - do { \ - nsresult rv; \ - rv = aCb->Callback(EmptyCString(), NS_LITERAL_CSTRING(_path), \ - KIND_OTHER, UNITS_BYTES, _amount, \ - NS_LITERAL_CSTRING(_desc), aClosure); \ - NS_ENSURE_SUCCESS(rv, rv); \ - } while (0) + MOZ_COLLECT_REPORT( + "gpu-committed", KIND_OTHER, UNITS_BYTES, committedBytesUsed, + "Memory committed by the Windows graphics system."); - REPORT("gpu-committed", committedBytesUsed, - "Memory committed by the Windows graphics system."); + MOZ_COLLECT_REPORT( + "gpu-dedicated", KIND_OTHER, UNITS_BYTES, + dedicatedBytesUsed, + "Out-of-process memory allocated for this process in a physical " + "GPU adapter's memory."); - REPORT("gpu-dedicated", dedicatedBytesUsed, - "Out-of-process memory allocated for this process in a " - "physical GPU adapter's memory."); - - REPORT("gpu-shared", sharedBytesUsed, - "In-process memory that is shared with the GPU."); - -#undef REPORT + MOZ_COLLECT_REPORT( + "gpu-shared", KIND_OTHER, UNITS_BYTES, + sharedBytesUsed, + "In-process memory that is shared with the GPU."); return NS_OK; } }; NS_IMPL_ISUPPORTS(GPUAdapterReporter, nsIMemoryReporter) Atomic<size_t> gfxWindowsPlatform::sD3D11SharedTextures; @@ -299,32 +289,28 @@ class D3DSharedTexturesReporter final : ~D3DSharedTexturesReporter() {} public: NS_DECL_ISUPPORTS NS_IMETHOD CollectReports(nsIHandleReportCallback *aHandleReport, nsISupports* aData, bool aAnonymize) override { - nsresult rv; - if (gfxWindowsPlatform::sD3D11SharedTextures > 0) { - rv = MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "d3d11-shared-textures", KIND_OTHER, UNITS_BYTES, gfxWindowsPlatform::sD3D11SharedTextures, "D3D11 shared textures."); - NS_ENSURE_SUCCESS(rv, rv); } if (gfxWindowsPlatform::sD3D9SharedTextures > 0) { - rv = MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "d3d9-shared-textures", KIND_OTHER, UNITS_BYTES, gfxWindowsPlatform::sD3D9SharedTextures, "D3D9 shared textures."); - NS_ENSURE_SUCCESS(rv, rv); } return NS_OK; } }; NS_IMPL_ISUPPORTS(D3DSharedTexturesReporter, nsIMemoryReporter)
--- a/image/SurfaceCache.cpp +++ b/image/SurfaceCache.cpp @@ -809,39 +809,31 @@ public: nsISupports* aData, bool aAnonymize) override { MutexAutoLock lock(mMutex); // We have explicit memory reporting for the surface cache which is more // accurate than the cost metrics we report here, but these metrics are // still useful to report, since they control the cache's behavior. - nsresult rv; - - rv = MOZ_COLLECT_REPORT("imagelib-surface-cache-estimated-total", - KIND_OTHER, UNITS_BYTES, - (mMaxCost - mAvailableCost), - "Estimated total memory used by the imagelib " - "surface cache."); - NS_ENSURE_SUCCESS(rv, rv); + MOZ_COLLECT_REPORT( + "imagelib-surface-cache-estimated-total", + KIND_OTHER, UNITS_BYTES, (mMaxCost - mAvailableCost), +"Estimated total memory used by the imagelib surface cache."); - rv = MOZ_COLLECT_REPORT("imagelib-surface-cache-estimated-locked", - KIND_OTHER, UNITS_BYTES, - mLockedCost, - "Estimated memory used by locked surfaces in the " - "imagelib surface cache."); - NS_ENSURE_SUCCESS(rv, rv); + MOZ_COLLECT_REPORT( + "imagelib-surface-cache-estimated-locked", + KIND_OTHER, UNITS_BYTES, mLockedCost, +"Estimated memory used by locked surfaces in the imagelib surface cache."); - rv = MOZ_COLLECT_REPORT("imagelib-surface-cache-overflow-count", - KIND_OTHER, UNITS_COUNT, - mOverflowCount, - "Count of how many times the surface cache has hit " - "its capacity and been unable to insert a new " - "surface."); - NS_ENSURE_SUCCESS(rv, rv); + MOZ_COLLECT_REPORT( + "imagelib-surface-cache-overflow-count", + KIND_OTHER, UNITS_COUNT, mOverflowCount, +"Count of how many times the surface cache has hit its capacity and been " +"unable to insert a new surface."); return NS_OK; } void CollectSizeOfSurfaces(const ImageKey aImageKey, nsTArray<SurfaceMemoryCounter>& aCounters, MallocSizeOf aMallocSizeOf) {
--- a/image/imgLoader.cpp +++ b/image/imgLoader.cpp @@ -68,17 +68,16 @@ class imgMemoryReporter final : public n ~imgMemoryReporter() { } public: NS_DECL_ISUPPORTS NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { - nsresult rv; nsTArray<ImageMemoryCounter> chrome; nsTArray<ImageMemoryCounter> content; nsTArray<ImageMemoryCounter> uncached; for (uint32_t i = 0; i < mKnownLoaders.Length(); i++) { for (auto iter = mKnownLoaders[i]->mChromeCache.Iter(); !iter.Done(); iter.Next()) { imgCacheEntry* entry = iter.UserData(); RefPtr<imgRequest> req = entry->GetRequest(); @@ -96,27 +95,24 @@ public: nsPtrHashKey<imgRequest>* entry = iter.Get(); RefPtr<imgRequest> req = entry->GetKey(); RecordCounterForRequest(req, &uncached, req->HasConsumers()); } } // Note that we only need to anonymize content image URIs. - rv = ReportCounterArray(aHandleReport, aData, chrome, "images/chrome"); - NS_ENSURE_SUCCESS(rv, rv); - - rv = ReportCounterArray(aHandleReport, aData, content, - "images/content", aAnonymize); - NS_ENSURE_SUCCESS(rv, rv); + ReportCounterArray(aHandleReport, aData, chrome, "images/chrome"); + + ReportCounterArray(aHandleReport, aData, content, "images/content", + aAnonymize); // Uncached images may be content or chrome, so anonymize them. - rv = ReportCounterArray(aHandleReport, aData, uncached, - "images/uncached", aAnonymize); - NS_ENSURE_SUCCESS(rv, rv); + ReportCounterArray(aHandleReport, aData, uncached, "images/uncached", + aAnonymize); return NS_OK; } static int64_t ImagesContentUsedUncompressedDistinguishedAmount() { size_t n = 0; for (uint32_t i = 0; i < imgLoader::sMemReporter->mKnownLoaders.Length(); @@ -192,23 +188,22 @@ private: private: MemoryCounter mUsedRasterCounter; MemoryCounter mUnusedRasterCounter; MemoryCounter mUsedVectorCounter; MemoryCounter mUnusedVectorCounter; }; // Reports all images of a single kind, e.g. all used chrome images. - nsresult ReportCounterArray(nsIHandleReportCallback* aHandleReport, - nsISupports* aData, - nsTArray<ImageMemoryCounter>& aCounterArray, - const char* aPathPrefix, - bool aAnonymize = false) + void ReportCounterArray(nsIHandleReportCallback* aHandleReport, + nsISupports* aData, + nsTArray<ImageMemoryCounter>& aCounterArray, + const char* aPathPrefix, + bool aAnonymize = false) { - nsresult rv; MemoryTotal summaryTotal; MemoryTotal nonNotableTotal; // Report notable images, and compute total and non-notable aggregate sizes. for (uint32_t i = 0; i < aCounterArray.Length(); i++) { ImageMemoryCounter& counter = aCounterArray[i]; if (aAnonymize) { @@ -222,43 +217,36 @@ private: counter.URI().AppendLiteral(" (truncated)"); } counter.URI().ReplaceChar('/', '\\'); } summaryTotal += counter; if (counter.IsNotable()) { - rv = ReportImage(aHandleReport, aData, aPathPrefix, counter); - NS_ENSURE_SUCCESS(rv, rv); + ReportImage(aHandleReport, aData, aPathPrefix, counter); } else { nonNotableTotal += counter; } } // Report non-notable images in aggregate. - rv = ReportTotal(aHandleReport, aData, /* aExplicit = */ true, - aPathPrefix, "<non-notable images>/", nonNotableTotal); - NS_ENSURE_SUCCESS(rv, rv); + ReportTotal(aHandleReport, aData, /* aExplicit = */ true, + aPathPrefix, "<non-notable images>/", nonNotableTotal); // Report a summary in aggregate, outside of the explicit tree. - rv = ReportTotal(aHandleReport, aData, /* aExplicit = */ false, - aPathPrefix, "", summaryTotal); - NS_ENSURE_SUCCESS(rv, rv); - - return NS_OK; + ReportTotal(aHandleReport, aData, /* aExplicit = */ false, + aPathPrefix, "", summaryTotal); } - static nsresult ReportImage(nsIHandleReportCallback* aHandleReport, - nsISupports* aData, - const char* aPathPrefix, - const ImageMemoryCounter& aCounter) + static void ReportImage(nsIHandleReportCallback* aHandleReport, + nsISupports* aData, + const char* aPathPrefix, + const ImageMemoryCounter& aCounter) { - nsresult rv; - nsAutoCString pathPrefix(NS_LITERAL_CSTRING("explicit/")); pathPrefix.Append(aPathPrefix); pathPrefix.Append(aCounter.Type() == imgIContainer::TYPE_RASTER ? "/raster/" : "/vector/"); pathPrefix.Append(aCounter.IsUsed() ? "used/" : "unused/"); pathPrefix.Append("image("); pathPrefix.AppendInt(aCounter.IntrinsicSize().width); @@ -269,29 +257,25 @@ private: if (aCounter.URI().IsEmpty()) { pathPrefix.Append("<unknown URI>"); } else { pathPrefix.Append(aCounter.URI()); } pathPrefix.Append(")/"); - rv = ReportSurfaces(aHandleReport, aData, pathPrefix, aCounter); - NS_ENSURE_SUCCESS(rv, rv); - - rv = ReportSourceValue(aHandleReport, aData, pathPrefix, aCounter.Values()); - NS_ENSURE_SUCCESS(rv, rv); - - return NS_OK; + ReportSurfaces(aHandleReport, aData, pathPrefix, aCounter); + + ReportSourceValue(aHandleReport, aData, pathPrefix, aCounter.Values()); } - static nsresult ReportSurfaces(nsIHandleReportCallback* aHandleReport, - nsISupports* aData, - const nsACString& aPathPrefix, - const ImageMemoryCounter& aCounter) + static void ReportSurfaces(nsIHandleReportCallback* aHandleReport, + nsISupports* aData, + const nsACString& aPathPrefix, + const ImageMemoryCounter& aCounter) { for (const SurfaceMemoryCounter& counter : aCounter.Surfaces()) { nsAutoCString surfacePathPrefix(aPathPrefix); surfacePathPrefix.Append(counter.IsLocked() ? "locked/" : "unlocked/"); surfacePathPrefix.Append("surface("); surfacePathPrefix.AppendInt(counter.Key().Size().width); surfacePathPrefix.Append("x"); surfacePathPrefix.AppendInt(counter.Key().Size().height); @@ -312,128 +296,103 @@ private: } else if (counter.Type() == SurfaceMemoryCounterType::COMPOSITING_PREV) { surfacePathPrefix.Append(", compositing prev frame"); } else { MOZ_ASSERT_UNREACHABLE("Unknown counter type"); } surfacePathPrefix.Append(")/"); - nsresult rv = ReportValues(aHandleReport, aData, surfacePathPrefix, - counter.Values()); - NS_ENSURE_SUCCESS(rv, rv); + ReportValues(aHandleReport, aData, surfacePathPrefix, counter.Values()); } - - return NS_OK; } - static nsresult ReportTotal(nsIHandleReportCallback* aHandleReport, - nsISupports* aData, - bool aExplicit, - const char* aPathPrefix, - const char* aPathInfix, - const MemoryTotal& aTotal) + static void ReportTotal(nsIHandleReportCallback* aHandleReport, + nsISupports* aData, + bool aExplicit, + const char* aPathPrefix, + const char* aPathInfix, + const MemoryTotal& aTotal) { - nsresult rv; - nsAutoCString pathPrefix; if (aExplicit) { pathPrefix.Append("explicit/"); } pathPrefix.Append(aPathPrefix); nsAutoCString rasterUsedPrefix(pathPrefix); rasterUsedPrefix.Append("/raster/used/"); rasterUsedPrefix.Append(aPathInfix); - rv = ReportValues(aHandleReport, aData, rasterUsedPrefix, - aTotal.UsedRaster()); - NS_ENSURE_SUCCESS(rv, rv); + ReportValues(aHandleReport, aData, rasterUsedPrefix, aTotal.UsedRaster()); nsAutoCString rasterUnusedPrefix(pathPrefix); rasterUnusedPrefix.Append("/raster/unused/"); rasterUnusedPrefix.Append(aPathInfix); - rv = ReportValues(aHandleReport, aData, rasterUnusedPrefix, - aTotal.UnusedRaster()); - NS_ENSURE_SUCCESS(rv, rv); + ReportValues(aHandleReport, aData, rasterUnusedPrefix, + aTotal.UnusedRaster()); nsAutoCString vectorUsedPrefix(pathPrefix); vectorUsedPrefix.Append("/vector/used/"); vectorUsedPrefix.Append(aPathInfix); - rv = ReportValues(aHandleReport, aData, vectorUsedPrefix, - aTotal.UsedVector()); - NS_ENSURE_SUCCESS(rv, rv); + ReportValues(aHandleReport, aData, vectorUsedPrefix, aTotal.UsedVector()); nsAutoCString vectorUnusedPrefix(pathPrefix); vectorUnusedPrefix.Append("/vector/unused/"); vectorUnusedPrefix.Append(aPathInfix); - rv = ReportValues(aHandleReport, aData, vectorUnusedPrefix, - aTotal.UnusedVector()); - NS_ENSURE_SUCCESS(rv, rv); - - return NS_OK; + ReportValues(aHandleReport, aData, vectorUnusedPrefix, + aTotal.UnusedVector()); } - static nsresult ReportValues(nsIHandleReportCallback* aHandleReport, - nsISupports* aData, - const nsACString& aPathPrefix, - const MemoryCounter& aCounter) + static void ReportValues(nsIHandleReportCallback* aHandleReport, + nsISupports* aData, + const nsACString& aPathPrefix, + const MemoryCounter& aCounter) { - nsresult rv; - - rv = ReportSourceValue(aHandleReport, aData, aPathPrefix, aCounter); - NS_ENSURE_SUCCESS(rv, rv); - - rv = ReportValue(aHandleReport, aData, KIND_HEAP, aPathPrefix, - "decoded-heap", - "Decoded image data which is stored on the heap.", - aCounter.DecodedHeap()); - NS_ENSURE_SUCCESS(rv, rv); - - rv = ReportValue(aHandleReport, aData, KIND_NONHEAP, aPathPrefix, - "decoded-nonheap", - "Decoded image data which isn't stored on the heap.", - aCounter.DecodedNonHeap()); - NS_ENSURE_SUCCESS(rv, rv); - - return NS_OK; + ReportSourceValue(aHandleReport, aData, aPathPrefix, aCounter); + + ReportValue(aHandleReport, aData, KIND_HEAP, aPathPrefix, + "decoded-heap", + "Decoded image data which is stored on the heap.", + aCounter.DecodedHeap()); + + ReportValue(aHandleReport, aData, KIND_NONHEAP, aPathPrefix, + "decoded-nonheap", + "Decoded image data which isn't stored on the heap.", + aCounter.DecodedNonHeap()); } - static nsresult ReportSourceValue(nsIHandleReportCallback* aHandleReport, - nsISupports* aData, - const nsACString& aPathPrefix, - const MemoryCounter& aCounter) + static void ReportSourceValue(nsIHandleReportCallback* aHandleReport, + nsISupports* aData, + const nsACString& aPathPrefix, + const MemoryCounter& aCounter) { - nsresult rv; - - rv = ReportValue(aHandleReport, aData, KIND_HEAP, aPathPrefix, - "source", - "Raster image source data and vector image documents.", - aCounter.Source()); - - return rv; + ReportValue(aHandleReport, aData, KIND_HEAP, aPathPrefix, + "source", + "Raster image source data and vector image documents.", + aCounter.Source()); } - static nsresult ReportValue(nsIHandleReportCallback* aHandleReport, - nsISupports* aData, - int32_t aKind, - const nsACString& aPathPrefix, - const char* aPathSuffix, - const char* aDescription, - size_t aValue) + static void ReportValue(nsIHandleReportCallback* aHandleReport, + nsISupports* aData, + int32_t aKind, + const nsACString& aPathPrefix, + const char* aPathSuffix, + const char* aDescription, + size_t aValue) { if (aValue == 0) { - return NS_OK; + return; } nsAutoCString desc(aDescription); nsAutoCString path(aPathPrefix); path.Append(aPathSuffix); - return aHandleReport->Callback(EmptyCString(), path, aKind, UNITS_BYTES, - aValue, desc, aData); + aHandleReport->Callback(EmptyCString(), path, aKind, UNITS_BYTES, + aValue, desc, aData); } static void RecordCounterForRequest(imgRequest* aRequest, nsTArray<ImageMemoryCounter>* aArray, bool aIsUsed) { RefPtr<Image> image = aRequest->GetImage(); if (!image) {
--- a/ipc/glue/SharedMemory.cpp +++ b/ipc/glue/SharedMemory.cpp @@ -23,28 +23,25 @@ class ShmemReporter final : public nsIMe public: NS_DECL_THREADSAFE_ISUPPORTS NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { - nsresult rv; - rv = MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "shmem-allocated", KIND_OTHER, UNITS_BYTES, gShmemAllocated, "Memory shared with other processes that is accessible (but not " "necessarily mapped)."); - NS_ENSURE_SUCCESS(rv, rv); - rv = MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "shmem-mapped", KIND_OTHER, UNITS_BYTES, gShmemMapped, "Memory shared with other processes that is mapped into the address " "space."); - NS_ENSURE_SUCCESS(rv, rv); return NS_OK; } }; NS_IMPL_ISUPPORTS(ShmemReporter, nsIMemoryReporter) SharedMemory::SharedMemory()
--- a/js/xpconnect/src/XPCJSMemoryReporter.h +++ b/js/xpconnect/src/XPCJSMemoryReporter.h @@ -16,18 +16,18 @@ namespace xpc { typedef nsDataHashtable<nsUint64HashKey, nsCString> WindowPaths; // This is very nearly an instance of nsIMemoryReporter, but it's not, // because it's invoked by nsWindowMemoryReporter in order to get |windowPaths| // in CollectReports. class JSReporter { public: - static nsresult CollectReports(WindowPaths* windowPaths, - WindowPaths* topWindowPaths, - nsIMemoryReporterCallback* cb, - nsISupports* closure, - bool anonymize); + static void CollectReports(WindowPaths* windowPaths, + WindowPaths* topWindowPaths, + nsIMemoryReporterCallback* handleReport, + nsISupports* data, + bool anonymize); }; } // namespace xpc #endif
--- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -1804,131 +1804,117 @@ class JSMainRuntimeTemporaryPeakReporter ~JSMainRuntimeTemporaryPeakReporter() {} public: NS_DECL_ISUPPORTS NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { - return MOZ_COLLECT_REPORT("js-main-runtime-temporary-peak", - KIND_OTHER, UNITS_BYTES, + MOZ_COLLECT_REPORT( + "js-main-runtime-temporary-peak", KIND_OTHER, UNITS_BYTES, JSMainRuntimeTemporaryPeakDistinguishedAmount(), "Peak transient data size in the main JSRuntime (the current size " "of which is reported as " "'explicit/js-non-window/runtime/temporary')."); + + return NS_OK; } }; NS_IMPL_ISUPPORTS(JSMainRuntimeTemporaryPeakReporter, nsIMemoryReporter) // The REPORT* macros do an unconditional report. The ZCREPORT* macros are for // compartments and zones; they aggregate any entries smaller than // SUNDRIES_THRESHOLD into the "sundries/gc-heap" and "sundries/malloc-heap" // entries for the compartment. #define SUNDRIES_THRESHOLD js::MemoryReportingSundriesThreshold() -#define REPORT(_path, _kind, _units, _amount, _desc) \ - do { \ - nsresult rv; \ - rv = cb->Callback(EmptyCString(), _path, \ - nsIMemoryReporter::_kind, \ - nsIMemoryReporter::_units, \ - _amount, \ - NS_LITERAL_CSTRING(_desc), \ - closure); \ - NS_ENSURE_SUCCESS(rv, rv); \ - } while (0) - -#define REPORT_BYTES(_path, _kind, _amount, _desc) \ +#define REPORT(_path, _kind, _units, _amount, _desc) \ + handleReport->Callback(EmptyCString(), _path, \ + nsIMemoryReporter::_kind, \ + nsIMemoryReporter::_units, _amount, \ + NS_LITERAL_CSTRING(_desc), data); \ + +#define REPORT_BYTES(_path, _kind, _amount, _desc) \ REPORT(_path, _kind, UNITS_BYTES, _amount, _desc); -#define REPORT_GC_BYTES(_path, _amount, _desc) \ - do { \ - size_t amount = _amount; /* evaluate _amount only once */ \ - nsresult rv; \ - rv = cb->Callback(EmptyCString(), _path, \ - nsIMemoryReporter::KIND_NONHEAP, \ - nsIMemoryReporter::UNITS_BYTES, amount, \ - NS_LITERAL_CSTRING(_desc), closure); \ - NS_ENSURE_SUCCESS(rv, rv); \ - gcTotal += amount; \ +#define REPORT_GC_BYTES(_path, _amount, _desc) \ + do { \ + size_t amount = _amount; /* evaluate _amount only once */ \ + handleReport->Callback(EmptyCString(), _path, \ + nsIMemoryReporter::KIND_NONHEAP, \ + nsIMemoryReporter::UNITS_BYTES, amount, \ + NS_LITERAL_CSTRING(_desc), data); \ + gcTotal += amount; \ } while (0) // Report compartment/zone non-GC (KIND_HEAP) bytes. -#define ZCREPORT_BYTES(_path, _amount, _desc) \ - do { \ - /* Assign _descLiteral plus "" into a char* to prove that it's */ \ - /* actually a literal. */ \ - size_t amount = _amount; /* evaluate _amount only once */ \ - if (amount >= SUNDRIES_THRESHOLD) { \ - nsresult rv; \ - rv = cb->Callback(EmptyCString(), _path, \ - nsIMemoryReporter::KIND_HEAP, \ - nsIMemoryReporter::UNITS_BYTES, amount, \ - NS_LITERAL_CSTRING(_desc), closure); \ - NS_ENSURE_SUCCESS(rv, rv); \ - } else { \ - sundriesMallocHeap += amount; \ - } \ +#define ZCREPORT_BYTES(_path, _amount, _desc) \ + do { \ + /* Assign _descLiteral plus "" into a char* to prove that it's */ \ + /* actually a literal. */ \ + size_t amount = _amount; /* evaluate _amount only once */ \ + if (amount >= SUNDRIES_THRESHOLD) { \ + handleReport->Callback(EmptyCString(), _path, \ + nsIMemoryReporter::KIND_HEAP, \ + nsIMemoryReporter::UNITS_BYTES, amount, \ + NS_LITERAL_CSTRING(_desc), data); \ + } else { \ + sundriesMallocHeap += amount; \ + } \ } while (0) // Report compartment/zone GC bytes. -#define ZCREPORT_GC_BYTES(_path, _amount, _desc) \ - do { \ - size_t amount = _amount; /* evaluate _amount only once */ \ - if (amount >= SUNDRIES_THRESHOLD) { \ - nsresult rv; \ - rv = cb->Callback(EmptyCString(), _path, \ - nsIMemoryReporter::KIND_NONHEAP, \ - nsIMemoryReporter::UNITS_BYTES, amount, \ - NS_LITERAL_CSTRING(_desc), closure); \ - NS_ENSURE_SUCCESS(rv, rv); \ - gcTotal += amount; \ - } else { \ - sundriesGCHeap += amount; \ - } \ +#define ZCREPORT_GC_BYTES(_path, _amount, _desc) \ + do { \ + size_t amount = _amount; /* evaluate _amount only once */ \ + if (amount >= SUNDRIES_THRESHOLD) { \ + handleReport->Callback(EmptyCString(), _path, \ + nsIMemoryReporter::KIND_NONHEAP, \ + nsIMemoryReporter::UNITS_BYTES, amount, \ + NS_LITERAL_CSTRING(_desc), data); \ + gcTotal += amount; \ + } else { \ + sundriesGCHeap += amount; \ + } \ } while (0) // Report runtime bytes. -#define RREPORT_BYTES(_path, _kind, _amount, _desc) \ - do { \ - size_t amount = _amount; /* evaluate _amount only once */ \ - nsresult rv; \ - rv = cb->Callback(EmptyCString(), _path, \ - nsIMemoryReporter::_kind, \ - nsIMemoryReporter::UNITS_BYTES, amount, \ - NS_LITERAL_CSTRING(_desc), closure); \ - NS_ENSURE_SUCCESS(rv, rv); \ - rtTotal += amount; \ +#define RREPORT_BYTES(_path, _kind, _amount, _desc) \ + do { \ + size_t amount = _amount; /* evaluate _amount only once */ \ + handleReport->Callback(EmptyCString(), _path, \ + nsIMemoryReporter::_kind, \ + nsIMemoryReporter::UNITS_BYTES, amount, \ + NS_LITERAL_CSTRING(_desc), data); \ + rtTotal += amount; \ } while (0) // Report GC thing bytes. -#define MREPORT_BYTES(_path, _kind, _amount, _desc) \ - do { \ - size_t amount = _amount; /* evaluate _amount only once */ \ - nsresult rv; \ - rv = cb->Callback(EmptyCString(), _path, \ - nsIMemoryReporter::_kind, \ - nsIMemoryReporter::UNITS_BYTES, amount, \ - NS_LITERAL_CSTRING(_desc), closure); \ - NS_ENSURE_SUCCESS(rv, rv); \ - gcThingTotal += amount; \ +#define MREPORT_BYTES(_path, _kind, _amount, _desc) \ + do { \ + size_t amount = _amount; /* evaluate _amount only once */ \ + handleReport->Callback(EmptyCString(), _path, \ + nsIMemoryReporter::_kind, \ + nsIMemoryReporter::UNITS_BYTES, amount, \ + NS_LITERAL_CSTRING(_desc), data); \ + gcThingTotal += amount; \ } while (0) MOZ_DEFINE_MALLOC_SIZE_OF(JSMallocSizeOf) namespace xpc { -static nsresult +static void ReportZoneStats(const JS::ZoneStats& zStats, const xpc::ZoneStatsExtras& extras, - nsIMemoryReporterCallback* cb, - nsISupports* closure, + nsIHandleReportCallback* handleReport, + nsISupports* data, bool anonymize, size_t* gcTotalOut = nullptr) { const nsCString& pathPrefix = extras.pathPrefix; size_t gcTotal = 0, sundriesGCHeap = 0, sundriesMallocHeap = 0; MOZ_ASSERT(!gcTotalOut == zStats.isTotals); @@ -2157,25 +2143,23 @@ ReportZoneStats(const JS::ZoneStats& zSt KIND_HEAP, sundriesMallocHeap, "The sum of all 'malloc-heap' measurements that are too small to " "be worth showing individually."); } if (gcTotalOut) *gcTotalOut += gcTotal; - return NS_OK; - # undef STRING_LENGTH } -static nsresult +static void ReportClassStats(const ClassInfo& classInfo, const nsACString& path, - nsIHandleReportCallback* cb, - nsISupports* closure, size_t& gcTotal) + nsIHandleReportCallback* handleReport, + nsISupports* data, size_t& gcTotal) { // We deliberately don't use ZCREPORT_BYTES, so that these per-class values // don't go into sundries. if (classInfo.objectsGCHeap > 0) { REPORT_GC_BYTES(path + NS_LITERAL_CSTRING("objects/gc-heap"), classInfo.objectsGCHeap, "Objects, including fixed slots."); @@ -2233,33 +2217,30 @@ ReportClassStats(const ClassInfo& classI "AOT-compiled asm.js code."); } if (classInfo.objectsMallocHeapMisc > 0) { REPORT_BYTES(path + NS_LITERAL_CSTRING("objects/malloc-heap/misc"), KIND_HEAP, classInfo.objectsMallocHeapMisc, "Miscellaneous object data."); } - - return NS_OK; } -static nsresult +static void ReportCompartmentStats(const JS::CompartmentStats& cStats, const xpc::CompartmentStatsExtras& extras, amIAddonManager* addonManager, - nsIMemoryReporterCallback* cb, - nsISupports* closure, size_t* gcTotalOut = nullptr) + nsIHandleReportCallback* handleReport, + nsISupports* data, size_t* gcTotalOut = nullptr) { static const nsDependentCString addonPrefix("explicit/add-ons/"); size_t gcTotal = 0, sundriesGCHeap = 0, sundriesMallocHeap = 0; nsAutoCString cJSPathPrefix(extras.jsPathPrefix); nsAutoCString cDOMPathPrefix(extras.domPathPrefix); - nsresult rv; MOZ_ASSERT(!gcTotalOut == cStats.isTotals); // Only attempt to prefix if we got a location and the path wasn't already // prefixed. if (extras.location && addonManager && cJSPathPrefix.Find(addonPrefix, false, 0, 0) != 0) { nsAutoCString addonId; @@ -2277,29 +2258,27 @@ ReportCompartmentStats(const JS::Compart } } nsCString nonNotablePath = cJSPathPrefix; nonNotablePath += cStats.isTotals ? NS_LITERAL_CSTRING("classes/") : NS_LITERAL_CSTRING("classes/class(<non-notable classes>)/"); - rv = ReportClassStats(cStats.classInfo, nonNotablePath, cb, closure, - gcTotal); - NS_ENSURE_SUCCESS(rv, rv); + ReportClassStats(cStats.classInfo, nonNotablePath, handleReport, data, + gcTotal); for (size_t i = 0; i < cStats.notableClasses.length(); i++) { MOZ_ASSERT(!cStats.isTotals); const JS::NotableClassInfo& classInfo = cStats.notableClasses[i]; nsCString classPath = cJSPathPrefix + nsPrintfCString("classes/class(%s)/", classInfo.className_); - rv = ReportClassStats(classInfo, classPath, cb, closure, gcTotal); - NS_ENSURE_SUCCESS(rv, rv); + ReportClassStats(classInfo, classPath, handleReport, data, gcTotal); } // Note that we use cDOMPathPrefix here. This is because we measure orphan // DOM nodes in the JS reporter, but we want to report them in a "dom" // sub-tree rather than a "js" sub-tree. ZCREPORT_BYTES(cDOMPathPrefix + NS_LITERAL_CSTRING("orphan-nodes"), cStats.objectsPrivate, "Orphan DOM nodes, i.e. those that are only reachable from JavaScript " @@ -2400,64 +2379,57 @@ ReportCompartmentStats(const JS::Compart REPORT_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("sundries/malloc-heap"), KIND_HEAP, sundriesMallocHeap, "The sum of all 'malloc-heap' measurements that are too small to " "be worth showing individually."); } if (gcTotalOut) *gcTotalOut += gcTotal; - - return NS_OK; } -static nsresult +static void ReportScriptSourceStats(const ScriptSourceInfo& scriptSourceInfo, const nsACString& path, - nsIHandleReportCallback* cb, nsISupports* closure, - size_t& rtTotal) + nsIHandleReportCallback* handleReport, + nsISupports* data, size_t& rtTotal) { if (scriptSourceInfo.misc > 0) { RREPORT_BYTES(path + NS_LITERAL_CSTRING("misc"), KIND_HEAP, scriptSourceInfo.misc, "Miscellaneous data relating to JavaScript source code."); } - - return NS_OK; } -static nsresult +static void ReportJSRuntimeExplicitTreeStats(const JS::RuntimeStats& rtStats, const nsACString& rtPath, amIAddonManager* addonManager, - nsIMemoryReporterCallback* cb, - nsISupports* closure, + nsIHandleReportCallback* handleReport, + nsISupports* data, bool anonymize, size_t* rtTotalOut) { - nsresult rv; - size_t gcTotal = 0; for (size_t i = 0; i < rtStats.zoneStatsVector.length(); i++) { const JS::ZoneStats& zStats = rtStats.zoneStatsVector[i]; const xpc::ZoneStatsExtras* extras = static_cast<const xpc::ZoneStatsExtras*>(zStats.extra); - rv = ReportZoneStats(zStats, *extras, cb, closure, anonymize, &gcTotal); - NS_ENSURE_SUCCESS(rv, rv); + ReportZoneStats(zStats, *extras, handleReport, data, anonymize, + &gcTotal); } for (size_t i = 0; i < rtStats.compartmentStatsVector.length(); i++) { const JS::CompartmentStats& cStats = rtStats.compartmentStatsVector[i]; const xpc::CompartmentStatsExtras* extras = static_cast<const xpc::CompartmentStatsExtras*>(cStats.extra); - rv = ReportCompartmentStats(cStats, *extras, addonManager, cb, closure, - &gcTotal); - NS_ENSURE_SUCCESS(rv, rv); + ReportCompartmentStats(cStats, *extras, addonManager, handleReport, + data, &gcTotal); } // Report the rtStats.runtime numbers under "runtime/", and compute their // total for later. size_t rtTotal = 0; RREPORT_BYTES(rtPath + NS_LITERAL_CSTRING("runtime/runtime-object"), @@ -2496,19 +2468,18 @@ ReportJSRuntimeExplicitTreeStats(const J RREPORT_BYTES(rtPath + NS_LITERAL_CSTRING("runtime/script-data"), KIND_HEAP, rtStats.runtime.scriptData, "The table holding script data shared in the runtime."); nsCString nonNotablePath = rtPath + nsPrintfCString("runtime/script-sources/source(scripts=%d, <non-notable files>)/", rtStats.runtime.scriptSourceInfo.numScripts); - rv = ReportScriptSourceStats(rtStats.runtime.scriptSourceInfo, - nonNotablePath, cb, closure, rtTotal); - NS_ENSURE_SUCCESS(rv, rv); + ReportScriptSourceStats(rtStats.runtime.scriptSourceInfo, + nonNotablePath, handleReport, data, rtTotal); for (size_t i = 0; i < rtStats.runtime.notableScriptSources.length(); i++) { const JS::NotableScriptSourceInfo& scriptSourceInfo = rtStats.runtime.notableScriptSources[i]; // Escape / to \ before we put the filename into the memory reporter // path, because we don't want any forward slashes in the string to // count as path separators. Consumers of memory reporters (e.g. @@ -2522,19 +2493,18 @@ ReportJSRuntimeExplicitTreeStats(const J escapedFilename.Append(filename); escapedFilename.ReplaceSubstring("/", "\\"); } nsCString notablePath = rtPath + nsPrintfCString("runtime/script-sources/source(scripts=%d, %s)/", scriptSourceInfo.numScripts, escapedFilename.get()); - rv = ReportScriptSourceStats(scriptSourceInfo, notablePath, - cb, closure, rtTotal); - NS_ENSURE_SUCCESS(rv, rv); + ReportScriptSourceStats(scriptSourceInfo, notablePath, + handleReport, data, rtTotal); } RREPORT_BYTES(rtPath + NS_LITERAL_CSTRING("runtime/code/ion"), KIND_NONHEAP, rtStats.runtime.code.ion, "Code generated by the IonMonkey JIT."); RREPORT_BYTES(rtPath + NS_LITERAL_CSTRING("runtime/code/baseline"), KIND_NONHEAP, rtStats.runtime.code.baseline, @@ -2610,35 +2580,33 @@ ReportJSRuntimeExplicitTreeStats(const J REPORT_GC_BYTES(rtPath + NS_LITERAL_CSTRING("gc-heap/chunk-admin"), rtStats.gcHeapChunkAdmin, "Bookkeeping information within GC chunks."); // gcTotal is the sum of everything we've reported for the GC heap. It // should equal rtStats.gcHeapChunkTotal. MOZ_ASSERT(gcTotal == rtStats.gcHeapChunkTotal); - - return NS_OK; } -nsresult +void ReportJSRuntimeExplicitTreeStats(const JS::RuntimeStats& rtStats, const nsACString& rtPath, - nsIMemoryReporterCallback* cb, - nsISupports* closure, + nsIHandleReportCallback* handleReport, + nsISupports* data, bool anonymize, size_t* rtTotalOut) { nsCOMPtr<amIAddonManager> am; if (XRE_IsParentProcess()) { // Only try to access the service from the main process. am = do_GetService("@mozilla.org/addons/integration;1"); } - return ReportJSRuntimeExplicitTreeStats(rtStats, rtPath, am.get(), - cb, closure, anonymize, rtTotalOut); + ReportJSRuntimeExplicitTreeStats(rtStats, rtPath, am.get(), handleReport, + data, anonymize, rtTotalOut); } } // namespace xpc class JSMainRuntimeCompartmentsReporter final : public nsIMemoryReporter { @@ -2659,30 +2627,31 @@ class JSMainRuntimeCompartmentsReporter GetCompartmentName(c, path, &data->anonymizeID, /* replaceSlashes = */ true); path.Insert(js::IsSystemCompartment(c) ? NS_LITERAL_CSTRING("js-main-runtime-compartments/system/") : NS_LITERAL_CSTRING("js-main-runtime-compartments/user/"), 0); mozilla::Unused << data->paths.append(path); } - NS_IMETHOD CollectReports(nsIMemoryReporterCallback* cb, - nsISupports* closure, bool anonymize) override + NS_IMETHOD CollectReports(nsIHandleReportCallback* handleReport, + nsISupports* data, bool anonymize) override { // First we collect the compartment paths. Then we report them. Doing - // the two steps interleaved is a bad idea, because calling |cb| - // from within CompartmentCallback() leads to all manner of assertions. - - Data data; - data.anonymizeID = anonymize ? 1 : 0; + // the two steps interleaved is a bad idea, because calling + // |handleReport| from within CompartmentCallback() leads to all manner + // of assertions. + + Data d; + d.anonymizeID = anonymize ? 1 : 0; JS_IterateCompartments(nsXPConnect::GetRuntimeInstance()->Context(), - &data, CompartmentCallback); - - for (size_t i = 0; i < data.paths.length(); i++) - REPORT(nsCString(data.paths[i]), KIND_OTHER, UNITS_COUNT, 1, + &d, CompartmentCallback); + + for (size_t i = 0; i < d.paths.length(); i++) + REPORT(nsCString(d.paths[i]), KIND_OTHER, UNITS_COUNT, 1, "A live compartment in the main JSRuntime."); return NS_OK; } }; NS_IMPL_ISUPPORTS(JSMainRuntimeCompartmentsReporter, nsIMemoryReporter) @@ -2869,21 +2838,21 @@ class XPCJSRuntimeStats : public JS::Run MOZ_ASSERT(StartsWithExplicit(extras->jsPathPrefix)); MOZ_ASSERT(StartsWithExplicit(extras->domPathPrefix)); cstats->extra = extras; } }; -nsresult +void JSReporter::CollectReports(WindowPaths* windowPaths, WindowPaths* topWindowPaths, - nsIMemoryReporterCallback* cb, - nsISupports* closure, + nsIHandleReportCallback* handleReport, + nsISupports* data, bool anonymize) { XPCJSRuntime* xpcrt = nsXPConnect::GetRuntimeInstance(); // In the first step we get all the stats and stash them in a local // data structure. In the second step we pass all the stashed stats to // the callback. Separating these steps is important because the // callback may be a JS function, and executing JS while getting these @@ -2896,52 +2865,49 @@ JSReporter::CollectReports(WindowPaths* } bool getLocations = !!addonManager; XPCJSRuntimeStats rtStats(windowPaths, topWindowPaths, getLocations, anonymize); OrphanReporter orphanReporter(XPCConvert::GetISupportsFromJSObject); if (!JS::CollectRuntimeStats(xpcrt->Context(), &rtStats, &orphanReporter, anonymize)) { - return NS_ERROR_FAILURE; + return; } size_t xpcJSRuntimeSize = xpcrt->SizeOfIncludingThis(JSMallocSizeOf); size_t wrappedJSSize = xpcrt->GetMultiCompartmentWrappedJSMap()->SizeOfWrappedJS(JSMallocSizeOf); XPCWrappedNativeScope::ScopeSizeInfo sizeInfo(JSMallocSizeOf); XPCWrappedNativeScope::AddSizeOfAllScopesIncludingThis(&sizeInfo); mozJSComponentLoader* loader = mozJSComponentLoader::Get(); size_t jsComponentLoaderSize = loader ? loader->SizeOfIncludingThis(JSMallocSizeOf) : 0; // This is the second step (see above). First we report stuff in the // "explicit" tree, then we report other stuff. - nsresult rv; size_t rtTotal = 0; - rv = xpc::ReportJSRuntimeExplicitTreeStats(rtStats, - NS_LITERAL_CSTRING("explicit/js-non-window/"), - addonManager, cb, closure, - anonymize, &rtTotal); - NS_ENSURE_SUCCESS(rv, rv); + xpc::ReportJSRuntimeExplicitTreeStats(rtStats, + NS_LITERAL_CSTRING("explicit/js-non-window/"), + addonManager, handleReport, data, + anonymize, &rtTotal); // Report the sums of the compartment numbers. xpc::CompartmentStatsExtras cExtrasTotal; cExtrasTotal.jsPathPrefix.AssignLiteral("js-main-runtime/compartments/"); cExtrasTotal.domPathPrefix.AssignLiteral("window-objects/dom/"); - rv = ReportCompartmentStats(rtStats.cTotals, cExtrasTotal, addonManager, - cb, closure); - NS_ENSURE_SUCCESS(rv, rv); + ReportCompartmentStats(rtStats.cTotals, cExtrasTotal, addonManager, + handleReport, data); xpc::ZoneStatsExtras zExtrasTotal; zExtrasTotal.pathPrefix.AssignLiteral("js-main-runtime/zones/"); - rv = ReportZoneStats(rtStats.zTotals, zExtrasTotal, cb, closure, anonymize); - NS_ENSURE_SUCCESS(rv, rv); + ReportZoneStats(rtStats.zTotals, zExtrasTotal, handleReport, data, + anonymize); // Report the sum of the runtime/ numbers. REPORT_BYTES(NS_LITERAL_CSTRING("js-main-runtime/runtime"), KIND_OTHER, rtTotal, "The sum of all measurements under 'explicit/js-non-window/runtime/'."); // Report the numbers for memory outside of compartments. @@ -3068,18 +3034,16 @@ JSReporter::CollectReports(WindowPaths* REPORT_BYTES(NS_LITERAL_CSTRING("explicit/xpconnect/proto-iface-cache"), KIND_HEAP, sizeInfo.mProtoAndIfaceCacheSize, "Prototype and interface binding caches."); REPORT_BYTES(NS_LITERAL_CSTRING("explicit/xpconnect/js-component-loader"), KIND_HEAP, jsComponentLoaderSize, "XPConnect's JS component loader."); - - return NS_OK; } static nsresult JSSizeOfTab(JSObject* objArg, size_t* jsObjectsSize, size_t* jsStringsSize, size_t* jsPrivateSize, size_t* jsOtherSize) { JSContext* cx = nsXPConnect::GetRuntimeInstance()->Context(); JS::RootedObject obj(cx, objArg);
--- a/js/xpconnect/src/xpcpublic.h +++ b/js/xpconnect/src/xpcpublic.h @@ -412,21 +412,21 @@ private: CompartmentStatsExtras(const CompartmentStatsExtras& other) = delete; CompartmentStatsExtras& operator=(const CompartmentStatsExtras& other) = delete; }; // This reports all the stats in |rtStats| that belong in the "explicit" tree, // (which isn't all of them). // @see ZoneStatsExtras // @see CompartmentStatsExtras -nsresult +void ReportJSRuntimeExplicitTreeStats(const JS::RuntimeStats& rtStats, const nsACString& rtPath, - nsIMemoryReporterCallback* cb, - nsISupports* closure, + nsIMemoryReporterCallback* handleReport, + nsISupports* data, bool anonymize, size_t* rtTotal = nullptr); /** * Throws an exception on cx and returns false. */ bool Throw(JSContext* cx, nsresult rv);
--- a/layout/base/nsStyleSheetService.cpp +++ b/layout/base/nsStyleSheetService.cpp @@ -357,20 +357,22 @@ nsStyleSheetService::GetInstance() } MOZ_DEFINE_MALLOC_SIZE_OF(StyleSheetServiceMallocSizeOf) NS_IMETHODIMP nsStyleSheetService::CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) { - return MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "explicit/layout/style-sheet-service", KIND_HEAP, UNITS_BYTES, SizeOfIncludingThis(StyleSheetServiceMallocSizeOf), "Memory used for style sheets held by the style sheet service."); + + return NS_OK; } size_t nsStyleSheetService::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = aMallocSizeOf(this); for (auto& sheetArray : mSheets) { n += sheetArray.ShallowSizeOfExcludingThis(aMallocSizeOf);
--- a/layout/style/RuleProcessorCache.cpp +++ b/layout/style/RuleProcessorCache.cpp @@ -19,20 +19,22 @@ using namespace mozilla; NS_IMPL_ISUPPORTS(RuleProcessorCache, nsIMemoryReporter) MOZ_DEFINE_MALLOC_SIZE_OF(RuleProcessorCacheMallocSizeOf) NS_IMETHODIMP RuleProcessorCache::CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) { - return MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "explicit/layout/rule-processor-cache", KIND_HEAP, UNITS_BYTES, SizeOfIncludingThis(RuleProcessorCacheMallocSizeOf), "Memory used for cached rule processors."); + + return NS_OK; } RuleProcessorCache::~RuleProcessorCache() { UnregisterWeakMemoryReporter(this); for (Entry& e : mEntries) { for (DocumentEntry& de : e.mDocumentEntries) {
--- a/layout/style/nsLayoutStylesheetCache.cpp +++ b/layout/style/nsLayoutStylesheetCache.cpp @@ -257,20 +257,22 @@ nsLayoutStylesheetCache::Shutdown() } MOZ_DEFINE_MALLOC_SIZE_OF(LayoutStylesheetCacheMallocSizeOf) NS_IMETHODIMP nsLayoutStylesheetCache::CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) { - return MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "explicit/layout/style-sheet-cache", KIND_HEAP, UNITS_BYTES, SizeOfIncludingThis(LayoutStylesheetCacheMallocSizeOf), "Memory used for some built-in style sheets."); + + return NS_OK; } size_t nsLayoutStylesheetCache::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = aMallocSizeOf(this);
--- a/modules/libpref/Preferences.cpp +++ b/modules/libpref/Preferences.cpp @@ -312,33 +312,23 @@ protected: static const uint32_t kSuspectReferentCount = 1000; }; NS_IMPL_ISUPPORTS(PreferenceServiceReporter, nsIMemoryReporter) MOZ_DEFINE_MALLOC_SIZE_OF(PreferenceServiceMallocSizeOf) NS_IMETHODIMP -PreferenceServiceReporter::CollectReports(nsIMemoryReporterCallback* aCb, - nsISupports* aClosure, - bool aAnonymize) +PreferenceServiceReporter::CollectReports( + nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) { -#define REPORT(_path, _kind, _units, _amount, _desc) \ - do { \ - nsresult rv; \ - rv = aCb->Callback(EmptyCString(), _path, _kind, \ - _units, _amount, NS_LITERAL_CSTRING(_desc), \ - aClosure); \ - NS_ENSURE_SUCCESS(rv, rv); \ - } while (0) - - REPORT(NS_LITERAL_CSTRING("explicit/preferences"), - KIND_HEAP, UNITS_BYTES, - Preferences::SizeOfIncludingThisAndOtherStuff(PreferenceServiceMallocSizeOf), - "Memory used by the preferences system."); + MOZ_COLLECT_REPORT( + "explicit/preferences", KIND_HEAP, UNITS_BYTES, + Preferences::SizeOfIncludingThisAndOtherStuff(PreferenceServiceMallocSizeOf), + "Memory used by the preferences system."); nsPrefBranch* rootBranch = static_cast<nsPrefBranch*>(Preferences::GetRootBranch()); if (!rootBranch) { return NS_OK; } size_t numStrong = 0; @@ -380,37 +370,41 @@ PreferenceServiceReporter::CollectReport for (uint32_t i = 0; i < suspectPreferences.Length(); i++) { nsCString& suspect = suspectPreferences[i]; uint32_t totalReferentCount = 0; prefCounter.Get(suspect, &totalReferentCount); nsPrintfCString suspectPath("preference-service-suspect/" "referent(pref=%s)", suspect.get()); - REPORT(suspectPath, - KIND_OTHER, UNITS_COUNT, totalReferentCount, - "A preference with a suspiciously large number " - "referents (symptom of a leak)."); + aHandleReport->Callback( + /* process = */ EmptyCString(), + suspectPath, KIND_OTHER, UNITS_COUNT, totalReferentCount, + NS_LITERAL_CSTRING( + "A preference with a suspiciously large number referents (symptom of a " + "leak)."), + aData); } - REPORT(NS_LITERAL_CSTRING("preference-service/referent/strong"), - KIND_OTHER, UNITS_COUNT, numStrong, - "The number of strong referents held by the preference service."); + MOZ_COLLECT_REPORT( + "preference-service/referent/strong", KIND_OTHER, UNITS_COUNT, + numStrong, + "The number of strong referents held by the preference service."); - REPORT(NS_LITERAL_CSTRING("preference-service/referent/weak/alive"), - KIND_OTHER, UNITS_COUNT, numWeakAlive, - "The number of weak referents held by the preference service " - "that are still alive."); + MOZ_COLLECT_REPORT( + "preference-service/referent/weak/alive", KIND_OTHER, UNITS_COUNT, + numWeakAlive, + "The number of weak referents held by the preference service that are " + "still alive."); - REPORT(NS_LITERAL_CSTRING("preference-service/referent/weak/dead"), - KIND_OTHER, UNITS_COUNT, numWeakDead, - "The number of weak referents held by the preference service " - "that are dead."); - -#undef REPORT + MOZ_COLLECT_REPORT( + "preference-service/referent/weak/dead", KIND_OTHER, UNITS_COUNT, + numWeakDead, + "The number of weak referents held by the preference service that are " + "dead."); return NS_OK; } namespace { class AddPreferencesMemoryReporterRunnable : public Runnable { NS_IMETHOD Run() override
--- a/netwerk/cache/nsCacheService.cpp +++ b/netwerk/cache/nsCacheService.cpp @@ -3195,26 +3195,18 @@ nsCacheService::CollectReports(nsIHandle if (mDiskDevice) { nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHESERVICE_DISKDEVICEHEAPSIZE)); disk = mDiskDevice->SizeOfIncludingThis(DiskCacheDeviceMallocSizeOf); } size_t memory = mMemoryDevice ? mMemoryDevice->TotalSize() : 0; -#define REPORT(_path, _amount, _desc) \ - do { \ - nsresult rv; \ - rv = aHandleReport->Callback(EmptyCString(), \ - NS_LITERAL_CSTRING(_path), \ - KIND_HEAP, UNITS_BYTES, _amount, \ - NS_LITERAL_CSTRING(_desc), aData); \ - NS_ENSURE_SUCCESS(rv, rv); \ - } while (0) - - REPORT("explicit/network/disk-cache", disk, - "Memory used by the network disk cache."); - - REPORT("explicit/network/memory-cache", memory, - "Memory used by the network memory cache."); + MOZ_COLLECT_REPORT( + "explicit/network/disk-cache", KIND_HEAP, UNITS_BYTES, disk, + "Memory used by the network disk cache."); + + MOZ_COLLECT_REPORT( + "explicit/network/memory-cache", KIND_HEAP, UNITS_BYTES, memory, + "Memory used by the network memory cache."); return NS_OK; }
--- a/netwerk/cache2/CacheStorageService.cpp +++ b/netwerk/cache2/CacheStorageService.cpp @@ -2108,44 +2108,36 @@ CacheStorageService::SizeOfExcludingThis size_t CacheStorageService::SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return mallocSizeOf(this) + SizeOfExcludingThis(mallocSizeOf); } NS_IMETHODIMP -CacheStorageService::CollectReports(nsIMemoryReporterCallback* aHandleReport, +CacheStorageService::CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) { - nsresult rv; - - rv = MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "explicit/network/cache2/io", KIND_HEAP, UNITS_BYTES, CacheFileIOManager::SizeOfIncludingThis(MallocSizeOf), "Memory used by the cache IO manager."); - if (NS_WARN_IF(NS_FAILED(rv))) - return rv; - rv = MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "explicit/network/cache2/index", KIND_HEAP, UNITS_BYTES, CacheIndex::SizeOfIncludingThis(MallocSizeOf), "Memory used by the cache index."); - if (NS_WARN_IF(NS_FAILED(rv))) - return rv; MutexAutoLock lock(mLock); // Report the service instance, this doesn't report entries, done lower - rv = MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "explicit/network/cache2/service", KIND_HEAP, UNITS_BYTES, SizeOfIncludingThis(MallocSizeOf), "Memory used by the cache storage service."); - if (NS_WARN_IF(NS_FAILED(rv))) - return rv; // Report all entries, each storage separately (by the context key) // // References are: // sGlobalEntryTables to N CacheEntryTable // CacheEntryTable to N CacheEntry // CacheEntry to 1 CacheFile // CacheFile to @@ -2177,19 +2169,17 @@ CacheStorageService::CollectReports(nsIM } // These key names are not privacy-sensitive. aHandleReport->Callback( EmptyCString(), nsPrintfCString("explicit/network/cache2/%s-storage(%s)", table->Type() == CacheEntryTable::MEMORY_ONLY ? "memory" : "disk", iter1.Key().BeginReading()), - nsIMemoryReporter::KIND_HEAP, - nsIMemoryReporter::UNITS_BYTES, - size, + nsIMemoryReporter::KIND_HEAP, nsIMemoryReporter::UNITS_BYTES, size, NS_LITERAL_CSTRING("Memory used by the cache storage."), aData); } } return NS_OK; }
--- a/netwerk/cookie/nsCookieService.cpp +++ b/netwerk/cookie/nsCookieService.cpp @@ -4825,13 +4825,15 @@ nsCookieService::SizeOfIncludingThis(moz } MOZ_DEFINE_MALLOC_SIZE_OF(CookieServiceMallocSizeOf) NS_IMETHODIMP nsCookieService::CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) { - return MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "explicit/cookie-service", KIND_HEAP, UNITS_BYTES, SizeOfIncludingThis(CookieServiceMallocSizeOf), "Memory used by the cookie service."); + + return NS_OK; }
--- a/netwerk/dns/nsDNSService2.cpp +++ b/netwerk/dns/nsDNSService2.cpp @@ -1052,14 +1052,16 @@ nsDNSService::SizeOfIncludingThis(mozill } MOZ_DEFINE_MALLOC_SIZE_OF(DNSServiceMallocSizeOf) NS_IMETHODIMP nsDNSService::CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) { - return MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "explicit/network/dns-service", KIND_HEAP, UNITS_BYTES, SizeOfIncludingThis(DNSServiceMallocSizeOf), "Memory used for the DNS service."); + + return NS_OK; }
--- a/netwerk/dns/nsEffectiveTLDService.cpp +++ b/netwerk/dns/nsEffectiveTLDService.cpp @@ -122,20 +122,22 @@ MOZ_DEFINE_MALLOC_SIZE_OF(EffectiveTLDSe // The amount of heap memory measured here is tiny. It used to be bigger when // nsEffectiveTLDService used a separate hash table instead of binary search. // Nonetheless, we keep this code here in anticipation of bug 1083971 which will // change ETLDEntries::entries to a heap-allocated array modifiable at runtime. NS_IMETHODIMP nsEffectiveTLDService::CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) { - return MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "explicit/network/effective-TLD-service", KIND_HEAP, UNITS_BYTES, SizeOfIncludingThis(EffectiveTLDServiceMallocSizeOf), "Memory used by the effective TLD service."); + + return NS_OK; } size_t nsEffectiveTLDService::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) { size_t n = aMallocSizeOf(this); // Measurement of the following members may be added later if DMD finds it is
--- a/netwerk/protocol/http/Http2Compression.cpp +++ b/netwerk/protocol/http/Http2Compression.cpp @@ -30,20 +30,22 @@ public: NS_DECL_THREADSAFE_ISUPPORTS HpackStaticTableReporter() {} NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { - return MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "explicit/network/hpack/static-table", KIND_HEAP, UNITS_BYTES, gStaticHeaders->SizeOfIncludingThis(MallocSizeOf), "Memory usage of HPACK static table."); + + return NS_OK; } private: MOZ_DEFINE_MALLOC_SIZE_OF(MallocSizeOf) ~HpackStaticTableReporter() {} }; @@ -57,24 +59,23 @@ public: explicit HpackDynamicTableReporter(Http2BaseCompressor* aCompressor) : mCompressor(aCompressor) {} NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { - if (!mCompressor) { - return NS_OK; + if (mCompressor) { + MOZ_COLLECT_REPORT( + "explicit/network/hpack/dynamic-tables", KIND_HEAP, UNITS_BYTES, + mCompressor->SizeOfExcludingThis(MallocSizeOf), + "Aggregate memory usage of HPACK dynamic tables."); } - - return MOZ_COLLECT_REPORT( - "explicit/network/hpack/dynamic-tables", KIND_HEAP, UNITS_BYTES, - mCompressor->SizeOfExcludingThis(MallocSizeOf), - "Aggregate memory usage of HPACK dynamic tables."); + return NS_OK; } private: MOZ_DEFINE_MALLOC_SIZE_OF(MallocSizeOf) ~HpackDynamicTableReporter() {} Http2BaseCompressor* mCompressor;
--- a/startupcache/StartupCache.cpp +++ b/startupcache/StartupCache.cpp @@ -53,35 +53,26 @@ namespace mozilla { namespace scache { MOZ_DEFINE_MALLOC_SIZE_OF(StartupCacheMallocSizeOf) NS_IMETHODIMP StartupCache::CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) { -#define REPORT(_path, _kind, _amount, _desc) \ - do { \ - nsresult rv = \ - aHandleReport->Callback(EmptyCString(), \ - NS_LITERAL_CSTRING(_path), \ - _kind, UNITS_BYTES, _amount, \ - NS_LITERAL_CSTRING(_desc), aData); \ - NS_ENSURE_SUCCESS(rv, rv); \ - } while (0) + MOZ_COLLECT_REPORT( + "explicit/startup-cache/mapping", KIND_NONHEAP, UNITS_BYTES, + SizeOfMapping(), + "Memory used to hold the mapping of the startup cache from file. " + "This memory is likely to be swapped out shortly after start-up."); - REPORT("explicit/startup-cache/mapping", KIND_NONHEAP, - SizeOfMapping(), - "Memory used to hold the mapping of the startup cache from file. " - "This memory is likely to be swapped out shortly after start-up."); - - REPORT("explicit/startup-cache/data", KIND_HEAP, - HeapSizeOfIncludingThis(StartupCacheMallocSizeOf), - "Memory used by the startup cache for things other than the file " - "mapping."); + MOZ_COLLECT_REPORT( + "explicit/startup-cache/data", KIND_HEAP, UNITS_BYTES, + HeapSizeOfIncludingThis(StartupCacheMallocSizeOf), + "Memory used by the startup cache for things other than the file mapping."); return NS_OK; } #define STARTUP_CACHE_NAME "startupCache." SC_WORDSIZE "." SC_ENDIAN StartupCache* StartupCache::GetSingleton()
--- a/storage/mozStorageService.cpp +++ b/storage/mozStorageService.cpp @@ -85,52 +85,48 @@ StorageSQLiteDistinguishedAmount() * "schema". * @param aDesc * The memory report description. * @param aOption * The SQLite constant for getting the measurement. * @param aTotal * The accumulator for the measurement. */ -nsresult +static void ReportConn(nsIHandleReportCallback *aHandleReport, nsISupports *aData, Connection *aConn, const nsACString &aPathHead, const nsACString &aKind, const nsACString &aDesc, int32_t aOption, size_t *aTotal) { nsCString path(aPathHead); path.Append(aKind); path.AppendLiteral("-used"); int32_t val = aConn->getSqliteRuntimeStatus(aOption); - nsresult rv = aHandleReport->Callback(EmptyCString(), path, - nsIMemoryReporter::KIND_HEAP, - nsIMemoryReporter::UNITS_BYTES, - int64_t(val), aDesc, aData); - NS_ENSURE_SUCCESS(rv, rv); + aHandleReport->Callback(EmptyCString(), path, + nsIMemoryReporter::KIND_HEAP, + nsIMemoryReporter::UNITS_BYTES, + int64_t(val), aDesc, aData); *aTotal += val; - - return NS_OK; } // Warning: To get a Connection's measurements requires holding its lock. // There may be a delay getting the lock if another thread is accessing the // Connection. This isn't very nice if CollectReports is called from the main // thread! But at the time of writing this function is only called when // about:memory is loaded (not, for example, when telemetry pings occur) and // any delays in that case aren't so bad. NS_IMETHODIMP Service::CollectReports(nsIHandleReportCallback *aHandleReport, nsISupports *aData, bool aAnonymize) { - nsresult rv; size_t totalConnSize = 0; { nsTArray<RefPtr<Connection> > connections; getConnections(connections); for (uint32_t i = 0; i < connections.Length(); i++) { RefPtr<Connection> &conn = connections[i]; @@ -146,55 +142,48 @@ Service::CollectReports(nsIHandleReportC pathHead.Append(conn->getFilename()); pathHead.Append('/'); SQLiteMutexAutoLock lockedScope(conn->sharedDBMutex); NS_NAMED_LITERAL_CSTRING(stmtDesc, "Memory (approximate) used by all prepared statements used by " "connections to this database."); - rv = ReportConn(aHandleReport, aData, conn, pathHead, - NS_LITERAL_CSTRING("stmt"), stmtDesc, - SQLITE_DBSTATUS_STMT_USED, &totalConnSize); - NS_ENSURE_SUCCESS(rv, rv); + ReportConn(aHandleReport, aData, conn, pathHead, + NS_LITERAL_CSTRING("stmt"), stmtDesc, + SQLITE_DBSTATUS_STMT_USED, &totalConnSize); NS_NAMED_LITERAL_CSTRING(cacheDesc, "Memory (approximate) used by all pager caches used by connections " "to this database."); - rv = ReportConn(aHandleReport, aData, conn, pathHead, - NS_LITERAL_CSTRING("cache"), cacheDesc, - SQLITE_DBSTATUS_CACHE_USED, &totalConnSize); - NS_ENSURE_SUCCESS(rv, rv); + ReportConn(aHandleReport, aData, conn, pathHead, + NS_LITERAL_CSTRING("cache"), cacheDesc, + SQLITE_DBSTATUS_CACHE_USED, &totalConnSize); NS_NAMED_LITERAL_CSTRING(schemaDesc, "Memory (approximate) used to store the schema for all databases " "associated with connections to this database."); - rv = ReportConn(aHandleReport, aData, conn, pathHead, - NS_LITERAL_CSTRING("schema"), schemaDesc, - SQLITE_DBSTATUS_SCHEMA_USED, &totalConnSize); - NS_ENSURE_SUCCESS(rv, rv); + ReportConn(aHandleReport, aData, conn, pathHead, + NS_LITERAL_CSTRING("schema"), schemaDesc, + SQLITE_DBSTATUS_SCHEMA_USED, &totalConnSize); } #ifdef MOZ_DMD if (::sqlite3_memory_used() != int64_t(gSqliteMemoryUsed)) { NS_WARNING("memory consumption reported by SQLite doesn't match " "our measurements"); } #endif } int64_t other = ::sqlite3_memory_used() - totalConnSize; - rv = aHandleReport->Callback( - EmptyCString(), - NS_LITERAL_CSTRING("explicit/storage/sqlite/other"), - KIND_HEAP, UNITS_BYTES, other, - NS_LITERAL_CSTRING("All unclassified sqlite memory."), - aData); - NS_ENSURE_SUCCESS(rv, rv); + MOZ_COLLECT_REPORT( + "explicit/storage/sqlite/other", KIND_HEAP, UNITS_BYTES, other, + "All unclassified sqlite memory."); return NS_OK; } //////////////////////////////////////////////////////////////////////////////// //// Service NS_IMPL_ISUPPORTS(
--- a/toolkit/components/aboutmemory/content/aboutMemory.js +++ b/toolkit/components/aboutmemory/content/aboutMemory.js @@ -171,17 +171,17 @@ function updateTitleMainAndFooter(aTitle className = className + " " + aClassName; } msgElement = appendElementWithText(gMain, 'div', className, aMsg); } switch (aFooterAction) { case HIDE_FOOTER: gFooter.classList.add('hidden'); break; case SHOW_FOOTER: gFooter.classList.remove('hidden'); break; - default: assertInput(false, "bad footer action in updateTitleMainAndFooter"); + default: assert(false, "bad footer action in updateTitleMainAndFooter"); } return msgElement; } function updateMainAndFooter(aMsg, aFooterAction, aClassName) { return updateTitleMainAndFooter("", aMsg, aFooterAction, aClassName); }
--- a/toolkit/components/places/History.cpp +++ b/toolkit/components/places/History.cpp @@ -2235,21 +2235,23 @@ History::FetchPageInfo(VisitData& _place } MOZ_DEFINE_MALLOC_SIZE_OF(HistoryMallocSizeOf) NS_IMETHODIMP History::CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) { - return MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "explicit/history-links-hashtable", KIND_HEAP, UNITS_BYTES, SizeOfIncludingThis(HistoryMallocSizeOf), "Memory used by the hashtable that records changes to the visited state " "of links."); + + return NS_OK; } size_t History::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOfThis) { return aMallocSizeOfThis(this) + mObservers.SizeOfExcludingThis(aMallocSizeOfThis); }
--- a/toolkit/components/telemetry/Telemetry.cpp +++ b/toolkit/components/telemetry/Telemetry.cpp @@ -751,20 +751,22 @@ private: TelemetryImpl* TelemetryImpl::sTelemetry = nullptr; MOZ_DEFINE_MALLOC_SIZE_OF(TelemetryMallocSizeOf) NS_IMETHODIMP TelemetryImpl::CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) { - return MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "explicit/telemetry", KIND_HEAP, UNITS_BYTES, SizeOfIncludingThis(TelemetryMallocSizeOf), "Memory used by the telemetry system."); + + return NS_OK; } void InitHistogramRecordingEnabled() { TelemetryHistogram::InitHistogramRecordingEnabled(); }
--- a/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.cpp +++ b/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.cpp @@ -272,22 +272,23 @@ NS_IMETHODIMP nsUrlClassifierPrefixSet::CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) { MOZ_ASSERT(NS_IsMainThread()); // No need to get mLock here because this function does not directly touch // the class's data members. (SizeOfIncludingThis() will get mLock, however.) - size_t amount = SizeOfIncludingThis(UrlClassifierMallocSizeOf); - - return aHandleReport->Callback( - EmptyCString(), mMemoryReportPath, KIND_HEAP, UNITS_BYTES, amount, + aHandleReport->Callback( + EmptyCString(), mMemoryReportPath, KIND_HEAP, UNITS_BYTES, + SizeOfIncludingThis(UrlClassifierMallocSizeOf), NS_LITERAL_CSTRING("Memory used by the prefix set for a URL classifier."), aData); + + return NS_OK; } size_t nsUrlClassifierPrefixSet::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) { MutexAutoLock lock(mLock); size_t n = 0;
--- a/xpcom/base/AvailableMemoryTracker.cpp +++ b/xpcom/base/AvailableMemoryTracker.cpp @@ -341,50 +341,45 @@ class LowEventsReporter final : public n ~LowEventsReporter() {} public: NS_DECL_ISUPPORTS NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { - nsresult rv; - // We only do virtual-memory tracking on 32-bit builds. if (sizeof(void*) == 4) { - rv = MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "low-memory-events/virtual", KIND_OTHER, UNITS_COUNT_CUMULATIVE, LowMemoryEventsVirtualDistinguishedAmount(), "Number of low-virtual-memory events fired since startup. We fire such an " "event if we notice there is less than memory.low_virtual_mem_threshold_mb of " "virtual address space available (if zero, this behavior is disabled). The " "process will probably crash if it runs out of virtual address space, so " "this event is dire."); - NS_ENSURE_SUCCESS(rv, rv); } - rv = MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "low-commit-space-events", KIND_OTHER, UNITS_COUNT_CUMULATIVE, sNumLowCommitSpaceEvents, "Number of low-commit-space events fired since startup. We fire such an " "event if we notice there is less than memory.low_commit_space_threshold_mb of " "commit space available (if zero, this behavior is disabled). Windows will " "likely kill the process if it runs out of commit space, so this event is " "dire."); - NS_ENSURE_SUCCESS(rv, rv); - rv = MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "low-memory-events/physical", KIND_OTHER, UNITS_COUNT_CUMULATIVE, LowMemoryEventsPhysicalDistinguishedAmount(), "Number of low-physical-memory events fired since startup. We fire such an " "event if we notice there is less than memory.low_physical_memory_threshold_mb " "of physical memory available (if zero, this behavior is disabled). The " "machine will start to page if it runs out of physical memory. This may " "cause it to run slowly, but it shouldn't cause it to crash."); - NS_ENSURE_SUCCESS(rv, rv); return NS_OK; } }; NS_IMPL_ISUPPORTS(LowEventsReporter, nsIMemoryReporter) #endif // defined(XP_WIN)
--- a/xpcom/base/CountingAllocatorBase.h +++ b/xpcom/base/CountingAllocatorBase.h @@ -20,20 +20,22 @@ namespace mozilla { // // class MyMemoryReporter : public CountingAllocatorBase<MyMemoryReporter> // { // ... // NS_IMETHOD // CollectReports(nsIHandleReportCallback* aHandleReport, // nsISupports* aData, bool aAnonymize) override // { -// return MOZ_COLLECT_REPORT( +// MOZ_COLLECT_REPORT( // "explicit/path/to/somewhere", KIND_HEAP, UNITS_BYTES, // MemoryAllocated(), -// "A description of what we are reporting." +// "A description of what we are reporting."); +// +// return NS_OK; // } // }; // // ...somewhere later in the code... // SetThirdPartyMemoryFunctions(MyMemoryReporter::CountingAlloc, // MyMemoryReporter::CountingFree); template<typename T> class CountingAllocatorBase
--- a/xpcom/base/SystemMemoryReporter.cpp +++ b/xpcom/base/SystemMemoryReporter.cpp @@ -135,83 +135,73 @@ IsAnonymous(const nsACString& aName) class SystemReporter final : public nsIMemoryReporter { ~SystemReporter() {} public: NS_DECL_THREADSAFE_ISUPPORTS -#define REPORT_WITH_CLEANUP(_path, _units, _amount, _desc, _cleanup) \ +#define REPORT(_path, _units, _amount, _desc) \ do { \ - size_t amount = _amount; /* evaluate _amount only once */ \ - if (amount > 0) { \ - nsresult rvReport; \ - rvReport = aHandleReport->Callback(NS_LITERAL_CSTRING("System"), _path, \ - KIND_NONHEAP, _units, amount, _desc, \ - aData); \ - if (NS_WARN_IF(NS_FAILED(rvReport))) { \ - _cleanup; \ - return rvReport; \ - } \ + size_t __amount = _amount; /* evaluate _amount only once */ \ + if (__amount > 0) { \ + aHandleReport->Callback(NS_LITERAL_CSTRING("System"), _path, \ + KIND_OTHER, _units, __amount, _desc, aData); \ } \ } while (0) -#define REPORT(_path, _amount, _desc) \ - REPORT_WITH_CLEANUP(_path, UNITS_BYTES, _amount, _desc, (void)0) - NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { // There is lots of privacy-sensitive data in /proc. Just skip this // reporter entirely when anonymization is required. if (aAnonymize) { return NS_OK; } if (!Preferences::GetBool("memory.system_memory_reporter")) { return NS_OK; } // Read relevant fields from /proc/meminfo. int64_t memTotal = 0, memFree = 0; - nsresult rv = ReadMemInfo(&memTotal, &memFree); + nsresult rv1 = ReadMemInfo(&memTotal, &memFree); // Collect per-process reports from /proc/<pid>/smaps. int64_t totalPss = 0; - rv = CollectProcessReports(aHandleReport, aData, &totalPss); - NS_ENSURE_SUCCESS(rv, rv); + nsresult rv2 = CollectProcessReports(aHandleReport, aData, &totalPss); // Report the non-process numbers. - int64_t other = memTotal - memFree - totalPss; - REPORT(NS_LITERAL_CSTRING("mem/other"), other, NS_LITERAL_CSTRING( + if (NS_SUCCEEDED(rv1) && NS_SUCCEEDED(rv2)) { + int64_t other = memTotal - memFree - totalPss; + REPORT(NS_LITERAL_CSTRING("mem/other"), UNITS_BYTES, other, + NS_LITERAL_CSTRING( "Memory which is neither owned by any user-space process nor free. Note that " "this includes memory holding cached files from the disk which can be " "reclaimed by the OS at any time.")); - REPORT(NS_LITERAL_CSTRING("mem/free"), memFree, NS_LITERAL_CSTRING( + REPORT(NS_LITERAL_CSTRING("mem/free"), UNITS_BYTES, memFree, + NS_LITERAL_CSTRING( "Memory which is free and not being used for any purpose.")); + } // Report reserved memory not included in memTotal. - rv = CollectPmemReports(aHandleReport, aData); - NS_ENSURE_SUCCESS(rv, rv); + CollectPmemReports(aHandleReport, aData); // Report zram usage statistics. - rv = CollectZramReports(aHandleReport, aData); - NS_ENSURE_SUCCESS(rv, rv); + CollectZramReports(aHandleReport, aData); // Report kgsl graphics memory usage. - rv = CollectKgslReports(aHandleReport, aData); - NS_ENSURE_SUCCESS(rv, rv); + CollectKgslReports(aHandleReport, aData); // Report ION memory usage. - rv = CollectIonReports(aHandleReport, aData); - NS_ENSURE_SUCCESS(rv, rv); + CollectIonReports(aHandleReport, aData); - return rv; + return NS_OK; } private: // These are the cross-cutting measurements across all processes. class ProcessSizes { public: void Add(const nsACString& aKey, size_t aSize) @@ -227,19 +217,17 @@ private: nsAutoCString path("processes/"); path.Append(key); nsAutoCString desc("This is the sum of all processes' '"); desc.Append(key); desc.AppendLiteral("' numbers."); - aHandleReport->Callback(NS_LITERAL_CSTRING("System"), path, - KIND_NONHEAP, UNITS_BYTES, amount, - desc, aData); + REPORT(path, UNITS_BYTES, amount, desc); } } private: nsDataHashtable<nsCStringHashKey, size_t> mTagged; }; nsresult ReadMemInfo(int64_t* aMemTotal, int64_t* aMemFree) @@ -310,46 +298,39 @@ private: // Read the PSS values from the smaps file. nsPrintfCString smapsPath("/proc/%s/smaps", pidStr); f = fopen(smapsPath.get(), "r"); if (!f) { // Processes can terminate between the readdir() call above and now, // so just skip if we can't open the file. continue; } - nsresult rv = ParseMappings(f, processName, aHandleReport, aData, - &processSizes, aTotalPss); + ParseMappings(f, processName, aHandleReport, aData, &processSizes, + aTotalPss); fclose(f); - if (NS_FAILED(rv)) { - continue; - } // Report the open file descriptors for this process. nsPrintfCString procFdPath("/proc/%s/fd", pidStr); - rv = CollectOpenFileReports(aHandleReport, aData, procFdPath, - processName); - if (NS_FAILED(rv)) { - break; - } + CollectOpenFileReports(aHandleReport, aData, procFdPath, processName); } } closedir(d); // Report the "processes/" tree. processSizes.Report(aHandleReport, aData); return NS_OK; } - nsresult ParseMappings(FILE* aFile, - const nsACString& aProcessName, - nsIHandleReportCallback* aHandleReport, - nsISupports* aData, - ProcessSizes* aProcessSizes, - int64_t* aTotalPss) + void ParseMappings(FILE* aFile, + const nsACString& aProcessName, + nsIHandleReportCallback* aHandleReport, + nsISupports* aData, + ProcessSizes* aProcessSizes, + int64_t* aTotalPss) { // The first line of an entry in /proc/<pid>/smaps looks just like an entry // in /proc/<pid>/maps: // // address perms offset dev inode pathname // 02366000-025d8000 rw-p 00000000 00:00 0 [heap] // // Each of the following lines contains a key and a value, separated @@ -407,27 +388,26 @@ private: nsAutoCString name, description, tag; GetReporterNameAndDescription(currentPath.get(), perms, name, description, tag); nsAutoCString processMemPath("mem/processes/"); processMemPath.Append(aProcessName); processMemPath.Append('/'); processMemPath.Append(name); - REPORT(processMemPath, pss, description); + REPORT(processMemPath, UNITS_BYTES, pss, description); // Increment the appropriate aProcessSizes values, and the total. aProcessSizes->Add(tag, pss); *aTotalPss += pss; } // Now that we've seen the PSS, we're done with this entry. currentPath.SetIsVoid(true); } - return NS_OK; } void GetReporterNameAndDescription(const char* aPath, const char* aPerms, nsACString& aName, nsACString& aDesc, nsACString& aTag) { @@ -560,37 +540,33 @@ private: // Append the permissions. This is useful for non-verbose mode in // about:memory when the filename is long and goes of the right side of the // window. aDesc.AppendLiteral(" ["); aDesc.Append(aPerms); aDesc.Append(']'); } - nsresult CollectPmemReports(nsIHandleReportCallback* aHandleReport, - nsISupports* aData) + void CollectPmemReports(nsIHandleReportCallback* aHandleReport, + nsISupports* aData) { // The pmem subsystem allocates physically contiguous memory for // interfacing with hardware. In order to ensure availability, // this memory is reserved during boot, and allocations are made // within these regions at runtime. // // There are typically several of these pools allocated at boot. // The /sys/kernel/pmem_regions directory contains a subdirectory // for each one. Within each subdirectory, the files we care // about are "size" (the total amount of physical memory) and // "mapped_regions" (a list of the current allocations within that // area). DIR* d = opendir("/sys/kernel/pmem_regions"); if (!d) { - if (NS_WARN_IF(errno != ENOENT)) { - return NS_ERROR_FAILURE; - } - // If ENOENT, system doesn't use pmem. - return NS_OK; + return; } struct dirent* ent; while ((ent = readdir(d))) { const char* name = ent->d_name; uint64_t size; int scanned; @@ -643,35 +619,33 @@ private: if (NS_WARN_IF(scanned != 2)) { break; } nsPrintfCString path("mem/pmem/used/%s/segment(pid=%d, " "offset=0x%" PRIx64 ")", name, pid, mapStart); nsPrintfCString desc("Physical memory reserved for the \"%s\" pool " "and allocated to a buffer.", name); - REPORT_WITH_CLEANUP(path, UNITS_BYTES, mapLen, desc, - (fclose(regionsFile), closedir(d))); + REPORT(path, UNITS_BYTES, mapLen, desc); freeSize -= mapLen; } } fclose(regionsFile); } nsPrintfCString path("mem/pmem/free/%s", name); nsPrintfCString desc("Physical memory reserved for the \"%s\" pool and " "unavailable to the rest of the system, but not " "currently allocated.", name); - REPORT_WITH_CLEANUP(path, UNITS_BYTES, freeSize, desc, closedir(d)); + REPORT(path, UNITS_BYTES, freeSize, desc); } closedir(d); - return NS_OK; } - nsresult + void CollectIonReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData) { // ION is a replacement for PMEM (and other similar allocators). // // More details from http://lwn.net/Articles/480055/ // "Like its PMEM-like predecessors, ION manages one or more memory pools, // some of which are set aside at boot time to combat fragmentation or to @@ -707,21 +681,17 @@ private: // 3) size - The size of the allocation in bytes, read as as a uint64_t. const char* const kFormatString = "%63s %" SCNu32 " %" SCNu64; const int kNumFields = 3; const size_t kStringSize = 64; const char* const kIonIommuPath = "/sys/kernel/debug/ion/iommu"; FILE* iommu = fopen(kIonIommuPath, "r"); if (!iommu) { - if (NS_WARN_IF(errno != ENOENT)) { - return NS_ERROR_FAILURE; - } - // If ENOENT, system doesn't use ION. - return NS_OK; + return; } AutoFile iommuGuard(iommu); const size_t kBufferLen = 256; char buffer[kBufferLen]; char client[kStringSize]; uint32_t pid; @@ -736,39 +706,35 @@ private: const char* const kSep = "----"; const size_t kSepLen = 4; // Read non-orphaned entries. while (fgets(buffer, kBufferLen, iommu) && strncmp(kSep, buffer, kSepLen) != 0) { if (sscanf(buffer, kFormatString, client, &pid, &size) == kNumFields) { nsPrintfCString entryPath("ion-memory/%s (pid=%d)", client, pid); - REPORT(entryPath, - size, + REPORT(entryPath, UNITS_BYTES, size, NS_LITERAL_CSTRING("An ION kernel memory allocation.")); } } // Ignore the orphaned header. Unused << fgets(buffer, kBufferLen, iommu); // Read orphaned entries. while (fgets(buffer, kBufferLen, iommu) && strncmp(kSep, buffer, kSepLen) != 0) { if (sscanf(buffer, kFormatString, client, &pid, &size) == kNumFields) { nsPrintfCString entryPath("ion-memory/%s (pid=%d)", client, pid); - REPORT(entryPath, - size, + REPORT(entryPath, UNITS_BYTES, size, NS_LITERAL_CSTRING("An ION kernel memory allocation.")); } } // Ignore the rest of the file. - - return NS_OK; } uint64_t ReadSizeFromFile(const char* aFilename) { FILE* sizeFile = fopen(aFilename, "r"); if (NS_WARN_IF(!sizeFile)) { return 0; @@ -776,38 +742,34 @@ private: uint64_t size = 0; Unused << fscanf(sizeFile, "%" SCNu64, &size); fclose(sizeFile); return size; } - nsresult + void CollectZramReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData) { // zram usage stats files can be found under: // /sys/block/zram<id> // |--> disksize - Maximum amount of uncompressed data that can be // stored on the disk (bytes) // |--> orig_data_size - Uncompressed size of data in the disk (bytes) // |--> compr_data_size - Compressed size of the data in the disk (bytes) // |--> num_reads - Number of attempted reads to the disk (count) // |--> num_writes - Number of attempted writes to the disk (count) // // Each file contains a single integer value in decimal form. DIR* d = opendir("/sys/block"); if (!d) { - if (NS_WARN_IF(errno != ENOENT)) { - return NS_ERROR_FAILURE; - } - - return NS_OK; + return; } struct dirent* ent; while ((ent = readdir(d))) { const char* name = ent->d_name; // Skip non-zram entries. if (strncmp("zram", name, 4) != 0) { @@ -822,64 +784,58 @@ private: uint64_t origSize = ReadSizeFromFile(origSizeFile.get()); uint64_t unusedSize = diskSize - origSize; nsPrintfCString diskUsedPath("zram-disksize/%s/used", name); nsPrintfCString diskUsedDesc( "The uncompressed size of data stored in \"%s.\" " "This excludes zero-filled pages since " "no memory is allocated for them.", name); - REPORT_WITH_CLEANUP(diskUsedPath, UNITS_BYTES, origSize, - diskUsedDesc, closedir(d)); + REPORT(diskUsedPath, UNITS_BYTES, origSize, diskUsedDesc); nsPrintfCString diskUnusedPath("zram-disksize/%s/unused", name); nsPrintfCString diskUnusedDesc( "The amount of uncompressed data that can still be " "be stored in \"%s\"", name); - REPORT_WITH_CLEANUP(diskUnusedPath, UNITS_BYTES, unusedSize, - diskUnusedDesc, closedir(d)); + REPORT(diskUnusedPath, UNITS_BYTES, unusedSize, diskUnusedDesc); // Report disk accesses. nsPrintfCString readsFile("/sys/block/%s/num_reads", name); nsPrintfCString writesFile("/sys/block/%s/num_writes", name); uint64_t reads = ReadSizeFromFile(readsFile.get()); uint64_t writes = ReadSizeFromFile(writesFile.get()); nsPrintfCString readsDesc( "The number of reads (failed or successful) done on " "\"%s\"", name); nsPrintfCString readsPath("zram-accesses/%s/reads", name); - REPORT_WITH_CLEANUP(readsPath, UNITS_COUNT_CUMULATIVE, reads, - readsDesc, closedir(d)); + REPORT(readsPath, UNITS_COUNT_CUMULATIVE, reads, readsDesc); nsPrintfCString writesDesc( "The number of writes (failed or successful) done " "on \"%s\"", name); nsPrintfCString writesPath("zram-accesses/%s/writes", name); - REPORT_WITH_CLEANUP(writesPath, UNITS_COUNT_CUMULATIVE, writes, - writesDesc, closedir(d)); + REPORT(writesPath, UNITS_COUNT_CUMULATIVE, writes, writesDesc); // Report compressed data size. nsPrintfCString comprSizeFile("/sys/block/%s/compr_data_size", name); uint64_t comprSize = ReadSizeFromFile(comprSizeFile.get()); nsPrintfCString comprSizeDesc( "The compressed size of data stored in \"%s\"", name); nsPrintfCString comprSizePath("zram-compr-data-size/%s", name); - REPORT_WITH_CLEANUP(comprSizePath, UNITS_BYTES, comprSize, - comprSizeDesc, closedir(d)); + REPORT(comprSizePath, UNITS_BYTES, comprSize, comprSizeDesc); } closedir(d); - return NS_OK; } - nsresult + void CollectOpenFileReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, const nsACString& aProcPath, const nsACString& aProcessName) { // All file descriptors opened by a process are listed under // /proc/<pid>/fd/<numerical_fd>. Each entry is a symlink that points to the // path that was opened. This can be an actual file, a socket, a pipe, an @@ -887,20 +843,17 @@ private: const char kFilePrefix[] = "/"; const char kSocketPrefix[] = "socket:"; const char kPipePrefix[] = "pipe:"; const char kAnonInodePrefix[] = "anon_inode:"; const nsCString procPath(aProcPath); DIR* d = opendir(procPath.get()); if (!d) { - if (NS_WARN_IF(errno != ENOENT && errno != EACCES)) { - return NS_ERROR_FAILURE; - } - return NS_OK; + return; } char linkPath[PATH_MAX + 1]; struct dirent* ent; while ((ent = readdir(d))) { const char* fd = ent->d_name; // Skip "." and ".." (and any other dotfiles). @@ -938,26 +891,24 @@ private: #undef CHECK_PREFIX const nsCString processName(aProcessName); nsPrintfCString entryPath("open-fds/%s/%s%s/%s", processName.get(), category, linkPath, fd); nsPrintfCString entryDescription("%s file descriptor opened by the process", descriptionPrefix); - REPORT_WITH_CLEANUP(entryPath, UNITS_COUNT, 1, entryDescription, - closedir(d)); + REPORT(entryPath, UNITS_COUNT, 1, entryDescription); } } closedir(d); - return NS_OK; } - nsresult + void CollectKgslReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData) { // Each process that uses kgsl memory will have an entry under // /sys/kernel/debug/kgsl/proc/<pid>/mem. This file format includes a // header and then entries with types as follows: // gpuaddr useraddr size id flags type usage sglen // hexaddr hexaddr int int str str str int @@ -967,20 +918,17 @@ private: const char* const kScanFormat = "%" SCNx64 " %" SCNx64 " %" SCNu64 " %" SCNu64 " %63s %63s %63s %" SCNu64; const int kNumFields = 8; const size_t kStringSize = 64; DIR* d = opendir("/sys/kernel/debug/kgsl/proc/"); if (!d) { - if (NS_WARN_IF(errno != ENOENT && errno != EACCES)) { - return NS_ERROR_FAILURE; - } - return NS_OK; + return; } AutoDir dirGuard(d); struct dirent* ent; while ((ent = readdir(d))) { const char* pid = ent->d_name; @@ -1017,26 +965,21 @@ private: // Bypass the header line. char buff[1024]; Unused << fgets(buff, 1024, memFile); while (fscanf(memFile, kScanFormat, &gpuaddr, &useraddr, &size, &id, flags, type, usage, &sglen) == kNumFields) { nsPrintfCString entryPath("kgsl-memory/%s/%s", procName.get(), usage); - REPORT(entryPath, - size, + REPORT(entryPath, UNITS_BYTES, size, NS_LITERAL_CSTRING("A kgsl graphics memory allocation.")); } } - - return NS_OK; } - -#undef REPORT }; NS_IMPL_ISUPPORTS(SystemReporter, nsIMemoryReporter) void Init() { RegisterStrongMemoryReporter(new SystemReporter());
--- a/xpcom/base/nsCycleCollector.cpp +++ b/xpcom/base/nsCycleCollector.cpp @@ -3372,42 +3372,37 @@ NS_IMETHODIMP nsCycleCollector::CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) { size_t objectSize, graphSize, purpleBufferSize; SizeOfIncludingThis(CycleCollectorMallocSizeOf, &objectSize, &graphSize, &purpleBufferSize); -#define REPORT(_path, _amount, _desc) \ - do { \ - size_t amount = _amount; /* evaluate |_amount| only once */ \ - if (amount > 0) { \ - nsresult rv; \ - rv = aHandleReport->Callback(EmptyCString(), \ - NS_LITERAL_CSTRING(_path), \ - KIND_HEAP, UNITS_BYTES, _amount, \ - NS_LITERAL_CSTRING(_desc), \ - aData); \ - if (NS_WARN_IF(NS_FAILED(rv))) \ - return rv; \ - } \ - } while (0) - - REPORT("explicit/cycle-collector/collector-object", objectSize, - "Memory used for the cycle collector object itself."); - - REPORT("explicit/cycle-collector/graph", graphSize, - "Memory used for the cycle collector's graph. " - "This should be zero when the collector is idle."); - - REPORT("explicit/cycle-collector/purple-buffer", purpleBufferSize, - "Memory used for the cycle collector's purple buffer."); - -#undef REPORT + if (objectSize > 0) { + MOZ_COLLECT_REPORT( + "explicit/cycle-collector/collector-object", KIND_HEAP, UNITS_BYTES, + objectSize, + "Memory used for the cycle collector object itself."); + } + + if (graphSize > 0) { + MOZ_COLLECT_REPORT( + "explicit/cycle-collector/graph", KIND_HEAP, UNITS_BYTES, + graphSize, + "Memory used for the cycle collector's graph. This should be zero when " + "the collector is idle."); + } + + if (purpleBufferSize > 0) { + MOZ_COLLECT_REPORT( + "explicit/cycle-collector/purple-buffer", KIND_HEAP, UNITS_BYTES, + purpleBufferSize, + "Memory used for the cycle collector's purple buffer."); + } return NS_OK; }; //////////////////////////////////////////////////////////////////////// // Collector implementation ////////////////////////////////////////////////////////////////////////
--- a/xpcom/base/nsIMemoryReporter.idl +++ b/xpcom/base/nsIMemoryReporter.idl @@ -206,17 +206,17 @@ interface nsIFinishReportingCallback : n }; [scriptable, builtinclass, uuid(2998574d-8993-407a-b1a5-8ad7417653e1)] interface nsIMemoryReporterManager : nsISupports { /* * Initialize. */ - void init(); + [must_use] void init(); /* * Register the given nsIMemoryReporter. The Manager service will hold a * strong reference to the given reporter, and will be responsible for freeing * the reporter at shutdown. You may manually unregister the reporter with * unregisterStrongReporter() at any point. */ void registerStrongReporter(in nsIMemoryReporter reporter); @@ -368,41 +368,41 @@ interface nsIMemoryReporterManager : nsI * of low-{virtual,physical}-memory events that have occurred since the * process started. * * |ghostWindows| (UNITS_COUNT) The number of ghost windows. * * |pageFaultsHard| (UNITS_COUNT_CUMULATIVE) The number of hard (a.k.a. * major) page faults that have occurred since the process started. */ - readonly attribute int64_t vsize; - readonly attribute int64_t vsizeMaxContiguous; - readonly attribute int64_t resident; - readonly attribute int64_t residentFast; - readonly attribute int64_t residentPeak; - readonly attribute int64_t residentUnique; + [must_use] readonly attribute int64_t vsize; + [must_use] readonly attribute int64_t vsizeMaxContiguous; + [must_use] readonly attribute int64_t resident; + [must_use] readonly attribute int64_t residentFast; + [must_use] readonly attribute int64_t residentPeak; + [must_use] readonly attribute int64_t residentUnique; - readonly attribute int64_t heapAllocated; - readonly attribute int64_t heapOverheadFraction; + [must_use] readonly attribute int64_t heapAllocated; + [must_use] readonly attribute int64_t heapOverheadFraction; - readonly attribute int64_t JSMainRuntimeGCHeap; - readonly attribute int64_t JSMainRuntimeTemporaryPeak; - readonly attribute int64_t JSMainRuntimeCompartmentsSystem; - readonly attribute int64_t JSMainRuntimeCompartmentsUser; + [must_use] readonly attribute int64_t JSMainRuntimeGCHeap; + [must_use] readonly attribute int64_t JSMainRuntimeTemporaryPeak; + [must_use] readonly attribute int64_t JSMainRuntimeCompartmentsSystem; + [must_use] readonly attribute int64_t JSMainRuntimeCompartmentsUser; - readonly attribute int64_t imagesContentUsedUncompressed; + [must_use] readonly attribute int64_t imagesContentUsedUncompressed; - readonly attribute int64_t storageSQLite; + [must_use] readonly attribute int64_t storageSQLite; - readonly attribute int64_t lowMemoryEventsVirtual; - readonly attribute int64_t lowMemoryEventsPhysical; + [must_use] readonly attribute int64_t lowMemoryEventsVirtual; + [must_use] readonly attribute int64_t lowMemoryEventsPhysical; - readonly attribute int64_t ghostWindows; + [must_use] readonly attribute int64_t ghostWindows; - readonly attribute int64_t pageFaultsHard; + [must_use] readonly attribute int64_t pageFaultsHard; /* * This attribute indicates if moz_malloc_usable_size() works. */ [infallible] readonly attribute boolean hasMozMallocUsableSize; /* * These attributes indicate DMD's status. "Enabled" means enabled at @@ -411,28 +411,29 @@ interface nsIMemoryReporterManager : nsI [infallible] readonly attribute boolean isDMDEnabled; [infallible] readonly attribute boolean isDMDRunning; /* * Run a series of GC/CC's in an attempt to minimize the application's memory * usage. When we're finished, we invoke the given runnable if it's not * null. */ - void minimizeMemoryUsage(in nsIRunnable callback); + [must_use] void minimizeMemoryUsage(in nsIRunnable callback); /* * Measure the memory that is known to be owned by this tab, split up into * several broad categories. Note that this will be an underestimate of the * true number, due to imperfect memory reporter coverage (corresponding to * about:memory's "heap-unclassified"), and due to some memory shared between * tabs not being counted. * * The time taken for the measurement (split into JS and non-JS parts) is * also returned. */ + [must_use] void sizeOfTab(in mozIDOMWindowProxy window, out int64_t jsObjectsSize, out int64_t jsStringsSize, out int64_t jsOtherSize, out int64_t domSize, out int64_t styleSize, out int64_t otherSize, out int64_t totalSize, out double jsMilliseconds, out double nonJSMilliseconds); }; @@ -497,25 +498,25 @@ DECL_REGISTER_DISTINGUISHED_AMOUNT(Infal DECL_REGISTER_DISTINGUISHED_AMOUNT(Infallible, GhostWindows) #undef DECL_REGISTER_DISTINGUISHED_AMOUNT #undef DECL_UNREGISTER_DISTINGUISHED_AMOUNT // Likewise for per-tab measurement. -typedef nsresult (*JSSizeOfTabFn)(JSObject* aObj, - size_t* aJsObjectsSize, - size_t* aJsStringSize, - size_t* aJsPrivateSize, - size_t* aJsOtherSize); -typedef nsresult (*NonJSSizeOfTabFn)(nsPIDOMWindowOuter* aWindow, - size_t* aDomSize, - size_t* aStyleSize, - size_t* aOtherSize); +typedef MOZ_MUST_USE nsresult (*JSSizeOfTabFn)(JSObject* aObj, + size_t* aJsObjectsSize, + size_t* aJsStringSize, + size_t* aJsPrivateSize, + size_t* aJsOtherSize); +typedef MOZ_MUST_USE nsresult (*NonJSSizeOfTabFn)(nsPIDOMWindowOuter* aWindow, + size_t* aDomSize, + size_t* aStyleSize, + size_t* aOtherSize); nsresult RegisterJSSizeOfTab(JSSizeOfTabFn aSizeOfTabFn); nsresult RegisterNonJSSizeOfTab(NonJSSizeOfTabFn aSizeOfTabFn); } #if defined(MOZ_DMD) #if !defined(MOZ_MEMORY) @@ -564,15 +565,16 @@ nsresult RegisterNonJSSizeOfTab(NonJSSiz } #define MOZ_DEFINE_MALLOC_SIZE_OF_ON_FREE(fn) \ static size_t fn(const void* aPtr) \ { \ return moz_malloc_size_of(aPtr); \ } // This macro assumes the presence of appropriate |aHandleReport| and |aData| -// variables. +// variables. The (void) is there because we should always ignore the return +// value of the callback, because callback failures aren't fatal. #define MOZ_COLLECT_REPORT(path, kind, units, amount, description) \ - aHandleReport->Callback(EmptyCString(), NS_LITERAL_CSTRING(path), \ - kind, units, amount, \ - NS_LITERAL_CSTRING(description), aData) + (void)aHandleReport->Callback(EmptyCString(), NS_LITERAL_CSTRING(path), \ + kind, units, amount, \ + NS_LITERAL_CSTRING(description), aData) %}
--- a/xpcom/base/nsMemoryReporterManager.cpp +++ b/xpcom/base/nsMemoryReporterManager.cpp @@ -959,23 +959,19 @@ public: if (entry->mKind.mIsStack) { path.AppendLiteral("+stack"); } } // Append the segment count. path.AppendPrintf("(segments=%u)", entry->mCount); - nsresult rv; - rv = aHandleReport->Callback( + aHandleReport->Callback( EmptyCString(), path, KIND_OTHER, UNITS_BYTES, entry->mSize, NS_LITERAL_CSTRING("From MEMORY_BASIC_INFORMATION."), aData); - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } } return NS_OK; } }; NS_IMPL_ISUPPORTS(WindowsAddressSpaceReporter, nsIMemoryReporter) #endif // XP_<PLATFORM> @@ -987,22 +983,22 @@ class VsizeMaxContiguousReporter final : public: NS_DECL_ISUPPORTS NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { int64_t amount; - nsresult rv = VsizeMaxContiguousDistinguishedAmount(&amount); - NS_ENSURE_SUCCESS(rv, rv); - return MOZ_COLLECT_REPORT( - "vsize-max-contiguous", KIND_OTHER, UNITS_BYTES, amount, - "Size of the maximum contiguous block of available virtual " - "memory."); + if (NS_SUCCEEDED(VsizeMaxContiguousDistinguishedAmount(&amount))) { + MOZ_COLLECT_REPORT( + "vsize-max-contiguous", KIND_OTHER, UNITS_BYTES, amount, + "Size of the maximum contiguous block of available virtual memory."); + } + return NS_OK; } }; NS_IMPL_ISUPPORTS(VsizeMaxContiguousReporter, nsIMemoryReporter) #endif #ifdef HAVE_PRIVATE_REPORTER class PrivateReporter final : public nsIMemoryReporter { @@ -1010,23 +1006,24 @@ class PrivateReporter final : public nsI public: NS_DECL_ISUPPORTS NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { int64_t amount; - nsresult rv = PrivateDistinguishedAmount(&amount); - NS_ENSURE_SUCCESS(rv, rv); - return MOZ_COLLECT_REPORT( - "private", KIND_OTHER, UNITS_BYTES, amount, + if (NS_SUCCEEDED(PrivateDistinguishedAmount(&amount))) { + MOZ_COLLECT_REPORT( + "private", KIND_OTHER, UNITS_BYTES, amount, "Memory that cannot be shared with other processes, including memory that is " "committed and marked MEM_PRIVATE, data that is not mapped, and executable " "pages that have been written to."); + } + return NS_OK; } }; NS_IMPL_ISUPPORTS(PrivateReporter, nsIMemoryReporter) #endif #ifdef HAVE_VSIZE_AND_RESIDENT_REPORTERS class VsizeReporter final : public nsIMemoryReporter { @@ -1034,55 +1031,55 @@ class VsizeReporter final : public nsIMe public: NS_DECL_ISUPPORTS NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { int64_t amount; - nsresult rv = VsizeDistinguishedAmount(&amount); - NS_ENSURE_SUCCESS(rv, rv); - - return MOZ_COLLECT_REPORT( - "vsize", KIND_OTHER, UNITS_BYTES, amount, + if (NS_SUCCEEDED(VsizeDistinguishedAmount(&amount))) { + MOZ_COLLECT_REPORT( + "vsize", KIND_OTHER, UNITS_BYTES, amount, "Memory mapped by the process, including code and data segments, the heap, " "thread stacks, memory explicitly mapped by the process via mmap and similar " "operations, and memory shared with other processes. This is the vsize figure " "as reported by 'top' and 'ps'. This figure is of limited use on Mac, where " "processes share huge amounts of memory with one another. But even on other " "operating systems, 'resident' is a much better measure of the memory " "resources used by the process."); + } + return NS_OK; } }; NS_IMPL_ISUPPORTS(VsizeReporter, nsIMemoryReporter) class ResidentReporter final : public nsIMemoryReporter { ~ResidentReporter() {} public: NS_DECL_ISUPPORTS NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { int64_t amount; - nsresult rv = ResidentDistinguishedAmount(&amount); - NS_ENSURE_SUCCESS(rv, rv); - - return MOZ_COLLECT_REPORT( - "resident", KIND_OTHER, UNITS_BYTES, amount, + if (NS_SUCCEEDED(ResidentDistinguishedAmount(&amount))) { + MOZ_COLLECT_REPORT( + "resident", KIND_OTHER, UNITS_BYTES, amount, "Memory mapped by the process that is present in physical memory, also known " "as the resident set size (RSS). This is the best single figure to use when " "considering the memory resources used by the process, but it depends both on " "other processes being run and details of the OS kernel and so is best used " "for comparing the memory usage of a single process at different points in " "time."); } + return NS_OK; + } }; NS_IMPL_ISUPPORTS(ResidentReporter, nsIMemoryReporter) #endif // HAVE_VSIZE_AND_RESIDENT_REPORTERS #ifdef HAVE_RESIDENT_UNIQUE_REPORTER class ResidentUniqueReporter final : public nsIMemoryReporter { @@ -1090,25 +1087,25 @@ class ResidentUniqueReporter final : pub public: NS_DECL_ISUPPORTS NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { int64_t amount = 0; - nsresult rv = ResidentUniqueDistinguishedAmount(&amount); - NS_ENSURE_SUCCESS(rv, rv); - - return MOZ_COLLECT_REPORT( - "resident-unique", KIND_OTHER, UNITS_BYTES, amount, + if (NS_SUCCEEDED(ResidentUniqueDistinguishedAmount(&amount))) { + MOZ_COLLECT_REPORT( + "resident-unique", KIND_OTHER, UNITS_BYTES, amount, "Memory mapped by the process that is present in physical memory and not " "shared with any other processes. This is also known as the process's unique " "set size (USS). This is the amount of RAM we'd expect to be freed if we " "closed this process."); + } + return NS_OK; } }; NS_IMPL_ISUPPORTS(ResidentUniqueReporter, nsIMemoryReporter) #endif // HAVE_RESIDENT_UNIQUE_REPORTER #ifdef HAVE_SYSTEM_HEAP_REPORTER @@ -1118,25 +1115,25 @@ class SystemHeapReporter final : public public: NS_DECL_ISUPPORTS NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { int64_t amount; - nsresult rv = SystemHeapSize(&amount); - NS_ENSURE_SUCCESS(rv, rv); - - return MOZ_COLLECT_REPORT( - "system-heap-allocated", KIND_OTHER, UNITS_BYTES, amount, + if (NS_SUCCEEDED(SystemHeapSize(&amount))) { + MOZ_COLLECT_REPORT( + "system-heap-allocated", KIND_OTHER, UNITS_BYTES, amount, "Memory used by the system allocator that is currently allocated to the " "application. This is distinct from the jemalloc heap that Firefox uses for " "most or all of its heap allocations. Ideally this number is zero, but " "on some platforms we cannot force every heap allocation through jemalloc."); + } + return NS_OK; } }; NS_IMPL_ISUPPORTS(SystemHeapReporter, nsIMemoryReporter) #endif // HAVE_SYSTEM_HEAP_REPORTER #ifdef XP_UNIX @@ -1174,22 +1171,22 @@ class ResidentPeakReporter final : publi public: NS_DECL_ISUPPORTS NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { int64_t amount = 0; - nsresult rv = ResidentPeakDistinguishedAmount(&amount); - NS_ENSURE_SUCCESS(rv, rv); - - return MOZ_COLLECT_REPORT( - "resident-peak", KIND_OTHER, UNITS_BYTES, amount, + if (NS_SUCCEEDED(ResidentPeakDistinguishedAmount(&amount))) { + MOZ_COLLECT_REPORT( + "resident-peak", KIND_OTHER, UNITS_BYTES, amount, "The peak 'resident' value for the lifetime of the process."); + } + return NS_OK; } }; NS_IMPL_ISUPPORTS(ResidentPeakReporter, nsIMemoryReporter) #define HAVE_PAGE_FAULT_REPORTERS 1 class PageFaultsSoftReporter final : public nsIMemoryReporter { @@ -1198,32 +1195,31 @@ class PageFaultsSoftReporter final : pub public: NS_DECL_ISUPPORTS NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { struct rusage usage; int err = getrusage(RUSAGE_SELF, &usage); - if (err != 0) { - return NS_ERROR_FAILURE; - } - int64_t amount = usage.ru_minflt; - - return MOZ_COLLECT_REPORT( - "page-faults-soft", KIND_OTHER, UNITS_COUNT_CUMULATIVE, amount, + if (err == 0) { + int64_t amount = usage.ru_minflt; + MOZ_COLLECT_REPORT( + "page-faults-soft", KIND_OTHER, UNITS_COUNT_CUMULATIVE, amount, "The number of soft page faults (also known as 'minor page faults') that " "have occurred since the process started. A soft page fault occurs when the " "process tries to access a page which is present in physical memory but is " "not mapped into the process's address space. For instance, a process might " "observe soft page faults when it loads a shared library which is already " "present in physical memory. A process may experience many thousands of soft " "page faults even when the machine has plenty of available physical memory, " "and because the OS services a soft page fault without accessing the disk, " "they impact performance much less than hard page faults."); + } + return NS_OK; } }; NS_IMPL_ISUPPORTS(PageFaultsSoftReporter, nsIMemoryReporter) static MOZ_MUST_USE nsresult PageFaultsHardDistinguishedAmount(int64_t* aAmount) { struct rusage usage; @@ -1241,31 +1237,31 @@ class PageFaultsHardReporter final : pub public: NS_DECL_ISUPPORTS NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { int64_t amount = 0; - nsresult rv = PageFaultsHardDistinguishedAmount(&amount); - NS_ENSURE_SUCCESS(rv, rv); - - return MOZ_COLLECT_REPORT( - "page-faults-hard", KIND_OTHER, UNITS_COUNT_CUMULATIVE, amount, + if (NS_SUCCEEDED(PageFaultsHardDistinguishedAmount(&amount))) { + MOZ_COLLECT_REPORT( + "page-faults-hard", KIND_OTHER, UNITS_COUNT_CUMULATIVE, amount, "The number of hard page faults (also known as 'major page faults') that have " "occurred since the process started. A hard page fault occurs when a process " "tries to access a page which is not present in physical memory. The " "operating system must access the disk in order to fulfill a hard page fault. " "When memory is plentiful, you should see very few hard page faults. But if " "the process tries to use more memory than your machine has available, you " "may see many thousands of hard page faults. Because accessing the disk is up " "to a million times slower than accessing RAM, the program may run very " "slowly when it is experiencing more than 100 or so hard page faults a " "second."); + } + return NS_OK; } }; NS_IMPL_ISUPPORTS(PageFaultsHardReporter, nsIMemoryReporter) #endif // XP_UNIX /** ** memory reporter implementation for jemalloc and OSX malloc, @@ -1300,82 +1296,71 @@ public: NS_DECL_ISUPPORTS NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { jemalloc_stats_t stats; jemalloc_stats(&stats); - nsresult rv; - - rv = MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "heap-committed/allocated", KIND_OTHER, UNITS_BYTES, stats.allocated, "Memory mapped by the heap allocator that is currently allocated to the " "application. This may exceed the amount of memory requested by the " "application because the allocator regularly rounds up request sizes. (The " "exact amount requested is not recorded.)"); - NS_ENSURE_SUCCESS(rv, rv); - - rv = MOZ_COLLECT_REPORT( + + MOZ_COLLECT_REPORT( "heap-allocated", KIND_OTHER, UNITS_BYTES, stats.allocated, "The same as 'heap-committed/allocated'."); - NS_ENSURE_SUCCESS(rv, rv); // We mark this and the other heap-overhead reporters as KIND_NONHEAP // because KIND_HEAP memory means "counted in heap-allocated", which // this is not. - rv = MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "explicit/heap-overhead/bin-unused", KIND_NONHEAP, UNITS_BYTES, stats.bin_unused, "Unused bytes due to fragmentation in the bins used for 'small' (<= 2 KiB) " "allocations. These bytes will be used if additional allocations occur."); - NS_ENSURE_SUCCESS(rv, rv); if (stats.waste > 0) { - rv = MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "explicit/heap-overhead/waste", KIND_NONHEAP, UNITS_BYTES, stats.waste, "Committed bytes which do not correspond to an active allocation and which the " "allocator is not intentionally keeping alive (i.e., not " "'explicit/heap-overhead/{bookkeeping,page-cache,bin-unused}')."); - NS_ENSURE_SUCCESS(rv, rv); } - rv = MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "explicit/heap-overhead/bookkeeping", KIND_NONHEAP, UNITS_BYTES, stats.bookkeeping, "Committed bytes which the heap allocator uses for internal data structures."); - NS_ENSURE_SUCCESS(rv, rv); - - rv = MOZ_COLLECT_REPORT( + + MOZ_COLLECT_REPORT( "explicit/heap-overhead/page-cache", KIND_NONHEAP, UNITS_BYTES, stats.page_cache, "Memory which the allocator could return to the operating system, but hasn't. " "The allocator keeps this memory around as an optimization, so it doesn't " "have to ask the OS the next time it needs to fulfill a request. This value " "is typically not larger than a few megabytes."); - NS_ENSURE_SUCCESS(rv, rv); - - rv = MOZ_COLLECT_REPORT( + + MOZ_COLLECT_REPORT( "heap-committed/overhead", KIND_OTHER, UNITS_BYTES, HeapOverhead(&stats), "The sum of 'explicit/heap-overhead/*'."); - NS_ENSURE_SUCCESS(rv, rv); - - rv = MOZ_COLLECT_REPORT( + + MOZ_COLLECT_REPORT( "heap-mapped", KIND_OTHER, UNITS_BYTES, stats.mapped, "Amount of memory currently mapped. Includes memory that is uncommitted, i.e. " "neither in physical memory nor paged to disk."); - NS_ENSURE_SUCCESS(rv, rv); - - rv = MOZ_COLLECT_REPORT( + + MOZ_COLLECT_REPORT( "heap-chunksize", KIND_OTHER, UNITS_BYTES, stats.chunksize, "Size of chunks."); - NS_ENSURE_SUCCESS(rv, rv); return NS_OK; } }; NS_IMPL_ISUPPORTS(JemallocHeapReporter, nsIMemoryReporter) #endif // HAVE_JEMALLOC_STATS @@ -1394,26 +1379,23 @@ public: NS_DECL_ISUPPORTS NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { size_t Main, Static; NS_SizeOfAtomTablesIncludingThis(MallocSizeOf, &Main, &Static); - nsresult rv; - rv = MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "explicit/atom-tables/main", KIND_HEAP, UNITS_BYTES, Main, "Memory used by the main atoms table."); - NS_ENSURE_SUCCESS(rv, rv); - - rv = MOZ_COLLECT_REPORT( + + MOZ_COLLECT_REPORT( "explicit/atom-tables/static", KIND_HEAP, UNITS_BYTES, Static, "Memory used by the static atoms table."); - NS_ENSURE_SUCCESS(rv, rv); return NS_OK; } }; NS_IMPL_ISUPPORTS(AtomTablesReporter, nsIMemoryReporter) #ifdef DEBUG @@ -1428,20 +1410,22 @@ class DeadlockDetectorReporter final : p ~DeadlockDetectorReporter() {} public: NS_DECL_ISUPPORTS NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { - return MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "explicit/deadlock-detector", KIND_HEAP, UNITS_BYTES, BlockingResourceBase::SizeOfDeadlockDetector(MallocSizeOf), "Memory used by the deadlock detector."); + + return NS_OK; } }; NS_IMPL_ISUPPORTS(DeadlockDetectorReporter, nsIMemoryReporter) #endif #ifdef MOZ_DMD @@ -1454,50 +1438,42 @@ public: NS_DECL_ISUPPORTS NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { dmd::Sizes sizes; dmd::SizeOf(&sizes); -#define REPORT(_path, _amount, _desc) \ - do { \ - nsresult rv; \ - rv = aHandleReport->Callback(EmptyCString(), NS_LITERAL_CSTRING(_path), \ - KIND_HEAP, UNITS_BYTES, _amount, \ - NS_LITERAL_CSTRING(_desc), aData); \ - if (NS_WARN_IF(NS_FAILED(rv))) { \ - return rv; \ - } \ - } while (0) - - REPORT("explicit/dmd/stack-traces/used", - sizes.mStackTracesUsed, - "Memory used by stack traces which correspond to at least " - "one heap block DMD is tracking."); - - REPORT("explicit/dmd/stack-traces/unused", - sizes.mStackTracesUnused, - "Memory used by stack traces which don't correspond to any heap " - "blocks DMD is currently tracking."); - - REPORT("explicit/dmd/stack-traces/table", - sizes.mStackTraceTable, - "Memory used by DMD's stack trace table."); - - REPORT("explicit/dmd/live-block-table", - sizes.mLiveBlockTable, - "Memory used by DMD's live block table."); - - REPORT("explicit/dmd/dead-block-list", - sizes.mDeadBlockTable, - "Memory used by DMD's dead block list."); - -#undef REPORT + MOZ_COLLECT_REPORT( + "explicit/dmd/stack-traces/used", KIND_HEAP, UNITS_BYTES, + sizes.mStackTracesUsed, + "Memory used by stack traces which correspond to at least " + "one heap block DMD is tracking."); + + MOZ_COLLECT_REPORT( + "explicit/dmd/stack-traces/unused", KIND_HEAP, UNITS_BYTES, + sizes.mStackTracesUnused, + "Memory used by stack traces which don't correspond to any heap " + "blocks DMD is currently tracking."); + + MOZ_COLLECT_REPORT( + "explicit/dmd/stack-traces/table", KIND_HEAP, UNITS_BYTES, + sizes.mStackTraceTable, + "Memory used by DMD's stack trace table."); + + MOZ_COLLECT_REPORT( + "explicit/dmd/live-block-table", KIND_HEAP, UNITS_BYTES, + sizes.mLiveBlockTable, + "Memory used by DMD's live block table."); + + MOZ_COLLECT_REPORT( + "explicit/dmd/dead-block-list", KIND_HEAP, UNITS_BYTES, + sizes.mDeadBlockTable, + "Memory used by DMD's dead block list."); return NS_OK; } private: ~DMDReporter() {} }; NS_IMPL_ISUPPORTS(DMDReporter, nsIMemoryReporter) @@ -1772,19 +1748,17 @@ nsMemoryReporterManager::DispatchReporte // Grab refs to everything used in the lambda function. RefPtr<nsMemoryReporterManager> self = this; nsCOMPtr<nsIMemoryReporter> reporter = aReporter; nsCOMPtr<nsIHandleReportCallback> handleReport = aHandleReport; nsCOMPtr<nsISupports> handleReportData = aHandleReportData; nsCOMPtr<nsIRunnable> event = NS_NewRunnableFunction( [self, reporter, aIsAsync, handleReport, handleReportData, aAnonymize] () { - reporter->CollectReports(handleReport, - handleReportData, - aAnonymize); + reporter->CollectReports(handleReport, handleReportData, aAnonymize); if (!aIsAsync) { self->EndReport(); } }); NS_DispatchToMainThread(event); mPendingReportersState->mReportsPending++; } @@ -2598,17 +2572,20 @@ nsMemoryReporterManager::SizeOfTab(mozID if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } TimeStamp t2 = TimeStamp::Now(); // Measure non-JS memory consumption. size_t domSize, styleSize, otherSize; - mSizeOfTabFns.mNonJS(piWindow, &domSize, &styleSize, &otherSize); + rv = mSizeOfTabFns.mNonJS(piWindow, &domSize, &styleSize, &otherSize); + if (NS_WARN_IF(NS_FAILED(rv))) { + return rv; + } TimeStamp t3 = TimeStamp::Now(); *aTotalSize = 0; #define DO(aN, n) { *aN = (n); *aTotalSize += (n); } DO(aJSObjectsSize, jsObjectsSize); DO(aJSStringsSize, jsStringsSize); DO(aJSOtherSize, jsOtherSize);
--- a/xpcom/build/XPCOMInit.cpp +++ b/xpcom/build/XPCOMInit.cpp @@ -378,19 +378,21 @@ public: return CountingFree(aPtr); } private: NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { - return MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "explicit/icu", KIND_HEAP, UNITS_BYTES, MemoryAllocated(), "Memory used by ICU, a Unicode and globalization support library."); + + return NS_OK; } ~ICUReporter() {} }; NS_IMPL_ISUPPORTS(ICUReporter, nsIMemoryReporter) /* static */ template<> Atomic<size_t> @@ -403,19 +405,22 @@ class OggReporter final public: NS_DECL_ISUPPORTS private: NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { - return MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "explicit/media/libogg", KIND_HEAP, UNITS_BYTES, MemoryAllocated(), - "Memory allocated through libogg for Ogg, Theora, and related media files."); + "Memory allocated through libogg for Ogg, Theora, and related media " + "files."); + + return NS_OK; } ~OggReporter() {} }; NS_IMPL_ISUPPORTS(OggReporter, nsIMemoryReporter) /* static */ template<> Atomic<size_t> @@ -429,19 +434,21 @@ class VPXReporter final public: NS_DECL_ISUPPORTS private: NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) override { - return MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "explicit/media/libvpx", KIND_HEAP, UNITS_BYTES, MemoryAllocated(), "Memory allocated through libvpx for WebM media files."); + + return NS_OK; } ~VPXReporter() {} }; NS_IMPL_ISUPPORTS(VPXReporter, nsIMemoryReporter) /* static */ template<> Atomic<size_t>
--- a/xpcom/components/nsCategoryManager.cpp +++ b/xpcom/components/nsCategoryManager.cpp @@ -448,20 +448,22 @@ nsCategoryManager::get_category(const ch } MOZ_DEFINE_MALLOC_SIZE_OF(CategoryManagerMallocSizeOf) NS_IMETHODIMP nsCategoryManager::CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) { - return MOZ_COLLECT_REPORT("explicit/xpcom/category-manager", - KIND_HEAP, UNITS_BYTES, - SizeOfIncludingThis(CategoryManagerMallocSizeOf), - "Memory used for the XPCOM category manager."); + MOZ_COLLECT_REPORT( + "explicit/xpcom/category-manager", KIND_HEAP, UNITS_BYTES, + SizeOfIncludingThis(CategoryManagerMallocSizeOf), + "Memory used for the XPCOM category manager."); + + return NS_OK; } size_t nsCategoryManager::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) { size_t n = aMallocSizeOf(this); n += PL_SizeOfArenaPoolExcludingPool(&mArena, aMallocSizeOf);
--- a/xpcom/components/nsComponentManager.cpp +++ b/xpcom/components/nsComponentManager.cpp @@ -1762,20 +1762,22 @@ nsComponentManagerImpl::ContractIDToCID( } MOZ_DEFINE_MALLOC_SIZE_OF(ComponentManagerMallocSizeOf) NS_IMETHODIMP nsComponentManagerImpl::CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) { - return MOZ_COLLECT_REPORT("explicit/xpcom/component-manager", - KIND_HEAP, UNITS_BYTES, - SizeOfIncludingThis(ComponentManagerMallocSizeOf), - "Memory used for the XPCOM component manager."); + MOZ_COLLECT_REPORT( + "explicit/xpcom/component-manager", KIND_HEAP, UNITS_BYTES, + SizeOfIncludingThis(ComponentManagerMallocSizeOf), + "Memory used for the XPCOM component manager."); + + return NS_OK; } size_t nsComponentManagerImpl::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const { size_t n = aMallocSizeOf(this);
--- a/xpcom/ds/nsObserverService.cpp +++ b/xpcom/ds/nsObserverService.cpp @@ -88,70 +88,46 @@ nsObserverService::CollectReports(nsIHan size_t topicTotal = topicNumStrong + topicNumWeakAlive + topicNumWeakDead; if (topicTotal > kSuspectReferentCount) { SuspectObserver suspect(observerList->GetKey(), topicTotal); suspectObservers.AppendElement(suspect); } } // These aren't privacy-sensitive and so don't need anonymizing. - nsresult rv; for (uint32_t i = 0; i < suspectObservers.Length(); i++) { SuspectObserver& suspect = suspectObservers[i]; nsPrintfCString suspectPath("observer-service-suspect/referent(topic=%s)", suspect.mTopic); - rv = aHandleReport->Callback( + aHandleReport->Callback( /* process */ EmptyCString(), suspectPath, KIND_OTHER, UNITS_COUNT, suspect.mReferentCount, NS_LITERAL_CSTRING("A topic with a suspiciously large number of " "referents. This may be symptomatic of a leak " "if the number of referents is high with " "respect to the number of windows."), aData); - - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - } - - rv = aHandleReport->Callback( - /* process */ EmptyCString(), - NS_LITERAL_CSTRING("observer-service/referent/strong"), - KIND_OTHER, UNITS_COUNT, totalNumStrong, - NS_LITERAL_CSTRING("The number of strong references held by the " - "observer service."), - aData); - - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; } - rv = aHandleReport->Callback( - /* process */ EmptyCString(), - NS_LITERAL_CSTRING("observer-service/referent/weak/alive"), - KIND_OTHER, UNITS_COUNT, totalNumWeakAlive, - NS_LITERAL_CSTRING("The number of weak references held by the " - "observer service that are still alive."), - aData); - - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } + MOZ_COLLECT_REPORT( + "observer-service/referent/strong", KIND_OTHER, UNITS_COUNT, + totalNumStrong, + "The number of strong references held by the observer service."); - rv = aHandleReport->Callback( - /* process */ EmptyCString(), - NS_LITERAL_CSTRING("observer-service/referent/weak/dead"), - KIND_OTHER, UNITS_COUNT, totalNumWeakDead, - NS_LITERAL_CSTRING("The number of weak references held by the " - "observer service that are dead."), - aData); + MOZ_COLLECT_REPORT( + "observer-service/referent/weak/alive", KIND_OTHER, UNITS_COUNT, + totalNumWeakAlive, + "The number of weak references held by the observer service that are " + "still alive."); - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } + MOZ_COLLECT_REPORT( + "observer-service/referent/weak/dead", KIND_OTHER, UNITS_COUNT, + totalNumWeakDead, + "The number of weak references held by the observer service that are " + "dead."); return NS_OK; } //////////////////////////////////////////////////////////////////////////////// // nsObserverService Implementation NS_IMPL_ISUPPORTS(nsObserverService,
--- a/xpcom/reflect/xptinfo/xptiInterfaceInfoManager.cpp +++ b/xpcom/reflect/xptinfo/xptiInterfaceInfoManager.cpp @@ -49,19 +49,21 @@ XPTInterfaceInfoManager::CollectReports( { size_t amount = SizeOfIncludingThis(XPTIMallocSizeOf); // Measure gXPTIStructArena here, too. This is a bit grotty because it // doesn't belong to the XPTIInterfaceInfoManager, but there's no // obviously better place to measure it. amount += XPT_SizeOfArenaIncludingThis(gXPTIStructArena, XPTIMallocSizeOf); - return MOZ_COLLECT_REPORT( + MOZ_COLLECT_REPORT( "explicit/xpti-working-set", KIND_HEAP, UNITS_BYTES, amount, "Memory used by the XPCOM typelib system."); + + return NS_OK; } // static XPTInterfaceInfoManager* XPTInterfaceInfoManager::GetSingleton() { if (!gInterfaceInfoManager) { gInterfaceInfoManager = new XPTInterfaceInfoManager();