Bug 1395088 - Remove the jemalloc_bool type. r?njn draft
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 30 Aug 2017 18:04:47 +0900
changeset 655720 82f305477c41f4d8b1f53f54f5c5c61188c140e9
parent 655590 1f9ab405002ff699f2ef5a4e72524c2d91099058
child 728906 8044482295d819b4832126a008ee9e5c62d418aa
push id76953
push userbmo:mh+mozilla@glandium.org
push dateWed, 30 Aug 2017 09:59:37 +0000
reviewersnjn
bugs1395088, 488608
milestone57.0a1
Bug 1395088 - Remove the jemalloc_bool type. r?njn Back when it was added (for Windows CE, in bug 488608), mozjemalloc was C and all the supported compilers didn't support C99 bools. Now mozjemalloc is C++, and all the supported compilers support C99 bools for the cases where the type is used from C.
layout/style/ServoBindings.cpp
memory/build/malloc_decls.h
memory/build/mozmemory.h
memory/mozjemalloc/mozjemalloc_types.h
memory/replace/replace/ReplaceMalloc.cpp
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -2767,19 +2767,17 @@ Gecko_DocumentRule_UseForPresentation(Ra
   return css::DocumentRule::UseForPresentation(doc, docURI, docURISpec,
                                                *aPattern, aURLMatchingFunction);
 }
 
 void
 Gecko_SetJemallocThreadLocalArena(bool enabled)
 {
 #if defined(MOZ_MEMORY)
-  // At this point we convert |enabled| from a plain C++ bool to a
-  // |jemalloc_bool|, so be on the safe side.
-  jemalloc_thread_local_arena(!!enabled);
+  jemalloc_thread_local_arena(enabled);
 #endif
 }
 
 #include "nsStyleStructList.h"
 
 #undef STYLE_STRUCT
 
 #ifndef MOZ_STYLO
--- a/memory/build/malloc_decls.h
+++ b/memory/build/malloc_decls.h
@@ -56,16 +56,16 @@ MALLOC_DECL(memalign, void *, size_t, si
 MALLOC_DECL(valloc, void *, size_t)
 MALLOC_DECL(malloc_usable_size, size_t, usable_ptr_t)
 MALLOC_DECL(malloc_good_size, size_t, size_t)
 #  endif
 #  if MALLOC_FUNCS & MALLOC_FUNCS_JEMALLOC
 MALLOC_DECL_VOID(jemalloc_stats, jemalloc_stats_t *)
 MALLOC_DECL_VOID(jemalloc_purge_freed_pages)
 MALLOC_DECL_VOID(jemalloc_free_dirty_pages)
-MALLOC_DECL_VOID(jemalloc_thread_local_arena, jemalloc_bool)
+MALLOC_DECL_VOID(jemalloc_thread_local_arena, bool)
 #  endif
 
 #  undef MALLOC_DECL_VOID
 #endif /* MALLOC_DECL */
 
 #undef MALLOC_DECL
 #undef MALLOC_FUNCS
--- a/memory/build/mozmemory.h
+++ b/memory/build/mozmemory.h
@@ -80,11 +80,11 @@ MOZ_JEMALLOC_API void jemalloc_purge_fre
 /*
  * Free all unused dirty pages in all arenas. Calling this function will slow
  * down subsequent allocations so it is recommended to use it only when
  * memory needs to be reclaimed at all costs (see bug 805855). This function
  * provides functionality similar to mallctl("arenas.purge") in jemalloc 3.
  */
 MOZ_JEMALLOC_API void jemalloc_free_dirty_pages();
 
-MOZ_JEMALLOC_API void jemalloc_thread_local_arena(jemalloc_bool enabled);
+MOZ_JEMALLOC_API void jemalloc_thread_local_arena(bool enabled);
 
 #endif /* mozmemory_h */
--- a/memory/mozjemalloc/mozjemalloc_types.h
+++ b/memory/mozjemalloc/mozjemalloc_types.h
@@ -33,34 +33,33 @@
 #define _JEMALLOC_TYPES_H_
 
 /* grab size_t */
 #ifdef _MSC_VER
 #include <crtdefs.h>
 #else
 #include <stddef.h>
 #endif
+#include <stdbool.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-typedef unsigned char jemalloc_bool;
-
 /*
  * jemalloc_stats() is not a stable interface.  When using jemalloc_stats_t, be
  * sure that the compiled results of jemalloc.c are in sync with this header
  * file.
  */
 typedef struct {
 	/*
 	 * Run-time configuration settings.
 	 */
-	jemalloc_bool	opt_junk;	/* Fill allocated memory with kAllocJunk? */
-	jemalloc_bool	opt_zero;	/* Fill allocated memory with 0x0? */
+	bool	opt_junk;	/* Fill allocated memory with kAllocJunk? */
+	bool	opt_zero;	/* Fill allocated memory with 0x0? */
 	size_t	narenas;	/* Number of arenas. */
 	size_t	quantum;	/* Allocation quantum. */
 	size_t	small_max;	/* Max quantum-spaced allocation size. */
 	size_t	large_max;	/* Max sub-chunksize allocation size. */
 	size_t	chunksize;	/* Size of each virtual memory mapping. */
 	size_t	dirty_max;	/* Max dirty pages per arena. */
 
 	/*
--- a/memory/replace/replace/ReplaceMalloc.cpp
+++ b/memory/replace/replace/ReplaceMalloc.cpp
@@ -248,16 +248,16 @@ replace_jemalloc_free_dirty_pages(void)
   gFuncs->jemalloc_free_dirty_pages();
   const malloc_hook_table_t* hook_table = gHookTable;
   if (hook_table && hook_table->jemalloc_free_dirty_pages_hook) {
     hook_table->jemalloc_free_dirty_pages_hook();
   }
 }
 
 void
-replace_jemalloc_thread_local_arena(jemalloc_bool aEnabled)
+replace_jemalloc_thread_local_arena(bool aEnabled)
 {
   gFuncs->jemalloc_thread_local_arena(aEnabled);
   const malloc_hook_table_t* hook_table = gHookTable;
   if (hook_table && hook_table->jemalloc_thread_local_arena_hook) {
     hook_table->jemalloc_thread_local_arena_hook(aEnabled);
   }
 }