components/desktop/thunderbird/patches/firefox-32-solaris_jemalloc_linkage.patch
changeset 6431 e4667e7df088
equal deleted inserted replaced
6430:74bc7531ae5a 6431:e4667e7df088
       
     1 This patch makes it so jemalloc is not included in firefox. Not accepted by 
       
     2 the upstream community. 
       
     3 Put jemalloc inside libxul. Then need firefox to depend on libxul
       
     4 and build jemalloc library.
       
     5 Remove lines - do not include memory for every program
       
     6 Need to create/add our own versions of the functions malloc_usable, jemalloc_stats, etc.
       
     7 Remove mozalloc library
       
     8 Check if we have jemalloc; if not, skip it.
       
     9 Build libxul and use flags -Wl,-z,interpose, needed to build the library.
       
    10 
       
    11 diff --git a/config/jemalloc_solaris.map b/config/jemalloc_solaris.map
       
    12 new file mode 100644
       
    13 --- /dev/null
       
    14 +++ b/config/jemalloc_solaris.map
       
    15 @@ -0,0 +1,12 @@
       
    16 +{
       
    17 +    global:
       
    18 +        calloc             = NODIRECT;
       
    19 +        free               = NODIRECT;
       
    20 +        jemalloc_stats     = NODIRECT;
       
    21 +        malloc             = NODIRECT;
       
    22 +        malloc_usable_size = NODIRECT;
       
    23 +        memalign           = NODIRECT;
       
    24 +        posix_memalign     = NODIRECT;
       
    25 +        realloc            = NODIRECT;
       
    26 +        valloc             = NODIRECT;
       
    27 +};
       
    28 diff --git a/storage/mozStorageService.cpp b/storage/mozStorageService.cpp
       
    29 --- a/storage/mozStorageService.cpp
       
    30 +++ b/storage/mozStorageService.cpp
       
    31 @@ -514,9 +514,14 @@
       
    32    int rc;
       
    33  
       
    34  #ifdef MOZ_STORAGE_MEMORY
       
    35 -  rc = ::sqlite3_config(SQLITE_CONFIG_MALLOC, &memMethods);
       
    36 -  if (rc != SQLITE_OK)
       
    37 -    return convertResultCode(rc);
       
    38 +  // in case other malloc library is PRELOAD-ed
       
    39 +  void *test_jemalloc = malloc(4);
       
    40 +  if (::moz_malloc_usable_size(test_jemalloc)) {
       
    41 +    rc = ::sqlite3_config(SQLITE_CONFIG_MALLOC, &memMethods);
       
    42 +    if (rc != SQLITE_OK)
       
    43 +      return convertResultCode(rc);
       
    44 +  }
       
    45 +  free(test_jemalloc);
       
    46  #endif
       
    47  
       
    48    // Explicitly initialize sqlite3.  Although this is implicitly called by
       
    49 diff --git a/memory/jemalloc/src/include/jemalloc/internal/jemalloc_internal.h.in b/memory/jemalloc/src/include/jemalloc/internal/jemalloc_internal.h.in
       
    50 --- a/memory/jemalloc/src/include/jemalloc/internal/jemalloc_internal.h.in
       
    51 +++ b/memory/jemalloc/src/include/jemalloc/internal/jemalloc_internal.h.in
       
    52 @@ -184,6 +184,9 @@ static const bool config_cache_oblivious
       
    53  #include "jemalloc/internal/jemalloc_internal_macros.h"
       
    54  
       
    55  /* Size class index type. */
       
    56 +#ifdef __sun
       
    57 +#define index_t je_index_t
       
    58 +#endif
       
    59  typedef unsigned szind_t;
       
    60  
       
    61  /*
       
    62 --- a/memory/jemalloc/src/include/jemalloc/internal/jemalloc_internal.h.in	2015-09-15 13:37:17.326056000 +0800
       
    63 +++ b/memory/jemalloc/src/include/jemalloc/internal/jemalloc_internal.h.in	2015-09-15 13:37:51.959830000 +0800
       
    64 @@ -204,6 +204,9 @@
       
    65  #  ifdef __alpha__
       
    66  #    define LG_QUANTUM		4
       
    67  #  endif
       
    68 +#  ifdef __sparc__
       
    69 +#    define LG_QUANTUM		4
       
    70 +#  endif
       
    71  #  ifdef __sparc64__
       
    72  #    define LG_QUANTUM		4
       
    73  #  endif