summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Goldblatt <davidgoldblatt@fb.com>2019-03-19 16:04:35 -0700
committerDavid Goldblatt <davidtgoldblatt@gmail.com>2019-04-15 16:48:12 -0700
commitf4d24f05e1f270c43bc4129c0d18d673b8ac85b8 (patch)
tree4e3e0d1ae1f5c496a889ec13691bc6c090d7f8fb /src
parent7f7935cf7805036d42fb510592ab8b40bcfb0690 (diff)
Move extra size checks behind a config flag.
This will let us turn that flag into a generic "turn on runtime checks" flag that guards other functionality we have planned.
Diffstat (limited to 'src')
-rw-r--r--src/tcache.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/tcache.c b/src/tcache.c
index e7b970d9..160b0b77 100644
--- a/src/tcache.c
+++ b/src/tcache.c
@@ -101,7 +101,6 @@ tcache_alloc_small_hard(tsdn_t *tsdn, arena_t *arena, tcache_t *tcache,
}
/* Enabled with --enable-extra-size-check. */
-#ifdef JEMALLOC_EXTRA_SIZE_CHECK
static void
tbin_extents_lookup_size_check(tsdn_t *tsdn, cache_bin_t *tbin, szind_t binind,
size_t nflush, extent_t **extents){
@@ -129,7 +128,6 @@ tbin_extents_lookup_size_check(tsdn_t *tsdn, cache_bin_t *tbin, szind_t binind,
abort();
}
}
-#endif
void
tcache_bin_flush_small(tsd_t *tsd, tcache_t *tcache, cache_bin_t *tbin,
@@ -144,15 +142,16 @@ tcache_bin_flush_small(tsd_t *tsd, tcache_t *tcache, cache_bin_t *tbin,
unsigned nflush = tbin->ncached - rem;
VARIABLE_ARRAY(extent_t *, item_extent, nflush);
-#ifndef JEMALLOC_EXTRA_SIZE_CHECK
/* Look up extent once per item. */
- for (unsigned i = 0 ; i < nflush; i++) {
- item_extent[i] = iealloc(tsd_tsdn(tsd), *(tbin->avail - 1 - i));
+ if (config_opt_safety_checks) {
+ tbin_extents_lookup_size_check(tsd_tsdn(tsd), tbin, binind,
+ nflush, item_extent);
+ } else {
+ for (unsigned i = 0 ; i < nflush; i++) {
+ item_extent[i] = iealloc(tsd_tsdn(tsd),
+ *(tbin->avail - 1 - i));
+ }
}
-#else
- tbin_extents_lookup_size_check(tsd_tsdn(tsd), tbin, binind, nflush,
- item_extent);
-#endif
while (nflush > 0) {
/* Lock the arena bin associated with the first object. */
extent_t *extent = item_extent[0];