components/desktop/firefox/patches/firefox-32-solaris_jemalloc_linkage.patch
branchs11u3-sru
changeset 7035 4c2f26e9d5ab
child 7364 1ac24a377555
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/desktop/firefox/patches/firefox-32-solaris_jemalloc_linkage.patch	Mon Sep 05 05:00:46 2016 -0700
@@ -0,0 +1,73 @@
+This patch makes it so jemalloc is not included in firefox. Not accepted by 
+the upstream community. 
+Put jemalloc inside libxul. Then need firefox to depend on libxul
+and build jemalloc library.
+Remove lines - do not include memory for every program
+Need to create/add our own versions of the functions malloc_usable, jemalloc_stats, etc.
+Remove mozalloc library
+Check if we have jemalloc; if not, skip it.
+Build libxul and use flags -Wl,-z,interpose, needed to build the library.
+
+diff --git a/config/jemalloc_solaris.map b/config/jemalloc_solaris.map
+new file mode 100644
+--- /dev/null
++++ b/config/jemalloc_solaris.map
+@@ -0,0 +1,12 @@
++{
++    global:
++        calloc             = NODIRECT;
++        free               = NODIRECT;
++        jemalloc_stats     = NODIRECT;
++        malloc             = NODIRECT;
++        malloc_usable_size = NODIRECT;
++        memalign           = NODIRECT;
++        posix_memalign     = NODIRECT;
++        realloc            = NODIRECT;
++        valloc             = NODIRECT;
++};
+diff --git a/storage/mozStorageService.cpp b/storage/mozStorageService.cpp
+--- a/storage/mozStorageService.cpp
++++ b/storage/mozStorageService.cpp
+@@ -514,9 +514,14 @@
+   int rc;
+ 
+ #ifdef MOZ_STORAGE_MEMORY
+-  rc = ::sqlite3_config(SQLITE_CONFIG_MALLOC, &memMethods);
+-  if (rc != SQLITE_OK)
+-    return convertResultCode(rc);
++  // in case other malloc library is PRELOAD-ed
++  void *test_jemalloc = malloc(4);
++  if (::moz_malloc_usable_size(test_jemalloc)) {
++    rc = ::sqlite3_config(SQLITE_CONFIG_MALLOC, &memMethods);
++    if (rc != SQLITE_OK)
++      return convertResultCode(rc);
++  }
++  free(test_jemalloc);
+ #endif
+ 
+   // Explicitly initialize sqlite3.  Although this is implicitly called by
+diff --git a/memory/jemalloc/src/include/jemalloc/internal/jemalloc_internal.h.in b/memory/jemalloc/src/include/jemalloc/internal/jemalloc_internal.h.in
+--- a/memory/jemalloc/src/include/jemalloc/internal/jemalloc_internal.h.in
++++ b/memory/jemalloc/src/include/jemalloc/internal/jemalloc_internal.h.in
+@@ -184,6 +184,9 @@ static const bool config_cache_oblivious
+ #include "jemalloc/internal/jemalloc_internal_macros.h"
+ 
+ /* Size class index type. */
++#ifdef __sun
++#define index_t je_index_t
++#endif
+ typedef unsigned szind_t;
+ 
+ /*
+--- a/memory/jemalloc/src/include/jemalloc/internal/jemalloc_internal.h.in	2015-09-15 13:37:17.326056000 +0800
++++ b/memory/jemalloc/src/include/jemalloc/internal/jemalloc_internal.h.in	2015-09-15 13:37:51.959830000 +0800
+@@ -204,6 +204,9 @@
+ #  ifdef __alpha__
+ #    define LG_QUANTUM		4
+ #  endif
++#  ifdef __sparc__
++#    define LG_QUANTUM		4
++#  endif
+ #  ifdef __sparc64__
+ #    define LG_QUANTUM		4
+ #  endif