Backed out changeset 8cbc47eee659
authorChris Jones <jones.chris.g@gmail.com>
Fri, 02 Oct 2009 18:09:08 -0500
changeset 33405 e686eb984a9e3e942ad0f72a36f748c936eae85a
parent 33355 8cbc47eee6593699d684026ddb0a670a0154cc81
child 33406 e6ffec5b7dbefb52ab400b5c0d4dd30c312b3cc7
push id9483
push usercjones@mozilla.com
push dateFri, 02 Oct 2009 23:10:00 +0000
treeherdermozilla-central@e6ffec5b7dbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone1.9.3a1pre
backs out8cbc47eee6593699d684026ddb0a670a0154cc81
Backed out changeset 8cbc47eee659
Makefile.in
browser/installer/package-manifest.in
build/Makefile.in
build/wince/shunt/Makefile.in
build/wince/shunt/include/mozce_shunt.h
build/wince/shunt/memory.cpp
config/config.mk
configure.in
content/base/src/nsScriptLoader.cpp
content/xul/document/src/nsXULContentSink.cpp
dom/base/nsDOMClassInfo.cpp
dom/base/nsJSEnvironment.cpp
dom/src/threads/nsDOMThreadService.cpp
embedding/browser/activex/src/plugin/LegacyPlugin.cpp
js/ctypes/tests/Makefile.in
js/jsd/jsd_xpc.cpp
js/src/config/config.mk
js/src/xpconnect/shell/xpcshell.cpp
js/src/xpconnect/src/xpcJSWeakReference.cpp
js/src/xpconnect/src/xpcprivate.h
memory/Makefile.in
memory/mozalloc/Makefile.in
memory/mozalloc/mozalloc.cpp
memory/mozalloc/mozalloc.h
memory/mozalloc/mozalloc_macro_wrappers.h
memory/mozalloc/mozalloc_oom.cpp
memory/mozalloc/mozalloc_oom.h
modules/plugin/base/src/nsJSNPRuntime.cpp
modules/plugin/base/src/nsNPAPIPlugin.cpp
modules/plugin/default/windows/Makefile.in
toolkit/components/faststart/Makefile.in
toolkit/components/remote/nsGTKRemoteService.cpp
toolkit/library/Makefile.in
widget/src/xremoteclient/Makefile.in
xpcom/base/nsMemoryImpl.cpp
xpcom/base/nscore.h
xpcom/build/Makefile.in
xpcom/string/public/nsUTF8Utils.h
xpcom/stub/Makefile.in
--- a/Makefile.in
+++ b/Makefile.in
@@ -56,20 +56,23 @@ default::
 TIERS += base
 
 #
 # tier "base" - basic setup
 #
 tier_base_dirs = \
 	config \
 	build \
-	memory \
 	probes \
 	$(NULL)
 
+ifdef MOZ_MEMORY
+tier_base_dirs += memory/jemalloc
+endif
+
 ifdef COMPILE_ENVIRONMENT
 include $(topsrcdir)/$(MOZ_BUILD_APP)/build.mk
 endif
 
 TIERS += testharness
 
 # test harnesses
 ifdef ENABLE_TESTS
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -44,17 +44,16 @@
 @BINPATH@/js3250.dll
 #else
 @BINPATH@/@DLL_PREFIX@mozjs@DLL_SUFFIX@
 #endif
 @BINPATH@/@DLL_PREFIX@plc4@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@plds4@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@xpcom@DLL_SUFFIX@
 @BINPATH@/@DLL_PREFIX@nspr4@DLL_SUFFIX@
-@BINPATH@/@DLL_PREFIX@mozalloc@DLL_SUFFIX@
 #ifdef XP_MACOSX
 @BINPATH@/XUL
 #else
 @BINPATH@/@DLL_PREFIX@xul@DLL_SUFFIX@
 #endif
 #ifdef WINCE
 @BINPATH@/mozce_shunt.dll
 #elifdef XP_WIN32
--- a/build/Makefile.in
+++ b/build/Makefile.in
@@ -51,19 +51,19 @@ endif
 
 ifeq (WINNT,$(OS_ARCH))
 DIRS = win32
 endif
 
 ifdef WINCE
 # We need jemalloc built before the shunt
 ifdef MOZ_MEMORY
-DIRS += wince/tools $(DEPTH)/memory/jemalloc $(DEPTH)/memory/mozalloc wince/shunt
+DIRS += wince/tools $(DEPTH)/memory/jemalloc wince/shunt
 else
-DIRS += wince/tools $(DEPTH)/memory/mozalloc wince/shunt
+DIRS += wince/tools wince/shunt
 endif
 endif
 
 DIRS += pgo
 
 include $(topsrcdir)/config/rules.mk
 
 # we install to _leaktest/
--- a/build/wince/shunt/Makefile.in
+++ b/build/wince/shunt/Makefile.in
@@ -76,18 +76,16 @@ CFLAGS += -DMOZ_MEMORY
 CXXFLAGS += -DMOZ_MEMORY
 EXPORTS_mozce_shunt += $(topsrcdir)/memory/jemalloc/jemalloc.h
 
 # We have to include the obj file directly, because we want to export
 # some of its symbols through our def file
 EXTRA_LIBS += $(OBJDIR)/memory/jemalloc/jemalloc.obj
 endif
 
-EXTRA_DSO_LDOPTS += $(MOZALLOC_LIB)
-
 DEFFILE = mozce_shunt.def
 
 OS_LIBS += $(call EXPAND_LIBNAME, libcmt)
 
 CPPSRCS = \
 	shunt.cpp \
 	environment.cpp \
 	time.cpp \
--- a/build/wince/shunt/include/mozce_shunt.h
+++ b/build/wince/shunt/include/mozce_shunt.h
@@ -62,104 +62,82 @@ typedef unsigned short wchar_t;
 #define _NEW_
 #define _INC_NEW
 
 #ifndef __NOTHROW_T_DEFINED
 #define __NOTHROW_T_DEFINED
 namespace std {
   struct nothrow_t {};
   extern const nothrow_t nothrow;
-  struct bad_alloc {};
 };
 #endif
 
 // grab malloc and free prototypes
 #include "jemalloc.h"
 
-// mozalloc.h defines "normal" infallible operator new, but not
-// std::nothrow operator new, so we define that below.  This is inline
-// and exported from the shunt.
+// Normal and nothrow versions of operator new, none of which
+// actually throw for us.  These are both inline and exported
+// from the shunt.
+inline void *operator new(size_t size) throw() {
+  return (void*) malloc(size);
+}
 inline void *operator new(size_t size, const std::nothrow_t&) throw() {
-  return malloc(size);
+  return (void*) malloc(size);
+}
+inline void operator delete(void *ptr) throw() {
+  free(ptr);
+}
+inline void *operator new[](size_t size) throw() {
+  return (void*) malloc(size);
 }
 inline void *operator new[](size_t size, const std::nothrow_t&) throw() {
-  return malloc(size);
+  return (void*) malloc(size);
 }
-inline void operator delete(void* ptr, const std::nothrow_t&) throw() {
-  free(ptr);
-}
-inline void operator delete[](void* ptr, const std::nothrow_t&) throw() {
-  free(ptr);
+inline void operator delete[](void *ptr) throw() {
+  return free(ptr);
 }
 
 // Placement new.  Just inline, not exported (which doesn't work for
 // some reason, but it's a noop in any case)
 inline void *operator new(size_t, void *p) {
   return p;
 }
 inline void *operator new[](size_t, void *p) {
   return p;
 }
 
-
-// for Gecko, include infallible mozalloc allocators.  elsewhere, define
-// operator new() normally.
-// NB: this include guard needs to be kept in sync with the one in nscore.h
-#if defined(_MOZILLA_CONFIG_H_) && !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
-#  include "mozilla/mozalloc.h"
-#else
-
-inline void* operator new(size_t size) throw() {
-  return malloc(size);
-}
-inline void* operator new[](size_t size) throw() {
-  return malloc(size);
-}
-inline void operator delete(void* ptr) throw() {
-  free(ptr);
-}
-inline void operator delete[](void* ptr) throw() {
-  free(ptr);
-}
-
-#endif  // if defined(_MOZILLA_CONFIG_H_)
-
-
 extern "C" {
 #endif
 
 #undef _strdup
 #undef strdup
 #undef _strndup
 #undef strndup
 #undef _wcsdup
 #undef wcsdup
 #undef _wcsndup
 #undef wcsndup
 
-// _strdup() and _wcsdup() are both infallible, i.e., will never return
-// NULL
-
 char * __cdecl
 _strdup(const char*);
 
 wchar_t * __cdecl
 _wcsdup(const wchar_t *);
 
 char * __cdecl
 _strndup(const char *, unsigned int);
 
 wchar_t * __cdecl
 _wcsndup(const wchar_t *, unsigned int);
   
 #ifdef __cplusplus
 }   //extern "C" 
 #endif
 
-#endif  // ifdef MOZ_MEMORY
+#endif
 
 #define strdup  _strdup
 #define strndup _strndup
 #define wcsdup _wcsdup
 #define wcsndup _wcsndup
 
 
 #define strcmpi _stricmp
--- a/build/wince/shunt/memory.cpp
+++ b/build/wince/shunt/memory.cpp
@@ -34,41 +34,41 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "include/mozce_shunt.h"
 #include <stdlib.h>
 
-#include "mozilla/mozalloc_macro_wrappers.h" /* infallible malloc */
-
 #ifdef MOZ_MEMORY
 
 // declare the nothrow object
 const std::nothrow_t std::nothrow;
 
 char*
 _strndup(const char *src, size_t len) {
   char* dst = (char*)malloc(len + 1);
-  strncpy(dst, src, len + 1);
+  if(dst)
+    strncpy(dst, src, len + 1);
   return dst;
 }
 
 
 char*
 _strdup(const char *src) {
   size_t len = strlen(src);
   return _strndup(src, len );
 }
 
 wchar_t * 
 _wcsndup(const wchar_t *src, size_t len) {
   wchar_t* dst = (wchar_t*)malloc(sizeof(wchar_t) * (len + 1));
-  wcsncpy(dst, src, len + 1);
+  if(dst)
+    wcsncpy(dst, src, len + 1);
   return dst;
 }
 
 wchar_t * 
 _wcsdup(const wchar_t *src) {
   size_t len = wcslen(src);
   return _wcsndup(src, len);
 }
--- a/config/config.mk
+++ b/config/config.mk
@@ -220,17 +220,16 @@ else
       # the user didn't mention this module explicitly, 
       # but wanted all modules to be compiled with -g
       _DEBUG_CFLAGS += $(MOZ_DEBUG_FLAGS)
       _DEBUG_LDFLAGS += $(MOZ_DEBUG_LDFLAGS)      
     endif
   endif
 endif
 
-MOZALLOC_LIB = $(call EXPAND_MOZLIBNAME,mozalloc)
 
 # append debug flags 
 # (these might have been above when processing MOZ_DBGRINFO_MODULES)
 OS_CFLAGS += $(_DEBUG_CFLAGS)
 OS_CXXFLAGS += $(_DEBUG_CFLAGS)
 OS_LDFLAGS += $(_DEBUG_LDFLAGS)
 
 # XXX: What does this? Bug 482434 filed for better explanation.
--- a/configure.in
+++ b/configure.in
@@ -1050,19 +1050,19 @@ MOZ_JPEG_LIBS='$(call EXPAND_LIBNAME_PAT
 MOZ_ZLIB_CFLAGS=
 MOZ_ZLIB_LIBS='$(call EXPAND_LIBNAME_PATH,mozz,$(DEPTH)/modules/zlib/src)'
 MOZ_BZ2_CFLAGS=
 MOZ_BZ2_LIBS='$(call EXPAND_LIBNAME_PATH,bz2,$(DEPTH)/modules/libbz2/src)'
 MOZ_PNG_CFLAGS=
 MOZ_PNG_LIBS='$(call EXPAND_LIBNAME_PATH,mozpng,$(DEPTH)/modules/libimg/png)'
 
 MOZ_JS_LIBS='-L$(LIBXUL_DIST)/bin -lmozjs'
-DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/bin -lxpcom -lxpcom_core -lmozalloc'
+DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/bin -lxpcom -lxpcom_core'
 MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(LIBXUL_DIST)/bin -Wl,-rpath-link,$(prefix)/lib'
-XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/bin -lxpcom -lmozalloc'
+XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/bin -lxpcom'
 LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) -lxul'
 XPCOM_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) $(XPCOM_FROZEN_LDOPTS)'
 XPCOM_STANDALONE_GLUE_LDOPTS='$(LIBXUL_DIST)/lib/$(LIB_PREFIX)xpcomglue.$(LIB_SUFFIX)'
 
 MOZ_FS_LAYOUT=unix
 
 MOZ_COMPONENT_NSPR_LIBS='-L$(LIBXUL_DIST)/bin $(NSPR_LIBS)'
 
@@ -2008,21 +2008,21 @@ case "$target" in
     MOZ_OPTIMIZE_FLAGS='-Ox'
     AR_FLAGS='-NOLOGO -OUT:"$@"'
     ASM_SUFFIX=asm
     CFLAGS="$CFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
     CXXFLAGS="$CXXFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
     DLL_PREFIX=
     DOXYGEN=:
     DSO_LDOPTS=-SUBSYSTEM:WINDOWSCE
-    DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
+    DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib'
     GARBAGE=
     IMPORT_LIB_SUFFIX=lib
     LIBS="$LIBS"
-    LIBXUL_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
+    LIBXUL_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib'
     LIB_PREFIX=
     LIB_SUFFIX=lib 
     MKCSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ $(DSO_LDOPTS)'
     MKSHLIB='$(LD) -NOLOGO -DLL -OUT:$@ $(DSO_LDOPTS)'
     MKSHLIB_FORCE_ALL=
     MKSHLIB_UNFORCE_ALL=
     MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
     MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
@@ -2031,17 +2031,17 @@ case "$target" in
     MOZ_FIX_LINK_PATHS=
     MOZ_JS_LIBS='$(LIBXUL_DIST)/lib/js$(MOZ_BITS)$(VERSION_NUMBER).lib'
     OBJ_SUFFIX=obj
     RANLIB='echo not_ranlib'
     STRIP='echo not_strip'
     TARGET_NSPR_MDCPUCFG='\"md/_wince.cfg\"'
     UNZIP=unzip
     XARGS=xargs
-    XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
+    XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xpcom.lib'
     ZIP=zip
     LIBIDL_CFLAGS="-I$MOZ_TOOLS_DIR/include ${GLIB_CFLAGS}"
     LIBIDL_LIBS="$MOZ_TOOLS_DIR/lib/libidl-0.6_s.lib $MOZ_TOOLS_DIR/lib/glib-1.2_s.lib"
     STATIC_LIBIDL=1
     MOZ_TREE_FREETYPE=1
 
     AC_DEFINE(HAVE_SNPRINTF)
     AC_DEFINE(_WINDOWS)
@@ -2090,18 +2090,18 @@ case "$target" in
         MKCSHLIB='$(CC) $(DSO_LDOPTS) -o $@'
         RC='$(WINDRES)'
         # Use temp file for windres (bug 213281)
         RCFLAGS='-O coff --use-temp-file'
         # mingw doesn't require kernel32, user32, and advapi32 explicitly
         LIBS="$LIBS -lgdi32 -lwinmm -lwsock32"
         MOZ_JS_LIBS='-L$(LIBXUL_DIST)/lib -ljs$(MOZ_BITS)$(VERSION_NUMBER)'
         MOZ_FIX_LINK_PATHS=
-        DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib -lxpcom -lxpcom_core -lmozalloc'
-        XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/lib -lxpcom -lmozalloc'
+        DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib -lxpcom -lxpcom_core'
+        XPCOM_FROZEN_LDOPTS='-L$(LIBXUL_DIST)/lib -lxpcom'
         DLL_PREFIX=
         IMPORT_LIB_SUFFIX=dll.a
     else
         TARGET_COMPILER_ABI=msvc
         HOST_CC='$(CC)'
         HOST_CXX='$(CXX)'
         HOST_LD='$(LD)'
         AR='lib -NOLOGO -OUT:"$@"'
@@ -2130,19 +2130,19 @@ case "$target" in
         CXXFLAGS="$CXXFLAGS -W3 -Gy -Fd\$(COMPILE_PDBFILE)"
         LIBS="$LIBS kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib"
         MOZ_DEBUG_FLAGS='-Zi'
         MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV'
         WARNINGS_AS_ERRORS='-WX'
     	MOZ_OPTIMIZE_FLAGS='-O1'
         MOZ_JS_LIBS='$(LIBXUL_DIST)/lib/js$(MOZ_BITS)$(VERSION_NUMBER).lib'
         MOZ_FIX_LINK_PATHS=
-        DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
-        XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
-        LIBXUL_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
+        DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib'
+        XPCOM_FROZEN_LDOPTS='$(LIBXUL_DIST)/lib/xpcom.lib'
+        LIBXUL_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib'
         MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
         if test $_MSC_VER -ge 1400; then
             LDFLAGS="$LDFLAGS -NXCOMPAT -SAFESEH"
             dnl For profile-guided optimization
             PROFILE_GEN_CFLAGS="-GL"
             PROFILE_GEN_LDFLAGS="-LTCG:PGINSTRUMENT"
             dnl XXX: PGO builds can fail with warnings treated as errors,
             dnl specifically "no profile data available" appears to be
@@ -2431,18 +2431,18 @@ case "$target" in
     BIN_FLAGS='-Zlinker /ST:0x100000'
     IMPLIB='emximp -o'
     FILTER='emxexp -o'
     LDFLAGS='-Zmap'
     WARNINGS_AS_ERRORS='-Werror'
     MOZ_DEBUG_FLAGS="-g -fno-inline"
     MOZ_OPTIMIZE_FLAGS="-O2"
     MOZ_OPTIMIZE_LDFLAGS="-s -Zlinker /EXEPACK:2 -Zlinker /PACKCODE -Zlinker /PACKDATA"
-    DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcomcor.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
-    LIBXUL_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib $(LIBXUL_DIST)/lib/mozalloc.lib'
+    DYNAMIC_XPCOM_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcomcor.lib'
+    LIBXUL_LIBS='-L$(LIBXUL_DIST)/lib $(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xul.lib'
     TARGET_MD_ARCH=os2
     _PLATFORM_DEFAULT_TOOLKIT="cairo-os2"
     MOZ_ENABLE_POSTSCRIPT=
     RC=rc.exe
     RCFLAGS='-n'
     MOZ_USER_DIR="Mozilla"
 
     if test "$MOZTOOLS"; then
@@ -4117,62 +4117,17 @@ AC_CACHE_CHECK(for trouble comparing to 
                                 template <class T> int operator!=(const T2*, const T&) { return 0; }],
                                [Foo<int> f; return (0 != f);],
                                ac_cv_trouble_comparing_to_zero=no,
                                ac_cv_trouble_comparing_to_zero=yes)])
 if test "$ac_cv_trouble_comparing_to_zero" = yes ; then
   AC_DEFINE(HAVE_CPP_TROUBLE_COMPARING_TO_ZERO)
 fi
 
-dnl Check for the existence of various allocation headers/functions
-
-MALLOC_H=
-AC_CHECK_HEADER(malloc.h,        [MALLOC_H=malloc.h])
-if test "$MALLOC_H" = ""; then
-  AC_CHECK_HEADER(malloc/malloc.h, [MALLOC_H=malloc/malloc.h])
-  if test "$MALLOC_H" = ""; then
-    AC_CHECK_HEADER(sys/malloc.h,    [MALLOC_H=sys/malloc.h])
-  fi
-fi
-if test "$MALLOC_H" != ""; then
-   AC_DEFINE_UNQUOTED(MALLOC_H, <$MALLOC_H>)
-fi
-
-MOZ_ALLOCATING_FUNCS="strndup posix_memalign memalign valloc"
-AC_CHECK_FUNCS(strndup posix_memalign memalign valloc)
-
-dnl See if compiler supports some gcc-style attributes
-
-AC_CACHE_CHECK(for __attribute__((always_inline)),
-               ac_cv_attribute_always_inline,
-               [AC_TRY_COMPILE([],
-                               [inline void f(void) __attribute__((always_inline));],
-                               ac_cv_attribute_always_inline=yes,
-                               ac_cv_attribute_always_inline=no)])
-
-AC_CACHE_CHECK(for __attribute__((malloc)),
-               ac_cv_attribute_malloc,
-               [AC_TRY_COMPILE([],
-                               [void* f(int) __attribute__((malloc));],
-                               ac_cv_attribute_malloc=yes,
-                               ac_cv_attribute_malloc=no)])
-
-AC_CACHE_CHECK(for __attribute__((warn_unused_result)),
-               ac_cv_attribute_warn_unused,
-               [AC_TRY_COMPILE([],
-                               [int f(void) __attribute__((warn_unused_result));],
-                               ac_cv_attribute_warn_unused=yes,
-                               ac_cv_attribute_warn_unused=no)])
-
-AC_CACHE_CHECK(for __attribute__((noreturn)),
-               ac_cv_attribute_noreturn,
-               [AC_TRY_COMPILE([],
-                               [void f(void) __attribute__((noreturn));],
-                               ac_cv_attribute_noreturn=yes,
-                               ac_cv_attribute_noreturn=no)])
+
 
 dnl End of C++ language/feature checks
 AC_LANG_C
 
 dnl ========================================================
 dnl =  Internationalization checks
 dnl ========================================================
 dnl
@@ -4198,50 +4153,16 @@ if test -n "${CPU_ARCH}" -a -n "${TARGET
     TARGET_XPCOM_ABI="${CPU_ARCH}-${TARGET_COMPILER_ABI}"
 fi
 
 dnl Mozilla specific options
 dnl ========================================================
 dnl The macros used for command line options
 dnl are defined in build/autoconf/altoptions.m4.
 
-dnl If the compiler supports these attributes, define them as
-dnl convenience macros.
-if test "$ac_cv_attribute_always_inline" = yes ; then
-  AC_DEFINE(NS_ALWAYS_INLINE, [__attribute__((always_inline))])
-else
-  AC_DEFINE(NS_ALWAYS_INLINE,)
-fi
-
-if test "$ac_cv_attribute_malloc" = yes ; then
-  AC_DEFINE(NS_ATTR_MALLOC, [__attribute__((malloc))])
-else
-  AC_DEFINE(NS_ATTR_MALLOC,)
-fi
-
-if test "$ac_cv_attribute_warn_unused" = yes ; then
-  AC_DEFINE(NS_WARN_UNUSED_RESULT, [__attribute__((warn_unused_result))])
-else
-  AC_DEFINE(NS_WARN_UNUSED_RESULT,)
-fi
-
-if test "$ac_cv_attribute_noreturn" = yes ; then
-  AC_DEFINE(NS_NORETURN, [__attribute__((noreturn))])
-else
-  AC_DEFINE(NS_NORETURN,)
-fi
-
-dnl We can't run TRY_COMPILE tests on Windows, so hard-code some
-dnl features that Windows actually does support.
-
-if test -n "$SKIP_COMPILER_CHECKS"; then
-   dnl Windows has malloc.h
-   AC_DEFINE(MALLOC_H, [<malloc.h>])
-   AC_DEFINE(HAVE_FORCEINLINE)
-fi # SKIP_COMPILER_CHECKS
 
 dnl ========================================================
 dnl =
 dnl = Check for external package dependencies
 dnl =
 dnl ========================================================
 MOZ_ARG_HEADER(External Packages)
 
@@ -6554,23 +6475,16 @@ if test "$MOZ_MEMORY"; then
     if test -z "$WINCE_WINDOWS_MOBILE"; then
       AC_DEFINE(MOZ_MEMORY_WINCE6)
     fi
     ;;
   *)
     AC_MSG_ERROR([--enable-jemalloc not supported on ${target}])
     ;;
   esac
-
-  if test "$OS_ARCH" != "Darwin"; then
-    dnl NB: this must be kept in sync with jemalloc.h
-    AC_DEFINE(HAVE_JEMALLOC_VALLOC)
-    AC_DEFINE(HAVE_JEMALLOC_POSIX_MEMALIGN)
-    AC_DEFINE(HAVE_JEMALLOC_MEMALIGN)
-  fi
 fi
 AC_SUBST(MOZ_MEMORY)
 AC_SUBST(MOZ_MEMORY_LDFLAGS)
 AC_SUBST(WIN32_CRT_SRC_DIR)
 dnl Need to set this for make because NSS doesn't have configure
 AC_SUBST(DLLFLAGS)
 
 dnl ========================================================
--- a/content/base/src/nsScriptLoader.cpp
+++ b/content/base/src/nsScriptLoader.cpp
@@ -36,17 +36,16 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 /*
  * A class that handles loading and evaluation of <script> elements.
  */
 
-#include "jscntxt.h"
 #include "nsScriptLoader.h"
 #include "nsIDOMCharacterData.h"
 #include "nsParserUtils.h"
 #include "nsICharsetConverterManager.h"
 #include "nsIUnicodeDecoder.h"
 #include "nsIContent.h"
 #include "nsGkAtoms.h"
 #include "nsNetUtil.h"
@@ -56,16 +55,17 @@
 #include "nsIScriptSecurityManager.h"
 #include "nsIPrincipal.h"
 #include "nsContentPolicyUtils.h"
 #include "nsIDOMWindow.h"
 #include "nsIHttpChannel.h"
 #include "nsIScriptElement.h"
 #include "nsIDOMHTMLScriptElement.h"
 #include "nsIDocShell.h"
+#include "jscntxt.h"
 #include "nsContentUtils.h"
 #include "nsUnicharUtils.h"
 #include "nsAutoPtr.h"
 #include "nsIXPConnect.h"
 #include "nsContentErrors.h"
 #include "nsIParser.h"
 #include "nsThreadUtils.h"
 #include "nsIChannelClassifier.h"
--- a/content/xul/document/src/nsXULContentSink.cpp
+++ b/content/xul/document/src/nsXULContentSink.cpp
@@ -42,17 +42,16 @@
 /*
  * An implementation for a Gecko-style content sink that knows how
  * to build a content model (the "prototype" document) from XUL.
  *
  * For more information on XUL,
  * see http://developer.mozilla.org/en/docs/XUL
  */
 
-#include "jscntxt.h"  // for JSVERSION_HAS_XML
 #include "nsXULContentSink.h"
 #include "nsCOMPtr.h"
 #include "nsForwardReference.h"
 #include "nsIContentSink.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMEventListener.h"
 #include "nsIDOMHTMLFormElement.h"
 #include "nsIDOMXULDocument.h"
@@ -75,16 +74,17 @@
 #include "nsNetUtil.h"
 #include "nsRDFCID.h"
 #include "nsParserUtils.h"
 #include "nsXPIDLString.h"
 #include "nsReadableUtils.h"
 #include "nsXULElement.h"
 #include "prlog.h"
 #include "prmem.h"
+#include "jscntxt.h"  // for JSVERSION_HAS_XML
 #include "nsCRT.h"
 
 #include "nsXULPrototypeDocument.h"     // XXXbe temporary
 #include "nsICSSLoader.h"
 
 #include "nsUnicharUtils.h"
 #include "nsGkAtoms.h"
 #include "nsContentUtils.h"
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -32,23 +32,16 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-// JavaScript includes
-#include "jsapi.h"
-#include "jsprvtd.h"    // we are using private JS typedefs...
-#include "jscntxt.h"
-#include "jsdbgapi.h"
-#include "jsnum.h"
-
 #include "nscore.h"
 #include "nsDOMClassInfo.h"
 #include "nsCRT.h"
 #include "nsCRTGlue.h"
 #include "nsIServiceManager.h"
 #include "nsICategoryManager.h"
 #include "nsIComponentRegistrar.h"
 #include "nsXPCOM.h"
@@ -64,16 +57,23 @@
 #include "nsUnicharUtils.h"
 #include "xptcall.h"
 #include "prprf.h"
 #include "nsTArray.h"
 #include "nsCSSValue.h"
 #include "nsIRunnable.h"
 #include "nsThreadUtils.h"
 
+// JavaScript includes
+#include "jsapi.h"
+#include "jsprvtd.h"    // we are using private JS typedefs...
+#include "jscntxt.h"
+#include "jsdbgapi.h"
+#include "jsnum.h"
+
 // General helper includes
 #include "nsGlobalWindow.h"
 #include "nsIContent.h"
 #include "nsIAttribute.h"
 #include "nsIDocument.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOM3Document.h"
 #include "nsIDOMXMLDocument.h"
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -32,17 +32,16 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "jscntxt.h"
 #include "nsJSEnvironment.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIScriptObjectPrincipal.h"
 #include "nsIDOMChromeWindow.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDOMNode.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMDocument.h"
@@ -72,16 +71,17 @@
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIPrompt.h"
 #include "nsIObserverService.h"
 #include "nsGUIEvent.h"
 #include "nsThreadUtils.h"
 #include "nsITimer.h"
 #include "nsIAtom.h"
 #include "nsContentUtils.h"
+#include "jscntxt.h"
 #include "nsEventDispatcher.h"
 #include "nsIContent.h"
 #include "nsCycleCollector.h"
 #include "nsNetUtil.h"
 #include "nsXPCOMCIDInternal.h"
 #include "nsIXULRuntime.h"
 
 // For locale aware string methods
--- a/dom/src/threads/nsDOMThreadService.cpp
+++ b/dom/src/threads/nsDOMThreadService.cpp
@@ -32,18 +32,16 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include "jscntxt.h"
-
 #include "nsDOMThreadService.h"
 
 // Interfaces
 #include "nsIComponentManager.h"
 #include "nsIConsoleService.h"
 #include "nsIDocument.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMNavigator.h"
@@ -57,16 +55,17 @@
 #include "nsIScriptGlobalObject.h"
 #include "nsIServiceManager.h"
 #include "nsISupportsPriority.h"
 #include "nsIThreadPool.h"
 #include "nsIXPConnect.h"
 #include "nsPIDOMWindow.h"
 
 // Other includes
+#include "jscntxt.h"
 #include "nsAutoLock.h"
 #include "nsAutoPtr.h"
 #include "nsContentUtils.h"
 #include "nsDeque.h"
 #include "nsIClassInfoImpl.h"
 #include "nsThreadUtils.h"
 #include "nsXPCOM.h"
 #include "nsXPCOMCID.h"
--- a/embedding/browser/activex/src/plugin/LegacyPlugin.cpp
+++ b/embedding/browser/activex/src/plugin/LegacyPlugin.cpp
@@ -34,19 +34,16 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 #include "stdafx.h"
 
 #include "npapi.h"
 
-#include "jsapi.h"
-#include "jscntxt.h"
-
 #include "nsISupports.h"
 
 #ifdef MOZ_ACTIVEX_PLUGIN_XPCONNECT
 #include "XPConnect.h"
 #endif
 
 #include "LegacyPlugin.h"
 
@@ -56,16 +53,18 @@
 #include "nsIDocument.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMWindow.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIScriptContext.h"
 #include "nsIURI.h"
 #include "nsIJSContextStack.h"
+#include "jsapi.h"
+#include "jscntxt.h"
 #include "nsIScriptSecurityManager.h"
 #endif
 
 ///////////////////////////////////////////////////////////////////////////////
 // These are constants to control certain default behaviours
 
 #ifndef MOZ_ACTIVEX_PLUGIN_XPCONNECT
 // Flag determines if controls should be created if they are not marked
--- a/js/ctypes/tests/Makefile.in
+++ b/js/ctypes/tests/Makefile.in
@@ -47,17 +47,16 @@ MODULE = jsctypes-test
 LIBRARY_NAME = jsctypes-test
 FORCE_SHARED_LIB = 1
 NO_DIST_INSTALL = 1
 
 CPPSRCS = jsctypes-test.cpp
 
 EXTRA_DSO_LDOPTS += \
     $(XPCOM_STANDALONE_GLUE_LDOPTS) \
-    $(MOZALLOC_LIB) \
     $(NSPR_LIBS) \
     $(NULL)
 
 XPCSHELL_TESTS = unit
 
 include $(topsrcdir)/config/rules.mk
 
 xpctestdir = $(testxpcobjdir)/$(MODULE)/unit
--- a/js/jsd/jsd_xpc.cpp
+++ b/js/jsd/jsd_xpc.cpp
@@ -32,20 +32,20 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
+#include "jsd_xpc.h"
 #include "jsdbgapi.h"
 #include "jscntxt.h"
 #include "jsfun.h"
-#include "jsd_xpc.h"
 
 #include "nsIXPConnect.h"
 #include "nsIGenericFactory.h"
 #include "nsIServiceManager.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIObserver.h"
 #include "nsIObserverService.h"
 #include "nsICategoryManager.h"
--- a/js/src/config/config.mk
+++ b/js/src/config/config.mk
@@ -220,17 +220,16 @@ else
       # the user didn't mention this module explicitly, 
       # but wanted all modules to be compiled with -g
       _DEBUG_CFLAGS += $(MOZ_DEBUG_FLAGS)
       _DEBUG_LDFLAGS += $(MOZ_DEBUG_LDFLAGS)      
     endif
   endif
 endif
 
-MOZALLOC_LIB = $(call EXPAND_MOZLIBNAME,mozalloc)
 
 # append debug flags 
 # (these might have been above when processing MOZ_DBGRINFO_MODULES)
 OS_CFLAGS += $(_DEBUG_CFLAGS)
 OS_CXXFLAGS += $(_DEBUG_CFLAGS)
 OS_LDFLAGS += $(_DEBUG_LDFLAGS)
 
 # XXX: What does this? Bug 482434 filed for better explanation.
--- a/js/src/xpconnect/shell/xpcshell.cpp
+++ b/js/src/xpconnect/shell/xpcshell.cpp
@@ -41,20 +41,16 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 /* XPConnect JavaScript interactive shell. */
 
 #include <stdio.h>
-#include "jsapi.h"
-#include "jscntxt.h"
-#include "jsdbgapi.h"
-#include "jsprf.h"
 #include "nsXULAppAPI.h"
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsStringAPI.h"
 #include "nsIXPConnect.h"
 #include "nsIXPCScriptable.h"
 #include "nsIInterfaceInfo.h"
 #include "nsIInterfaceInfoManager.h"
@@ -63,16 +59,19 @@
 #include "nsIComponentManager.h"
 #include "nsIComponentRegistrar.h"
 #include "nsILocalFile.h"
 #include "nsStringAPI.h"
 #include "nsIDirectoryService.h"
 #include "nsILocalFile.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsAppDirectoryServiceDefs.h"
+#include "jsapi.h"
+#include "jsdbgapi.h"
+#include "jsprf.h"
 #include "nscore.h"
 #include "nsArrayEnumerator.h"
 #include "nsCOMArray.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsMemory.h"
 #include "nsIGenericFactory.h"
 #include "nsISupportsImpl.h"
 #include "nsIJSRuntimeService.h"
@@ -525,16 +524,19 @@ DumpXPC(JSContext *cx, JSObject *obj, ui
     }
 
     nsCOMPtr<nsIXPConnect> xpc = do_GetService(nsIXPConnect::GetCID());
     if(xpc)
         xpc->DebugDump((int16)depth);
     return JS_TRUE;
 }
 
+/* XXX needed only by GC() */
+#include "jscntxt.h"
+
 static JSBool
 GC(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 {
     JSRuntime *rt;
     uint32 preBytes;
 
     rt = cx->runtime;
     preBytes = rt->gcBytes;
--- a/js/src/xpconnect/src/xpcJSWeakReference.cpp
+++ b/js/src/xpconnect/src/xpcJSWeakReference.cpp
@@ -29,18 +29,18 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
+#include "xpcJSWeakReference.h"
 #include "xpcprivate.h"
-#include "xpcJSWeakReference.h"
 
 xpcJSWeakReference::xpcJSWeakReference()
 {
 }
 
 NS_IMPL_ISUPPORTS1(xpcJSWeakReference, xpcIJSWeakReference)
 
 nsresult xpcJSWeakReference::Init()
--- a/js/src/xpconnect/src/xpcprivate.h
+++ b/js/src/xpconnect/src/xpcprivate.h
@@ -45,24 +45,16 @@
 
 #ifndef xpcprivate_h___
 #define xpcprivate_h___
 
 #include <string.h>
 #include <stdlib.h>
 #include <stdarg.h>
 #include <math.h>
-#include "jsapi.h"
-#include "jsdhash.h"
-#include "jsprf.h"
-#include "prprf.h"
-#include "jsinterp.h"
-#include "jscntxt.h"
-#include "jsdbgapi.h"
-#include "jsgc.h"
 #include "nscore.h"
 #include "nsXPCOM.h"
 #include "nsAutoPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsCycleCollector.h"
 #include "nsISupports.h"
 #include "nsIServiceManager.h"
 #include "nsIClassInfoImpl.h"
@@ -77,16 +69,24 @@
 #include "nsIXPCScriptable.h"
 #include "nsIXPCSecurityManager.h"
 #include "nsIJSRuntimeService.h"
 #include "nsWeakReference.h"
 #include "nsCOMPtr.h"
 #include "nsIModule.h"
 #include "nsAutoLock.h"
 #include "nsXPTCUtils.h"
+#include "jsapi.h"
+#include "jsdhash.h"
+#include "jsprf.h"
+#include "prprf.h"
+#include "jsinterp.h"
+#include "jscntxt.h"
+#include "jsdbgapi.h"
+#include "jsgc.h"
 #include "xptinfo.h"
 #include "xpcforwards.h"
 #include "xpclog.h"
 #include "xpccomponents.h"
 #include "xpcexception.h"
 #include "xpcjsid.h"
 #include "prlong.h"
 #include "prmem.h"
deleted file mode 100644
--- a/memory/Makefile.in
+++ /dev/null
@@ -1,52 +0,0 @@
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Original Code is the Mozilla platform.
-#
-# The Initial Developer of the Original Code is
-# the Mozilla Foundation <http://www.mozilla.org/>.
-# Portions created by the Initial Developer are Copyright (C) 2009
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 2 or later (the "GPL"), or
-# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
-
-DEPTH = ..
-topsrcdir = @top_srcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-DIRS =
-
-ifdef MOZ_MEMORY
-DIRS += jemalloc
-endif
-
-DIRS += mozalloc
-
-include $(topsrcdir)/config/rules.mk
deleted file mode 100644
--- a/memory/mozalloc/Makefile.in
+++ /dev/null
@@ -1,64 +0,0 @@
-#
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Original Code is mozilla.org code.
-#
-# The Initial Developer of the Original Code is
-# Mozilla Foundation
-# Portions created by the Initial Developer are Copyright (C) 2008
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#  Ted Mielczarek <ted.mielczarek@gmail.com>
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either of the GNU General Public License Version 2 or later (the "GPL"),
-# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
-
-DEPTH		= ../..
-topsrcdir	= @top_srcdir@
-srcdir		= @srcdir@
-VPATH		= @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-VISIBILITY_FLAGS=
-
-MODULE		= mozalloc
-LIBRARY_NAME	= mozalloc
-FORCE_SHARED_LIB= 1
-DIST_INSTALL 	= 1
-
-# The wince shunt relies on this library
-export NO_SHUNT	= 1
-
-EXPORTS_NAMESPACES 	= mozilla
-EXPORTS_mozilla 	= mozalloc.h mozalloc_macro_wrappers.h mozalloc_oom.h
-
-CPPSRCS =					\
-	mozalloc.cpp				\
-	mozalloc_oom.cpp			\
-	$(NULL)
-
-include $(topsrcdir)/config/rules.mk
deleted file mode 100644
--- a/memory/mozalloc/mozalloc.cpp
+++ /dev/null
@@ -1,209 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * vim: sw=4 ts=4 et :
- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation
- * Portions created by the Initial Developer are Copyright (C) 2009
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *  Chris Jones <jones.chris.g@gmail.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include <errno.h>
-#include <new>                  // for std::bad_alloc
-#include <string.h>
-
-#if defined(MALLOC_H)
-#  include MALLOC_H             // for memalign, valloc where available
-#endif // if defined(MALLOC_H)
-#include <stddef.h>             // for size_t
-#include <stdlib.h>             // for malloc, free
-
-// Make sure that "malloc" et al. resolve to their libc variants.
-#define MOZALLOC_DONT_DEFINE_MACRO_WRAPPERS
-#include "mozilla/mozalloc.h"
-#include "mozilla/mozalloc_oom.h"  // for mozalloc_handle_oom
-
-
-#if defined(__GNUC__) && (__GNUC__ > 2)
-#define LIKELY(x)    (__builtin_expect(!!(x), 1))
-#define UNLIKELY(x)  (__builtin_expect(!!(x), 0))
-#else
-#define LIKELY(x)    (x)
-#define UNLIKELY(x)  (x)
-#endif
-
-
-void*
-moz_xmalloc(size_t size)
-{
-    void* ptr = malloc(size);
-    if (UNLIKELY(!ptr)) {
-        mozalloc_handle_oom();
-        return moz_xmalloc(size);
-    }
-    return ptr;
-}
-void*
-moz_malloc(size_t size)
-{
-    return malloc(size);
-}
-
-void*
-moz_xcalloc(size_t nmemb, size_t size)
-{
-    void* ptr = calloc(nmemb, size);
-    if (UNLIKELY(!ptr)) {
-        mozalloc_handle_oom();
-        return moz_xcalloc(nmemb, size);
-    }
-    return ptr;
-}
-void*
-moz_calloc(size_t nmemb, size_t size)
-{
-    return calloc(nmemb, size);
-}
-
-void*
-moz_xrealloc(void* ptr, size_t size)
-{
-    void* newptr = realloc(ptr, size);
-    if (UNLIKELY(!newptr)) {
-        mozalloc_handle_oom();
-        return moz_xrealloc(ptr, size);
-    }
-    return newptr;
-}
-void*
-moz_realloc(void* ptr, size_t size)
-{
-    return realloc(ptr, size);
-}
-
-char*
-moz_xstrdup(const char* str)
-{
-    char* dup = strdup(str);
-    if (UNLIKELY(!dup)) {
-        mozalloc_handle_oom();
-        return moz_xstrdup(str);
-    }
-    return dup;
-}
-char*
-moz_strdup(const char* str)
-{
-    return strdup(str);
-}
-
-#if defined(HAVE_STRNDUP)
-char*
-moz_xstrndup(const char* str, size_t strsize)
-{
-    char* dup = strndup(str, strsize);
-    if (UNLIKELY(!dup)) {
-        mozalloc_handle_oom();
-        return moz_xstrndup(str, strsize);
-    }
-    return dup;
-}
-char*
-moz_strndup(const char* str, size_t strsize)
-{
-    return strndup(str, strsize);
-}
-#endif  // if defined(HAVE_STRNDUP)
-
-#if defined(HAVE_POSIX_MEMALIGN)
-int
-moz_xposix_memalign(void **ptr, size_t alignment, size_t size)
-{
-    int err = posix_memalign(ptr, alignment, size);
-    if (UNLIKELY(err && ENOMEM == err)) {
-        mozalloc_handle_oom();
-        return moz_xposix_memalign(ptr, alignment, size);
-    }
-    // else: (0 == err) or (EINVAL == err)
-    return err;
-}
-int
-moz_posix_memalign(void **ptr, size_t alignment, size_t size)
-{
-    return posix_memalign(ptr, alignment, size);
-}
-#endif // if defined(HAVE_POSIX_MEMALIGN)
-
-#if defined(HAVE_MEMALIGN)
-void*
-moz_xmemalign(size_t boundary, size_t size)
-{
-    void* ptr = memalign(boundary, size);
-    if (UNLIKELY(!ptr && EINVAL != errno)) {
-        mozalloc_handle_oom();
-        return moz_xmemalign(boundary, size);
-    }
-    // non-NULL ptr or errno == EINVAL
-    return ptr;
-}
-void*
-moz_memalign(size_t boundary, size_t size)
-{
-    return memalign(boundary, size);
-}
-#endif // if defined(HAVE_MEMALIGN)
-
-#if defined(HAVE_VALLOC)
-void*
-moz_xvalloc(size_t size)
-{
-    void* ptr = valloc(size);
-    if (UNLIKELY(!ptr)) {
-        mozalloc_handle_oom();
-        return moz_xvalloc(size);
-    }
-    return ptr;
-}
-void*
-moz_valloc(size_t size)
-{
-    return valloc(size);
-}
-#endif // if defined(HAVE_VALLOC)
-
-
-namespace mozilla {
-
-const fallible_t fallible = fallible_t();
-
-} // namespace mozilla
deleted file mode 100644
--- a/memory/mozalloc/mozalloc.h
+++ /dev/null
@@ -1,279 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * vim: sw=4 ts=4 et :
- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation
- * Portions created by the Initial Developer are Copyright (C) 2009
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *  Chris Jones <jones.chris.g@gmail.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef mozilla_mozalloc_h
-#define mozilla_mozalloc_h
-
-
-/*
- * https://bugzilla.mozilla.org/show_bug.cgi?id=427099
- */
-
-/* 
- * NB: this header depends on the symbols malloc(), free(), and
- * std::bad_alloc.  But because this header is used in situations
- * where malloc/free have different visibility, we rely on code
- * including this header to provide the declarations of malloc/free.
- * I.e., we don't #include <stdlib.h> or <new> on purpose.
- */
-
-#if defined(XP_WIN) || (defined(XP_OS2) && defined(__declspec))
-#  define MOZALLOC_EXPORT __declspec(dllexport)
-#elif defined(HAVE_VISIBILITY_ATTRIBUTE)
-/* Make sure symbols are still exported even if we're wrapped in a
- * |visibility push(hidden)| blanket. */
-#  define MOZALLOC_EXPORT __attribute__ ((visibility ("default")))
-#else
-#  define MOZALLOC_EXPORT
-#endif
-
-
-#if defined(NS_ALWAYS_INLINE)
-#  define MOZALLOC_INLINE NS_ALWAYS_INLINE inline
-#elif defined(HAVE_FORCEINLINE)
-#  define MOZALLOC_INLINE __forceinline
-#else
-#  define MOZALLOC_INLINE inline
-#endif
-
-
-#if defined(__cplusplus)
-extern "C" {
-#endif /* ifdef __cplusplus */
-
-
-/* 
- * If we don't have these system functions, but do have jemalloc
- * replacements, go ahead and declare them independently of jemalloc.
- * Trying to #include the jemalloc header causes redeclaration of some
- * system functions with different visibility.
- */
-/* FIXME/cjones: make something like the following work with jemalloc */
-#if 0
-#if !defined(HAVE_POSIX_MEMALIGN) && defined(HAVE_JEMALLOC_POSIX_MEMALIGN)
-MOZALLOC_IMPORT int posix_memalign(void **, size_t, size_t)
-    NS_WARN_UNUSED_RESULT;
-#endif
-#endif
-
-
-/*
- * Each pair of declarations below is analogous to a "standard"
- * allocation function, except that the out-of-memory handling is made
- * explicit.  The |moz_x| versions will never return a NULL pointer;
- * if memory is exhausted, they abort.  The |moz_| versions may return
- * NULL pointers if memory is exhausted: their return value must be
- * checked.
- *
- * All these allocation functions are *guaranteed* to return a pointer
- * to memory allocated in such a way that that memory can be freed by
- * passing that pointer to whatever function the symbol |free()|
- * resolves to at link time.
- */
-
-MOZALLOC_EXPORT void* moz_xmalloc(size_t size)
-    NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
-
-MOZALLOC_EXPORT
-void* moz_malloc(size_t size)
-    NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
-
-
-MOZALLOC_EXPORT void* moz_xcalloc(size_t nmemb, size_t size)
-    NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
-
-MOZALLOC_EXPORT void* moz_calloc(size_t nmemb, size_t size)
-    NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
-
-
-MOZALLOC_EXPORT void* moz_xrealloc(void* ptr, size_t size)
-    NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
-
-MOZALLOC_EXPORT void* moz_realloc(void* ptr, size_t size)
-    NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
-
-
-MOZALLOC_EXPORT char* moz_xstrdup(const char* str)
-    NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
-
-MOZALLOC_EXPORT char* moz_strdup(const char* str)
-    NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
-
-
-#if defined(HAVE_STRNDUP)
-MOZALLOC_EXPORT char* moz_xstrndup(const char* str, size_t strsize)
-    NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
-
-MOZALLOC_EXPORT char* moz_strndup(const char* str, size_t strsize)
-    NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
-#endif /* if defined(HAVE_STRNDUP) */
-
-
-#if defined(HAVE_POSIX_MEMALIGN)
-MOZALLOC_EXPORT int moz_xposix_memalign(void **ptr, size_t alignment, size_t size)
-    NS_WARN_UNUSED_RESULT;
-
-MOZALLOC_EXPORT int moz_posix_memalign(void **ptr, size_t alignment, size_t size)
-    NS_WARN_UNUSED_RESULT;
-#endif /* if defined(HAVE_POSIX_MEMALIGN) */
-
-
-#if defined(HAVE_MEMALIGN)
-MOZALLOC_EXPORT void* moz_xmemalign(size_t boundary, size_t size)
-    NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
-
-MOZALLOC_EXPORT void* moz_memalign(size_t boundary, size_t size)
-    NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
-#endif /* if defined(HAVE_MEMALIGN) */
-
-
-#if defined(HAVE_VALLOC)
-MOZALLOC_EXPORT void* moz_xvalloc(size_t size)
-    NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
-
-MOZALLOC_EXPORT void* moz_valloc(size_t size)
-    NS_ATTR_MALLOC NS_WARN_UNUSED_RESULT;
-#endif /* if defined(HAVE_VALLOC) */
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif /* ifdef __cplusplus */
-
-
-#ifdef __cplusplus
-
-/*
- * We implement the default operators new/delete as part of
- * libmozalloc, replacing their definitions in libstdc++.  The
- * operator new* definitions in libmozalloc will never return a NULL
- * pointer.
- *
- * Each operator new immediately below returns a pointer to memory
- * that can be delete'd by any of
- *
- *   (1) the matching infallible operator delete immediately below
- *   (2) the matching "fallible" operator delete further below
- *   (3) the matching system |operator delete(void*, std::nothrow)|
- *   (4) the matching system |operator delete(void*) throw(std::bad_alloc)|
- *
- * NB: these are declared |throw(std::bad_alloc)|, though they will never
- * throw that exception.  This declaration is consistent with the rule
- * that |::operator new() throw(std::bad_alloc)| will never return NULL.
- */
-
-MOZALLOC_INLINE
-void* operator new(size_t size) throw(std::bad_alloc)
-{
-    return moz_xmalloc(size);
-}
-
-MOZALLOC_INLINE
-void* operator new[](size_t size) throw(std::bad_alloc)
-{
-    return moz_xmalloc(size);
-}
-
-MOZALLOC_INLINE
-void operator delete(void* ptr) throw()
-{
-    return free(ptr);
-}
-
-MOZALLOC_INLINE
-void operator delete[](void* ptr) throw()
-{
-    return free(ptr);
-}
-
-
-/*
- * We also add a new allocator variant: "fallible operator new."
- * Unlike libmozalloc's implementations of the standard nofail
- * allocators, this allocator is allowed to return NULL.  It can be used
- * as follows
- *
- *   Foo* f = new (mozilla::fallible) Foo(...);
- *
- * operator delete(fallible) is defined for completeness only.
- *
- * Each operator new below returns a pointer to memory that can be
- * delete'd by any of
- *
- *   (1) the matching "fallible" operator delete below
- *   (2) the matching infallible operator delete above
- *   (3) the matching system |operator delete(void*, std::nothrow)|
- *   (4) the matching system |operator delete(void*) throw(std::bad_alloc)|
- */
-
-namespace mozilla {
-
-struct MOZALLOC_EXPORT fallible_t { };
-
-} /* namespace mozilla */
-
-MOZALLOC_INLINE
-void* operator new(size_t size, const mozilla::fallible_t&) throw()
-{
-    return malloc(size);
-}
-
-MOZALLOC_INLINE
-void* operator new[](size_t size, const mozilla::fallible_t&) throw()
-{
-    return malloc(size);
-}
-
-MOZALLOC_INLINE
-void operator delete(void* ptr, const mozilla::fallible_t&) throw()
-{
-    free(ptr);
-}
-
-MOZALLOC_INLINE
-void operator delete[](void* ptr, const mozilla::fallible_t&) throw()
-{
-    free(ptr);
-}
-
-#endif  /* ifdef __cplusplus */
-
-
-#endif /* ifndef mozilla_mozalloc_h */
deleted file mode 100644
--- a/memory/mozalloc/mozalloc_macro_wrappers.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * vim: sw=4 ts=4 et :
- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation
- * Portions created by the Initial Developer are Copyright (C) 2009
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *  Chris Jones <jones.chris.g@gmail.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef mozilla_mozalloc_macro_wrappers_h
-#define mozilla_mozalloc_macro_wrappers_h
-
-
-/*
- * Make libc "allocating functions" never fail (return NULL).
- *
- * FIXME: use infallible allocators by default after 
- *   http://bugzilla.mozilla.org/show_bug.cgi?id=507249
- * lands.
- */
-#define malloc(_) moz_malloc(_)
-
-#define calloc(_, __) moz_calloc(_, __)
-
-#define realloc(_, __) moz_realloc(_, __)
-
-#define strdup(_) moz_strdup(_)
-
-#if defined(HAVE_STRNDUP)
-#define strndup(_, __) moz_strndup(_, __)
-#endif
-
-#if defined(HAVE_POSIX_MEMALIGN)
-#define posix_memalign(_, __, ___) moz_posix_memalign(_, __, ___)
-#endif
-
-#if defined(HAVE_MEMALIGN)
-#define memalign(_, __) moz_memalign(_, __)
-#endif
-
-#if defined(HAVE_VALLOC)
-#define valloc(_) moz_valloc(_)
-#endif
-
-
-#endif /* ifndef mozilla_mozalloc_macro_wrappers_h */
deleted file mode 100644
--- a/memory/mozalloc/mozalloc_oom.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * vim: sw=4 ts=4 et :
- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation
- * Portions created by the Initial Developer are Copyright (C) 2009
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *  Chris Jones <jones.chris.g@gmail.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include <stdlib.h>             // for abort()
-
-#if defined(_WIN32)
-#  include <signal.h>           // for raise
-#elif defined(XP_UNIX)
-#  include <unistd.h>           // for _exit
-#endif
-
-#include "mozilla/mozalloc_oom.h"
-
-static int gDummyCounter;
-
-void
-mozalloc_handle_oom()
-{
-    // NB: this is handle_oom() stage 1, which simply aborts on OOM.
-    // we might proceed to a stage 2 in which an attempt is made to
-    // reclaim memory
-
-    // XXX/cjones: most of this function was copied from
-    // xpcom/base/nsDebugImpl.cpp:Abort(), except that we assume on
-    // UNIX-like platforms can directly abort() rather than need to go
-    // through PR_Abort(). we don't want this code to rely on NSPR.
-
-#if defined(_WIN32)
-#  if !defined(WINCE)
-    //This should exit us
-    raise(SIGABRT);
-#  endif
-    //If we are ignored exit this way..
-    _exit(3);
-#elif defined(XP_UNIX) || defined(XP_OS2) || defined(XP_BEOS)
-    abort();
-#else
-#  warning not attempting to abort() on this platform
-#endif
-
-    // Still haven't aborted?  Try dereferencing null.
-    // (Written this way to lessen the likelihood of it being optimized away.)
-    gDummyCounter += *((int*) 0); // TODO annotation saying we know 
-    // this is crazy
-    
-    // Still haven't aborted?  Try _exit().
-    _exit(127);
-}
deleted file mode 100644
--- a/memory/mozalloc/mozalloc_oom.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * vim: sw=4 ts=4 et :
- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Mozilla Foundation
- * Portions created by the Initial Developer are Copyright (C) 2009
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *  Chris Jones <jones.chris.g@gmail.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef mozilla_mozalloc_oom_h
-#define mozilla_mozalloc_oom_h
-
-
-#if defined(XP_WIN) || (defined(XP_OS2) && defined(__declspec))
-#  define MOZALLOC_EXPORT __declspec(dllexport)
-#elif defined(HAVE_VISIBILITY_ATTRIBUTE)
-/* Make sure symbols are still exported even if we're wrapped in a
- * |visibility push(hidden)| blanket. */
-#  define MOZALLOC_EXPORT __attribute__ ((visibility ("default")))
-#else
-#  define MOZALLOC_EXPORT
-#endif
-
-
-/**
- * Called when memory is critically low.  Returns iff it was able to 
- * remedy the critical memory situation; if not, it will abort().
- * 
- * We have to re-#define MOZALLOC_EXPORT because this header can be
- * used indepedently of mozalloc.h.
- */
-MOZALLOC_EXPORT void mozalloc_handle_oom();
-
-
-/* TODO: functions to query system memory usage and register
- * critical-memory handlers. */
-
-
-#endif /* ifndef mozilla_mozalloc_oom_h */
--- a/modules/plugin/base/src/nsJSNPRuntime.cpp
+++ b/modules/plugin/base/src/nsJSNPRuntime.cpp
@@ -31,33 +31,33 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-// FIXME(bug 332648): Give me a real API please!
-#include "jscntxt.h"
-
 #include "nsJSNPRuntime.h"
 #include "nsNPAPIPlugin.h"
 #include "nsNPAPIPluginInstance.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIScriptContext.h"
 #include "nsDOMJSUtils.h"
 #include "nsIDocument.h"
 #include "nsIJSRuntimeService.h"
 #include "nsIJSContextStack.h"
 #include "nsIXPConnect.h"
 #include "nsIDOMElement.h"
 #include "prmem.h"
 #include "nsIContent.h"
 
+// FIXME(bug 332648): Give me a real API please!
+#include "jscntxt.h"
+
 // Hash of JSObject wrappers that wraps JSObjects as NPObjects. There
 // will be one wrapper per JSObject per plugin instance, i.e. if two
 // plugins access the JSObject x, two wrappers for x will be
 // created. This is needed to be able to properly drop the wrappers
 // when a plugin is torn down in case there's a leak in the plugin (we
 // don't want to leak the world just because a plugin leaks an
 // NPObject).
 static PLDHashTable sJSObjWrappers;
--- a/modules/plugin/base/src/nsNPAPIPlugin.cpp
+++ b/modules/plugin/base/src/nsNPAPIPlugin.cpp
@@ -34,19 +34,16 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "prtypes.h"
 #include "prmem.h"
 #include "prclist.h"
-
-#include "jscntxt.h"
-
 #include "nsAutoLock.h"
 #include "nsNPAPIPlugin.h"
 #include "nsNPAPIPluginInstance.h"
 #include "nsNPAPIPluginStreamListener.h"
 #include "nsIServiceManager.h"
 #include "nsThreadUtils.h"
 #include "nsIPrivateBrowsingService.h"
 
@@ -63,16 +60,18 @@
 #include "nsIDOMDocument.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDocument.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIScriptContext.h"
 #include "nsDOMJSUtils.h"
 #include "nsIPrincipal.h"
 
+#include "jscntxt.h"
+
 #include "nsIXPConnect.h"
 
 #include "nsIObserverService.h"
 #include <prinrval.h>
 
 #ifdef XP_MACOSX
 #include <Carbon/Carbon.h>
 #endif
--- a/modules/plugin/default/windows/Makefile.in
+++ b/modules/plugin/default/windows/Makefile.in
@@ -56,18 +56,16 @@ CPPSRCS		= \
 		dialogs.cpp \
 		npshell.cpp \
 		npwin.cpp \
 		utils.cpp \
 		$(NULL)
 
 LOCAL_INCLUDES	= -I$(srcdir)
 
-DEFINES += -DXPCOM_GLUE
-
 # plugins should always be shared, even in the "static" build
 FORCE_SHARED_LIB = 1
 
 # Force use of PIC
 FORCE_USE_PIC	= 1
 
 # must link statically with the CRT to avoid problems with VC8
 USE_STATIC_LIBS = 1
--- a/toolkit/components/faststart/Makefile.in
+++ b/toolkit/components/faststart/Makefile.in
@@ -37,18 +37,16 @@
 
 DEPTH     = ../../..
 topsrcdir = @top_srcdir@
 srcdir    = @srcdir@
 VPATH     = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
-DEFINES += -DMOZ_NO_MOZALLOC
-
 EXTRA_PP_COMPONENTS = \
     FastStartup.js \
     $(NULL)
 
 ifdef _MSC_VER
 ifdef WINCE
 CPPSRCS = \
     faststartstub.cpp \
--- a/toolkit/components/remote/nsGTKRemoteService.cpp
+++ b/toolkit/components/remote/nsGTKRemoteService.cpp
@@ -337,16 +337,20 @@ nsGTKRemoteService::HandleCommand(char* 
   if (p1 == kNotFound || p2 == kNotFound || p1 == 0 || p2 < p1) {
     return "500 command not parseable";
   }
 
   command.Truncate(p1);
   command.Trim(" ", PR_TRUE, PR_TRUE);
   ToLowerCase(command);
 
+#ifdef DEBUG_bsmedberg
+  printf("Processing xremote command: %s\n", command.get());
+#endif
+
   if (!command.EqualsLiteral("ping")) {
     nsCAutoString desktopStartupID;
     nsDependentCString cmd(aCommand);
     FindExtensionParameterInCommand("DESKTOP_STARTUP_ID",
                                     cmd, '\n',
                                     &desktopStartupID);
 
     char* argv[3] = {"dummyappname", "-remote", aCommand};
@@ -384,16 +388,23 @@ nsGTKRemoteService::HandleCommandLine(ch
   // followed by a series of null-terminated strings:
   //
   // [argc][offsetargv0][offsetargv1...]<workingdir>\0<argv[0]>\0argv[1]...\0
   // (offset is from the beginning of the buffer)
 
   PRInt32 argc = TO_LITTLE_ENDIAN32(*reinterpret_cast<PRInt32*>(aBuffer));
   char *wd   = aBuffer + ((argc + 1) * sizeof(PRInt32));
 
+#ifdef DEBUG_bsmedberg
+  printf("Receiving command line:\n"
+         "  wd:\t%s\n"
+         "  argc:\t%i\n",
+         wd, argc);
+#endif
+
   nsCOMPtr<nsILocalFile> lf;
   rv = NS_NewNativeLocalFile(nsDependentCString(wd), PR_TRUE,
                              getter_AddRefs(lf));
   if (NS_FAILED(rv))
     return "509 internal error";
 
   nsCAutoString desktopStartupID;
 
@@ -406,16 +417,19 @@ nsGTKRemoteService::HandleCommandLine(ch
     argv[i] = aBuffer + TO_LITTLE_ENDIAN32(offset[i]);
 
     if (i == 0) {
       nsDependentCString cmd(argv[0]);
       FindExtensionParameterInCommand("DESKTOP_STARTUP_ID",
                                       cmd, ' ',
                                       &desktopStartupID);
     }
+#ifdef DEBUG_bsmedberg
+    printf("  argv[%i]:\t%s\n", i, argv[i]);
+#endif
   }
 
   rv = cmdline->Init(argc, argv, lf, nsICommandLine::STATE_REMOTE_AUTO);
   free (argv);
   if (NS_FAILED(rv)) {
     return "509 internal error";
   }
 
@@ -506,16 +520,20 @@ nsGTKRemoteService::HandlePropertyChange
                                  &actual_type,             /* actual_type return */
                                  &actual_format,           /* actual_format_return */
                                  &nitems,                  /* nitems_return */
                                  &bytes_after,             /* bytes_after_return */
                                  (unsigned char **)&data); /* prop_return
                                                               (we only care
                                                               about the first ) */
 
+#ifdef DEBUG_bsmedberg
+    printf("Handling command: %s\n", data);
+#endif
+
     // Failed to get property off the window?
     if (result != Success)
       return FALSE;
 
     // Failed to get the data off the window or it was the wrong type?
     if (!data || !TO_LITTLE_ENDIAN32(*reinterpret_cast<PRInt32*>(data)))
       return FALSE;
 
--- a/toolkit/library/Makefile.in
+++ b/toolkit/library/Makefile.in
@@ -175,17 +175,17 @@ else
 EXTRA_DSO_LDOPTS += \
 	$(MOZ_COMPONENT_LIBS) \
 	$(MOZ_JS_LIBS) \
 	$(NULL)
 endif
 
 DEFINES += -DIMPL_XREAPI
 
-EXTRA_DSO_LDOPTS += $(NSPR_LIBS) $(MOZALLOC_LIB)
+EXTRA_DSO_LDOPTS += $(NSPR_LIBS)
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
 CXXFLAGS	+= $(TK_CFLAGS)
 EXTRA_DSO_LDOPTS += \
 	-framework SystemConfiguration \
 	-framework QuickTime \
 	-framework IOKit \
 	-lcrypto \
--- a/widget/src/xremoteclient/Makefile.in
+++ b/widget/src/xremoteclient/Makefile.in
@@ -46,18 +46,16 @@ VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= xremoteclient
 LIBRARY_NAME = xremote_client_s
 FORCE_STATIC_LIB = 1
 
 
-DEFINES += -DXPCOM_GLUE
-
 ifdef MOZ_ENABLE_PHOTON
 	CPPSRCS		+= PhRemoteClient.cpp
 else
 	CPPSRCS		+= XRemoteClient.cpp
 endif
 
 EXTRA_DSO_LDOPTS = \
 		$(XLIBS) $(XLDFLAGS)  \
--- a/xpcom/base/nsMemoryImpl.cpp
+++ b/xpcom/base/nsMemoryImpl.cpp
@@ -259,41 +259,41 @@ nsMemoryImpl::FlushEvent
 nsMemoryImpl::sFlushEvent;
 
 XPCOM_API(void*)
 NS_Alloc(PRSize size)
 {
     if (size > PR_INT32_MAX)
         return nsnull;
 
-    void* result = moz_malloc(size);
+    void* result = PR_Malloc(size);
     if (! result) {
         // Request an asynchronous flush
         sGlobalMemory.FlushMemory(NS_LITERAL_STRING("alloc-failure").get(), PR_FALSE);
     }
     return result;
 }
 
 XPCOM_API(void*)
 NS_Realloc(void* ptr, PRSize size)
 {
     if (size > PR_INT32_MAX)
         return nsnull;
 
-    void* result = moz_realloc(ptr, size);
+    void* result = PR_Realloc(ptr, size);
     if (! result && size != 0) {
         // Request an asynchronous flush
         sGlobalMemory.FlushMemory(NS_LITERAL_STRING("alloc-failure").get(), PR_FALSE);
     }
     return result;
 }
 
 XPCOM_API(void)
 NS_Free(void* ptr)
 {
-    free(ptr);
+    PR_Free(ptr);
 }
 
 nsresult
 NS_GetMemoryManager(nsIMemory* *result)
 {
     return sGlobalMemory.QueryInterface(NS_GET_IID(nsIMemory), (void**) result);
 }
--- a/xpcom/base/nscore.h
+++ b/xpcom/base/nscore.h
@@ -40,26 +40,16 @@
 /**
  * Make sure that we have the proper platform specific
  * c++ definitions needed by nscore.h
  */
 #ifndef _XPCOM_CONFIG_H_
 #include "xpcom-config.h"
 #endif
 
-/* Definitions of functions and operators that allocate memory. */
-#if !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
-#  if defined(__cplusplus)
-#    include <new>              /* to give mozalloc std::bad_alloc */
-#  endif
-#  include <stdlib.h>         /* to give mozalloc malloc/free decls */
-#  include "mozilla/mozalloc.h"
-#  include "mozilla/mozalloc_macro_wrappers.h"
-#endif
-
 /**
  * Incorporate the core NSPR data types which XPCOM uses.
  */
 #include "prtypes.h"
 
 /* Core XPCOM declarations. */
 
 /**
--- a/xpcom/build/Makefile.in
+++ b/xpcom/build/Makefile.in
@@ -144,20 +144,17 @@ GARBAGE         += $(XPCOM_GLUE_SRC_LCSR
 include $(topsrcdir)/config/rules.mk
 
 DEFINES		+= \
 		-D_IMPL_NS_COM \
 		-D_IMPL_NS_STRINGAPI \
 		-DEXPORT_XPT_API \
 		-DEXPORT_XPTC_API
 
-EXTRA_DSO_LDOPTS +=				\
-	$(MOZALLOC_LIB)				\
-	$(NSPR_LIBS)				\
-	$(NULL)
+EXTRA_DSO_LDOPTS += $(NSPR_LIBS)
 
 ifdef TARGET_XPCOM_ABI
 DEFINES += -DTARGET_XPCOM_ABI=\"$(TARGET_XPCOM_ABI)\"
 endif
 
 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
 CXXFLAGS	+= $(TK_CFLAGS)
 EXTRA_DSO_LDOPTS += \
--- a/xpcom/string/public/nsUTF8Utils.h
+++ b/xpcom/string/public/nsUTF8Utils.h
@@ -53,16 +53,22 @@ class UTF8traits
       static PRBool isInSeq(char c) { return (c & 0xC0) == 0x80; }
       static PRBool is2byte(char c) { return (c & 0xE0) == 0xC0; }
       static PRBool is3byte(char c) { return (c & 0xF0) == 0xE0; }
       static PRBool is4byte(char c) { return (c & 0xF8) == 0xF0; }
       static PRBool is5byte(char c) { return (c & 0xFC) == 0xF8; }
       static PRBool is6byte(char c) { return (c & 0xFE) == 0xFC; }
   };
 
+#ifdef __GNUC__
+#define NS_ALWAYS_INLINE __attribute__((always_inline))
+#else
+#define NS_ALWAYS_INLINE
+#endif
+
 /**
  * Extract the next UCS-4 character from the buffer and return it.  The
  * pointer passed in is advanced to the start of the next character in the
  * buffer.  If non-null, the parameters err and overlong are filled in to
  * indicate that the character was represented by an overlong sequence, or
  * that an error occurred.
  */
 
--- a/xpcom/stub/Makefile.in
+++ b/xpcom/stub/Makefile.in
@@ -73,17 +73,16 @@ FORCE_USE_PIC	= 1
 FORCE_SHARED_LIB = 1
 
 EXTRA_DSO_LDOPTS = $(LIBS_DIR)
 
 DEPENDENT_LIBS_LIST += \
 	$(LIB_PREFIX)nspr4$(DLL_SUFFIX) \
 	$(LIB_PREFIX)plc4$(DLL_SUFFIX) \
 	$(LIB_PREFIX)plds4$(DLL_SUFFIX) \
-	$(LIB_PREFIX)mozalloc$(DLL_SUFFIX) \
 	$(NULL)
 
 ifdef MOZ_ENABLE_LIBXUL
 
 DEPENDENT_LIBS_LIST += \
 	$(LIB_PREFIX)sqlite3$(DLL_SUFFIX) \
 	$(LIB_PREFIX)nssutil3$(DLL_SUFFIX) \
 	$(LIB_PREFIX)softokn3$(DLL_SUFFIX) \
@@ -111,23 +110,19 @@ else #!MOZ_ENABLE_LIBXUL
 ifeq ($(OS_TARGET),OS2)
 EXTRA_DSO_LIBS = xpcomcor
 DEPENDENT_LIBS_LIST += xpcomcor.dll
 else
 EXTRA_DSO_LIBS = xpcom_core
 DEPENDENT_LIBS_LIST += $(LIB_PREFIX)xpcom_core$(DLL_SUFFIX)
 endif
 
-endif #ifdef MOZ_ENABLE_LIBXUL
+endif
 
-EXTRA_DSO_LDOPTS +=				\
-	$(EXTRA_DSO_LIBS)			\
-	$(NSPR_LIBS)				\
-	$(MOZALLOC_LIB)				\
-	$(NULL)
+EXTRA_DSO_LDOPTS += $(EXTRA_DSO_LIBS) $(NSPR_LIBS)
 
 include $(topsrcdir)/config/rules.mk
 
 libs:: $(FINAL_TARGET)/dependentlibs.list
 
 $(FINAL_TARGET)/dependentlibs.list: Makefile.in
 	$(EXIT_ON_ERROR) \
 	( $(foreach dlib,$(DEPENDENT_LIBS_LIST),echo $(dlib);) ) > $@