Bug 1027921 - Part 9: Add DeadlockDetector memory reporter. r=njn, r=froydnj

This commit is contained in:
Eric Rahm 2014-08-04 16:20:37 -07:00
parent 9961766b9d
commit 4d0205fb6f
3 changed files with 43 additions and 1 deletions

View File

@ -883,6 +883,34 @@ public:
};
NS_IMPL_ISUPPORTS(AtomTablesReporter, nsIMemoryReporter)
#ifdef DEBUG
// Ideally, this would be implemented in BlockingResourceBase.cpp.
// However, this ends up breaking the linking step of various unit tests due
// to adding a new dependency to libdmd for a commonly used feature (mutexes)
// in DMD builds. So instead we do it here.
class DeadlockDetectorReporter MOZ_FINAL : public nsIMemoryReporter
{
MOZ_DEFINE_MALLOC_SIZE_OF(MallocSizeOf)
~DeadlockDetectorReporter() {}
public:
NS_DECL_ISUPPORTS
NS_METHOD CollectReports(nsIHandleReportCallback* aHandleReport,
nsISupports* aData, bool aAnonymize)
{
return MOZ_COLLECT_REPORT(
"explicit/deadlock-detector", KIND_HEAP, UNITS_BYTES,
BlockingResourceBase::SizeOfDeadlockDetector(MallocSizeOf),
"Memory used by the deadlock detector.");
}
};
NS_IMPL_ISUPPORTS(DeadlockDetectorReporter, nsIMemoryReporter)
#endif
#ifdef MOZ_DMD
namespace mozilla {
@ -986,6 +1014,10 @@ nsMemoryReporterManager::Init()
RegisterStrongReporter(new AtomTablesReporter());
#ifdef DEBUG
RegisterStrongReporter(new DeadlockDetectorReporter());
#endif
#ifdef MOZ_DMD
RegisterStrongReporter(new mozilla::dmd::DMDReporter());
#endif

View File

@ -269,7 +269,12 @@ public:
SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
{
size_t n = aMallocSizeOf(this);
n += mOrdering.SizeOfExcludingThis(SizeOfEntryExcludingThis, aMallocSizeOf);
{
PRAutoLock _(mLock);
n += mOrdering.SizeOfExcludingThis(SizeOfEntryExcludingThis, aMallocSizeOf);
}
return n;
}

View File

@ -129,3 +129,8 @@ USE_LIBS += [
'xpcomglue_s',
'xul',
]
if CONFIG['MOZ_DMD']:
USE_LIBS += [
'dmd'
]