components/desktop/firefox/patches/firefox-32-solaris_jemalloc_linkage.patch
author Petr Sumbera <petr.sumbera@oracle.com>
Mon, 05 Sep 2016 05:00:46 -0700
branchs11u3-sru
changeset 7035 4c2f26e9d5ab
child 7364 1ac24a377555
permissions -rw-r--r--
24361911 Upgrade Firefox to version 45.4.0 ESR 23033044 firefox needs to be built with "--with-intl-api" option 24708365 problem in FIREFOX/BROWSER 24708614 problem in FIREFOX/BROWSER

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