Bug 945046 - Implement private and vsize-max-contiguous reporters on FreeBSD. r=njn, r=glandium
authorJan Beich <jbeich@tormail.org>
Mon, 02 Dec 2013 12:51:27 -0500
changeset 173973 cb5d23080c7012b83282cf01f8dd3ed8ed187bf6
parent 173972 3d407295139eebef15a630dbd9dd8e14670aa26d
child 173974 07e357311cf304e2b55d78f4af0fa03a05a3e637
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn, glandium
bugs945046
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 945046 - Implement private and vsize-max-contiguous reporters on FreeBSD. r=njn, r=glandium
config/system-headers
js/src/config/system-headers
toolkit/library/Makefile.in
xpcom/base/nsMemoryReporterManager.cpp
--- a/config/system-headers
+++ b/config/system-headers
@@ -1126,8 +1126,9 @@ unicode/uclean.h
 unicode/ucol.h
 unicode/udat.h
 unicode/udatpg.h
 unicode/uenum.h
 unicode/unum.h
 unicode/ustring.h
 unicode/utypes.h
 #endif
+libutil.h
--- a/js/src/config/system-headers
+++ b/js/src/config/system-headers
@@ -1126,8 +1126,9 @@ unicode/uclean.h
 unicode/ucol.h
 unicode/udat.h
 unicode/udatpg.h
 unicode/uenum.h
 unicode/unum.h
 unicode/ustring.h
 unicode/utypes.h
 #endif
+libutil.h
--- a/toolkit/library/Makefile.in
+++ b/toolkit/library/Makefile.in
@@ -284,16 +284,20 @@ endif
 endif
 
 ifneq (,$(filter DragonFly FreeBSD NetBSD OpenBSD,$(OS_ARCH)))
 OS_LIBS += $(call EXPAND_LIBNAME,kvm)
 # keep `environ' unresolved, see bug 14426 for binutils
 EXTRA_DSO_LDOPTS += -Wl,--warn-unresolved-symbols
 endif
 
+ifeq ($(OS_ARCH),FreeBSD)
+OS_LIBS += $(call EXPAND_LIBNAME,util)
+endif
+
 ifeq ($(OS_ARCH),WINNT)
 OS_LIBS += $(call EXPAND_LIBNAME,shell32 ole32 version winspool comdlg32 imm32 msimg32 shlwapi psapi ws2_32 dbghelp rasapi32 rasdlg iphlpapi uxtheme setupapi secur32 sensorsapi portabledeviceguids windowscodecs wininet wbemuuid)
 ifdef ACCESSIBILITY
 OS_LIBS += $(call EXPAND_LIBNAME,oleacc)
 endif
 ifdef MOZ_METRO
 OS_LIBS += $(call EXPAND_LIBNAME,uiautomationcore runtimeobject)
 endif
--- a/xpcom/base/nsMemoryReporterManager.cpp
+++ b/xpcom/base/nsMemoryReporterManager.cpp
@@ -199,16 +199,70 @@ ResidentDistinguishedAmount(int64_t* aN)
 }
 
 static nsresult
 ResidentFastDistinguishedAmount(int64_t* aN)
 {
     return ResidentDistinguishedAmount(aN);
 }
 
+#ifdef __FreeBSD__
+#include <libutil.h>
+
+static nsresult
+GetKinfoVmentrySelf(int64_t* prss, uint64_t* maxreg)
+{
+    int cnt;
+    struct kinfo_vmentry *vmmap, *kve;
+    if ((vmmap = kinfo_getvmmap(getpid(), &cnt)) == NULL)
+        return NS_ERROR_FAILURE;
+
+    if (prss)
+        *prss = 0;
+    if (maxreg)
+        *maxreg = 0;
+
+    for (int i = 0; i < cnt; i++) {
+        kve = &vmmap[i];
+        if (prss)
+            *prss += kve->kve_private_resident;
+        if (maxreg)
+            *maxreg = std::max(*maxreg,
+                               kve->kve_end - kve->kve_start);
+    }
+
+    free(vmmap);
+    return NS_OK;
+}
+
+#define HAVE_PRIVATE_REPORTER
+static nsresult
+PrivateDistinguishedAmount(int64_t* aN)
+{
+    int64_t priv;
+    nsresult rv = GetKinfoVmentrySelf(&priv, NULL);
+    if (NS_SUCCEEDED(rv))
+        *aN = priv * getpagesize();
+
+    return NS_OK;
+}
+
+#define HAVE_VSIZE_MAX_CONTIGUOUS_REPORTER 1
+static nsresult
+VsizeMaxContiguousDistinguishedAmount(int64_t* aN)
+{
+    uint64_t biggestRegion;
+    nsresult rv = GetKinfoVmentrySelf(NULL, &biggestRegion);
+    if (NS_SUCCEEDED(rv))
+        *aN = biggestRegion;
+
+    return NS_OK;
+}
+#endif // FreeBSD
+
 #elif defined(SOLARIS)
 
 #include <procfs.h>
 #include <fcntl.h>
 #include <unistd.h>
 
 static void XMappingIter(int64_t& vsize, int64_t& resident)
 {