Restore --enable-ivsalloc.

However, unlike before it was removed do not force --enable-ivsalloc
when Darwin zone allocator integration is enabled, since the zone
allocator code uses ivsalloc() regardless of whether
malloc_usable_size() and sallocx() do.

This resolves #211.
This commit is contained in:
Jason Evans 2015-03-18 21:06:58 -07:00
parent 8d6a3e8321
commit e0a08a1496
6 changed files with 43 additions and 5 deletions

View File

@ -133,8 +133,6 @@ found in the git revision history:
- Remove the "stats.huge.allocated", "stats.huge.nmalloc", and - Remove the "stats.huge.allocated", "stats.huge.nmalloc", and
"stats.huge.ndalloc" mallctls. "stats.huge.ndalloc" mallctls.
- Remove the --enable-mremap option. - Remove the --enable-mremap option.
- Remove the --enable-ivsalloc option, and merge its functionality into
--enable-debug.
- Remove the "stats.chunks.current", "stats.chunks.total", and - Remove the "stats.chunks.current", "stats.chunks.total", and
"stats.chunks.high" mallctls. "stats.chunks.high" mallctls.

View File

@ -92,6 +92,7 @@ any of the following arguments (not a definitive list) to 'configure':
--enable-debug --enable-debug
Enable assertions and validation code. This incurs a substantial Enable assertions and validation code. This incurs a substantial
performance hit, but is very useful during application development. performance hit, but is very useful during application development.
Implies --enable-ivsalloc.
--enable-code-coverage --enable-code-coverage
Enable code coverage support, for use during jemalloc test development. Enable code coverage support, for use during jemalloc test development.
@ -110,6 +111,11 @@ any of the following arguments (not a definitive list) to 'configure':
Disable statistics gathering functionality. See the "opt.stats_print" Disable statistics gathering functionality. See the "opt.stats_print"
option documentation for usage details. option documentation for usage details.
--enable-ivsalloc
Enable validation code, which verifies that pointers reside within
jemalloc-owned chunks before dereferencing them. This incurs a minor
performance hit.
--enable-prof --enable-prof
Enable heap profiling and leak detection functionality. See the "opt.prof" Enable heap profiling and leak detection functionality. See the "opt.prof"
option documentation for usage details. When enabled, there are several option documentation for usage details. When enabled, there are several

View File

@ -625,7 +625,8 @@ fi
dnl Do not compile with debugging by default. dnl Do not compile with debugging by default.
AC_ARG_ENABLE([debug], AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug], [Build debugging code])], [AS_HELP_STRING([--enable-debug],
[Build debugging code (implies --enable-ivsalloc)])],
[if test "x$enable_debug" = "xno" ; then [if test "x$enable_debug" = "xno" ; then
enable_debug="0" enable_debug="0"
else else
@ -637,8 +638,28 @@ fi
if test "x$enable_debug" = "x1" ; then if test "x$enable_debug" = "x1" ; then
AC_DEFINE([JEMALLOC_DEBUG], [ ]) AC_DEFINE([JEMALLOC_DEBUG], [ ])
fi fi
if test "x$enable_debug" = "x1" ; then
AC_DEFINE([JEMALLOC_DEBUG], [ ])
enable_ivsalloc="1"
fi
AC_SUBST([enable_debug]) AC_SUBST([enable_debug])
dnl Do not validate pointers by default.
AC_ARG_ENABLE([ivsalloc],
[AS_HELP_STRING([--enable-ivsalloc],
[Validate pointers passed through the public API])],
[if test "x$enable_ivsalloc" = "xno" ; then
enable_ivsalloc="0"
else
enable_ivsalloc="1"
fi
],
[enable_ivsalloc="0"]
)
if test "x$enable_ivsalloc" = "x1" ; then
AC_DEFINE([JEMALLOC_IVSALLOC], [ ])
fi
dnl Only optimize if not debugging. dnl Only optimize if not debugging.
if test "x$enable_debug" = "x0" -a "x$no_CFLAGS" = "xyes" ; then if test "x$enable_debug" = "x0" -a "x$no_CFLAGS" = "xyes" ; then
dnl Make sure that an optimization flag was not specified in EXTRA_CFLAGS. dnl Make sure that an optimization flag was not specified in EXTRA_CFLAGS.

View File

@ -119,6 +119,13 @@ static const bool config_xmalloc =
false false
#endif #endif
; ;
static const bool config_ivsalloc =
#ifdef JEMALLOC_IVSALLOC
true
#else
false
#endif
;
#ifdef JEMALLOC_C11ATOMICS #ifdef JEMALLOC_C11ATOMICS
#include <stdatomic.h> #include <stdatomic.h>

View File

@ -186,6 +186,12 @@
#undef JEMALLOC_INTERNAL_FFSL #undef JEMALLOC_INTERNAL_FFSL
#undef JEMALLOC_INTERNAL_FFS #undef JEMALLOC_INTERNAL_FFS
/*
* JEMALLOC_IVSALLOC enables ivsalloc(), which verifies that pointers reside
* within jemalloc-owned chunks before dereferencing them.
*/
#undef JEMALLOC_IVSALLOC
/* /*
* Darwin (OS X) uses zones to work around Mach-O symbol override shortcomings. * Darwin (OS X) uses zones to work around Mach-O symbol override shortcomings.
*/ */

View File

@ -2306,7 +2306,7 @@ je_sallocx(const void *ptr, int flags)
assert(malloc_initialized() || IS_INITIALIZER); assert(malloc_initialized() || IS_INITIALIZER);
malloc_thread_init(); malloc_thread_init();
if (config_debug) if (config_ivsalloc)
usize = ivsalloc(ptr, config_prof); usize = ivsalloc(ptr, config_prof);
else else
usize = isalloc(ptr, config_prof); usize = isalloc(ptr, config_prof);
@ -2434,7 +2434,7 @@ je_malloc_usable_size(JEMALLOC_USABLE_SIZE_CONST void *ptr)
assert(malloc_initialized() || IS_INITIALIZER); assert(malloc_initialized() || IS_INITIALIZER);
malloc_thread_init(); malloc_thread_init();
if (config_debug) if (config_ivsalloc)
ret = ivsalloc(ptr, config_prof); ret = ivsalloc(ptr, config_prof);
else else
ret = (ptr == NULL) ? 0 : isalloc(ptr, config_prof); ret = (ptr == NULL) ? 0 : isalloc(ptr, config_prof);