summaryrefslogtreecommitdiffstats
path: root/xpcom/base
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-05-31 09:45:25 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-05-31 09:45:25 +0200
commit2d4ff8df91414b42974c72b2870f5c6e9ad397a8 (patch)
tree15b23dc6494a147e723cfdb3765be1568cf6c113 /xpcom/base
parentf4b8be889cb7ee31a62af5660f36aaa192599009 (diff)
parent14eb8dc7bee8670e39d1199591d335579601f2ad (diff)
downloadUXP-2d4ff8df91414b42974c72b2870f5c6e9ad397a8.tar
UXP-2d4ff8df91414b42974c72b2870f5c6e9ad397a8.tar.gz
UXP-2d4ff8df91414b42974c72b2870f5c6e9ad397a8.tar.lz
UXP-2d4ff8df91414b42974c72b2870f5c6e9ad397a8.tar.xz
UXP-2d4ff8df91414b42974c72b2870f5c6e9ad397a8.zip
Merge branch 'master' into Basilisk-release
Diffstat (limited to 'xpcom/base')
-rw-r--r--xpcom/base/nsIMemoryReporter.idl21
-rw-r--r--xpcom/base/nsMemoryInfoDumper.cpp62
-rw-r--r--xpcom/base/nsMemoryInfoDumper.h9
-rw-r--r--xpcom/base/nsMemoryReporterManager.cpp132
-rw-r--r--xpcom/base/nsTraceRefcnt.cpp42
5 files changed, 3 insertions, 263 deletions
diff --git a/xpcom/base/nsIMemoryReporter.idl b/xpcom/base/nsIMemoryReporter.idl
index 9617877df..babfa646f 100644
--- a/xpcom/base/nsIMemoryReporter.idl
+++ b/xpcom/base/nsIMemoryReporter.idl
@@ -405,13 +405,6 @@ interface nsIMemoryReporterManager : nsISupports
[infallible] readonly attribute boolean hasMozMallocUsableSize;
/*
- * These attributes indicate DMD's status. "Enabled" means enabled at
- * build-time.
- */
- [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.
@@ -519,23 +512,9 @@ nsresult RegisterNonJSSizeOfTab(NonJSSizeOfTabFn aSizeOfTabFn);
}
-#if defined(MOZ_DMD)
-#if !defined(MOZ_MEMORY)
-#error "MOZ_DMD requires MOZ_MEMORY"
-#endif
-
-#include "DMD.h"
-
-#define MOZ_REPORT(ptr) mozilla::dmd::Report(ptr)
-#define MOZ_REPORT_ON_ALLOC(ptr) mozilla::dmd::ReportOnAlloc(ptr)
-
-#else
-
#define MOZ_REPORT(ptr)
#define MOZ_REPORT_ON_ALLOC(ptr)
-#endif // defined(MOZ_DMD)
-
// Functions generated via this macro should be used by all traversal-based
// memory reporters. Such functions return |moz_malloc_size_of(ptr)|; this
// will always be zero on some obscure platforms.
diff --git a/xpcom/base/nsMemoryInfoDumper.cpp b/xpcom/base/nsMemoryInfoDumper.cpp
index 06453b126..afb18382d 100644
--- a/xpcom/base/nsMemoryInfoDumper.cpp
+++ b/xpcom/base/nsMemoryInfoDumper.cpp
@@ -766,65 +766,3 @@ nsMemoryInfoDumper::DumpMemoryInfoToTempDir(const nsAString& aIdentifier,
aAnonymize, aMinimizeMemoryUsage, identifier);
}
-#ifdef MOZ_DMD
-dmd::DMDFuncs::Singleton dmd::DMDFuncs::sSingleton;
-
-nsresult
-nsMemoryInfoDumper::OpenDMDFile(const nsAString& aIdentifier, int aPid,
- FILE** aOutFile)
-{
- if (!dmd::IsRunning()) {
- *aOutFile = nullptr;
- return NS_OK;
- }
-
- // Create a filename like dmd-<identifier>-<pid>.json.gz, which will be used
- // if DMD is enabled.
- nsCString dmdFilename;
- MakeFilename("dmd", aIdentifier, aPid, "json.gz", dmdFilename);
-
- // Open a new DMD file named |dmdFilename| in NS_OS_TEMP_DIR for writing,
- // and dump DMD output to it. This must occur after the memory reporters
- // have been run (above), but before the memory-reports file has been
- // renamed (so scripts can detect the DMD file, if present).
-
- nsresult rv;
- nsCOMPtr<nsIFile> dmdFile;
- rv = nsDumpUtils::OpenTempFile(dmdFilename,
- getter_AddRefs(dmdFile),
- NS_LITERAL_CSTRING("memory-reports"));
- if (NS_WARN_IF(NS_FAILED(rv))) {
- return rv;
- }
- rv = dmdFile->OpenANSIFileDesc("wb", aOutFile);
- NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "OpenANSIFileDesc failed");
-
- // Print the path, because on some platforms (e.g. Mac) it's not obvious.
- nsCString path;
- rv = dmdFile->GetNativePath(path);
- if (NS_WARN_IF(NS_FAILED(rv))) {
- return rv;
- }
- dmd::StatusMsg("opened %s for writing\n", path.get());
-
- return rv;
-}
-
-nsresult
-nsMemoryInfoDumper::DumpDMDToFile(FILE* aFile)
-{
- RefPtr<nsGZFileWriter> gzWriter = new nsGZFileWriter();
- nsresult rv = gzWriter->InitANSIFileDesc(aFile);
- if (NS_WARN_IF(NS_FAILED(rv))) {
- return rv;
- }
-
- // Dump DMD's memory reports analysis to the file.
- dmd::Analyze(MakeUnique<GZWriterWrapper>(gzWriter));
-
- rv = gzWriter->Finish();
- NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "Finish failed");
- return rv;
-}
-#endif // MOZ_DMD
-
diff --git a/xpcom/base/nsMemoryInfoDumper.h b/xpcom/base/nsMemoryInfoDumper.h
index 6bba176f2..281bb3e51 100644
--- a/xpcom/base/nsMemoryInfoDumper.h
+++ b/xpcom/base/nsMemoryInfoDumper.h
@@ -28,15 +28,6 @@ public:
nsMemoryInfoDumper();
static void Initialize();
-
-#ifdef MOZ_DMD
- // Open an appropriately named file for a DMD report. If DMD is
- // disabled, return a null FILE* instead.
- static nsresult OpenDMDFile(const nsAString& aIdentifier, int aPid,
- FILE** aOutFile);
- // Write a DMD report to the given file and close it.
- static nsresult DumpDMDToFile(FILE* aFile);
-#endif
};
#define NS_MEMORY_INFO_DUMPER_CID \
diff --git a/xpcom/base/nsMemoryReporterManager.cpp b/xpcom/base/nsMemoryReporterManager.cpp
index 7c62e2af5..2d4f3fa9c 100644
--- a/xpcom/base/nsMemoryReporterManager.cpp
+++ b/xpcom/base/nsMemoryReporterManager.cpp
@@ -17,7 +17,7 @@
#include "nsIObserverService.h"
#include "nsIGlobalObject.h"
#include "nsIXPConnect.h"
-#if defined(XP_UNIX) || defined(MOZ_DMD)
+#if defined(XP_UNIX)
#include "nsMemoryInfoDumper.h"
#endif
#include "mozilla/Attributes.h"
@@ -1425,62 +1425,6 @@ NS_IMPL_ISUPPORTS(DeadlockDetectorReporter, nsIMemoryReporter)
#endif
-#ifdef MOZ_DMD
-
-namespace mozilla {
-namespace dmd {
-
-class DMDReporter final : public nsIMemoryReporter
-{
-public:
- NS_DECL_ISUPPORTS
-
- NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport,
- nsISupports* aData, bool aAnonymize) override
- {
- dmd::Sizes sizes;
- dmd::SizeOf(&sizes);
-
- 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)
-
-} // namespace dmd
-} // namespace mozilla
-
-#endif // MOZ_DMD
-
/**
** nsMemoryReporterManager implementation
**/
@@ -1560,10 +1504,6 @@ nsMemoryReporterManager::Init()
RegisterStrongReporter(new DeadlockDetectorReporter());
#endif
-#ifdef MOZ_DMD
- RegisterStrongReporter(new mozilla::dmd::DMDReporter());
-#endif
-
#ifdef XP_WIN
RegisterStrongReporter(new WindowsAddressSpaceReporter());
#endif
@@ -1679,22 +1619,9 @@ nsMemoryReporterManager::StartGettingReports()
PendingProcessesState* s = mPendingProcessesState;
nsresult rv;
- // Get reports for this process.
- FILE* parentDMDFile = nullptr;
-#ifdef MOZ_DMD
- if (!s->mDMDDumpIdent.IsEmpty()) {
- rv = nsMemoryInfoDumper::OpenDMDFile(s->mDMDDumpIdent, getpid(),
- &parentDMDFile);
- if (NS_WARN_IF(NS_FAILED(rv))) {
- // Proceed with the memory report as if DMD were disabled.
- parentDMDFile = nullptr;
- }
- }
-#endif
-
// This is async.
GetReportsForThisProcessExtended(s->mHandleReport, s->mHandleReportData,
- s->mAnonymize, parentDMDFile,
+ s->mAnonymize, nullptr,
s->mFinishReporting, s->mFinishReportingData);
nsTArray<ContentParent*> childWeakRefs;
@@ -1775,16 +1702,6 @@ nsMemoryReporterManager::GetReportsForThisProcessExtended(
return NS_ERROR_IN_PROGRESS;
}
-#ifdef MOZ_DMD
- if (aDMDFile) {
- // Clear DMD's reportedness state before running the memory
- // reporters, to avoid spurious twice-reported warnings.
- dmd::ClearReports();
- }
-#else
- MOZ_ASSERT(!aDMDFile);
-#endif
-
mPendingReportersState = new PendingReportersState(
aFinishReporting, aFinishReportingData, aDMDFile);
@@ -1810,11 +1727,6 @@ NS_IMETHODIMP
nsMemoryReporterManager::EndReport()
{
if (--mPendingReportersState->mReportsPending == 0) {
-#ifdef MOZ_DMD
- if (mPendingReportersState->mDMDFile) {
- nsMemoryInfoDumper::DumpDMDToFile(mPendingReportersState->mDMDFile);
- }
-#endif
if (mPendingProcessesState) {
// This is the parent process.
EndProcessReport(mPendingProcessesState->mGeneration, true);
@@ -1902,24 +1814,8 @@ nsMemoryReporterManager::StartChildReport(mozilla::dom::ContentParent* aChild,
return false;
}
- mozilla::dom::MaybeFileDesc dmdFileDesc = void_t();
-#ifdef MOZ_DMD
- if (!aState->mDMDDumpIdent.IsEmpty()) {
- FILE *dmdFile = nullptr;
- nsresult rv = nsMemoryInfoDumper::OpenDMDFile(aState->mDMDDumpIdent,
- aChild->Pid(), &dmdFile);
- if (NS_WARN_IF(NS_FAILED(rv))) {
- // Proceed with the memory report as if DMD were disabled.
- dmdFile = nullptr;
- }
- if (dmdFile) {
- dmdFileDesc = mozilla::ipc::FILEToFileDescriptor(dmdFile);
- fclose(dmdFile);
- }
- }
-#endif
return aChild->SendPMemoryReportRequestConstructor(
- aState->mGeneration, aState->mAnonymize, aState->mMinimize, dmdFileDesc);
+ aState->mGeneration, aState->mAnonymize, aState->mMinimize, void_t());
}
void
@@ -2452,28 +2348,6 @@ nsMemoryReporterManager::GetHasMozMallocUsableSize(bool* aHas)
return NS_OK;
}
-NS_IMETHODIMP
-nsMemoryReporterManager::GetIsDMDEnabled(bool* aIsEnabled)
-{
-#ifdef MOZ_DMD
- *aIsEnabled = true;
-#else
- *aIsEnabled = false;
-#endif
- return NS_OK;
-}
-
-NS_IMETHODIMP
-nsMemoryReporterManager::GetIsDMDRunning(bool* aIsRunning)
-{
-#ifdef MOZ_DMD
- *aIsRunning = dmd::IsRunning();
-#else
- *aIsRunning = false;
-#endif
- return NS_OK;
-}
-
namespace {
/**
diff --git a/xpcom/base/nsTraceRefcnt.cpp b/xpcom/base/nsTraceRefcnt.cpp
index 3b415174b..da51305a9 100644
--- a/xpcom/base/nsTraceRefcnt.cpp
+++ b/xpcom/base/nsTraceRefcnt.cpp
@@ -42,11 +42,6 @@
#include <dlfcn.h>
#endif
-#ifdef MOZ_DMD
-#include "base/process_util.h"
-#include "nsMemoryInfoDumper.h"
-#endif
-
////////////////////////////////////////////////////////////////////////////////
#include "plhash.h"
@@ -936,39 +931,6 @@ NS_LogTerm()
mozilla::LogTerm();
}
-#ifdef MOZ_DMD
-// If MOZ_DMD_SHUTDOWN_LOG is set, dump a DMD report to a file.
-// The value of this environment variable is used as the prefix
-// of the file name, so you probably want something like "/tmp/".
-// By default, this is run in all processes, but you can record a
-// log only for a specific process type by setting MOZ_DMD_LOG_PROCESS
-// to the process type you want to log, such as "default" or "tab".
-// This method can't use the higher level XPCOM file utilities
-// because it is run very late in shutdown to avoid recording
-// information about refcount logging entries.
-static void
-LogDMDFile()
-{
- const char* dmdFilePrefix = PR_GetEnv("MOZ_DMD_SHUTDOWN_LOG");
- if (!dmdFilePrefix) {
- return;
- }
-
- const char* logProcessEnv = PR_GetEnv("MOZ_DMD_LOG_PROCESS");
- if (logProcessEnv && !!strcmp(logProcessEnv, XRE_ChildProcessTypeToString(XRE_GetProcessType()))) {
- return;
- }
-
- nsPrintfCString fileName("%sdmd-%d.log.gz", dmdFilePrefix, base::GetCurrentProcId());
- FILE* logFile = fopen(fileName.get(), "w");
- if (NS_WARN_IF(!logFile)) {
- return;
- }
-
- nsMemoryInfoDumper::DumpDMDToFile(logFile);
-}
-#endif // MOZ_DMD
-
namespace mozilla {
void
LogTerm()
@@ -1000,10 +962,6 @@ LogTerm()
nsTraceRefcnt::Shutdown();
nsTraceRefcnt::SetActivityIsLegal(false);
gActivityTLS = BAD_TLS_INDEX;
-
-#ifdef MOZ_DMD
- LogDMDFile();
-#endif
}
}