mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 859657 (part 2) - Remove nsIMemoryMultiReporter.explicitNonHeap because it's more trouble than it's worth; also remove the "explicit" single reporter. r=jlebar.
--HG-- extra : rebase_source : a146536a3dd0043082bcb1c26d980c4c6d4c0730
This commit is contained in:
parent
710595a8db
commit
f5378cec64
@ -631,13 +631,6 @@ class nsDOMMemoryFileDataOwnerMemoryReporter MOZ_FINAL
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetExplicitNonHeap(int64_t *aResult)
|
||||
{
|
||||
// All of this reporter's memory is on the heap.
|
||||
*aResult = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD CollectReports(nsIMemoryMultiReporterCallback *aCallback,
|
||||
nsISupports *aClosure)
|
||||
{
|
||||
|
@ -26,14 +26,6 @@ WebGLMemoryMultiReporter::GetName(nsACString &aName)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
WebGLMemoryMultiReporter::GetExplicitNonHeap(int64_t *aAmount)
|
||||
{
|
||||
// WebGLMemoryMultiReporterWrapper has no KIND_NONHEAP measurements.
|
||||
*aAmount = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
WebGLMemoryMultiReporter::CollectReports(nsIMemoryMultiReporterCallback* aCb,
|
||||
nsISupports* aClosure)
|
||||
|
@ -410,14 +410,6 @@ nsWindowMemoryReporter::CollectReports(nsIMemoryMultiReporterCallback* aCb,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowMemoryReporter::GetExplicitNonHeap(int64_t* aAmount)
|
||||
{
|
||||
// This reporter only measures heap memory, so we don't need to report any
|
||||
// bytes for it. However, the JS multi-reporter needs to be invoked.
|
||||
return xpc::JSMemoryMultiReporter::GetExplicitNonHeap(aAmount);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
nsWindowMemoryReporter::GetGhostTimeout()
|
||||
{
|
||||
@ -668,14 +660,6 @@ GhostURLsReporter::GetName(nsACString& aName)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowMemoryReporter::
|
||||
GhostURLsReporter::GetExplicitNonHeap(int64_t* aOut)
|
||||
{
|
||||
*aOut = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
struct ReportGhostWindowsEnumeratorData
|
||||
{
|
||||
nsIMemoryMultiReporterCallback* callback;
|
||||
|
@ -1774,8 +1774,7 @@ public:
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
if (!mWorkerPrivate ||
|
||||
!mWorkerPrivate->BlockAndCollectRuntimeStats(/* aIsQuick = */ false,
|
||||
&rtStats)) {
|
||||
!mWorkerPrivate->BlockAndCollectRuntimeStats(&rtStats)) {
|
||||
// Returning NS_OK here will effectively report 0 memory.
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1785,24 +1784,6 @@ public:
|
||||
aCallback, aClosure);
|
||||
}
|
||||
|
||||
NS_IMETHOD
|
||||
GetExplicitNonHeap(int64_t* aAmount)
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
if (!mWorkerPrivate ||
|
||||
!mWorkerPrivate->BlockAndCollectRuntimeStats(/* aIsQuick = */ true,
|
||||
aAmount)) {
|
||||
*aAmount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
~MemoryReporter()
|
||||
{ }
|
||||
@ -2940,11 +2921,11 @@ WorkerPrivate::ScheduleDeletion(bool aWasPending)
|
||||
}
|
||||
|
||||
bool
|
||||
WorkerPrivate::BlockAndCollectRuntimeStats(bool aIsQuick, void* aData)
|
||||
WorkerPrivate::BlockAndCollectRuntimeStats(JS::RuntimeStats* aRtStats)
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
mMutex.AssertCurrentThreadOwns();
|
||||
NS_ASSERTION(aData, "Null data!");
|
||||
NS_ASSERTION(aRtStats, "Null RuntimeStats!");
|
||||
|
||||
NS_ASSERTION(!mMemoryReporterRunning, "How can we get reentered here?!");
|
||||
|
||||
@ -2973,16 +2954,7 @@ WorkerPrivate::BlockAndCollectRuntimeStats(bool aIsQuick, void* aData)
|
||||
if (mMemoryReporter) {
|
||||
// Don't hold the lock while doing the actual report.
|
||||
MutexAutoUnlock unlock(mMutex);
|
||||
|
||||
if (aIsQuick) {
|
||||
*static_cast<int64_t*>(aData) =
|
||||
JS::GetExplicitNonHeapForRuntime(rt, JsWorkerMallocSizeOf);
|
||||
succeeded = true;
|
||||
} else {
|
||||
succeeded =
|
||||
JS::CollectRuntimeStats(rt, static_cast<JS::RuntimeStats*>(aData),
|
||||
nullptr);
|
||||
}
|
||||
succeeded = JS::CollectRuntimeStats(rt, aRtStats, nullptr);
|
||||
}
|
||||
|
||||
NS_ASSERTION(mMemoryReporterRunning, "This isn't possible!");
|
||||
|
@ -41,6 +41,7 @@ class nsIURI;
|
||||
class nsPIDOMWindow;
|
||||
class nsITimer;
|
||||
class nsIXPCScriptNotify;
|
||||
namespace JS { class RuntimeStats; }
|
||||
|
||||
BEGIN_WORKERS_NAMESPACE
|
||||
|
||||
@ -821,7 +822,7 @@ public:
|
||||
ScheduleDeletion(bool aWasPending);
|
||||
|
||||
bool
|
||||
BlockAndCollectRuntimeStats(bool aIsQuick, void* aData);
|
||||
BlockAndCollectRuntimeStats(JS::RuntimeStats* aRtStats);
|
||||
|
||||
bool
|
||||
XHRParamsAllowed() const
|
||||
|
@ -634,12 +634,6 @@ public:
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetExplicitNonHeap(int64_t *n)
|
||||
{
|
||||
*n = 0; // this reporter makes neither "explicit" non NONHEAP reports
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(SurfaceMemoryReporter, nsIMemoryMultiReporter)
|
||||
|
@ -1137,14 +1137,6 @@ gfxFontCache::MemoryReporter::CollectReports
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
gfxFontCache::MemoryReporter::GetExplicitNonHeap(int64_t* aAmount)
|
||||
{
|
||||
// This reporter only measures heap memory.
|
||||
*aAmount = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Observer for the memory-pressure notification, to trigger
|
||||
// flushing of the shaped-word caches
|
||||
class MemoryPressureObserver MOZ_FINAL : public nsIObserver,
|
||||
|
@ -120,14 +120,6 @@ gfxPlatformFontList::MemoryReporter::CollectReports
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
gfxPlatformFontList::MemoryReporter::GetExplicitNonHeap(int64_t* aAmount)
|
||||
{
|
||||
// This reporter only measures heap memory.
|
||||
*aAmount = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
gfxPlatformFontList::gfxPlatformFontList(bool aNeedFullnamePostscriptNames)
|
||||
: mNeedFullnamePostscriptNames(aNeedFullnamePostscriptNames),
|
||||
mStartIndex(0), mIncrement(kNumFontsPerSlice), mNumFamilies(0)
|
||||
|
@ -323,15 +323,6 @@ public:
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIMemoryMultiReporter abstract method implementation
|
||||
NS_IMETHOD
|
||||
GetExplicitNonHeap(int64_t *aExplicitNonHeap)
|
||||
{
|
||||
// This reporter doesn't do any non-heap measurements.
|
||||
*aExplicitNonHeap = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
NS_IMPL_ISUPPORTS1(GPUAdapterMultiReporter, nsIMemoryMultiReporter)
|
||||
#endif // ENABLE_GPU_MEM_REPORTER
|
||||
|
@ -150,17 +150,6 @@ public:
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetExplicitNonHeap(int64_t *n)
|
||||
{
|
||||
size_t n2 = 0;
|
||||
for (uint32_t i = 0; i < mKnownLoaders.Length(); i++) {
|
||||
mKnownLoaders[i]->mChromeCache.EnumerateRead(EntryExplicitNonHeapSize, &n2);
|
||||
mKnownLoaders[i]->mCache.EnumerateRead(EntryExplicitNonHeapSize, &n2);
|
||||
}
|
||||
*n = n2;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static int64_t GetImagesContentUsedUncompressed()
|
||||
{
|
||||
size_t n = 0;
|
||||
@ -222,20 +211,6 @@ private:
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
static PLDHashOperator EntryExplicitNonHeapSize(const nsACString&,
|
||||
imgCacheEntry *entry,
|
||||
void *userArg)
|
||||
{
|
||||
size_t *n = static_cast<size_t*>(userArg);
|
||||
nsRefPtr<imgRequest> req = entry->GetRequest();
|
||||
Image *image = static_cast<Image*>(req->mImage.get());
|
||||
if (image) {
|
||||
*n += image->NonHeapSizeOfDecoded();
|
||||
}
|
||||
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
static PLDHashOperator EntryUsedUncompressedSize(const nsACString&,
|
||||
imgCacheEntry *entry,
|
||||
void *userArg)
|
||||
|
@ -444,9 +444,6 @@ class ObjectPrivateVisitor
|
||||
extern JS_PUBLIC_API(bool)
|
||||
CollectRuntimeStats(JSRuntime *rt, RuntimeStats *rtStats, ObjectPrivateVisitor *opv);
|
||||
|
||||
extern JS_PUBLIC_API(int64_t)
|
||||
GetExplicitNonHeapForRuntime(JSRuntime *rt, JSMallocSizeOfFun mallocSizeOf);
|
||||
|
||||
extern JS_PUBLIC_API(size_t)
|
||||
SystemCompartmentCount(JSRuntime *rt);
|
||||
|
||||
|
@ -880,7 +880,6 @@ JSRuntime::JSRuntime(JSUseHelperThreads useHelperThreads)
|
||||
data(NULL),
|
||||
gcLock(NULL),
|
||||
gcHelperThread(thisFromCtor()),
|
||||
sizeOfNonHeapAsmJSArrays_(0),
|
||||
#ifdef JS_THREADSAFE
|
||||
#ifdef JS_ION
|
||||
workerThreadState(NULL),
|
||||
|
@ -143,24 +143,6 @@ JSRuntime::sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf, JS::RuntimeSizes
|
||||
rtSizes->scriptData += mallocSizeOf(r.front());
|
||||
}
|
||||
|
||||
size_t
|
||||
JSRuntime::sizeOfExplicitNonHeap()
|
||||
{
|
||||
size_t n = stackSpace.sizeOf();
|
||||
|
||||
if (execAlloc_) {
|
||||
JS::CodeSizes sizes;
|
||||
execAlloc_->sizeOfCode(&sizes);
|
||||
n += sizes.jaeger + sizes.ion + sizes.baseline + sizes.asmJS +
|
||||
sizes.regexp + sizes.other + sizes.unused;
|
||||
}
|
||||
|
||||
if (bumpAlloc_)
|
||||
n += bumpAlloc_->sizeOfNonHeapData();
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
void
|
||||
JSRuntime::triggerOperationCallback()
|
||||
{
|
||||
|
@ -1204,8 +1204,6 @@ struct JSRuntime : private JS::shadow::Runtime,
|
||||
js::AsmJSMachExceptionHandler asmJSMachExceptionHandler;
|
||||
#endif
|
||||
|
||||
size_t sizeOfNonHeapAsmJSArrays_;
|
||||
|
||||
#ifdef JS_THREADSAFE
|
||||
# ifdef JS_ION
|
||||
js::WorkerThreadState *workerThreadState;
|
||||
@ -1405,7 +1403,6 @@ struct JSRuntime : private JS::shadow::Runtime,
|
||||
}
|
||||
|
||||
void sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf, JS::RuntimeSizes *runtime);
|
||||
size_t sizeOfExplicitNonHeap();
|
||||
|
||||
private:
|
||||
|
||||
|
@ -375,29 +375,6 @@ JS::CollectRuntimeStats(JSRuntime *rt, RuntimeStats *rtStats, ObjectPrivateVisit
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(int64_t)
|
||||
JS::GetExplicitNonHeapForRuntime(JSRuntime *rt, JSMallocSizeOfFun mallocSizeOf)
|
||||
{
|
||||
// explicit/*/gc-heap/*
|
||||
size_t n = size_t(JS_GetGCParameter(rt, JSGC_TOTAL_CHUNKS)) * gc::ChunkSize;
|
||||
|
||||
// Subtract decommitted arenas, which aren't included in "explicit".
|
||||
size_t decommittedArenas = 0;
|
||||
IterateChunks(rt, &decommittedArenas, DecommittedArenasChunkCallback);
|
||||
n -= decommittedArenas;
|
||||
|
||||
// explicit/*/objects-extra/elements/asm.js (64-bit platforms only)
|
||||
n += rt->sizeOfNonHeapAsmJSArrays_;
|
||||
|
||||
// explicit/runtime/mjit-code
|
||||
// explicit/runtime/regexp-code
|
||||
// explicit/runtime/stack-committed
|
||||
// explicit/runtime/unused-code-memory
|
||||
n += rt->sizeOfExplicitNonHeap();
|
||||
|
||||
return int64_t(n);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(size_t)
|
||||
JS::SystemCompartmentCount(JSRuntime *rt)
|
||||
{
|
||||
|
@ -379,11 +379,6 @@ ArrayBufferObject::prepareForAsmJS(JSContext *cx, Handle<ArrayBufferObject*> buf
|
||||
}
|
||||
# endif
|
||||
|
||||
// We don't include the PageSize at the front so that when we sum the
|
||||
// individual asm.js arrays for all the compartments in the runtime, they
|
||||
// match this number.
|
||||
buffer->runtime()->sizeOfNonHeapAsmJSArrays_ += buffer->byteLength();
|
||||
|
||||
// Copy over the current contents of the typed array.
|
||||
uint8_t *data = reinterpret_cast<uint8_t*>(p) + PageSize;
|
||||
memcpy(data, buffer->dataPointer(), buffer->byteLength());
|
||||
@ -407,8 +402,6 @@ ArrayBufferObject::releaseAsmJSArrayBuffer(FreeOp *fop, RawObject obj)
|
||||
ArrayBufferObject &buffer = obj->asArrayBuffer();
|
||||
JS_ASSERT(buffer.isAsmJSArrayBuffer());
|
||||
|
||||
buffer.runtime()->sizeOfNonHeapAsmJSArrays_ -= buffer.byteLength();
|
||||
|
||||
uint8_t *p = buffer.dataPointer() - PageSize ;
|
||||
JS_ASSERT(uintptr_t(p) % PageSize == 0);
|
||||
# ifdef XP_WIN
|
||||
|
@ -26,8 +26,6 @@ public:
|
||||
WindowPaths *topWindowPaths,
|
||||
nsIMemoryMultiReporterCallback *cb,
|
||||
nsISupports *closure);
|
||||
|
||||
static nsresult GetExplicitNonHeap(int64_t *n);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -2150,14 +2150,6 @@ class JSCompartmentsMultiReporter MOZ_FINAL : public nsIMemoryMultiReporter
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD
|
||||
GetExplicitNonHeap(int64_t *n)
|
||||
{
|
||||
// This reporter does neither "explicit" nor NONHEAP measurements.
|
||||
*n = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(JSCompartmentsMultiReporter
|
||||
@ -2425,14 +2417,6 @@ JSMemoryMultiReporter::CollectReports(WindowPaths *windowPaths,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
JSMemoryMultiReporter::GetExplicitNonHeap(int64_t *n)
|
||||
{
|
||||
JSRuntime *rt = nsXPConnect::GetRuntimeInstance()->GetJSRuntime();
|
||||
*reinterpret_cast<int64_t*>(n) = JS::GetExplicitNonHeapForRuntime(rt, JsMallocSizeOf);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace xpc
|
||||
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
|
@ -163,13 +163,6 @@ public:
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetExplicitNonHeap(int64_t *aAmount)
|
||||
{
|
||||
// This reporter doesn't do any non-heap measurements.
|
||||
*aAmount = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* Passes a single SQLite memory statistic to a memory multi-reporter
|
||||
|
@ -39,7 +39,6 @@
|
||||
const COUNT_CUMULATIVE = Ci.nsIMemoryReporter.UNITS_COUNT_CUMULATIVE;
|
||||
const PERCENTAGE = Ci.nsIMemoryReporter.UNITS_PERCENTAGE;
|
||||
|
||||
let explicitAmounts = [];
|
||||
let vsizeAmounts = [];
|
||||
let residentAmounts = [];
|
||||
let jsGcHeapAmounts = [];
|
||||
@ -60,9 +59,7 @@
|
||||
function handleReport(aProcess, aPath, aKind, aUnits, aAmount, aDescription)
|
||||
{
|
||||
// Record the values of some notable reporters.
|
||||
if (aPath === "explicit") {
|
||||
explicitAmounts.push(aAmount);
|
||||
} else if (aPath === "vsize") {
|
||||
if (aPath === "vsize") {
|
||||
vsizeAmounts.push(aAmount);
|
||||
} else if (aPath === "resident") {
|
||||
residentAmounts.push(aAmount);
|
||||
@ -122,10 +119,8 @@
|
||||
let r = e.getNext().QueryInterface(Ci.nsIMemoryMultiReporter);
|
||||
r.collectReports(handleReport, null);
|
||||
|
||||
// Access |name| and |explicitNonHeap| to make sure they don't crash or
|
||||
// assert.
|
||||
// Access |name| to make sure it doesn't crash or assert.
|
||||
dummy = r.name;
|
||||
dummy = r.explicitNonHeap;
|
||||
}
|
||||
|
||||
function checkSpecialReport(aName, aAmounts)
|
||||
@ -139,7 +134,6 @@
|
||||
|
||||
// If mgr.explicit failed, we won't have "heap-allocated" either.
|
||||
if (haveExplicit) {
|
||||
checkSpecialReport("explicit", explicitAmounts);
|
||||
checkSpecialReport("heap-allocated", heapAllocatedAmounts);
|
||||
}
|
||||
checkSpecialReport("vsize", vsizeAmounts);
|
||||
|
@ -128,13 +128,6 @@ public:
|
||||
CollectReports(nsIMemoryMultiReporterCallback *aCb,
|
||||
nsISupports *aClosure);
|
||||
|
||||
NS_IMETHOD
|
||||
GetExplicitNonHeap(int64_t *aAmount) {
|
||||
// This reporter doesn't do any "explicit" measurements.
|
||||
*aAmount = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
// Search through /proc/self/maps for libxul.so, and set mLibxulDir to the
|
||||
// the directory containing libxul.
|
||||
|
@ -2431,13 +2431,6 @@ class CycleCollectorMultiReporter MOZ_FINAL : public nsIMemoryMultiReporter
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetExplicitNonHeap(int64_t* n)
|
||||
{
|
||||
// This reporter does neither "explicit" nor NONHEAP measurements.
|
||||
*n = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(MallocSizeOf)
|
||||
|
||||
|
@ -199,7 +199,7 @@ interface nsIMemoryMultiReporterCallback : nsISupports
|
||||
* (Compare and contrast this with nsIMemoryReporter, which allows all
|
||||
* fields except |amount| to be accessed without triggering computation.)
|
||||
*/
|
||||
[scriptable, uuid(61d498d5-b460-4398-a8ea-7f75208534b4)]
|
||||
[scriptable, uuid(24d61ead-237b-4969-a6bd-73fd8fed1d99)]
|
||||
interface nsIMemoryMultiReporter : nsISupports
|
||||
{
|
||||
/*
|
||||
@ -214,18 +214,6 @@ interface nsIMemoryMultiReporter : nsISupports
|
||||
*/
|
||||
void collectReports(in nsIMemoryMultiReporterCallback callback,
|
||||
in nsISupports closure);
|
||||
|
||||
/*
|
||||
* Return the sum of all this multi-reporter's measurements that have a
|
||||
* path that starts with "explicit" and are KIND_NONHEAP.
|
||||
*
|
||||
* This is a hack that's required to implement
|
||||
* nsIMemoryReporterManager::explicit efficiently, which is important --
|
||||
* multi-reporters can special-case this operation so it's much faster
|
||||
* than getting all the reports, filtering out the unneeded ones, and
|
||||
* summing the remainder.
|
||||
*/
|
||||
readonly attribute int64_t explicitNonHeap;
|
||||
};
|
||||
|
||||
[scriptable, builtinclass, uuid(70b0e608-8dbf-4dc7-b88f-f1c745c1b48c)]
|
||||
|
@ -594,27 +594,6 @@ private:
|
||||
return (int64_t) stats.allocated;
|
||||
}
|
||||
};
|
||||
|
||||
// The computation of "explicit" fails if "heap-allocated" isn't available,
|
||||
// which is why this is depends on HAVE_JEMALLOC_STATS.
|
||||
class ExplicitReporter MOZ_FINAL : public MemoryReporterBase
|
||||
{
|
||||
public:
|
||||
ExplicitReporter()
|
||||
: MemoryReporterBase("explicit", KIND_OTHER, UNITS_BYTES,
|
||||
"This is the same measurement as the root of the 'explicit' tree. However, "
|
||||
"it is measured at a different time and so gives slightly different results.")
|
||||
{}
|
||||
|
||||
NS_IMETHOD GetAmount(int64_t *aAmount)
|
||||
{
|
||||
nsCOMPtr<nsIMemoryReporterManager> mgr = do_GetService("@mozilla.org/memory-reporter-manager;1");
|
||||
if (mgr == nullptr)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return mgr->GetExplicit(aAmount);
|
||||
}
|
||||
};
|
||||
#endif // HAVE_JEMALLOC_STATS
|
||||
|
||||
// Why is this here? At first glance, you'd think it could be defined and
|
||||
@ -690,13 +669,6 @@ public:
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetExplicitNonHeap(int64_t *n)
|
||||
{
|
||||
// No non-heap allocations.
|
||||
*n = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(DMDMultiReporter, nsIMemoryMultiReporter)
|
||||
@ -727,7 +699,6 @@ nsMemoryReporterManager::Init()
|
||||
RegisterReporter(new HeapCommittedUnusedReporter);
|
||||
RegisterReporter(new HeapCommittedUnusedRatioReporter);
|
||||
RegisterReporter(new HeapDirtyReporter);
|
||||
RegisterReporter(new ExplicitReporter);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_VSIZE_AND_RESIDENT_REPORTERS
|
||||
@ -1107,54 +1078,23 @@ nsMemoryReporterManager::GetExplicit(int64_t *aExplicit)
|
||||
}
|
||||
}
|
||||
|
||||
// For each multi-reporter we could call CollectReports and filter out the
|
||||
// non-explicit, non-NONHEAP measurements. But that's lots of wasted work,
|
||||
// so we instead use GetExplicitNonHeap() which exists purely for this
|
||||
// purpose.
|
||||
//
|
||||
// (Actually, in debug builds we also do it the slow way and compare the
|
||||
// result to the result obtained from GetExplicitNonHeap(). This
|
||||
// guarantees the two measurement paths are equivalent. This is wise
|
||||
// because it's easy for memory reporters to have bugs. But there's an
|
||||
// exception if DMD is enabled, because that makes DMD think that all the
|
||||
// blocks are double-counted.)
|
||||
// For each multi-reporter we call CollectReports and filter out the
|
||||
// non-explicit, non-NONHEAP measurements. That's lots of wasted work,
|
||||
// and we used to have a GetExplicitNonHeap() method which did this more
|
||||
// efficiently, but it ended up being more trouble than it was worth.
|
||||
|
||||
int64_t explicitNonHeapMultiSize = 0;
|
||||
nsRefPtr<ExplicitNonHeapCountingCallback> cb =
|
||||
new ExplicitNonHeapCountingCallback();
|
||||
nsRefPtr<Int64Wrapper> wrappedExplicitNonHeapMultiSize =
|
||||
new Int64Wrapper();
|
||||
nsCOMPtr<nsISimpleEnumerator> e2;
|
||||
EnumerateMultiReporters(getter_AddRefs(e2));
|
||||
while (NS_SUCCEEDED(e2->HasMoreElements(&more)) && more) {
|
||||
nsCOMPtr<nsIMemoryMultiReporter> r;
|
||||
e2->GetNext(getter_AddRefs(r));
|
||||
int64_t n;
|
||||
rv = r->GetExplicitNonHeap(&n);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
explicitNonHeapMultiSize += n;
|
||||
r->CollectReports(cb, wrappedExplicitNonHeapMultiSize);
|
||||
}
|
||||
|
||||
#if defined(DEBUG) && !defined(MOZ_DMD)
|
||||
nsRefPtr<ExplicitNonHeapCountingCallback> cb =
|
||||
new ExplicitNonHeapCountingCallback();
|
||||
nsRefPtr<Int64Wrapper> wrappedExplicitNonHeapMultiSize2 =
|
||||
new Int64Wrapper();
|
||||
nsCOMPtr<nsISimpleEnumerator> e3;
|
||||
EnumerateMultiReporters(getter_AddRefs(e3));
|
||||
while (NS_SUCCEEDED(e3->HasMoreElements(&more)) && more) {
|
||||
nsCOMPtr<nsIMemoryMultiReporter> r;
|
||||
e3->GetNext(getter_AddRefs(r));
|
||||
r->CollectReports(cb, wrappedExplicitNonHeapMultiSize2);
|
||||
}
|
||||
int64_t explicitNonHeapMultiSize2 = wrappedExplicitNonHeapMultiSize2->mValue;
|
||||
|
||||
// Check the two measurements give the same result. This was an
|
||||
// NS_ASSERTION but they occasionally don't match due to races (bug
|
||||
// 728990).
|
||||
if (explicitNonHeapMultiSize != explicitNonHeapMultiSize2) {
|
||||
NS_WARNING(nsPrintfCString("The two measurements of 'explicit' memory "
|
||||
"usage don't match (%lld vs %lld)",
|
||||
explicitNonHeapMultiSize,
|
||||
explicitNonHeapMultiSize2).get());
|
||||
}
|
||||
#endif // defined(DEBUG) && !defined(MOZ_DMD)
|
||||
int64_t explicitNonHeapMultiSize = wrappedExplicitNonHeapMultiSize->mValue;
|
||||
|
||||
*aExplicit = heapAllocated + explicitNonHeapNormalSize + explicitNonHeapMultiSize;
|
||||
return NS_OK;
|
||||
|
Loading…
Reference in New Issue
Block a user