Skip to content

Commit

Permalink
Bug 1014341 (part 1) - Remove trace-malloc. r=dbaron,glandium.
Browse files Browse the repository at this point in the history
--HG--
extra : rebase_source : 771710c5427141d738eef112fab00951eb8e20e3
  • Loading branch information
nnethercote committed Jan 8, 2015
1 parent e9f49ca commit 97b5d34
Show file tree
Hide file tree
Showing 60 changed files with 18 additions and 25,852 deletions.
1 change: 0 additions & 1 deletion addon-sdk/source/python-lib/cuddlefish/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,6 @@ def maybe_remove_logfile():
env['MOZ_DISABLE_NONLOCAL_CONNECTIONS'] = '1'
env['MOZ_NO_REMOTE'] = '1'
env['XPCOM_DEBUG_BREAK'] = 'stack'
env['NS_TRACE_MALLOC_DISABLE_STACKS'] = '1'
env.update(extra_environment)
if norun:
cmdargs.append("-no-remote")
Expand Down
1 change: 0 additions & 1 deletion build/automation.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,6 @@ class Automation(object):

env['GNOME_DISABLE_CRASH_DIALOG'] = '1'
env['XRE_NO_WINDOWS_CRASH_DIALOG'] = '1'
env['NS_TRACE_MALLOC_DISABLE_STACKS'] = '1'

# Set WebRTC logging in case it is not set yet
env.setdefault('NSPR_LOG_MODULES', 'signaling:5,mtransport:5,datachannel:5,jsep:5,MediaPipelineFactory:5')
Expand Down
1 change: 0 additions & 1 deletion build/automationutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ def environment(xrePath, env=None, crashreporter=True, debugger=False, dmdPath=N
# crashreporter
env['GNOME_DISABLE_CRASH_DIALOG'] = '1'
env['XRE_NO_WINDOWS_CRASH_DIALOG'] = '1'
env['NS_TRACE_MALLOC_DISABLE_STACKS'] = '1'

if crashreporter and not debugger:
env['MOZ_CRASHREPORTER_NO_REPORT'] = '1'
Expand Down
14 changes: 7 additions & 7 deletions config/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -228,17 +228,17 @@ endif
endif

#
# Handle trace-malloc and DMD in optimized builds.
# Handle DMD in optimized builds.
# No opt to give sane callstacks.
#
ifneq (,$(NS_TRACE_MALLOC)$(MOZ_DMD))
ifdef MOZ_DMD
MOZ_OPTIMIZE_FLAGS=-Zi -Od -UDEBUG -DNDEBUG
ifdef HAVE_64BIT_BUILD
OS_LDFLAGS = -DEBUG -OPT:REF,ICF
else
OS_LDFLAGS = -DEBUG -OPT:REF
endif
endif # NS_TRACE_MALLOC || MOZ_DMD
endif # MOZ_DMD

endif # MOZ_DEBUG

Expand Down Expand Up @@ -421,20 +421,20 @@ ifeq ($(OS_ARCH)_$(GNU_CC),WINNT_)
#//------------------------------------------------------------------------
ifdef USE_STATIC_LIBS
RTL_FLAGS=-MT # Statically linked multithreaded RTL
ifneq (,$(MOZ_DEBUG)$(NS_TRACE_MALLOC))
ifdef MOZ_DEBUG
ifndef MOZ_NO_DEBUG_RTL
RTL_FLAGS=-MTd # Statically linked multithreaded MSVC4.0 debug RTL
endif
endif # MOZ_DEBUG || NS_TRACE_MALLOC
endif # MOZ_DEBUG

else # !USE_STATIC_LIBS

RTL_FLAGS=-MD # Dynamically linked, multithreaded RTL
ifneq (,$(MOZ_DEBUG)$(NS_TRACE_MALLOC))
ifdef MOZ_DEBUG
ifndef MOZ_NO_DEBUG_RTL
RTL_FLAGS=-MDd # Dynamically linked, multithreaded MSVC4.0 debug RTL
endif
endif # MOZ_DEBUG || NS_TRACE_MALLOC
endif # MOZ_DEBUG
endif # USE_STATIC_LIBS
endif # WINNT && !GNU_CC

Expand Down
35 changes: 3 additions & 32 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -7046,21 +7046,6 @@ if test -n "$MOZ_DEBUG"; then
AC_DEFINE(MOZ_DUMP_PAINTING)
fi

dnl ========================================================
dnl = Enable trace malloc
dnl ========================================================
NS_TRACE_MALLOC=${MOZ_TRACE_MALLOC}
MOZ_ARG_ENABLE_BOOL(trace-malloc,
[ --enable-trace-malloc Enable malloc tracing; also disables DMD and jemalloc],
NS_TRACE_MALLOC=1,
NS_TRACE_MALLOC= )
if test "$NS_TRACE_MALLOC"; then
# Please, Mr. Linker Man, don't take away our symbol names
MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
AC_DEFINE(NS_TRACE_MALLOC)
fi
AC_SUBST(NS_TRACE_MALLOC)

dnl ========================================================
dnl = Enable DMD
dnl ========================================================
Expand All @@ -7070,11 +7055,6 @@ MOZ_ARG_ENABLE_BOOL(dmd,
MOZ_DMD=1,
MOZ_DMD= )

dnl The two options are conflicting. Fails the configure to alert the user.
if test "$NS_TRACE_MALLOC" -a "$MOZ_DMD"; then
AC_MSG_ERROR([--enable-trace-malloc and --enable-dmd are conflicting options])
fi

if test "$MOZ_DMD"; then
AC_DEFINE(MOZ_DMD)

Expand All @@ -7096,10 +7076,6 @@ MOZ_ARG_ENABLE_BOOL(jemalloc,
MOZ_MEMORY=1,
MOZ_MEMORY=)

if test "$NS_TRACE_MALLOC"; then
MOZ_MEMORY=
fi

case "${OS_TARGET}" in
Android|WINNT|Darwin)
MOZ_GLUE_IN_PROGRAM=
Expand All @@ -7122,11 +7098,6 @@ MOZ_ARG_ENABLE_BOOL(replace-malloc,
MOZ_REPLACE_MALLOC=1,
MOZ_REPLACE_MALLOC= )

dnl The two options are conflicting. Fails the configure to alert the user.
if test "$NS_TRACE_MALLOC" -a "$MOZ_REPLACE_MALLOC"; then
AC_MSG_ERROR([--enable-trace-malloc and --enable-replace-malloc are conflicting options])
fi

if test -n "$MOZ_REPLACE_MALLOC" -a -z "$MOZ_MEMORY"; then
dnl We don't want to enable jemalloc unconditionally because it may be a
dnl deliberate choice not to enable it (bug 702250, for instance)
Expand Down Expand Up @@ -7601,9 +7572,9 @@ if test -z "$SKIP_LIBRARY_CHECKS"; then
AC_LANG_RESTORE
fi

# Demangle only for debug or trace-malloc or DMD builds
# Demangle only for debug or DMD builds
MOZ_DEMANGLE_SYMBOLS=
if test "$HAVE_DEMANGLE" && test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC" -o "$MOZ_DMD"; then
if test "$HAVE_DEMANGLE" && test "$MOZ_DEBUG" -o "$MOZ_DMD"; then
MOZ_DEMANGLE_SYMBOLS=1
AC_DEFINE(MOZ_DEMANGLE_SYMBOLS)
fi
Expand Down Expand Up @@ -8423,7 +8394,7 @@ if test -n "$MOZ_DEVICES"; then
fi

dnl ========================================================
if test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC" -o "$MOZ_DMD"; then
if test "$MOZ_DEBUG" -o "$MOZ_DMD"; then
MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
fi

Expand Down
178 changes: 0 additions & 178 deletions dom/base/nsJSEnvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1087,177 +1087,6 @@ nsJSContext::AddSupportsPrimitiveTojsvals(nsISupports *aArg, JS::Value *aArgv)
return NS_OK;
}

#ifdef NS_TRACE_MALLOC

#include <errno.h> // XXX assume Linux if NS_TRACE_MALLOC
#include <fcntl.h>
#ifdef XP_UNIX
#include <unistd.h>
#endif
#ifdef XP_WIN32
#include <io.h>
#endif
#include "nsTraceMalloc.h"

static bool
CheckUniversalXPConnectForTraceMalloc(JSContext *cx)
{
if (nsContentUtils::IsCallerChrome())
return true;
JS_ReportError(cx, "trace-malloc functions require UniversalXPConnect");
return false;
}

static bool
TraceMallocDisable(JSContext *cx, unsigned argc, JS::Value *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);

if (!CheckUniversalXPConnectForTraceMalloc(cx))
return false;

NS_TraceMallocDisable();
args.rval().setUndefined();
return true;
}

static bool
TraceMallocEnable(JSContext *cx, unsigned argc, JS::Value *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);

if (!CheckUniversalXPConnectForTraceMalloc(cx))
return false;

NS_TraceMallocEnable();
args.rval().setUndefined();
return true;
}

static bool
TraceMallocOpenLogFile(JSContext *cx, unsigned argc, JS::Value *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);

if (!CheckUniversalXPConnectForTraceMalloc(cx))
return false;

int fd;
if (argc == 0) {
fd = -1;
} else {
JSString *str = JS::ToString(cx, args[0]);
if (!str)
return false;
JSAutoByteString filename(cx, str);
if (!filename)
return false;
fd = open(filename.ptr(), O_CREAT | O_WRONLY | O_TRUNC, 0644);
if (fd < 0) {
JS_ReportError(cx, "can't open %s: %s", filename.ptr(), strerror(errno));
return false;
}
}
args.rval().setInt32(fd);
return true;
}

static bool
TraceMallocChangeLogFD(JSContext *cx, unsigned argc, JS::Value *vp)
{
JS::CallArgs args = CallArgsFromVp(argc, vp);

if (!CheckUniversalXPConnectForTraceMalloc(cx))
return false;

int32_t fd, oldfd;
if (args.length() == 0) {
oldfd = -1;
} else {
if (!JS::ToInt32(cx, args[0], &fd))
return false;
oldfd = NS_TraceMallocChangeLogFD(fd);
if (oldfd == -2) {
JS_ReportOutOfMemory(cx);
return false;
}
}
args.rval().setInt32(oldfd);
return true;
}

static bool
TraceMallocCloseLogFD(JSContext *cx, unsigned argc, JS::Value *vp)
{
JS::CallArgs args = CallArgsFromVp(argc, vp);

if (!CheckUniversalXPConnectForTraceMalloc(cx))
return false;

int32_t fd;
if (args.length() == 0) {
args.rval().setUndefined();
return true;
}
if (!JS::ToInt32(cx, args[0], &fd))
return false;
NS_TraceMallocCloseLogFD((int) fd);
args.rval().setInt32(fd);
return true;
}

static bool
TraceMallocLogTimestamp(JSContext *cx, unsigned argc, JS::Value *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
if (!CheckUniversalXPConnectForTraceMalloc(cx))
return false;

JSString *str = JS::ToString(cx, args.get(0));
if (!str)
return false;
JSAutoByteString caption(cx, str);
if (!caption)
return false;
NS_TraceMallocLogTimestamp(caption.ptr());
args.rval().setUndefined();
return true;
}

static bool
TraceMallocDumpAllocations(JSContext *cx, unsigned argc, JS::Value *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
if (!CheckUniversalXPConnectForTraceMalloc(cx))
return false;

JSString *str = JS::ToString(cx, args.get(0));
if (!str)
return false;
JSAutoByteString pathname(cx, str);
if (!pathname)
return false;
if (NS_TraceMallocDumpAllocations(pathname.ptr()) < 0) {
JS_ReportError(cx, "can't dump to %s: %s", pathname.ptr(), strerror(errno));
return false;
}
args.rval().setUndefined();
return true;
}

static const JSFunctionSpec TraceMallocFunctions[] = {
JS_FS("TraceMallocDisable", TraceMallocDisable, 0, 0),
JS_FS("TraceMallocEnable", TraceMallocEnable, 0, 0),
JS_FS("TraceMallocOpenLogFile", TraceMallocOpenLogFile, 1, 0),
JS_FS("TraceMallocChangeLogFD", TraceMallocChangeLogFD, 1, 0),
JS_FS("TraceMallocCloseLogFD", TraceMallocCloseLogFD, 1, 0),
JS_FS("TraceMallocLogTimestamp", TraceMallocLogTimestamp, 1, 0),
JS_FS("TraceMallocDumpAllocations", TraceMallocDumpAllocations, 1, 0),
JS_FS_END
};

#endif /* NS_TRACE_MALLOC */

#ifdef MOZ_JPROF

#include <signal.h>
Expand Down Expand Up @@ -1374,13 +1203,6 @@ nsJSContext::InitClasses(JS::Handle<JSObject*> aGlobalObj)
// Attempt to initialize profiling functions
::JS_DefineProfilingFunctions(cx, aGlobalObj);

#ifdef NS_TRACE_MALLOC
if (nsContentUtils::IsCallerChrome()) {
// Attempt to initialize TraceMalloc functions
::JS_DefineFunctions(cx, aGlobalObj, TraceMallocFunctions);
}
#endif

#ifdef MOZ_JPROF
// Attempt to initialize JProf functions
::JS_DefineFunctions(cx, aGlobalObj, JProfFunctions);
Expand Down
2 changes: 1 addition & 1 deletion gfx/thebes/gfxPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ gfxPlatform::~gfxPlatform()
// cairo_debug_* function unconditionally.
//
// because cairo can assert and thus crash on shutdown, don't do this in release builds
#if defined(DEBUG) || defined(NS_BUILD_REFCNT_LOGGING) || defined(NS_TRACE_MALLOC) || defined(MOZ_VALGRIND)
#if defined(DEBUG) || defined(NS_BUILD_REFCNT_LOGGING) || defined(MOZ_VALGRIND)
#ifdef USE_SKIA
// must do Skia cleanup before Cairo cleanup, because Skia may be referencing
// Cairo objects e.g. through SkCairoFTTypeface
Expand Down
Loading

0 comments on commit 97b5d34

Please sign in to comment.