author | Chris Jones <jones.chris.g@gmail.com> |
Wed, 21 Apr 2010 23:41:40 -0500 | |
changeset 41149 | 97db872fb3b542a3a3b1819e29a8eea961bb9e8b |
parent 41148 | dff91f83bc84e05e3a669efc81d3f7c323815821 |
child 41150 | 774f9718376fefe51b1cf25b289df9ed4cb560a3 |
push id | 1 |
push user | root |
push date | Tue, 26 Apr 2011 22:38:44 +0000 |
treeherder | mozilla-beta@bfdb6e623a36 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | bsmedberg |
bugs | 550692 |
milestone | 1.9.3a5pre |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
|
--- a/memory/jemalloc/jemalloc.h +++ b/memory/jemalloc/jemalloc.h @@ -84,21 +84,21 @@ typedef struct { void *malloc(size_t size); void *valloc(size_t size); void *calloc(size_t num, size_t size); void *realloc(void *ptr, size_t size); void free(void *ptr); int posix_memalign(void **memptr, size_t alignment, size_t size); #endif /* MOZ_MEMORY_DARWIN, MOZ_MEMORY_LINUX */ -/* Linux has memalign */ +/* Linux has memalign and malloc_usable_size */ #if !defined(MOZ_MEMORY_LINUX) void *memalign(size_t alignment, size_t size); +size_t malloc_usable_size(const void *ptr); #endif /* MOZ_MEMORY_LINUX */ -size_t malloc_usable_size(const void *ptr); void jemalloc_stats(jemalloc_stats_t *stats); #ifdef __cplusplus } /* extern "C" */ #endif #endif /* _JEMALLOC_H_ */
--- a/memory/mozalloc/mozalloc.cpp +++ b/memory/mozalloc/mozalloc.cpp @@ -46,16 +46,21 @@ # 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 #if defined(XP_UNIX) # include <unistd.h> // for valloc on *BSD #endif //if defined(XP_UNIX) +#if defined(MOZ_MEMORY) +// jemalloc.h doesn't redeclare symbols if they're provided by the OS +# include "jemalloc.h" +#endif + #if defined(XP_WIN) || (defined(XP_OS2) && defined(__declspec)) # define MOZALLOC_EXPORT __declspec(dllexport) #endif // 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 @@ -153,17 +158,17 @@ moz_xstrndup(const char* str, size_t str } char* moz_strndup(const char* str, size_t strsize) { return strndup(str, strsize); } #endif // if defined(HAVE_STRNDUP) -#if defined(HAVE_POSIX_MEMALIGN) +#if defined(HAVE_POSIX_MEMALIGN) || defined(HAVE_JEMALLOC_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); } @@ -172,17 +177,17 @@ moz_xposix_memalign(void **ptr, size_t a } 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) +#if defined(HAVE_MEMALIGN) || defined(HAVE_JEMALLOC_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); }
--- a/memory/mozalloc/mozalloc.h +++ b/memory/mozalloc/mozalloc.h @@ -82,31 +82,16 @@ # define NS_ATTR_MALLOC #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. * @@ -151,26 +136,26 @@ MOZALLOC_EXPORT char* moz_strdup(const c 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) +#if defined(HAVE_POSIX_MEMALIGN) || defined(HAVE_JEMALLOC_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) +#if defined(HAVE_MEMALIGN) || defined(HAVE_JEMALLOC_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) */
--- a/memory/mozalloc/mozalloc_macro_wrappers.h +++ b/memory/mozalloc/mozalloc_macro_wrappers.h @@ -58,21 +58,21 @@ #define realloc(_, __) moz_realloc(_, __) #define strdup(_) moz_strdup(_) #if defined(HAVE_STRNDUP) #define strndup(_, __) moz_strndup(_, __) #endif -#if defined(HAVE_POSIX_MEMALIGN) +#if defined(HAVE_POSIX_MEMALIGN) || defined(HAVE_JEMALLOC_POSIX_MEMALIGN) #define posix_memalign(_, __, ___) moz_posix_memalign(_, __, ___) #endif -#if defined(HAVE_MEMALIGN) +#if defined(HAVE_MEMALIGN) || defined(HAVE_JEMALLOC_MEMALIGN) #define memalign(_, __) moz_memalign(_, __) #endif #if defined(HAVE_VALLOC) #define valloc(_) moz_valloc(_) #endif