Bug 800703 - Rename the existing, Valgrind-based DMD as "DMDV". r=khuey.

--HG--
rename : xpcom/base/dmd.h => tools/dmdv/dmdv.h
This commit is contained in:
Nicholas Nethercote 2012-10-08 15:31:17 -07:00
parent fb79803e35
commit e37c1e657a
11 changed files with 2134 additions and 69 deletions

View File

@ -1675,18 +1675,19 @@ fi
AC_SUBST(MOZ_VALGRIND)
dnl ========================================================
dnl = Use DMD
dnl = Enable DMDV
dnl ========================================================
MOZ_ARG_ENABLE_BOOL(dmd,
[ --enable-dmd Enable DMD; also disables jemalloc (default=no)],
MOZ_DMD=1,
MOZ_DMD= )
if test -n "$MOZ_DMD"; then
MOZ_ARG_ENABLE_BOOL(dmdv,
[ --enable-dmdv Enable DMDV; also disables jemalloc (default=no)],
MOZ_DMDV=1,
MOZ_DMDV= )
if test -n "$MOZ_DMDV"; then
MOZ_CHECK_HEADER([valgrind/valgrind.h], [],
AC_MSG_ERROR(
[--enable-dmd specified but Valgrind is not installed]))
AC_DEFINE(MOZ_DMD)
[--enable-dmdv specified but Valgrind is not installed]))
AC_DEFINE(MOZ_DMDV)
fi
AC_SUBST(MOZ_DMDV)
dnl ========================================================
dnl jprof
@ -6978,7 +6979,7 @@ MOZ_ARG_ENABLE_BOOL(jemalloc,
if test "$NS_TRACE_MALLOC"; then
MOZ_MEMORY=
fi
if test "$MOZ_DMD"; then
if test "$MOZ_DMDV"; then
MOZ_MEMORY=
fi

View File

@ -2719,24 +2719,24 @@ static JSFunctionSpec JProfFunctions[] = {
#endif /* defined(MOZ_JPROF) */
#ifdef MOZ_DMD
#ifdef MOZ_DMDV
// See https://wiki.mozilla.org/Performance/MemShrink/DMD for instructions on
// how to use DMD.
// how to use DMDV.
static JSBool
DMDCheckJS(JSContext *cx, unsigned argc, jsval *vp)
DMDVCheckAndDumpJS(JSContext *cx, unsigned argc, jsval *vp)
{
mozilla::DMDCheckAndDump();
mozilla::DMDVCheckAndDump();
return JS_TRUE;
}
static JSFunctionSpec DMDFunctions[] = {
JS_FS("DMD", DMDCheckJS, 0, 0),
static JSFunctionSpec DMDVFunctions[] = {
JS_FS("DMDV", DMDVCheckAndDumpJS, 0, 0),
JS_FS_END
};
#endif /* defined(MOZ_DMD) */
#endif /* defined(MOZ_DMDV) */
nsresult
nsJSContext::InitClasses(JSObject* aGlobalObj)
@ -2761,9 +2761,9 @@ nsJSContext::InitClasses(JSObject* aGlobalObj)
::JS_DefineFunctions(mContext, aGlobalObj, JProfFunctions);
#endif
#ifdef MOZ_DMD
// Attempt to initialize DMD functions
::JS_DefineFunctions(mContext, aGlobalObj, DMDFunctions);
#ifdef MOZ_DMDV
// Attempt to initialize DMDV functions
::JS_DefineFunctions(mContext, aGlobalObj, DMDVFunctions);
#endif
return rv;

View File

@ -1586,6 +1586,12 @@ if [ ! "$MOZ_NATIVE_PNG" ]; then
"
fi
if [ "$MOZ_DMDV" ]; then
add_makefiles "
tools/dmdv/Makefile
"
fi
if [ "$MOZ_JPROF" ]; then
add_makefiles "
tools/jprof/Makefile

View File

@ -19,6 +19,11 @@ ifdef MOZ_TREE_FREETYPE
tier_platform_staticdirs += modules/freetype2
endif
# this must precede xpcom
ifdef MOZ_DMDV
tier_platform_dirs += tools/dmdv
endif
tier_platform_dirs += xpcom
tier_platform_dirs += \
@ -206,7 +211,7 @@ endif
tier_platform_dirs += profile
# This must preceed xpfe
# This must precede xpfe
ifdef MOZ_JPROF
tier_platform_dirs += tools/jprof
endif

18
tools/dmdv/Makefile.in Normal file
View File

@ -0,0 +1,18 @@
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DEPTH = @DEPTH@
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
EXPORTS = \
dmdv.h \
$(NULL)
include $(topsrcdir)/config/config.mk
include $(topsrcdir)/config/rules.mk

4
tools/dmdv/README Normal file
View File

@ -0,0 +1,4 @@
dmdv.patch is a patch for Valgrind that adds DMDV to it. See
https://wiki.mozilla.org/Performance/MemShrink/DMD for details.
dmdv.h is #include by Firefox, to allow it to interact with DMDV.

View File

@ -1,6 +1,6 @@
/*
----------------------------------------------------------------
The following BSD-style license applies to this one file (dmd.h) only.
The following BSD-style license applies to this one file (dmdv.h) only.
----------------------------------------------------------------
The Initial Developer of the Original Code is
@ -18,16 +18,16 @@
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product
2. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
3. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
4. The name of the author may not be used to endorse or promote
products derived from this software without specific prior written
4. The name of the author may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
@ -43,40 +43,40 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __DMD_H
#define __DMD_H
#ifndef __DMDV_H
#define __DMDV_H
#include "valgrind/valgrind.h"
/* !! ABIWARNING !! ABIWARNING !! ABIWARNING !! ABIWARNING !!
/* !! ABIWARNING !! ABIWARNING !! ABIWARNING !! ABIWARNING !!
This enum comprises an ABI exported by Valgrind to programs
which use client requests. DO NOT CHANGE THE ORDER OF THESE
ENTRIES, NOR DELETE ANY -- add new ones at the end. */
typedef
enum {
VG_USERREQ__DMD_REPORT = VG_USERREQ_TOOL_BASE('D','M'),
VG_USERREQ__DMD_UNREPORT,
VG_USERREQ__DMD_CHECK_REPORTING
} Vg_DMDClientRequest;
enum {
VG_USERREQ__DMDV_REPORT = VG_USERREQ_TOOL_BASE('D','M'),
VG_USERREQ__DMDV_UNREPORT,
VG_USERREQ__DMDV_CHECK_REPORTING
} Vg_DMDVClientRequest;
/* Mark heap block at _qzz_addr as reported for _qzz_len bytes.
* _qzz_name is the name of the reporter. */
#define VALGRIND_DMD_REPORT(_qzz_addr,_qzz_len,_qzz_name) \
#define VALGRIND_DMDV_REPORT(_qzz_addr,_qzz_len,_qzz_name) \
VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */, \
VG_USERREQ__DMD_REPORT, \
VG_USERREQ__DMDV_REPORT, \
(_qzz_addr), (_qzz_len), (_qzz_name), 0, 0)
/* Mark heap block at _qzz_addr as not reported. */
#define VALGRIND_DMD_UNREPORT(_qzz_addr) \
#define VALGRIND_DMDV_UNREPORT(_qzz_addr) \
VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */, \
VG_USERREQ__DMD_UNREPORT, \
VG_USERREQ__DMDV_UNREPORT, \
(_qzz_addr), 0, 0, 0, 0)
/* Do a reporting check. */
#define VALGRIND_DMD_CHECK_REPORTING \
#define VALGRIND_DMDV_CHECK_REPORTING \
VALGRIND_DO_CLIENT_REQUEST_EXPR(0 /* default return */, \
VG_USERREQ__DMD_CHECK_REPORTING, \
VG_USERREQ__DMDV_CHECK_REPORTING, \
0, 0, 0, 0, 0)
#endif

2032
tools/dmdv/dmdv.patch Normal file

File diff suppressed because it is too large Load Diff

View File

@ -64,7 +64,6 @@ EXPORTS = \
nsTraceRefcntImpl.h \
nsWeakPtr.h \
nsInterfaceRequestorAgg.h \
dmd.h \
nsGZFileWriter.h \
$(NULL)

View File

@ -450,14 +450,14 @@ nsresult NS_RegisterMemoryMultiReporter(nsIMemoryMultiReporter *reporter);
nsresult NS_UnregisterMemoryReporter(nsIMemoryReporter *reporter);
nsresult NS_UnregisterMemoryMultiReporter(nsIMemoryMultiReporter *reporter);
// Because DMD is not a tool that comes with the standard Valgrind
// distribution, we have to #include our own local copy of dmd.h. Ugly but
// Because DMDV is not a tool that comes with the standard Valgrind
// distribution, we have to #include our own local copy of dmdv.h. Ugly but
// unavoidable.
#ifdef MOZ_DMD
#ifdef MOZ_DMDV
#if MOZ_MEMORY
#error "--disable-jemalloc should have been forced when --enable-dmd was specified"
#error "--disable-jemalloc should have been forced when --enable-dmdv was specified"
#endif
#include "dmd.h"
#include "dmdv.h"
#endif
namespace mozilla {
@ -469,7 +469,7 @@ namespace mozilla {
*
* You might be wondering why we have a macro that creates multiple functions
* distinguished only by |name|, instead of a single MemoryReporterMallocSizeOf
* function. It's mostly to help with DMD integration, though it sometimes
* function. It's mostly to help with DMDV integration, though it sometimes
* also helps with debugging and temporary ad hoc profiling. The |name| chosen
* doesn't matter greatly, but it's best to make it similar to the path used by
* the relevant memory reporter(s).
@ -478,38 +478,38 @@ namespace mozilla {
static size_t fn(const void *ptr) \
{ \
size_t usable = moz_malloc_size_of(ptr); \
VALGRIND_DMD_REPORT(ptr, usable, name); \
VALGRIND_DMDV_REPORT(ptr, usable, name); \
return usable; \
}
/*
* Like NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN, but the created function sends an
* "unreport" message to DMD.
* "unreport" message to DMDV.
*/
#define NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN_UN(fn) \
static size_t fn(const void *ptr) \
{ \
size_t usable = moz_malloc_size_of(ptr); \
VALGRIND_DMD_UNREPORT(ptr); \
VALGRIND_DMDV_UNREPORT(ptr); \
return usable; \
}
#ifdef MOZ_DMD
#ifdef MOZ_DMDV
/*
* This runs all the memory reporters but does nothing with the results; i.e.
* it does the minimal amount of work possible for DMD to do its thing. Then
* it dumps the DMD output to stderr (or somewhere else, if one of
* DMD/Valgrind's logging options was used).
* it does the minimal amount of work possible for DMDV to do its thing. Then
* it dumps the DMDV output to stderr (or somewhere else, if one of
* DMDV/Valgrind's logging options was used).
*/
void DMDCheckAndDump();
void DMDVCheckAndDump();
#else
#define VALGRIND_DMD_REPORT(ptr, usable, name)
#define VALGRIND_DMD_UNREPORT(ptr)
#define VALGRIND_DMDV_REPORT(ptr, usable, name)
#define VALGRIND_DMDV_UNREPORT(ptr)
#endif /* defined(MOZ_DMD) */
#endif /* defined(MOZ_DMDV) */
}
%}

View File

@ -540,10 +540,10 @@ static int64_t GetHeapAllocated()
return stats.bytes_used;
}
// malloc_zone_statistics() crashes when run under DMD because Valgrind doesn't
// intercept it. This measurement isn't important for DMD, so don't even try
// to get it.
#ifndef MOZ_DMD
// malloc_zone_statistics() crashes when run under DMDV because Valgrind
// doesn't intercept it. This measurement isn't important for DMDV, so don't
// even try to get it.
#ifndef MOZ_DMDV
#define HAVE_HEAP_ZONE0_REPORTERS 1
static int64_t GetHeapZone0Committed()
{
@ -574,7 +574,7 @@ NS_MEMORY_REPORTER_IMPLEMENT(HeapZone0Used,
GetHeapZone0Used,
"Memory mapped by the heap allocator in the default zone that is "
"allocated to the application.")
#endif // MOZ_DMD
#endif // MOZ_DMDV
#endif
@ -1589,7 +1589,7 @@ NS_UnregisterMemoryMultiReporter (nsIMemoryMultiReporter *reporter)
namespace mozilla {
#ifdef MOZ_DMD
#ifdef MOZ_DMDV
class NullMultiReporterCallback : public nsIMemoryMultiReporterCallback
{
@ -1601,7 +1601,7 @@ public:
const nsACString &aDescription,
nsISupports *aData)
{
// Do nothing; the reporter has already reported to DMD.
// Do nothing; the reporter has already reported to DMDV.
return NS_OK;
}
};
@ -1611,7 +1611,7 @@ NS_IMPL_ISUPPORTS1(
)
void
DMDCheckAndDump()
DMDVCheckAndDump()
{
nsCOMPtr<nsIMemoryReporterManager> mgr =
do_GetService("@mozilla.org/memory-reporter-manager;1");
@ -1624,7 +1624,7 @@ DMDCheckAndDump()
nsCOMPtr<nsIMemoryReporter> r;
e->GetNext(getter_AddRefs(r));
// Just getting the amount is enough for the reporter to report to DMD.
// Just getting the amount is enough for the reporter to report to DMDV.
int64_t amount;
(void)r->GetAmount(&amount);
}
@ -1639,9 +1639,9 @@ DMDCheckAndDump()
r->CollectReports(cb, nullptr);
}
VALGRIND_DMD_CHECK_REPORTING;
VALGRIND_DMDV_CHECK_REPORTING;
}
#endif /* defined(MOZ_DMD) */
#endif /* defined(MOZ_DMDV) */
}