From 04ef218d872ae73964f9f6c8d1186c4a1e270d70 Mon Sep 17 00:00:00 2001
From: Qi Wang <interwq@gwu.edu>
Date: Fri, 7 Apr 2017 14:20:57 -0700
Subject: Move reentrancy_level to the beginning of TSD.

---
 include/jemalloc/internal/tsd_structs.h | 14 +++++++-------
 src/arena.c                             |  2 +-
 src/jemalloc.c                          |  2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/include/jemalloc/internal/tsd_structs.h b/include/jemalloc/internal/tsd_structs.h
index 12df63d..7f34d1b 100644
--- a/include/jemalloc/internal/tsd_structs.h
+++ b/include/jemalloc/internal/tsd_structs.h
@@ -26,8 +26,8 @@ struct tsd_init_head_s {
  * t: tcache
  * --- data not accessed on tcache fast path: arena related fields ---
  * d: arenas_tdata_bypass
- * r: narenas_tdata
- * x: blank space (1 byte)
+ * r: reentrancy_level
+ * x: narenas_tdata
  * i: iarena
  * a: arena
  * o: arenas_tdata
@@ -36,7 +36,7 @@ struct tsd_init_head_s {
  * Use a compact layout to reduce cache footprint.
  * +--- 64-bit and 64B cacheline; 1B each letter; First byte on the left. ---+
  * |----------------------------  1st cacheline  ----------------------------|
- * | sedxrrrr mmmmmmmm ffffffff pppppppp [c * 32  ........ ........ .......] |
+ * | sedrxxxx mmmmmmmm ffffffff pppppppp [c * 32  ........ ........ .......] |
  * |----------------------------  2nd cacheline  ----------------------------|
  * | [c * 64  ........ ........ ........ ........ ........ ........ .......] |
  * |----------------------------  3nd cacheline  ----------------------------|
@@ -53,6 +53,7 @@ struct tsd_init_head_s {
 /*  O(name,			type,		[gs]et,	init,	cleanup) */ \
     O(tcache_enabled,		bool,		yes,	yes,	no)	\
     O(arenas_tdata_bypass,	bool,		no,	no,	no)	\
+    O(reentrancy_level,		int8_t,		no,	no,	no)	\
     O(narenas_tdata,		uint32_t,	yes,	no,	no)	\
     O(thread_allocated,		uint64_t,	yes,	no,	no)	\
     O(thread_deallocated,	uint64_t,	yes,	no,	no)	\
@@ -65,8 +66,7 @@ struct tsd_init_head_s {
     O(witnesses,		witness_list_t,	no,	no,	yes)	\
     O(rtree_leaf_elm_witnesses,	rtree_leaf_elm_witness_tsd_t,		\
 						no,	no,	no)	\
-    O(witness_fork,		bool,		yes,	no,	no)	\
-    O(reentrancy_level,		int,		no,	no,	no)
+    O(witness_fork,		bool,		yes,	no,	no)
 
 #define TSD_INITIALIZER {						\
     tsd_state_uninitialized,						\
@@ -75,6 +75,7 @@ struct tsd_init_head_s {
     0,									\
     0,									\
     0,									\
+    0,									\
     NULL,								\
     RTREE_CTX_ZERO_INITIALIZER,						\
     NULL,								\
@@ -83,8 +84,7 @@ struct tsd_init_head_s {
     TCACHE_ZERO_INITIALIZER,						\
     ql_head_initializer(witnesses),					\
     RTREE_ELM_WITNESS_TSD_INITIALIZER,					\
-    false,								\
-    0									\
+    false								\
 }
 
 struct tsd_s {
diff --git a/src/arena.c b/src/arena.c
index 19069bb..198c6e4 100644
--- a/src/arena.c
+++ b/src/arena.c
@@ -1958,7 +1958,7 @@ arena_new(tsdn_t *tsdn, unsigned ind, extent_hooks_t *extent_hooks) {
 		 * If we're here, then arena 0 already exists, so bootstrapping
 		 * is done enough that we should have tsd.
 		 */
-		int *reentrancy_level = tsd_reentrancy_levelp_get(tsdn_tsd(
+		int8_t *reentrancy_level = tsd_reentrancy_levelp_get(tsdn_tsd(
 		    tsdn));
 		++*reentrancy_level;
 		hooks_arena_new_hook();
diff --git a/src/jemalloc.c b/src/jemalloc.c
index 7b205ff..513d9cd 100644
--- a/src/jemalloc.c
+++ b/src/jemalloc.c
@@ -1662,7 +1662,7 @@ imalloc_body(static_opts_t *sopts, dynamic_opts_t *dopts) {
 	 * bother getting the old level, so we shouldn't try to reset it.  This
 	 * is indicated by leaving the pointer as NULL.
 	 */
-	int *reentrancy_level = NULL;
+	int8_t *reentrancy_level = NULL;
 
 	/* Initialize (if we can't prove we don't have to). */
 	if (sopts->slow) {
-- 
cgit v0.12