summaryrefslogtreecommitdiffstats
path: root/memory
diff options
context:
space:
mode:
authorathenian200 <athenian200@outlook.com>2019-10-01 21:36:29 -0500
committerathenian200 <athenian200@outlook.com>2019-10-21 04:53:40 -0500
commit3647f42c27761472e4ee204bade964e8ffad4679 (patch)
tree40fa50571360bd3630ddb2f3e153c4a7ef468cd7 /memory
parent57bfda37aebdef6a0f7bbb320d508dfaf1a89718 (diff)
downloadUXP-3647f42c27761472e4ee204bade964e8ffad4679.tar
UXP-3647f42c27761472e4ee204bade964e8ffad4679.tar.gz
UXP-3647f42c27761472e4ee204bade964e8ffad4679.tar.lz
UXP-3647f42c27761472e4ee204bade964e8ffad4679.tar.xz
UXP-3647f42c27761472e4ee204bade964e8ffad4679.zip
MoonchildProductions#1251 - Part 7: All the posix_m* memory-related stuff, gathered together.
https://bugzilla.mozilla.org/show_bug.cgi?id=1158445 https://bugzilla.mozilla.org/show_bug.cgi?id=963983 https://bugzilla.mozilla.org/show_bug.cgi?id=1542758 Solaris madvise and malign don't perfectly map to their POSIX counterparts, and some Linux versions (especially Android) don't define the POSIX counterparts at all, so options are limited. Ideally posix_madvise and posix_malign should be the safer and more portable options for all platforms.
Diffstat (limited to 'memory')
-rw-r--r--memory/mozjemalloc/jemalloc.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/memory/mozjemalloc/jemalloc.c b/memory/mozjemalloc/jemalloc.c
index c54a85959..acaf2572c 100644
--- a/memory/mozjemalloc/jemalloc.c
+++ b/memory/mozjemalloc/jemalloc.c
@@ -410,8 +410,8 @@ 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. */
+#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
@@ -1040,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__)
@@ -2646,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
@@ -3603,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
@@ -5131,7 +5141,7 @@ malloc_ncpus(void)
static inline unsigned
malloc_ncpus(void)
{
- return sysconf(_SC_NPROCESSORS_ONLN);
+ return sysconf(_SC_NPROCESSORS_ONLN);
}
#elif (defined(MOZ_MEMORY_WINDOWS))
static inline unsigned