Bug 1061066 - Make DMD work properly with e10s. r=mccr8.

--HG--
extra : rebase_source : 35ff4f1b3c7d4af91cbc5f813030136ffc3b70e4
This commit is contained in:
Nicholas Nethercote 2014-09-01 17:22:53 -07:00
parent c1eda789ba
commit a0fab2e233
2 changed files with 18 additions and 143 deletions

View File

@ -1396,105 +1396,6 @@ static const JSFunctionSpec TraceMallocFunctions[] = {
#endif /* NS_TRACE_MALLOC */
#ifdef MOZ_DMD
#include <errno.h>
namespace mozilla {
namespace dmd {
// See https://wiki.mozilla.org/Performance/MemShrink/DMD for instructions on
// how to use DMD.
static FILE *
OpenDMDOutputFile(JSContext *cx, JS::CallArgs &args)
{
JSString *str = JS::ToString(cx, args.get(0));
if (!str)
return nullptr;
JSAutoByteString pathname(cx, str);
if (!pathname)
return nullptr;
FILE* fp = fopen(pathname.ptr(), "w");
if (!fp) {
JS_ReportError(cx, "DMD can't open %s: %s",
pathname.ptr(), strerror(errno));
return nullptr;
}
return fp;
}
static bool
AnalyzeReports(JSContext *cx, unsigned argc, JS::Value *vp)
{
if (!dmd::IsRunning()) {
JS_ReportError(cx, "DMD is not running");
return false;
}
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
FILE *fp = OpenDMDOutputFile(cx, args);
if (!fp) {
return false;
}
dmd::ClearReports();
dmd::RunReportersForThisProcess();
dmd::Writer writer(FpWrite, fp);
dmd::AnalyzeReports(writer);
fclose(fp);
args.rval().setUndefined();
return true;
}
// This will be removed eventually.
static bool
ReportAndDump(JSContext *cx, unsigned argc, JS::Value *vp)
{
JS_ReportWarning(cx, "DMDReportAndDump() is deprecated; "
"please use DMDAnalyzeReports() instead");
return AnalyzeReports(cx, argc, vp);
}
static bool
AnalyzeHeap(JSContext *cx, unsigned argc, JS::Value *vp)
{
if (!dmd::IsRunning()) {
JS_ReportError(cx, "DMD is not running");
return false;
}
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
FILE *fp = OpenDMDOutputFile(cx, args);
if (!fp) {
return false;
}
dmd::Writer writer(FpWrite, fp);
dmd::AnalyzeHeap(writer);
fclose(fp);
args.rval().setUndefined();
return true;
}
} // namespace dmd
} // namespace mozilla
static const JSFunctionSpec DMDFunctions[] = {
JS_FS("DMDReportAndDump", dmd::ReportAndDump, 1, 0),
JS_FS("DMDAnalyzeReports", dmd::AnalyzeReports, 1, 0),
JS_FS("DMDAnalyzeHeap", dmd::AnalyzeHeap, 1, 0),
JS_FS_END
};
#endif // defined(MOZ_DMD)
#ifdef MOZ_JPROF
#include <signal.h>
@ -1618,13 +1519,6 @@ nsJSContext::InitClasses(JS::Handle<JSObject*> aGlobalObj)
}
#endif
#ifdef MOZ_DMD
if (nsContentUtils::IsCallerChrome()) {
// Attempt to initialize DMD functions
::JS_DefineFunctions(cx, aGlobalObj, DMDFunctions);
}
#endif
#ifdef MOZ_JPROF
// Attempt to initialize JProf functions
::JS_DefineFunctions(cx, aGlobalObj, JProfFunctions);

View File

@ -53,9 +53,6 @@ const gUnnamedProcessStr = "Main Process";
let gIsDiff = false;
const gAnalyzeReportsFile = "reports.dmd";
const gAnalyzeHeapFile = "heap.dmd";
//---------------------------------------------------------------------------
// Forward slashes in URLs in paths are represented with backslashes to avoid
@ -299,10 +296,8 @@ function onLoad()
"collection log.\n" +
"WARNING: These logs may be large (>1GB).";
const AnalyzeReportsDesc = "Analyze memory reports coverage and save the " +
"output to '" + gAnalyzeReportsFile + "'.\n";
const AnalyzeHeapDesc = "Analyze heap usage and save the output to '" +
gAnalyzeHeapFile + "'.\n";
const DMDEnabledDesc = "Analyze memory reports coverage and save the " +
"output to the temp directory.\n";
const DMDDisabledDesc = "DMD is not running. Please re-start with $DMD and " +
"the other relevant environment variables set " +
"appropriately.";
@ -364,20 +359,13 @@ function onLoad()
if (gMgr.isDMDEnabled) {
let row5 = appendElement(ops, "div", "opsRow");
appendElementWithText(row5, "div", "opsRowLabel", "DMD operations");
appendElementWithText(row5, "div", "opsRowLabel", "Save DMD output");
let enableButtons = gMgr.isDMDRunning;
let analyzeReportsButton =
appendButton(row5,
enableButtons ? AnalyzeReportsDesc : DMDDisabledDesc,
doAnalyzeReports, "Analyze reports");
analyzeReportsButton.disabled = !enableButtons;
let analyzeHeapButton =
appendButton(row5,
enableButtons ? AnalyzeHeapDesc : DMDDisabledDesc,
doAnalyzeHeap, "Analyze heap");
analyzeHeapButton.disabled = !enableButtons;
let dmdButton =
appendButton(row5, enableButtons ? DMDEnabledDesc : DMDDisabledDesc,
doDMD, "Save");
dmdButton.disabled = !enableButtons;
}
// Generate the main div, where content ("section" divs) will go. It's
@ -458,24 +446,19 @@ function saveGCLogAndVerboseCCLog()
dumpGCLogAndCCLog(true);
}
function doAnalyzeReports()
function doDMD()
{
updateMainAndFooter('Saving DMD output...', HIDE_FOOTER);
updateMainAndFooter("Saving memory reports and DMD output...", HIDE_FOOTER);
try {
let x = DMDAnalyzeReports(gAnalyzeReportsFile);
updateMainAndFooter('Saved DMD output to ' + gAnalyzeReportsFile,
HIDE_FOOTER);
} catch (ex) {
updateMainAndFooter(ex.toString(), HIDE_FOOTER);
}
}
let dumper = Cc["@mozilla.org/memory-info-dumper;1"]
.getService(Ci.nsIMemoryInfoDumper);
function doAnalyzeHeap()
{
updateMainAndFooter('Saving DMD output...', HIDE_FOOTER);
try {
let x = DMDAnalyzeHeap(gAnalyzeHeapFile);
updateMainAndFooter('Saved DMD output to ' + gAnalyzeHeapFile, HIDE_FOOTER);
dumper.dumpMemoryInfoToTempDir(/* identifier = */ "",
gAnonymize.checked,
/* minimize = */ false);
updateMainAndFooter("Saved memory reports and DMD reports analysis " +
"to the temp directory",
HIDE_FOOTER);
} catch (ex) {
updateMainAndFooter(ex.toString(), HIDE_FOOTER);
}
@ -1995,11 +1978,9 @@ function saveReportsToFile()
let fpFinish = function(file) {
let dumper = Cc["@mozilla.org/memory-info-dumper;1"]
.getService(Ci.nsIMemoryInfoDumper);
let finishDumping = () => {
updateMainAndFooter("Saved reports to " + file.path, HIDE_FOOTER);
updateMainAndFooter("Saved memory reports to " + file.path, HIDE_FOOTER);
}
dumper.dumpMemoryReportsToNamedFile(file.path, finishDumping, null,
gAnonymize.checked);
}