summaryrefslogtreecommitdiff
path: root/memory
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2019-11-02 14:37:22 +0100
committerGitHub <noreply@github.com>2019-11-02 14:37:22 +0100
commit21b3f6247403c06f85e1f45d219f87549862198f (patch)
tree0038ae92f1cc7aaff0b55d6e5ac59efcc28bdf8f /memory
parentff881bdb6795e0f307b93919f98f454bedde4bb6 (diff)
parenta9dc528a4a7b0aaad5308aff70963485ec3e9bec (diff)
downloaduxp-21b3f6247403c06f85e1f45d219f87549862198f.tar.gz
Merge pull request #1262 from athenian200/solaris-work
Support Modern Solaris
Diffstat (limited to 'memory')
-rw-r--r--memory/mozalloc/mozalloc_abort.cpp2
-rw-r--r--memory/mozjemalloc/jemalloc.c33
2 files changed, 32 insertions, 3 deletions
diff --git a/memory/mozalloc/mozalloc_abort.cpp b/memory/mozalloc/mozalloc_abort.cpp
index a998d81644..85e566db02 100644
--- a/memory/mozalloc/mozalloc_abort.cpp
+++ b/memory/mozalloc/mozalloc_abort.cpp
@@ -68,7 +68,7 @@ void fillAbortMessage(char (&msg)[N], uintptr_t retAddress) {
//
// That segmentation fault will be interpreted as another bug by ASan and as a
// result, ASan will just exit(1) instead of aborting.
-void abort(void)
+extern "C" void abort(void)
{
#ifdef MOZ_WIDGET_ANDROID
char msg[64] = {};
diff --git a/memory/mozjemalloc/jemalloc.c b/memory/mozjemalloc/jemalloc.c
index 9a97bbb09c..acaf2572c9 100644
--- a/memory/mozjemalloc/jemalloc.c
+++ b/memory/mozjemalloc/jemalloc.c
@@ -280,7 +280,9 @@ typedef long ssize_t;
#define JEMALLOC_RECYCLE
#ifndef MOZ_MEMORY_WINDOWS
+#ifndef MOZ_MEMORY_SOLARIS
#include <sys/cdefs.h>
+#endif
#ifndef __DECONST
# define __DECONST(type, var) ((type)(uintptr_t)(const void *)(var))
#endif
@@ -306,7 +308,7 @@ __FBSDID("$FreeBSD: head/lib/libc/stdlib/malloc.c 180599 2008-07-18 19:35:44Z ja
#endif
#include <sys/time.h>
#include <sys/types.h>
-#if !defined(MOZ_MEMORY_ANDROID)
+#if !defined(MOZ_MEMORY_SOLARIS) && !defined(MOZ_MEMORY_ANDROID)
#include <sys/sysctl.h>
#endif
#include <sys/uio.h>
@@ -408,6 +410,10 @@ void *_mmap(void *addr, size_t length, int prot, int flags,
#endif
#endif
+#if defined(MOZ_MEMORY_SOLARIS) && defined(MAP_ALIGN) && !defined(JEMALLOC_NEVER_USES_MAP_ALIGN)
+#define JEMALLOC_USES_MAP_ALIGN /* Required on Solaris 10. Might improve performance elsewhere. */
+#endif
+
#ifndef __DECONST
#define __DECONST(type, var) ((type)(uintptr_t)(const void *)(var))
#endif
@@ -1034,7 +1040,7 @@ static const bool config_recycle = false;
* will abort.
* Platform specific page size conditions copied from js/public/HeapAPI.h
*/
-#if (defined(__FreeBSD__)) && \
+#if (defined(SOLARIS) || defined(__FreeBSD__)) && \
(defined(__sparc) || defined(__sparcv9) || defined(__ia64))
#define pagesize_2pow ((size_t) 13)
#elif defined(__powerpc64__)
@@ -2640,8 +2646,13 @@ pages_purge(void *addr, size_t length)
# define JEMALLOC_MADV_PURGE MADV_FREE
# define JEMALLOC_MADV_ZEROS false
# endif
+#ifdef MOZ_MEMORY_SOLARIS
+ int err = posix_madvise(addr, length, JEMALLOC_MADV_PURGE);
+ unzeroed = (JEMALLOC_MADV_ZEROS == false || err != 0);
+#else
int err = madvise(addr, length, JEMALLOC_MADV_PURGE);
unzeroed = (JEMALLOC_MADV_ZEROS == false || err != 0);
+#endif
# undef JEMALLOC_MADV_PURGE
# undef JEMALLOC_MADV_ZEROS
# endif
@@ -3597,9 +3608,14 @@ arena_purge(arena_t *arena, bool all)
#endif
#ifndef MALLOC_DECOMMIT
+#ifdef MOZ_MEMORY_SOLARIS
+ posix_madvise((void*)((uintptr_t)chunk + (i << pagesize_2pow)),
+ (npages << pagesize_2pow),MADV_FREE);
+#else
madvise((void *)((uintptr_t)chunk + (i <<
pagesize_2pow)), (npages << pagesize_2pow),
MADV_FREE);
+#endif
# ifdef MALLOC_DOUBLE_PURGE
madvised = true;
# endif
@@ -5120,6 +5136,13 @@ malloc_ncpus(void)
else
return (n);
}
+#elif (defined(MOZ_MEMORY_SOLARIS))
+
+static inline unsigned
+malloc_ncpus(void)
+{
+ return sysconf(_SC_NPROCESSORS_ONLN);
+}
#elif (defined(MOZ_MEMORY_WINDOWS))
static inline unsigned
malloc_ncpus(void)
@@ -5916,9 +5939,15 @@ RETURN:
#define MOZ_MEMORY_ELF
#endif
+#ifdef MOZ_MEMORY_SOLARIS
+# if (defined(__GNUC__))
+__attribute__((noinline))
+# endif
+#else
#if (defined(MOZ_MEMORY_ELF))
__attribute__((visibility ("hidden")))
#endif
+#endif
#endif /* MOZ_REPLACE_MALLOC */
#ifdef MOZ_MEMORY_ELF