Update generated files for 4.1.0 update.

Removed the hack to do an always purge. Instead use the new decay
purging mechanism, but set the decay timeout to 0 so it always purges
without the need to change the code.

Added back the a0get function to use for huge chunk allocation patch
we use for android.

Bug: 27408522
Change-Id: Ic75c4a03b362fd0f9654f0803fb9624ef82d417e
diff --git a/Android.mk b/Android.mk
index a08b16f..43cb8a1 100644
--- a/Android.mk
+++ b/Android.mk
@@ -88,12 +88,15 @@
 	src/jemalloc.c \
 	src/mb.c \
 	src/mutex.c \
+	src/nstime.c \
 	src/pages.c \
+	src/prng.c \
 	src/prof.c \
 	src/quarantine.c \
 	src/rtree.c \
 	src/stats.c \
 	src/tcache.c \
+	src/ticker.c \
 	src/tsd.c \
 	src/util.c \
 
@@ -203,6 +206,7 @@
 	test/unit/atomic.c \
 	test/unit/bitmap.c \
 	test/unit/ckh.c \
+	test/unit/decay.c \
 	test/unit/hash.c \
 	test/unit/junk.c \
 	test/unit/junk_alloc.c \
@@ -212,6 +216,8 @@
 	test/unit/math.c \
 	test/unit/mq.c \
 	test/unit/mtx.c \
+	test/unit/nstime.c \
+	test/unit/prng.c \
 	test/unit/prof_accum.c \
 	test/unit/prof_active.c \
 	test/unit/prof_gdump.c \
@@ -223,9 +229,12 @@
 	test/unit/quarantine.c \
 	test/unit/rb.c \
 	test/unit/rtree.c \
+	test/unit/run_quantize.c \
 	test/unit/SFMT.c \
 	test/unit/size_classes.c \
+	test/unit/smoothstep.c \
 	test/unit/stats.c \
+	test/unit/ticker.c \
 	test/unit/tsd.c \
 	test/unit/util.c \
 	test/unit/zero.c \
diff --git a/android/test/run_jemalloc_tests.sh b/android/test/run_jemalloc_tests.sh
index 75670f4..e4a935d 100755
--- a/android/test/run_jemalloc_tests.sh
+++ b/android/test/run_jemalloc_tests.sh
@@ -20,6 +20,7 @@
   "atomic" \
   "bitmap" \
   "ckh" \
+  "decay" \
   "hash" \
   "junk" \
   "junk_alloc" \
@@ -29,6 +30,8 @@
   "math" \
   "mq" \
   "mtx" \
+  "nstime" \
+  "prng" \
   "prof_accum" \
   "prof_active" \
   "prof_gdump" \
@@ -40,9 +43,12 @@
   "quarantine" \
   "rb" \
   "rtree" \
+  "run_quantize" \
   "SFMT" \
   "size_classes" \
+  "smoothstep" \
   "stats" \
+  "ticker" \
   "tsd" \
   "util" \
   "zero" \
diff --git a/include/jemalloc/internal/arena.h b/include/jemalloc/internal/arena.h
index a6cce02..f234ec6 100644
--- a/include/jemalloc/internal/arena.h
+++ b/include/jemalloc/internal/arena.h
@@ -29,9 +29,14 @@
 
 	purge_mode_limit = 2
 } purge_mode_t;
-#define	PURGE_DEFAULT		purge_mode_ratio
+/* ANDROID change */
+/* Use the decay mode purge method. By setting the DECAY_TIME_DEFAULT to
+ * zero, this forces all pages to be purged as soon as they are not in use.
+ */
+#define	PURGE_DEFAULT		purge_mode_decay
 /* Default decay time in seconds. */
-#define	DECAY_TIME_DEFAULT	10
+#define	DECAY_TIME_DEFAULT	0
+/* End ANDROID change */
 /* Number of event ticks between time checks. */
 #define	DECAY_NTICKS_PER_UPDATE	1000
 
diff --git a/include/jemalloc/internal/jemalloc_internal.h b/include/jemalloc/internal/jemalloc_internal.h
index c172006..6f94356 100644
--- a/include/jemalloc/internal/jemalloc_internal.h
+++ b/include/jemalloc/internal/jemalloc_internal.h
@@ -49,6 +49,7 @@
     false
 #endif
     ;
+static const char * const config_malloc_conf = JEMALLOC_CONFIG_MALLOC_CONF;
 static const bool config_prof =
 #ifdef JEMALLOC_PROF
     true
@@ -355,12 +356,15 @@
 #  define VARIABLE_ARRAY(type, name, count) type name[(count)]
 #endif
 
+#include "jemalloc/internal/nstime.h"
 #include "jemalloc/internal/valgrind.h"
 #include "jemalloc/internal/util.h"
 #include "jemalloc/internal/atomic.h"
 #include "jemalloc/internal/prng.h"
+#include "jemalloc/internal/ticker.h"
 #include "jemalloc/internal/ckh.h"
 #include "jemalloc/internal/size_classes.h"
+#include "jemalloc/internal/smoothstep.h"
 #include "jemalloc/internal/stats.h"
 #include "jemalloc/internal/ctl.h"
 #include "jemalloc/internal/mutex.h"
@@ -383,12 +387,15 @@
 /******************************************************************************/
 #define	JEMALLOC_H_STRUCTS
 
+#include "jemalloc/internal/nstime.h"
 #include "jemalloc/internal/valgrind.h"
 #include "jemalloc/internal/util.h"
 #include "jemalloc/internal/atomic.h"
 #include "jemalloc/internal/prng.h"
+#include "jemalloc/internal/ticker.h"
 #include "jemalloc/internal/ckh.h"
 #include "jemalloc/internal/size_classes.h"
+#include "jemalloc/internal/smoothstep.h"
 #include "jemalloc/internal/stats.h"
 #include "jemalloc/internal/ctl.h"
 #include "jemalloc/internal/mutex.h"
@@ -426,12 +433,18 @@
 extern bool	opt_utrace;
 extern bool	opt_xmalloc;
 extern bool	opt_zero;
-extern size_t	opt_narenas;
+extern unsigned	opt_narenas;
 
 extern bool	in_valgrind;
 
 /* Number of CPUs. */
-extern unsigned		ncpus;
+extern unsigned	ncpus;
+
+/*
+ * Arenas that are used to service external requests.  Not all elements of the
+ * arenas array are necessarily used; arenas are created lazily as needed.
+ */
+extern arena_t	**arenas;
 
 /*
  * index2size_tab encodes the same information as could be computed (at
@@ -445,35 +458,36 @@
  */
 extern uint8_t const	size2index_tab[];
 
-arena_t	*a0get(void);
 void	*a0malloc(size_t size);
 void	a0dalloc(void *ptr);
 void	*bootstrap_malloc(size_t size);
 void	*bootstrap_calloc(size_t num, size_t size);
 void	bootstrap_free(void *ptr);
 arena_t	*arenas_extend(unsigned ind);
-arena_t	*arena_init(unsigned ind);
 unsigned	narenas_total_get(void);
-arena_t	*arena_get_hard(tsd_t *tsd, unsigned ind, bool init_if_missing);
+arena_t	*arena_init(unsigned ind);
+arena_tdata_t	*arena_tdata_get_hard(tsd_t *tsd, unsigned ind);
 arena_t	*arena_choose_hard(tsd_t *tsd);
 void	arena_migrate(tsd_t *tsd, unsigned oldind, unsigned newind);
-unsigned	arena_nbound(unsigned ind);
 void	thread_allocated_cleanup(tsd_t *tsd);
 void	thread_deallocated_cleanup(tsd_t *tsd);
 void	arena_cleanup(tsd_t *tsd);
-void	arenas_cache_cleanup(tsd_t *tsd);
-void	narenas_cache_cleanup(tsd_t *tsd);
-void	arenas_cache_bypass_cleanup(tsd_t *tsd);
+void	arenas_tdata_cleanup(tsd_t *tsd);
+void	narenas_tdata_cleanup(tsd_t *tsd);
+void	arenas_tdata_bypass_cleanup(tsd_t *tsd);
 void	jemalloc_prefork(void);
 void	jemalloc_postfork_parent(void);
 void	jemalloc_postfork_child(void);
 
+#include "jemalloc/internal/nstime.h"
 #include "jemalloc/internal/valgrind.h"
 #include "jemalloc/internal/util.h"
 #include "jemalloc/internal/atomic.h"
 #include "jemalloc/internal/prng.h"
+#include "jemalloc/internal/ticker.h"
 #include "jemalloc/internal/ckh.h"
 #include "jemalloc/internal/size_classes.h"
+#include "jemalloc/internal/smoothstep.h"
 #include "jemalloc/internal/stats.h"
 #include "jemalloc/internal/ctl.h"
 #include "jemalloc/internal/mutex.h"
@@ -496,12 +510,15 @@
 /******************************************************************************/
 #define	JEMALLOC_H_INLINES
 
+#include "jemalloc/internal/nstime.h"
 #include "jemalloc/internal/valgrind.h"
 #include "jemalloc/internal/util.h"
 #include "jemalloc/internal/atomic.h"
 #include "jemalloc/internal/prng.h"
+#include "jemalloc/internal/ticker.h"
 #include "jemalloc/internal/ckh.h"
 #include "jemalloc/internal/size_classes.h"
+#include "jemalloc/internal/smoothstep.h"
 #include "jemalloc/internal/stats.h"
 #include "jemalloc/internal/ctl.h"
 #include "jemalloc/internal/mutex.h"
@@ -526,8 +543,10 @@
 size_t	s2u(size_t size);
 size_t	sa2u(size_t size, size_t alignment);
 arena_t	*arena_choose(tsd_t *tsd, arena_t *arena);
-arena_t	*arena_get(tsd_t *tsd, unsigned ind, bool init_if_missing,
+arena_tdata_t	*arena_tdata_get(tsd_t *tsd, unsigned ind,
     bool refresh_if_missing);
+arena_t	*arena_get(unsigned ind, bool init_if_missing);
+ticker_t	*decay_ticker_get(tsd_t *tsd, unsigned ind);
 #endif
 
 #if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_C_))
@@ -537,27 +556,27 @@
 
 #if (NTBINS != 0)
 	if (size <= (ZU(1) << LG_TINY_MAXCLASS)) {
-		size_t lg_tmin = LG_TINY_MAXCLASS - NTBINS + 1;
-		size_t lg_ceil = lg_floor(pow2_ceil(size));
+		szind_t lg_tmin = LG_TINY_MAXCLASS - NTBINS + 1;
+		szind_t lg_ceil = lg_floor(pow2_ceil_zu(size));
 		return (lg_ceil < lg_tmin ? 0 : lg_ceil - lg_tmin);
 	}
 #endif
 	{
-		size_t x = unlikely(ZI(size) < 0) ? ((size<<1) ?
+		szind_t x = unlikely(ZI(size) < 0) ? ((size<<1) ?
 		    (ZU(1)<<(LG_SIZEOF_PTR+3)) : ((ZU(1)<<(LG_SIZEOF_PTR+3))-1))
 		    : lg_floor((size<<1)-1);
-		size_t shift = (x < LG_SIZE_CLASS_GROUP + LG_QUANTUM) ? 0 :
+		szind_t shift = (x < LG_SIZE_CLASS_GROUP + LG_QUANTUM) ? 0 :
 		    x - (LG_SIZE_CLASS_GROUP + LG_QUANTUM);
-		size_t grp = shift << LG_SIZE_CLASS_GROUP;
+		szind_t grp = shift << LG_SIZE_CLASS_GROUP;
 
-		size_t lg_delta = (x < LG_SIZE_CLASS_GROUP + LG_QUANTUM + 1)
+		szind_t lg_delta = (x < LG_SIZE_CLASS_GROUP + LG_QUANTUM + 1)
 		    ? LG_QUANTUM : x - LG_SIZE_CLASS_GROUP - 1;
 
 		size_t delta_inverse_mask = ZI(-1) << lg_delta;
-		size_t mod = ((((size-1) & delta_inverse_mask) >> lg_delta)) &
+		szind_t mod = ((((size-1) & delta_inverse_mask) >> lg_delta)) &
 		    ((ZU(1) << LG_SIZE_CLASS_GROUP) - 1);
 
-		size_t index = NTBINS + grp + mod;
+		szind_t index = NTBINS + grp + mod;
 		return (index);
 	}
 }
@@ -568,8 +587,7 @@
 
 	assert(size <= LOOKUP_MAXCLASS);
 	{
-		size_t ret = ((size_t)(size2index_tab[(size-1) >>
-		    LG_TINY_MIN]));
+		szind_t ret = (size2index_tab[(size-1) >> LG_TINY_MIN]);
 		assert(ret == size2index_compute(size));
 		return (ret);
 	}
@@ -624,7 +642,7 @@
 index2size(szind_t index)
 {
 
-	assert(index <= NSIZES);
+	assert(index < NSIZES);
 	return (index2size_lookup(index));
 }
 
@@ -635,7 +653,7 @@
 #if (NTBINS > 0)
 	if (size <= (ZU(1) << LG_TINY_MAXCLASS)) {
 		size_t lg_tmin = LG_TINY_MAXCLASS - NTBINS + 1;
-		size_t lg_ceil = lg_floor(pow2_ceil(size));
+		size_t lg_ceil = lg_floor(pow2_ceil_zu(size));
 		return (lg_ceil < lg_tmin ? (ZU(1) << lg_tmin) :
 		    (ZU(1) << lg_ceil));
 	}
@@ -727,17 +745,16 @@
 			return (usize);
 	}
 
-	/* Huge size class.  Beware of size_t overflow. */
+	/* Huge size class.  Beware of overflow. */
+
+	if (unlikely(alignment > HUGE_MAXCLASS))
+		return (0);
 
 	/*
 	 * We can't achieve subchunk alignment, so round up alignment to the
 	 * minimum that can actually be supported.
 	 */
 	alignment = CHUNK_CEILING(alignment);
-	if (alignment == 0) {
-		/* size_t overflow. */
-		return (0);
-	}
 
 	/* Make sure result is a huge size class. */
 	if (size <= chunksize)
@@ -776,32 +793,56 @@
 	return (ret);
 }
 
-JEMALLOC_INLINE arena_t *
-arena_get(tsd_t *tsd, unsigned ind, bool init_if_missing,
-    bool refresh_if_missing)
+JEMALLOC_INLINE arena_tdata_t *
+arena_tdata_get(tsd_t *tsd, unsigned ind, bool refresh_if_missing)
 {
-	arena_t *arena;
-	arena_t **arenas_cache = tsd_arenas_cache_get(tsd);
+	arena_tdata_t *tdata;
+	arena_tdata_t *arenas_tdata = tsd_arenas_tdata_get(tsd);
 
-	/* init_if_missing requires refresh_if_missing. */
-	assert(!init_if_missing || refresh_if_missing);
-
-	if (unlikely(arenas_cache == NULL)) {
-		/* arenas_cache hasn't been initialized yet. */
-		return (arena_get_hard(tsd, ind, init_if_missing));
+	if (unlikely(arenas_tdata == NULL)) {
+		/* arenas_tdata hasn't been initialized yet. */
+		return (arena_tdata_get_hard(tsd, ind));
 	}
-	if (unlikely(ind >= tsd_narenas_cache_get(tsd))) {
+	if (unlikely(ind >= tsd_narenas_tdata_get(tsd))) {
 		/*
-		 * ind is invalid, cache is old (too small), or arena to be
+		 * ind is invalid, cache is old (too small), or tdata to be
 		 * initialized.
 		 */
-		return (refresh_if_missing ? arena_get_hard(tsd, ind,
-		    init_if_missing) : NULL);
+		return (refresh_if_missing ? arena_tdata_get_hard(tsd, ind) :
+		    NULL);
 	}
-	arena = arenas_cache[ind];
-	if (likely(arena != NULL) || !refresh_if_missing)
-		return (arena);
-	return (arena_get_hard(tsd, ind, init_if_missing));
+
+	tdata = &arenas_tdata[ind];
+	if (likely(tdata != NULL) || !refresh_if_missing)
+		return (tdata);
+	return (arena_tdata_get_hard(tsd, ind));
+}
+
+JEMALLOC_INLINE arena_t *
+arena_get(unsigned ind, bool init_if_missing)
+{
+	arena_t *ret;
+
+	assert(ind <= MALLOCX_ARENA_MAX);
+
+	ret = arenas[ind];
+	if (unlikely(ret == NULL)) {
+		ret = atomic_read_p((void *)&arenas[ind]);
+		if (init_if_missing && unlikely(ret == NULL))
+			ret = arena_init(ind);
+	}
+	return (ret);
+}
+
+JEMALLOC_INLINE ticker_t *
+decay_ticker_get(tsd_t *tsd, unsigned ind)
+{
+	arena_tdata_t *tdata;
+
+	tdata = arena_tdata_get(tsd, ind, true);
+	if (unlikely(tdata == NULL))
+		return (NULL);
+	return (&tdata->decay_ticker);
 }
 #endif
 
@@ -853,8 +894,8 @@
     size_t alignment, bool zero, tcache_t *tcache, arena_t *arena);
 void	*iralloc(tsd_t *tsd, void *ptr, size_t oldsize, size_t size,
     size_t alignment, bool zero);
-bool	ixalloc(void *ptr, size_t oldsize, size_t size, size_t extra,
-    size_t alignment, bool zero);
+bool	ixalloc(tsd_t *tsd, void *ptr, size_t oldsize, size_t size,
+    size_t extra, size_t alignment, bool zero);
 #endif
 
 #if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_C_))
@@ -959,8 +1000,8 @@
 ipalloc(tsd_t *tsd, size_t usize, size_t alignment, bool zero)
 {
 
-	return (ipallocztm(tsd, usize, alignment, zero, tcache_get(tsd,
-	    NULL), false, NULL));
+	return (ipallocztm(tsd, usize, alignment, zero, tcache_get(tsd, true),
+	    false, NULL));
 }
 
 JEMALLOC_ALWAYS_INLINE size_t
@@ -1064,7 +1105,7 @@
 	size_t usize, copysize;
 
 	usize = sa2u(size + extra, alignment);
-	if (usize == 0)
+	if (unlikely(usize == 0 || usize > HUGE_MAXCLASS))
 		return (NULL);
 	p = ipalloct(tsd, usize, alignment, zero, tcache, arena);
 	if (p == NULL) {
@@ -1072,7 +1113,7 @@
 			return (NULL);
 		/* Try again, without extra this time. */
 		usize = sa2u(size, alignment);
-		if (usize == 0)
+		if (unlikely(usize == 0 || usize > HUGE_MAXCLASS))
 			return (NULL);
 		p = ipalloct(tsd, usize, alignment, zero, tcache, arena);
 		if (p == NULL)
@@ -1120,8 +1161,8 @@
 }
 
 JEMALLOC_ALWAYS_INLINE bool
-ixalloc(void *ptr, size_t oldsize, size_t size, size_t extra, size_t alignment,
-    bool zero)
+ixalloc(tsd_t *tsd, void *ptr, size_t oldsize, size_t size, size_t extra,
+    size_t alignment, bool zero)
 {
 
 	assert(ptr != NULL);
@@ -1133,7 +1174,7 @@
 		return (true);
 	}
 
-	return (arena_ralloc_no_move(ptr, oldsize, size, extra, zero));
+	return (arena_ralloc_no_move(tsd, ptr, oldsize, size, extra, zero));
 }
 #endif
 
diff --git a/include/jemalloc/internal/jemalloc_internal_defs.h b/include/jemalloc/internal/jemalloc_internal_defs.h
index d72831f..c746c92 100644
--- a/include/jemalloc/internal/jemalloc_internal_defs.h
+++ b/include/jemalloc/internal/jemalloc_internal_defs.h
@@ -195,9 +195,10 @@
 /* #undef JEMALLOC_TLS */
 
 /*
- * ffs()/ffsl() functions to use for bitmapping.  Don't use these directly;
- * instead, use jemalloc_ffs() or jemalloc_ffsl() from util.h.
+ * ffs*() functions to use for bitmapping.  Don't use these directly; instead,
+ * use ffs_*() from util.h.
  */
+#define JEMALLOC_INTERNAL_FFSLL __builtin_ffsll
 #define JEMALLOC_INTERNAL_FFSL __builtin_ffsl
 #define JEMALLOC_INTERNAL_FFS __builtin_ffs
 
@@ -251,6 +252,9 @@
 #define LG_SIZEOF_LONG 2
 #endif
 
+/* sizeof(long long) == 2^LG_SIZEOF_LONG_LONG. */
+#define LG_SIZEOF_LONG_LONG 3
+
 /* sizeof(intmax_t) == 2^LG_SIZEOF_INTMAX_T. */
 #define LG_SIZEOF_INTMAX_T 3
 
@@ -269,4 +273,7 @@
  */
 #define JEMALLOC_EXPORT 
 
+/* config.malloc_conf options string. */
+#define JEMALLOC_CONFIG_MALLOC_CONF ""
+
 #endif /* JEMALLOC_INTERNAL_DEFS_H_ */
diff --git a/include/jemalloc/internal/private_namespace.h b/include/jemalloc/internal/private_namespace.h
index c43f73d..e1cb05b 100644
--- a/include/jemalloc/internal/private_namespace.h
+++ b/include/jemalloc/internal/private_namespace.h
@@ -1,8 +1,8 @@
 #define	a0dalloc JEMALLOC_N(a0dalloc)
-#define	a0get JEMALLOC_N(a0get)
 #define	a0malloc JEMALLOC_N(a0malloc)
 #define	arena_aalloc JEMALLOC_N(arena_aalloc)
 #define	arena_alloc_junk_small JEMALLOC_N(arena_alloc_junk_small)
+#define	arena_basic_stats_merge JEMALLOC_N(arena_basic_stats_merge)
 #define	arena_bin_index JEMALLOC_N(arena_bin_index)
 #define	arena_bin_info JEMALLOC_N(arena_bin_info)
 #define	arena_bitselm_get JEMALLOC_N(arena_bitselm_get)
@@ -25,18 +25,23 @@
 #define	arena_dalloc_large JEMALLOC_N(arena_dalloc_large)
 #define	arena_dalloc_large_junked_locked JEMALLOC_N(arena_dalloc_large_junked_locked)
 #define	arena_dalloc_small JEMALLOC_N(arena_dalloc_small)
+#define	arena_decay_tick JEMALLOC_N(arena_decay_tick)
+#define	arena_decay_ticks JEMALLOC_N(arena_decay_ticks)
+#define	arena_decay_time_default_get JEMALLOC_N(arena_decay_time_default_get)
+#define	arena_decay_time_default_set JEMALLOC_N(arena_decay_time_default_set)
+#define	arena_decay_time_get JEMALLOC_N(arena_decay_time_get)
+#define	arena_decay_time_set JEMALLOC_N(arena_decay_time_set)
 #define	arena_dss_prec_get JEMALLOC_N(arena_dss_prec_get)
 #define	arena_dss_prec_set JEMALLOC_N(arena_dss_prec_set)
 #define	arena_get JEMALLOC_N(arena_get)
-#define	arena_get_hard JEMALLOC_N(arena_get_hard)
 #define	arena_init JEMALLOC_N(arena_init)
 #define	arena_lg_dirty_mult_default_get JEMALLOC_N(arena_lg_dirty_mult_default_get)
 #define	arena_lg_dirty_mult_default_set JEMALLOC_N(arena_lg_dirty_mult_default_set)
 #define	arena_lg_dirty_mult_get JEMALLOC_N(arena_lg_dirty_mult_get)
 #define	arena_lg_dirty_mult_set JEMALLOC_N(arena_lg_dirty_mult_set)
 #define	arena_malloc JEMALLOC_N(arena_malloc)
+#define	arena_malloc_hard JEMALLOC_N(arena_malloc_hard)
 #define	arena_malloc_large JEMALLOC_N(arena_malloc_large)
-#define	arena_malloc_small JEMALLOC_N(arena_malloc_small)
 #define	arena_mapbits_allocated_get JEMALLOC_N(arena_mapbits_allocated_get)
 #define	arena_mapbits_binind_get JEMALLOC_N(arena_mapbits_binind_get)
 #define	arena_mapbits_decommitted_get JEMALLOC_N(arena_mapbits_decommitted_get)
@@ -47,9 +52,6 @@
 #define	arena_mapbits_large_get JEMALLOC_N(arena_mapbits_large_get)
 #define	arena_mapbits_large_set JEMALLOC_N(arena_mapbits_large_set)
 #define	arena_mapbits_large_size_get JEMALLOC_N(arena_mapbits_large_size_get)
-#define	arena_mapbitsp_get JEMALLOC_N(arena_mapbitsp_get)
-#define	arena_mapbitsp_read JEMALLOC_N(arena_mapbitsp_read)
-#define	arena_mapbitsp_write JEMALLOC_N(arena_mapbitsp_write)
 #define	arena_mapbits_size_decode JEMALLOC_N(arena_mapbits_size_decode)
 #define	arena_mapbits_size_encode JEMALLOC_N(arena_mapbits_size_encode)
 #define	arena_mapbits_small_runind_get JEMALLOC_N(arena_mapbits_small_runind_get)
@@ -58,6 +60,9 @@
 #define	arena_mapbits_unallocated_size_get JEMALLOC_N(arena_mapbits_unallocated_size_get)
 #define	arena_mapbits_unallocated_size_set JEMALLOC_N(arena_mapbits_unallocated_size_set)
 #define	arena_mapbits_unzeroed_get JEMALLOC_N(arena_mapbits_unzeroed_get)
+#define	arena_mapbitsp_get JEMALLOC_N(arena_mapbitsp_get)
+#define	arena_mapbitsp_read JEMALLOC_N(arena_mapbitsp_read)
+#define	arena_mapbitsp_write JEMALLOC_N(arena_mapbitsp_write)
 #define	arena_maxrun JEMALLOC_N(arena_maxrun)
 #define	arena_maybe_purge JEMALLOC_N(arena_maybe_purge)
 #define	arena_metadata_allocated_add JEMALLOC_N(arena_metadata_allocated_add)
@@ -67,10 +72,12 @@
 #define	arena_miscelm_get JEMALLOC_N(arena_miscelm_get)
 #define	arena_miscelm_to_pageind JEMALLOC_N(arena_miscelm_to_pageind)
 #define	arena_miscelm_to_rpages JEMALLOC_N(arena_miscelm_to_rpages)
-#define	arena_nbound JEMALLOC_N(arena_nbound)
 #define	arena_new JEMALLOC_N(arena_new)
 #define	arena_node_alloc JEMALLOC_N(arena_node_alloc)
 #define	arena_node_dalloc JEMALLOC_N(arena_node_dalloc)
+#define	arena_nthreads_dec JEMALLOC_N(arena_nthreads_dec)
+#define	arena_nthreads_get JEMALLOC_N(arena_nthreads_get)
+#define	arena_nthreads_inc JEMALLOC_N(arena_nthreads_inc)
 #define	arena_palloc JEMALLOC_N(arena_palloc)
 #define	arena_postfork_child JEMALLOC_N(arena_postfork_child)
 #define	arena_postfork_parent JEMALLOC_N(arena_postfork_parent)
@@ -83,7 +90,7 @@
 #define	arena_prof_tctx_reset JEMALLOC_N(arena_prof_tctx_reset)
 #define	arena_prof_tctx_set JEMALLOC_N(arena_prof_tctx_set)
 #define	arena_ptr_small_binind_get JEMALLOC_N(arena_ptr_small_binind_get)
-#define	arena_purge_all JEMALLOC_N(arena_purge_all)
+#define	arena_purge JEMALLOC_N(arena_purge)
 #define	arena_quarantine_junk_small JEMALLOC_N(arena_quarantine_junk_small)
 #define	arena_ralloc JEMALLOC_N(arena_ralloc)
 #define	arena_ralloc_junk_large JEMALLOC_N(arena_ralloc_junk_large)
@@ -93,11 +100,14 @@
 #define	arena_run_regind JEMALLOC_N(arena_run_regind)
 #define	arena_run_to_miscelm JEMALLOC_N(arena_run_to_miscelm)
 #define	arena_salloc JEMALLOC_N(arena_salloc)
-#define	arenas_cache_bypass_cleanup JEMALLOC_N(arenas_cache_bypass_cleanup)
-#define	arenas_cache_cleanup JEMALLOC_N(arenas_cache_cleanup)
 #define	arena_sdalloc JEMALLOC_N(arena_sdalloc)
 #define	arena_stats_merge JEMALLOC_N(arena_stats_merge)
 #define	arena_tcache_fill_small JEMALLOC_N(arena_tcache_fill_small)
+#define	arena_tdata_get JEMALLOC_N(arena_tdata_get)
+#define	arena_tdata_get_hard JEMALLOC_N(arena_tdata_get_hard)
+#define	arenas JEMALLOC_N(arenas)
+#define	arenas_tdata_bypass_cleanup JEMALLOC_N(arenas_tdata_bypass_cleanup)
+#define	arenas_tdata_cleanup JEMALLOC_N(arenas_tdata_cleanup)
 #define	atomic_add_p JEMALLOC_N(atomic_add_p)
 #define	atomic_add_u JEMALLOC_N(atomic_add_u)
 #define	atomic_add_uint32 JEMALLOC_N(atomic_add_uint32)
@@ -122,7 +132,6 @@
 #define	bitmap_full JEMALLOC_N(bitmap_full)
 #define	bitmap_get JEMALLOC_N(bitmap_get)
 #define	bitmap_info_init JEMALLOC_N(bitmap_info_init)
-#define	bitmap_info_ngroups JEMALLOC_N(bitmap_info_ngroups)
 #define	bitmap_init JEMALLOC_N(bitmap_init)
 #define	bitmap_set JEMALLOC_N(bitmap_set)
 #define	bitmap_sfu JEMALLOC_N(bitmap_sfu)
@@ -162,9 +171,9 @@
 #define	chunk_purge_arena JEMALLOC_N(chunk_purge_arena)
 #define	chunk_purge_wrapper JEMALLOC_N(chunk_purge_wrapper)
 #define	chunk_register JEMALLOC_N(chunk_register)
+#define	chunks_rtree JEMALLOC_N(chunks_rtree)
 #define	chunksize JEMALLOC_N(chunksize)
 #define	chunksize_mask JEMALLOC_N(chunksize_mask)
-#define	chunks_rtree JEMALLOC_N(chunks_rtree)
 #define	ckh_count JEMALLOC_N(ckh_count)
 #define	ckh_delete JEMALLOC_N(ckh_delete)
 #define	ckh_insert JEMALLOC_N(ckh_insert)
@@ -183,6 +192,7 @@
 #define	ctl_postfork_child JEMALLOC_N(ctl_postfork_child)
 #define	ctl_postfork_parent JEMALLOC_N(ctl_postfork_parent)
 #define	ctl_prefork JEMALLOC_N(ctl_prefork)
+#define	decay_ticker_get JEMALLOC_N(decay_ticker_get)
 #define	dss_prec_names JEMALLOC_N(dss_prec_names)
 #define	extent_node_achunk_get JEMALLOC_N(extent_node_achunk_get)
 #define	extent_node_achunk_set JEMALLOC_N(extent_node_achunk_set)
@@ -234,6 +244,12 @@
 #define	extent_tree_szad_reverse_iter_recurse JEMALLOC_N(extent_tree_szad_reverse_iter_recurse)
 #define	extent_tree_szad_reverse_iter_start JEMALLOC_N(extent_tree_szad_reverse_iter_start)
 #define	extent_tree_szad_search JEMALLOC_N(extent_tree_szad_search)
+#define	ffs_llu JEMALLOC_N(ffs_llu)
+#define	ffs_lu JEMALLOC_N(ffs_lu)
+#define	ffs_u JEMALLOC_N(ffs_u)
+#define	ffs_u32 JEMALLOC_N(ffs_u32)
+#define	ffs_u64 JEMALLOC_N(ffs_u64)
+#define	ffs_zu JEMALLOC_N(ffs_zu)
 #define	get_errno JEMALLOC_N(get_errno)
 #define	hash JEMALLOC_N(hash)
 #define	hash_fmix_32 JEMALLOC_N(hash_fmix_32)
@@ -265,11 +281,11 @@
 #define	idalloctm JEMALLOC_N(idalloctm)
 #define	imalloc JEMALLOC_N(imalloc)
 #define	imalloct JEMALLOC_N(imalloct)
+#define	in_valgrind JEMALLOC_N(in_valgrind)
 #define	index2size JEMALLOC_N(index2size)
 #define	index2size_compute JEMALLOC_N(index2size_compute)
 #define	index2size_lookup JEMALLOC_N(index2size_lookup)
 #define	index2size_tab JEMALLOC_N(index2size_tab)
-#define	in_valgrind JEMALLOC_N(in_valgrind)
 #define	ipalloc JEMALLOC_N(ipalloc)
 #define	ipalloct JEMALLOC_N(ipalloct)
 #define	ipallocztm JEMALLOC_N(ipallocztm)
@@ -311,11 +327,25 @@
 #define	map_misc_offset JEMALLOC_N(map_misc_offset)
 #define	mb_write JEMALLOC_N(mb_write)
 #define	mutex_boot JEMALLOC_N(mutex_boot)
-#define	narenas_cache_cleanup JEMALLOC_N(narenas_cache_cleanup)
+#define	narenas_tdata_cleanup JEMALLOC_N(narenas_tdata_cleanup)
 #define	narenas_total_get JEMALLOC_N(narenas_total_get)
 #define	ncpus JEMALLOC_N(ncpus)
 #define	nhbins JEMALLOC_N(nhbins)
+#define	nstime_add JEMALLOC_N(nstime_add)
+#define	nstime_compare JEMALLOC_N(nstime_compare)
+#define	nstime_copy JEMALLOC_N(nstime_copy)
+#define	nstime_divide JEMALLOC_N(nstime_divide)
+#define	nstime_idivide JEMALLOC_N(nstime_idivide)
+#define	nstime_imultiply JEMALLOC_N(nstime_imultiply)
+#define	nstime_init JEMALLOC_N(nstime_init)
+#define	nstime_init2 JEMALLOC_N(nstime_init2)
+#define	nstime_ns JEMALLOC_N(nstime_ns)
+#define	nstime_nsec JEMALLOC_N(nstime_nsec)
+#define	nstime_sec JEMALLOC_N(nstime_sec)
+#define	nstime_subtract JEMALLOC_N(nstime_subtract)
+#define	nstime_update JEMALLOC_N(nstime_update)
 #define	opt_abort JEMALLOC_N(opt_abort)
+#define	opt_decay_time JEMALLOC_N(opt_decay_time)
 #define	opt_dss JEMALLOC_N(opt_dss)
 #define	opt_junk JEMALLOC_N(opt_junk)
 #define	opt_junk_alloc JEMALLOC_N(opt_junk_alloc)
@@ -334,6 +364,7 @@
 #define	opt_prof_leak JEMALLOC_N(opt_prof_leak)
 #define	opt_prof_prefix JEMALLOC_N(opt_prof_prefix)
 #define	opt_prof_thread_active_init JEMALLOC_N(opt_prof_thread_active_init)
+#define	opt_purge JEMALLOC_N(opt_purge)
 #define	opt_quarantine JEMALLOC_N(opt_quarantine)
 #define	opt_redzone JEMALLOC_N(opt_redzone)
 #define	opt_stats_print JEMALLOC_N(opt_stats_print)
@@ -348,7 +379,11 @@
 #define	pages_purge JEMALLOC_N(pages_purge)
 #define	pages_trim JEMALLOC_N(pages_trim)
 #define	pages_unmap JEMALLOC_N(pages_unmap)
-#define	pow2_ceil JEMALLOC_N(pow2_ceil)
+#define	pow2_ceil_u32 JEMALLOC_N(pow2_ceil_u32)
+#define	pow2_ceil_u64 JEMALLOC_N(pow2_ceil_u64)
+#define	pow2_ceil_zu JEMALLOC_N(pow2_ceil_zu)
+#define	prng_lg_range JEMALLOC_N(prng_lg_range)
+#define	prng_range JEMALLOC_N(prng_range)
 #define	prof_active_get JEMALLOC_N(prof_active_get)
 #define	prof_active_get_unlocked JEMALLOC_N(prof_active_get_unlocked)
 #define	prof_active_set JEMALLOC_N(prof_active_set)
@@ -393,6 +428,7 @@
 #define	prof_thread_active_set JEMALLOC_N(prof_thread_active_set)
 #define	prof_thread_name_get JEMALLOC_N(prof_thread_name_get)
 #define	prof_thread_name_set JEMALLOC_N(prof_thread_name_set)
+#define	purge_mode_names JEMALLOC_N(purge_mode_names)
 #define	quarantine JEMALLOC_N(quarantine)
 #define	quarantine_alloc_hook JEMALLOC_N(quarantine_alloc_hook)
 #define	quarantine_alloc_hook_work JEMALLOC_N(quarantine_alloc_hook_work)
@@ -413,6 +449,9 @@
 #define	rtree_subtree_tryread JEMALLOC_N(rtree_subtree_tryread)
 #define	rtree_val_read JEMALLOC_N(rtree_val_read)
 #define	rtree_val_write JEMALLOC_N(rtree_val_write)
+#define	run_quantize_ceil JEMALLOC_N(run_quantize_ceil)
+#define	run_quantize_floor JEMALLOC_N(run_quantize_floor)
+#define	run_quantize_max JEMALLOC_N(run_quantize_max)
 #define	s2u JEMALLOC_N(s2u)
 #define	s2u_compute JEMALLOC_N(s2u_compute)
 #define	s2u_lookup JEMALLOC_N(s2u_lookup)
@@ -451,15 +490,20 @@
 #define	tcache_get JEMALLOC_N(tcache_get)
 #define	tcache_get_hard JEMALLOC_N(tcache_get_hard)
 #define	tcache_maxclass JEMALLOC_N(tcache_maxclass)
-#define	tcaches JEMALLOC_N(tcaches)
 #define	tcache_salloc JEMALLOC_N(tcache_salloc)
+#define	tcache_stats_merge JEMALLOC_N(tcache_stats_merge)
+#define	tcaches JEMALLOC_N(tcaches)
 #define	tcaches_create JEMALLOC_N(tcaches_create)
 #define	tcaches_destroy JEMALLOC_N(tcaches_destroy)
 #define	tcaches_flush JEMALLOC_N(tcaches_flush)
 #define	tcaches_get JEMALLOC_N(tcaches_get)
-#define	tcache_stats_merge JEMALLOC_N(tcache_stats_merge)
 #define	thread_allocated_cleanup JEMALLOC_N(thread_allocated_cleanup)
 #define	thread_deallocated_cleanup JEMALLOC_N(thread_deallocated_cleanup)
+#define	ticker_copy JEMALLOC_N(ticker_copy)
+#define	ticker_init JEMALLOC_N(ticker_init)
+#define	ticker_read JEMALLOC_N(ticker_read)
+#define	ticker_tick JEMALLOC_N(ticker_tick)
+#define	ticker_ticks JEMALLOC_N(ticker_ticks)
 #define	tsd_arena_get JEMALLOC_N(tsd_arena_get)
 #define	tsd_arena_set JEMALLOC_N(tsd_arena_set)
 #define	tsd_boot JEMALLOC_N(tsd_boot)
@@ -477,6 +521,8 @@
 #define	tsd_init_finish JEMALLOC_N(tsd_init_finish)
 #define	tsd_init_head JEMALLOC_N(tsd_init_head)
 #define	tsd_nominal JEMALLOC_N(tsd_nominal)
+#define	tsd_prof_tdata_get JEMALLOC_N(tsd_prof_tdata_get)
+#define	tsd_prof_tdata_set JEMALLOC_N(tsd_prof_tdata_set)
 #define	tsd_quarantine_get JEMALLOC_N(tsd_quarantine_get)
 #define	tsd_quarantine_set JEMALLOC_N(tsd_quarantine_set)
 #define	tsd_set JEMALLOC_N(tsd_set)
@@ -484,14 +530,12 @@
 #define	tsd_tcache_enabled_set JEMALLOC_N(tsd_tcache_enabled_set)
 #define	tsd_tcache_get JEMALLOC_N(tsd_tcache_get)
 #define	tsd_tcache_set JEMALLOC_N(tsd_tcache_set)
-#define	tsd_tls JEMALLOC_N(tsd_tls)
-#define	tsd_tsd JEMALLOC_N(tsd_tsd)
-#define	tsd_prof_tdata_get JEMALLOC_N(tsd_prof_tdata_get)
-#define	tsd_prof_tdata_set JEMALLOC_N(tsd_prof_tdata_set)
 #define	tsd_thread_allocated_get JEMALLOC_N(tsd_thread_allocated_get)
 #define	tsd_thread_allocated_set JEMALLOC_N(tsd_thread_allocated_set)
 #define	tsd_thread_deallocated_get JEMALLOC_N(tsd_thread_deallocated_get)
 #define	tsd_thread_deallocated_set JEMALLOC_N(tsd_thread_deallocated_set)
+#define	tsd_tls JEMALLOC_N(tsd_tls)
+#define	tsd_tsd JEMALLOC_N(tsd_tsd)
 #define	u2rz JEMALLOC_N(u2rz)
 #define	valgrind_freelike_block JEMALLOC_N(valgrind_freelike_block)
 #define	valgrind_make_mem_defined JEMALLOC_N(valgrind_make_mem_defined)
diff --git a/include/jemalloc/internal/private_unnamespace.h b/include/jemalloc/internal/private_unnamespace.h
index 9e060fc..e620fc7 100644
--- a/include/jemalloc/internal/private_unnamespace.h
+++ b/include/jemalloc/internal/private_unnamespace.h
@@ -1,8 +1,8 @@
 #undef a0dalloc
-#undef a0get
 #undef a0malloc
 #undef arena_aalloc
 #undef arena_alloc_junk_small
+#undef arena_basic_stats_merge
 #undef arena_bin_index
 #undef arena_bin_info
 #undef arena_bitselm_get
@@ -25,18 +25,23 @@
 #undef arena_dalloc_large
 #undef arena_dalloc_large_junked_locked
 #undef arena_dalloc_small
+#undef arena_decay_tick
+#undef arena_decay_ticks
+#undef arena_decay_time_default_get
+#undef arena_decay_time_default_set
+#undef arena_decay_time_get
+#undef arena_decay_time_set
 #undef arena_dss_prec_get
 #undef arena_dss_prec_set
 #undef arena_get
-#undef arena_get_hard
 #undef arena_init
 #undef arena_lg_dirty_mult_default_get
 #undef arena_lg_dirty_mult_default_set
 #undef arena_lg_dirty_mult_get
 #undef arena_lg_dirty_mult_set
 #undef arena_malloc
+#undef arena_malloc_hard
 #undef arena_malloc_large
-#undef arena_malloc_small
 #undef arena_mapbits_allocated_get
 #undef arena_mapbits_binind_get
 #undef arena_mapbits_decommitted_get
@@ -47,9 +52,6 @@
 #undef arena_mapbits_large_get
 #undef arena_mapbits_large_set
 #undef arena_mapbits_large_size_get
-#undef arena_mapbitsp_get
-#undef arena_mapbitsp_read
-#undef arena_mapbitsp_write
 #undef arena_mapbits_size_decode
 #undef arena_mapbits_size_encode
 #undef arena_mapbits_small_runind_get
@@ -58,6 +60,9 @@
 #undef arena_mapbits_unallocated_size_get
 #undef arena_mapbits_unallocated_size_set
 #undef arena_mapbits_unzeroed_get
+#undef arena_mapbitsp_get
+#undef arena_mapbitsp_read
+#undef arena_mapbitsp_write
 #undef arena_maxrun
 #undef arena_maybe_purge
 #undef arena_metadata_allocated_add
@@ -67,10 +72,12 @@
 #undef arena_miscelm_get
 #undef arena_miscelm_to_pageind
 #undef arena_miscelm_to_rpages
-#undef arena_nbound
 #undef arena_new
 #undef arena_node_alloc
 #undef arena_node_dalloc
+#undef arena_nthreads_dec
+#undef arena_nthreads_get
+#undef arena_nthreads_inc
 #undef arena_palloc
 #undef arena_postfork_child
 #undef arena_postfork_parent
@@ -83,7 +90,7 @@
 #undef arena_prof_tctx_reset
 #undef arena_prof_tctx_set
 #undef arena_ptr_small_binind_get
-#undef arena_purge_all
+#undef arena_purge
 #undef arena_quarantine_junk_small
 #undef arena_ralloc
 #undef arena_ralloc_junk_large
@@ -93,11 +100,14 @@
 #undef arena_run_regind
 #undef arena_run_to_miscelm
 #undef arena_salloc
-#undef arenas_cache_bypass_cleanup
-#undef arenas_cache_cleanup
 #undef arena_sdalloc
 #undef arena_stats_merge
 #undef arena_tcache_fill_small
+#undef arena_tdata_get
+#undef arena_tdata_get_hard
+#undef arenas
+#undef arenas_tdata_bypass_cleanup
+#undef arenas_tdata_cleanup
 #undef atomic_add_p
 #undef atomic_add_u
 #undef atomic_add_uint32
@@ -122,7 +132,6 @@
 #undef bitmap_full
 #undef bitmap_get
 #undef bitmap_info_init
-#undef bitmap_info_ngroups
 #undef bitmap_init
 #undef bitmap_set
 #undef bitmap_sfu
@@ -162,9 +171,9 @@
 #undef chunk_purge_arena
 #undef chunk_purge_wrapper
 #undef chunk_register
+#undef chunks_rtree
 #undef chunksize
 #undef chunksize_mask
-#undef chunks_rtree
 #undef ckh_count
 #undef ckh_delete
 #undef ckh_insert
@@ -183,6 +192,7 @@
 #undef ctl_postfork_child
 #undef ctl_postfork_parent
 #undef ctl_prefork
+#undef decay_ticker_get
 #undef dss_prec_names
 #undef extent_node_achunk_get
 #undef extent_node_achunk_set
@@ -234,6 +244,12 @@
 #undef extent_tree_szad_reverse_iter_recurse
 #undef extent_tree_szad_reverse_iter_start
 #undef extent_tree_szad_search
+#undef ffs_llu
+#undef ffs_lu
+#undef ffs_u
+#undef ffs_u32
+#undef ffs_u64
+#undef ffs_zu
 #undef get_errno
 #undef hash
 #undef hash_fmix_32
@@ -265,11 +281,11 @@
 #undef idalloctm
 #undef imalloc
 #undef imalloct
+#undef in_valgrind
 #undef index2size
 #undef index2size_compute
 #undef index2size_lookup
 #undef index2size_tab
-#undef in_valgrind
 #undef ipalloc
 #undef ipalloct
 #undef ipallocztm
@@ -311,11 +327,25 @@
 #undef map_misc_offset
 #undef mb_write
 #undef mutex_boot
-#undef narenas_cache_cleanup
+#undef narenas_tdata_cleanup
 #undef narenas_total_get
 #undef ncpus
 #undef nhbins
+#undef nstime_add
+#undef nstime_compare
+#undef nstime_copy
+#undef nstime_divide
+#undef nstime_idivide
+#undef nstime_imultiply
+#undef nstime_init
+#undef nstime_init2
+#undef nstime_ns
+#undef nstime_nsec
+#undef nstime_sec
+#undef nstime_subtract
+#undef nstime_update
 #undef opt_abort
+#undef opt_decay_time
 #undef opt_dss
 #undef opt_junk
 #undef opt_junk_alloc
@@ -334,6 +364,7 @@
 #undef opt_prof_leak
 #undef opt_prof_prefix
 #undef opt_prof_thread_active_init
+#undef opt_purge
 #undef opt_quarantine
 #undef opt_redzone
 #undef opt_stats_print
@@ -348,7 +379,11 @@
 #undef pages_purge
 #undef pages_trim
 #undef pages_unmap
-#undef pow2_ceil
+#undef pow2_ceil_u32
+#undef pow2_ceil_u64
+#undef pow2_ceil_zu
+#undef prng_lg_range
+#undef prng_range
 #undef prof_active_get
 #undef prof_active_get_unlocked
 #undef prof_active_set
@@ -393,6 +428,7 @@
 #undef prof_thread_active_set
 #undef prof_thread_name_get
 #undef prof_thread_name_set
+#undef purge_mode_names
 #undef quarantine
 #undef quarantine_alloc_hook
 #undef quarantine_alloc_hook_work
@@ -413,6 +449,9 @@
 #undef rtree_subtree_tryread
 #undef rtree_val_read
 #undef rtree_val_write
+#undef run_quantize_ceil
+#undef run_quantize_floor
+#undef run_quantize_max
 #undef s2u
 #undef s2u_compute
 #undef s2u_lookup
@@ -451,15 +490,20 @@
 #undef tcache_get
 #undef tcache_get_hard
 #undef tcache_maxclass
-#undef tcaches
 #undef tcache_salloc
+#undef tcache_stats_merge
+#undef tcaches
 #undef tcaches_create
 #undef tcaches_destroy
 #undef tcaches_flush
 #undef tcaches_get
-#undef tcache_stats_merge
 #undef thread_allocated_cleanup
 #undef thread_deallocated_cleanup
+#undef ticker_copy
+#undef ticker_init
+#undef ticker_read
+#undef ticker_tick
+#undef ticker_ticks
 #undef tsd_arena_get
 #undef tsd_arena_set
 #undef tsd_boot
@@ -477,6 +521,8 @@
 #undef tsd_init_finish
 #undef tsd_init_head
 #undef tsd_nominal
+#undef tsd_prof_tdata_get
+#undef tsd_prof_tdata_set
 #undef tsd_quarantine_get
 #undef tsd_quarantine_set
 #undef tsd_set
@@ -484,14 +530,12 @@
 #undef tsd_tcache_enabled_set
 #undef tsd_tcache_get
 #undef tsd_tcache_set
-#undef tsd_tls
-#undef tsd_tsd
-#undef tsd_prof_tdata_get
-#undef tsd_prof_tdata_set
 #undef tsd_thread_allocated_get
 #undef tsd_thread_allocated_set
 #undef tsd_thread_deallocated_get
 #undef tsd_thread_deallocated_set
+#undef tsd_tls
+#undef tsd_tsd
 #undef u2rz
 #undef valgrind_freelike_block
 #undef valgrind_make_mem_defined
diff --git a/include/jemalloc/internal/size_classes.h b/include/jemalloc/internal/size_classes.h
index d6715bb..f33390d 100644
--- a/include/jemalloc/internal/size_classes.h
+++ b/include/jemalloc/internal/size_classes.h
@@ -166,22 +166,17 @@
     SC(104,     30,       28,      1,  no, no) \
     SC(105,     30,       28,      2,  no, no) \
     SC(106,     30,       28,      3,  no, no) \
-    SC(107,     30,       28,      4,  no, no) \
-                                               \
-    SC(108,     31,       29,      1,  no, no) \
-    SC(109,     31,       29,      2,  no, no) \
-    SC(110,     31,       29,      3,  no, no) \
 
 #define	SIZE_CLASSES_DEFINED
 #define	NTBINS			0
 #define	NLBINS			32
 #define	NBINS			39
-#define	NSIZES			111
+#define	NSIZES			107
 #define	LG_TINY_MAXCLASS	"NA"
 #define	LOOKUP_MAXCLASS		((((size_t)1) << 11) + (((size_t)4) << 9))
 #define	SMALL_MAXCLASS		((((size_t)1) << 13) + (((size_t)3) << 11))
 #define	LG_LARGE_MINCLASS	14
-#define	HUGE_MAXCLASS		((((size_t)1) << 31) + (((size_t)3) << 29))
+#define	HUGE_MAXCLASS		((((size_t)1) << 30) + (((size_t)3) << 28))
 #endif
 
 #if (LG_SIZEOF_PTR == 2 && LG_TINY_MIN == 3 && LG_QUANTUM == 4 && LG_PAGE == 12)
@@ -317,22 +312,17 @@
     SC(101,     30,       28,      1,  no, no) \
     SC(102,     30,       28,      2,  no, no) \
     SC(103,     30,       28,      3,  no, no) \
-    SC(104,     30,       28,      4,  no, no) \
-                                               \
-    SC(105,     31,       29,      1,  no, no) \
-    SC(106,     31,       29,      2,  no, no) \
-    SC(107,     31,       29,      3,  no, no) \
 
 #define	SIZE_CLASSES_DEFINED
 #define	NTBINS			1
 #define	NLBINS			29
 #define	NBINS			36
-#define	NSIZES			108
+#define	NSIZES			104
 #define	LG_TINY_MAXCLASS	3
 #define	LOOKUP_MAXCLASS		((((size_t)1) << 11) + (((size_t)4) << 9))
 #define	SMALL_MAXCLASS		((((size_t)1) << 13) + (((size_t)3) << 11))
 #define	LG_LARGE_MINCLASS	14
-#define	HUGE_MAXCLASS		((((size_t)1) << 31) + (((size_t)3) << 29))
+#define	HUGE_MAXCLASS		((((size_t)1) << 30) + (((size_t)3) << 28))
 #endif
 
 #if (LG_SIZEOF_PTR == 2 && LG_TINY_MIN == 4 && LG_QUANTUM == 4 && LG_PAGE == 12)
@@ -466,22 +456,17 @@
     SC(100,     30,       28,      1,  no, no) \
     SC(101,     30,       28,      2,  no, no) \
     SC(102,     30,       28,      3,  no, no) \
-    SC(103,     30,       28,      4,  no, no) \
-                                               \
-    SC(104,     31,       29,      1,  no, no) \
-    SC(105,     31,       29,      2,  no, no) \
-    SC(106,     31,       29,      3,  no, no) \
 
 #define	SIZE_CLASSES_DEFINED
 #define	NTBINS			0
 #define	NLBINS			28
 #define	NBINS			35
-#define	NSIZES			107
+#define	NSIZES			103
 #define	LG_TINY_MAXCLASS	"NA"
 #define	LOOKUP_MAXCLASS		((((size_t)1) << 11) + (((size_t)4) << 9))
 #define	SMALL_MAXCLASS		((((size_t)1) << 13) + (((size_t)3) << 11))
 #define	LG_LARGE_MINCLASS	14
-#define	HUGE_MAXCLASS		((((size_t)1) << 31) + (((size_t)3) << 29))
+#define	HUGE_MAXCLASS		((((size_t)1) << 30) + (((size_t)3) << 28))
 #endif
 
 #if (LG_SIZEOF_PTR == 3 && LG_TINY_MIN == 3 && LG_QUANTUM == 3 && LG_PAGE == 12)
@@ -780,22 +765,17 @@
     SC(232,     62,       60,      1,  no, no) \
     SC(233,     62,       60,      2,  no, no) \
     SC(234,     62,       60,      3,  no, no) \
-    SC(235,     62,       60,      4,  no, no) \
-                                               \
-    SC(236,     63,       61,      1,  no, no) \
-    SC(237,     63,       61,      2,  no, no) \
-    SC(238,     63,       61,      3,  no, no) \
 
 #define	SIZE_CLASSES_DEFINED
 #define	NTBINS			0
 #define	NLBINS			32
 #define	NBINS			39
-#define	NSIZES			239
+#define	NSIZES			235
 #define	LG_TINY_MAXCLASS	"NA"
 #define	LOOKUP_MAXCLASS		((((size_t)1) << 11) + (((size_t)4) << 9))
 #define	SMALL_MAXCLASS		((((size_t)1) << 13) + (((size_t)3) << 11))
 #define	LG_LARGE_MINCLASS	14
-#define	HUGE_MAXCLASS		((((size_t)1) << 63) + (((size_t)3) << 61))
+#define	HUGE_MAXCLASS		((((size_t)1) << 62) + (((size_t)3) << 60))
 #endif
 
 #if (LG_SIZEOF_PTR == 3 && LG_TINY_MIN == 3 && LG_QUANTUM == 4 && LG_PAGE == 12)
@@ -1091,22 +1071,17 @@
     SC(229,     62,       60,      1,  no, no) \
     SC(230,     62,       60,      2,  no, no) \
     SC(231,     62,       60,      3,  no, no) \
-    SC(232,     62,       60,      4,  no, no) \
-                                               \
-    SC(233,     63,       61,      1,  no, no) \
-    SC(234,     63,       61,      2,  no, no) \
-    SC(235,     63,       61,      3,  no, no) \
 
 #define	SIZE_CLASSES_DEFINED
 #define	NTBINS			1
 #define	NLBINS			29
 #define	NBINS			36
-#define	NSIZES			236
+#define	NSIZES			232
 #define	LG_TINY_MAXCLASS	3
 #define	LOOKUP_MAXCLASS		((((size_t)1) << 11) + (((size_t)4) << 9))
 #define	SMALL_MAXCLASS		((((size_t)1) << 13) + (((size_t)3) << 11))
 #define	LG_LARGE_MINCLASS	14
-#define	HUGE_MAXCLASS		((((size_t)1) << 63) + (((size_t)3) << 61))
+#define	HUGE_MAXCLASS		((((size_t)1) << 62) + (((size_t)3) << 60))
 #endif
 
 #if (LG_SIZEOF_PTR == 3 && LG_TINY_MIN == 4 && LG_QUANTUM == 4 && LG_PAGE == 12)
@@ -1400,22 +1375,17 @@
     SC(228,     62,       60,      1,  no, no) \
     SC(229,     62,       60,      2,  no, no) \
     SC(230,     62,       60,      3,  no, no) \
-    SC(231,     62,       60,      4,  no, no) \
-                                               \
-    SC(232,     63,       61,      1,  no, no) \
-    SC(233,     63,       61,      2,  no, no) \
-    SC(234,     63,       61,      3,  no, no) \
 
 #define	SIZE_CLASSES_DEFINED
 #define	NTBINS			0
 #define	NLBINS			28
 #define	NBINS			35
-#define	NSIZES			235
+#define	NSIZES			231
 #define	LG_TINY_MAXCLASS	"NA"
 #define	LOOKUP_MAXCLASS		((((size_t)1) << 11) + (((size_t)4) << 9))
 #define	SMALL_MAXCLASS		((((size_t)1) << 13) + (((size_t)3) << 11))
 #define	LG_LARGE_MINCLASS	14
-#define	HUGE_MAXCLASS		((((size_t)1) << 63) + (((size_t)3) << 61))
+#define	HUGE_MAXCLASS		((((size_t)1) << 62) + (((size_t)3) << 60))
 #endif
 
 #ifndef SIZE_CLASSES_DEFINED
diff --git a/include/jemalloc/jemalloc.h b/include/jemalloc/jemalloc.h
index 9c9ae6e..bfc95ec 100644
--- a/include/jemalloc/jemalloc.h
+++ b/include/jemalloc/jemalloc.h
@@ -43,6 +43,14 @@
  */
 /* #undef	JEMALLOC_USE_CXX_THROW */
 
+#ifdef _MSC_VER
+#  ifdef _WIN64
+#    define LG_SIZEOF_PTR_WIN 3
+#  else
+#    define LG_SIZEOF_PTR_WIN 2
+#  endif
+#endif
+
 /* sizeof(void *) == 2^LG_SIZEOF_PTR. */
 #ifdef __LP64__
 #define	LG_SIZEOF_PTR 3
@@ -86,19 +94,20 @@
 #include <limits.h>
 #include <strings.h>
 
-#define	JEMALLOC_VERSION "4.0.4-16-gf459d5a2034e733eab74cc9b029dfec2ff13b196"
+#define	JEMALLOC_VERSION "4.1.0-4-g33184bf69813087bf1885b0993685f9d03320c69"
 #define	JEMALLOC_VERSION_MAJOR 4
-#define	JEMALLOC_VERSION_MINOR 0
-#define	JEMALLOC_VERSION_BUGFIX 4
-#define	JEMALLOC_VERSION_NREV 16
-#define	JEMALLOC_VERSION_GID "f459d5a2034e733eab74cc9b029dfec2ff13b196"
+#define	JEMALLOC_VERSION_MINOR 1
+#define	JEMALLOC_VERSION_BUGFIX 0
+#define	JEMALLOC_VERSION_NREV 4
+#define	JEMALLOC_VERSION_GID "33184bf69813087bf1885b0993685f9d03320c69"
 
-#  define MALLOCX_LG_ALIGN(la)	(la)
+#  define MALLOCX_LG_ALIGN(la)	((int)(la))
 #  if LG_SIZEOF_PTR == 2
-#    define MALLOCX_ALIGN(a)	(ffs(a)-1)
+#    define MALLOCX_ALIGN(a)	((int)(ffs(a)-1))
 #  else
 #    define MALLOCX_ALIGN(a)						\
-	 ((a < (size_t)INT_MAX) ? ffs(a)-1 : ffs(a>>32)+31)
+       ((int)(((a) < (size_t)INT_MAX) ? ffs((int)(a))-1 :		\
+       ffs((int)((a)>>32))+31))
 #  endif
 #  define MALLOCX_ZERO	((int)0x40)
 /*
diff --git a/include/jemalloc/jemalloc_defs.h b/include/jemalloc/jemalloc_defs.h
index 422ef67..0fb1170 100644
--- a/include/jemalloc/jemalloc_defs.h
+++ b/include/jemalloc/jemalloc_defs.h
@@ -36,6 +36,14 @@
  */
 /* #undef JEMALLOC_USE_CXX_THROW */
 
+#ifdef _MSC_VER
+#  ifdef _WIN64
+#    define LG_SIZEOF_PTR_WIN 3
+#  else
+#    define LG_SIZEOF_PTR_WIN 2
+#  endif
+#endif
+
 /* sizeof(void *) == 2^LG_SIZEOF_PTR. */
 #ifdef __LP64__
 #define LG_SIZEOF_PTR 3
diff --git a/include/jemalloc/jemalloc_macros.h b/include/jemalloc/jemalloc_macros.h
index 6038f92..d4a3794 100644
--- a/include/jemalloc/jemalloc_macros.h
+++ b/include/jemalloc/jemalloc_macros.h
@@ -4,19 +4,20 @@
 #include <limits.h>
 #include <strings.h>
 
-#define	JEMALLOC_VERSION "4.0.4-16-gf459d5a2034e733eab74cc9b029dfec2ff13b196"
+#define	JEMALLOC_VERSION "4.1.0-4-g33184bf69813087bf1885b0993685f9d03320c69"
 #define	JEMALLOC_VERSION_MAJOR 4
-#define	JEMALLOC_VERSION_MINOR 0
-#define	JEMALLOC_VERSION_BUGFIX 4
-#define	JEMALLOC_VERSION_NREV 16
-#define	JEMALLOC_VERSION_GID "f459d5a2034e733eab74cc9b029dfec2ff13b196"
+#define	JEMALLOC_VERSION_MINOR 1
+#define	JEMALLOC_VERSION_BUGFIX 0
+#define	JEMALLOC_VERSION_NREV 4
+#define	JEMALLOC_VERSION_GID "33184bf69813087bf1885b0993685f9d03320c69"
 
-#  define MALLOCX_LG_ALIGN(la)	(la)
+#  define MALLOCX_LG_ALIGN(la)	((int)(la))
 #  if LG_SIZEOF_PTR == 2
-#    define MALLOCX_ALIGN(a)	(ffs(a)-1)
+#    define MALLOCX_ALIGN(a)	((int)(ffs(a)-1))
 #  else
 #    define MALLOCX_ALIGN(a)						\
-	 ((a < (size_t)INT_MAX) ? ffs(a)-1 : ffs(a>>32)+31)
+       ((int)(((a) < (size_t)INT_MAX) ? ffs((int)(a))-1 :		\
+       ffs((int)((a)>>32))+31))
 #  endif
 #  define MALLOCX_ZERO	((int)0x40)
 /*
diff --git a/src/huge.c b/src/huge.c
index 89a1d7f..3f3943f 100644
--- a/src/huge.c
+++ b/src/huge.c
@@ -73,6 +73,7 @@
 	 * virtual address space. Force all huge allocations to
 	 * always take place in the first arena.
 	 */
+	extern arena_t *a0get(void);
 	arena = a0get();
 #else
 	arena = arena_choose(tsd, arena);
diff --git a/src/jemalloc.c b/src/jemalloc.c
index 0ba96f3..a53b004 100644
--- a/src/jemalloc.c
+++ b/src/jemalloc.c
@@ -2732,6 +2732,12 @@
 /******************************************************************************/
 
 /* ANDROID extension */
+arena_t * a0get(void)
+{
+	assert(a0 != NULL);
+	return (a0);
+}
+
 #include "android_je_iterate.c"
 #include "android_je_mallinfo.c"
 /* End ANDROID extension */
diff --git a/test/include/test/jemalloc_test.h b/test/include/test/jemalloc_test.h
index 1d9a756..8348ac5 100644
--- a/test/include/test/jemalloc_test.h
+++ b/test/include/test/jemalloc_test.h
@@ -11,7 +11,6 @@
 #ifdef _WIN32
 #  include "msvc_compat/strings.h"
 #endif
-#include <sys/time.h>
 
 #ifdef _WIN32
 #  include <windows.h>
@@ -94,6 +93,7 @@
 #  define JEMALLOC_H_STRUCTS
 #  define JEMALLOC_H_EXTERNS
 #  define JEMALLOC_H_INLINES
+#  include "jemalloc/internal/nstime.h"
 #  include "jemalloc/internal/util.h"
 #  include "jemalloc/internal/qr.h"
 #  include "jemalloc/internal/ql.h"