Bug 744311 (part 1) - Preliminary whitespace and code order changes. r=jlebar.

--HG--
extra : rebase_source : f700733d8aa1aed1ae1f9206b4ee9063f9a03341
This commit is contained in:
Nicholas Nethercote 2012-04-09 22:52:33 -07:00
parent 7e0db46628
commit 08dc2dae6b
12 changed files with 130 additions and 135 deletions

View File

@ -222,18 +222,18 @@ namespace mozilla {
MediaMemoryReporter* MediaMemoryReporter::sUniqueInstance;
NS_MEMORY_REPORTER_IMPLEMENT(MediaDecodedVideoMemory,
"explicit/media/decoded-video",
KIND_HEAP,
UNITS_BYTES,
MediaMemoryReporter::GetDecodedVideoMemory,
"Memory used by decoded video frames.")
"explicit/media/decoded-video",
KIND_HEAP,
UNITS_BYTES,
MediaMemoryReporter::GetDecodedVideoMemory,
"Memory used by decoded video frames.")
NS_MEMORY_REPORTER_IMPLEMENT(MediaDecodedAudioMemory,
"explicit/media/decoded-audio",
KIND_HEAP,
UNITS_BYTES,
MediaMemoryReporter::GetDecodedAudioMemory,
"Memory used by decoded audio chunks.")
"explicit/media/decoded-audio",
KIND_HEAP,
UNITS_BYTES,
MediaMemoryReporter::GetDecodedAudioMemory,
"Memory used by decoded audio chunks.")
MediaMemoryReporter::MediaMemoryReporter()
: mMediaDecodedVideoMemory(new NS_MEMORY_REPORTER_NAME(MediaDecodedVideoMemory))

View File

@ -381,14 +381,16 @@ ContentChild::RecvPMemoryReportRequestConstructor(PMemoryReportRequestChild* chi
PRInt32 units;
PRInt64 amount;
nsCString desc;
r->GetPath(path);
r->GetKind(&kind);
r->GetUnits(&units);
r->GetAmount(&amount);
r->GetDescription(desc);
MemoryReport memreport(process, path, kind, units, amount, desc);
reports.AppendElement(memreport);
if (NS_SUCCEEDED(r->GetPath(path)) &&
NS_SUCCEEDED(r->GetKind(&kind)) &&
NS_SUCCEEDED(r->GetUnits(&units)) &&
NS_SUCCEEDED(r->GetAmount(&amount)) &&
NS_SUCCEEDED(r->GetDescription(desc)))
{
MemoryReport memreport(process, path, kind, units, amount, desc);
reports.AppendElement(memreport);
}
}
// Then do the memory multi-reporters, by calling CollectReports on each

View File

@ -112,12 +112,12 @@ static PRInt64 HunspellGetCurrentAllocatedSize() {
}
NS_MEMORY_REPORTER_IMPLEMENT(Hunspell,
"explicit/spell-check",
KIND_HEAP,
UNITS_BYTES,
HunspellGetCurrentAllocatedSize,
"Memory used by the Hunspell spell checking engine. This number accounts "
"for the memory in use by Hunspell's internal data structures."
"explicit/spell-check",
KIND_HEAP,
UNITS_BYTES,
HunspellGetCurrentAllocatedSize,
"Memory used by the Hunspell spell checking engine. This number accounts "
"for the memory in use by Hunspell's internal data structures."
)
nsresult

View File

@ -53,18 +53,19 @@ static PRInt64 GetShmemAllocated() { return gShmemAllocated; }
static PRInt64 GetShmemMapped() { return gShmemMapped; }
NS_MEMORY_REPORTER_IMPLEMENT(ShmemAllocated,
"shmem-allocated",
KIND_OTHER,
UNITS_BYTES,
GetShmemAllocated,
"Memory shared with other processes that is accessible (but not "
"necessarily mapped).")
"shmem-allocated",
KIND_OTHER,
UNITS_BYTES,
GetShmemAllocated,
"Memory shared with other processes that is accessible (but not "
"necessarily mapped).")
NS_MEMORY_REPORTER_IMPLEMENT(ShmemMapped,
"shmem-mapped",
KIND_OTHER,
UNITS_BYTES,
GetShmemMapped,
"Memory shared with other processes that is mapped into the address space.")
"shmem-mapped",
KIND_OTHER,
UNITS_BYTES,
GetShmemMapped,
"Memory shared with other processes that is mapped into the address space.")
SharedMemory::SharedMemory()
: mAllocSize(0)

View File

@ -1268,8 +1268,7 @@ GetJSUserCompartmentCount()
// XPConnectJSCompartmentCount to avoid that problem, but then we couldn't
// easily report them via telemetry, so we live with the small risk of
// inconsistencies.
NS_MEMORY_REPORTER_IMPLEMENT(
XPConnectJSSystemCompartmentCount,
NS_MEMORY_REPORTER_IMPLEMENT(XPConnectJSSystemCompartmentCount,
"js-compartments-system",
KIND_OTHER,
nsIMemoryReporter::UNITS_COUNT,
@ -1279,8 +1278,7 @@ NS_MEMORY_REPORTER_IMPLEMENT(
"listed under 'js' if a garbage collection occurs at an inopportune time, "
"but such cases should be rare.")
NS_MEMORY_REPORTER_IMPLEMENT(
XPConnectJSUserCompartmentCount,
NS_MEMORY_REPORTER_IMPLEMENT(XPConnectJSUserCompartmentCount,
"js-compartments-user",
KIND_OTHER,
nsIMemoryReporter::UNITS_COUNT,

View File

@ -59,11 +59,11 @@ GetStylesheetCacheSize()
}
NS_MEMORY_REPORTER_IMPLEMENT(Sheets,
"explicit/layout/style-sheet-cache",
KIND_HEAP,
nsIMemoryReporter::UNITS_BYTES,
GetStylesheetCacheSize,
"Memory used for some built-in style sheets.")
"explicit/layout/style-sheet-cache",
KIND_HEAP,
nsIMemoryReporter::UNITS_BYTES,
GetStylesheetCacheSize,
"Memory used for some built-in style sheets.")
NS_IMPL_ISUPPORTS1(nsLayoutStylesheetCache, nsIObserver)

View File

@ -137,8 +137,7 @@ public:
static
nsCacheService * GlobalInstance() { return gService; }
static
PRInt64 MemoryDeviceSize();
static PRInt64 MemoryDeviceSize();
static nsresult DoomEntry(nsCacheEntry * entry);

View File

@ -95,13 +95,12 @@ GetStartupCacheMappingSize()
}
NS_MEMORY_REPORTER_IMPLEMENT(StartupCacheMapping,
"explicit/startup-cache/mapping",
KIND_NONHEAP,
nsIMemoryReporter::UNITS_BYTES,
GetStartupCacheMappingSize,
"Memory used to hold the mapping of the startup "
"cache from file. This memory is likely to be "
"swapped out shortly after start-up.")
"explicit/startup-cache/mapping",
KIND_NONHEAP,
nsIMemoryReporter::UNITS_BYTES,
GetStartupCacheMappingSize,
"Memory used to hold the mapping of the startup cache from file. This "
"memory is likely to be swapped out shortly after start-up.")
NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(StartupCacheDataMallocSizeOf, "startup-cache/data")
@ -113,12 +112,11 @@ GetStartupCacheDataSize()
}
NS_MEMORY_REPORTER_IMPLEMENT(StartupCacheData,
"explicit/startup-cache/data",
KIND_HEAP,
nsIMemoryReporter::UNITS_BYTES,
GetStartupCacheDataSize,
"Memory used by the startup cache for things "
"other than the file mapping.")
"explicit/startup-cache/data",
KIND_HEAP,
nsIMemoryReporter::UNITS_BYTES,
GetStartupCacheDataSize,
"Memory used by the startup cache for things other than the file mapping.")
static const char sStartupCacheName[] = "startupCache." SC_WORDSIZE "." SC_ENDIAN;
static NS_DEFINE_CID(kZipReaderCID, NS_ZIPREADER_CID);

View File

@ -220,7 +220,7 @@ function processMemoryReporters(aMgr, aIgnoreSingle, aIgnoreMulti,
// gAssertionFailureMsgPrefix in their string representation.
//
// - We want to continue on when faced with exceptions thrown outside this
// file (i.e. in collectReports).
// file (e.g. within a multi-reporter).
let str = aE.toString();
if (str.search(gAssertionFailureMsgPrefix) >= 0) {

View File

@ -1434,18 +1434,17 @@ NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(HistoryLinksHashtableMallocSizeOf,
PRInt64 GetHistoryObserversSize()
{
History* history = History::GetService();
if (!history)
return 0;
return history->SizeOfIncludingThis(HistoryLinksHashtableMallocSizeOf);
return history ?
history->SizeOfIncludingThis(HistoryLinksHashtableMallocSizeOf) : 0;
}
NS_MEMORY_REPORTER_IMPLEMENT(HistoryService,
"explicit/history-links-hashtable",
KIND_HEAP,
UNITS_BYTES,
GetHistoryObserversSize,
"Memory used by the hashtable of observers Places uses to notify objects of "
"changes to links' visited state.")
"explicit/history-links-hashtable",
KIND_HEAP,
UNITS_BYTES,
GetHistoryObserversSize,
"Memory used by the hashtable of observers Places uses to notify objects of "
"changes to links' visited state.")
} // anonymous namespace

View File

@ -3284,7 +3284,7 @@ nsCycleCollector::WasFreed(nsISupports *n)
////////////////////////
static PRInt64
ReportCycleCollectorMem()
GetCycleCollectorSize()
{
if (!sCollector)
return 0;
@ -3300,7 +3300,7 @@ NS_MEMORY_REPORTER_IMPLEMENT(CycleCollector,
"explicit/cycle-collector",
KIND_HEAP,
UNITS_BYTES,
ReportCycleCollectorMem,
GetCycleCollectorSize,
"Memory used by the cycle collector. This "
"includes the cycle collector structure, the "
"purple buffer, the graph, and the white nodes. "

View File

@ -48,19 +48,6 @@
using namespace mozilla;
static PRInt64 GetExplicit()
{
nsCOMPtr<nsIMemoryReporterManager> mgr = do_GetService("@mozilla.org/memory-reporter-manager;1");
if (mgr == nsnull)
return (PRInt64)-1;
PRInt64 n;
nsresult rv = mgr->GetExplicit(&n);
NS_ENSURE_SUCCESS(rv, rv);
return n;
}
#if defined(MOZ_MEMORY)
# define HAVE_JEMALLOC_STATS 1
# include "jemalloc.h"
@ -73,24 +60,22 @@ static PRInt64 GetExplicit()
static PRInt64 GetHardPageFaults()
{
struct rusage usage;
int err = getrusage(RUSAGE_SELF, &usage);
if (err != 0) {
return PRInt64(-1);
}
return usage.ru_majflt;
struct rusage usage;
int err = getrusage(RUSAGE_SELF, &usage);
if (err != 0) {
return PRInt64(-1);
}
return usage.ru_majflt;
}
static PRInt64 GetSoftPageFaults()
{
struct rusage usage;
int err = getrusage(RUSAGE_SELF, &usage);
if (err != 0) {
return PRInt64(-1);
}
return usage.ru_minflt;
struct rusage usage;
int err = getrusage(RUSAGE_SELF, &usage);
if (err != 0) {
return PRInt64(-1);
}
return usage.ru_minflt;
}
#endif
@ -234,14 +219,25 @@ static PRInt64 GetResident()
static PRInt64 GetVsize()
{
MEMORYSTATUSEX s;
s.dwLength = sizeof(s);
MEMORYSTATUSEX s;
s.dwLength = sizeof(s);
bool success = GlobalMemoryStatusEx(&s);
if (!success)
return -1;
bool success = GlobalMemoryStatusEx(&s);
if (!success)
return -1;
return s.ullTotalVirtual - s.ullAvailVirtual;
return s.ullTotalVirtual - s.ullAvailVirtual;
}
static PRInt64 GetResident()
{
PROCESS_MEMORY_COUNTERS pmc;
pmc.cb = sizeof(PROCESS_MEMORY_COUNTERS);
if (!GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc)))
return (PRInt64) -1;
return pmc.WorkingSetSize;
}
static PRInt64 GetPrivate()
@ -265,17 +261,6 @@ NS_MEMORY_REPORTER_IMPLEMENT(Private,
"is committed and marked MEM_PRIVATE, data that is not mapped, and "
"executable pages that have been written to.")
static PRInt64 GetResident()
{
PROCESS_MEMORY_COUNTERS pmc;
pmc.cb = sizeof(PROCESS_MEMORY_COUNTERS);
if (!GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc)))
return (PRInt64) -1;
return pmc.WorkingSetSize;
}
#else
static PRInt64 GetResident()
@ -298,6 +283,18 @@ NS_MEMORY_REPORTER_IMPLEMENT(Vsize,
"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.")
NS_MEMORY_REPORTER_IMPLEMENT(Resident,
"resident",
KIND_OTHER,
UNITS_BYTES,
GetResident,
"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.")
#endif
#if defined(XP_LINUX) || defined(XP_MACOSX) || defined(SOLARIS)
@ -333,27 +330,6 @@ NS_MEMORY_REPORTER_IMPLEMENT(PageFaultsHard,
"so hard page faults a second.")
#endif
NS_MEMORY_REPORTER_IMPLEMENT(Explicit,
"explicit",
KIND_OTHER,
UNITS_BYTES,
GetExplicit,
"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_MEMORY_REPORTER_IMPLEMENT(Resident,
"resident",
KIND_OTHER,
UNITS_BYTES,
GetResident,
"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.")
/**
** memory reporter implementation for jemalloc and OSX malloc,
** to obtain info on total memory in use (that we know about,
@ -519,6 +495,28 @@ NS_MEMORY_REPORTER_IMPLEMENT(HeapAllocated,
"application because the allocator regularly rounds up request sizes. (The "
"exact amount requested is not recorded.)")
static PRInt64 GetExplicit()
{
nsCOMPtr<nsIMemoryReporterManager> mgr = do_GetService("@mozilla.org/memory-reporter-manager;1");
if (mgr == nsnull)
return (PRInt64)-1;
PRInt64 n;
nsresult rv = mgr->GetExplicit(&n);
NS_ENSURE_SUCCESS(rv, rv);
return n;
}
NS_MEMORY_REPORTER_IMPLEMENT(Explicit,
"explicit",
KIND_OTHER,
UNITS_BYTES,
GetExplicit,
"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_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(AtomTableMallocSizeOf, "atom-table")
static PRInt64 GetAtomTableSize() {