summaryrefslogtreecommitdiffstats
path: root/memory/mozjemalloc
diff options
context:
space:
mode:
authorathenian200 <athenian200@outlook.com>2020-05-31 11:48:49 -0500
committerMoonchild <moonchild@palemoon.org>2020-06-01 11:48:25 +0000
commit744b044935f7d1d67fbe0df42d898efcbdd00536 (patch)
treeb8df5a4b66f64bff453553997dc553aa14b44ccf /memory/mozjemalloc
parentb246f7b2f1e2480ea10124537d2c6f40628d5c61 (diff)
downloadUXP-744b044935f7d1d67fbe0df42d898efcbdd00536.tar
UXP-744b044935f7d1d67fbe0df42d898efcbdd00536.tar.gz
UXP-744b044935f7d1d67fbe0df42d898efcbdd00536.tar.lz
UXP-744b044935f7d1d67fbe0df42d898efcbdd00536.tar.xz
UXP-744b044935f7d1d67fbe0df42d898efcbdd00536.zip
Issue #1571 - Remove JEMALLOC_USES_MAP_ALIGN and fix 48-bit addressing on SunOS AMD64.
The JEMALLOC_USES_MAP_ALIGN code has turned out to be worse than useless, and in fact it breaks 64-bit SunOS. It's very old and turned out not to be needed anymore because the way the memory allocator works has changed since it was implemented. It prevented a fix I tried for 48-bit addressing from working properly. However, without either this code or the 48-bit addressing fix, the 64-bit version won't even start, which is why I thought the code was still needed. https://bugzilla.mozilla.org/show_bug.cgi?id=457189 https://hg.mozilla.org/mozilla-central/rev/a26c500b98ab The 48-bit addressing fix is based on code found here: https://github.com/OpenIndiana/oi-userland/blob/oi/hipster/components/web/firefox/patches/patch-js_src_gc_Memory.cpp.patch I already applied these changes to js/src/gc/Memory.cpp, but as I was looking through jemalloc.c I saw that there were very similar ifdefs for Linux on SPARC as the ones I'd had to enaable in Memory.cpp, but for whatever reason the patches I found didn't touch them. So I tried doing for jemalloc.c what was already done for Memory.cpp, and it worked (but only after I removed the map align code).
Diffstat (limited to 'memory/mozjemalloc')
-rw-r--r--memory/mozjemalloc/jemalloc.c46
1 files changed, 4 insertions, 42 deletions
diff --git a/memory/mozjemalloc/jemalloc.c b/memory/mozjemalloc/jemalloc.c
index 47a5a9f5c..86864e1cd 100644
--- a/memory/mozjemalloc/jemalloc.c
+++ b/memory/mozjemalloc/jemalloc.c
@@ -357,10 +357,6 @@ 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
@@ -1940,33 +1936,12 @@ pages_unmap(void *addr, size_t size)
}
}
#else
-#ifdef JEMALLOC_USES_MAP_ALIGN
-static void *
-pages_map_align(size_t size, size_t alignment)
-{
- void *ret;
-
- /*
- * We don't use MAP_FIXED here, because it can cause the *replacement*
- * of existing mappings, and we only want to create new mappings.
- */
- ret = mmap((void *)alignment, size, PROT_READ | PROT_WRITE,
- MAP_PRIVATE | MAP_NOSYNC | MAP_ALIGN | MAP_ANON, -1, 0);
- assert(ret != NULL);
-
- if (ret == MAP_FAILED)
- ret = NULL;
- else
- MozTagAnonymousMemory(ret, size, "jemalloc");
- return (ret);
-}
-#endif
static void *
pages_map(void *addr, size_t size)
{
void *ret;
-#if defined(__ia64__) || (defined(__sparc__) && defined(__arch64__) && defined(__linux__))
+#if defined(__ia64__) || (defined(__sparc__) && defined(__arch64__) && defined(__linux__)) || (defined(__sun) && defined(__x86_64__))
/*
* The JS engine assumes that all allocated pointers have their high 17 bits clear,
* which ia64's mmap doesn't support directly. However, we can emulate it by passing
@@ -1987,7 +1962,7 @@ pages_map(void *addr, size_t size)
}
#endif
-#if defined(__sparc__) && defined(__arch64__) && defined(__linux__)
+#if defined(__sparc__) && defined(__arch64__) && defined(__linux__) || (defined(__sun) && defined(__x86_64__))
const uintptr_t start = 0x0000070000000000ULL;
const uintptr_t end = 0x0000800000000000ULL;
@@ -2021,7 +1996,7 @@ pages_map(void *addr, size_t size)
if (ret == MAP_FAILED) {
ret = NULL;
}
-#if defined(__ia64__) || (defined(__sparc__) && defined(__arch64__) && defined(__linux__))
+#if defined(__ia64__) || (defined(__sparc__) && defined(__arch64__) && defined(__linux__)) || (defined(__sun) && defined(__x86_64__))
/*
* If the allocated memory doesn't have its upper 17 bits clear, consider it
* as out of memory.
@@ -2054,7 +2029,7 @@ pages_map(void *addr, size_t size)
MozTagAnonymousMemory(ret, size, "jemalloc");
}
-#if defined(__ia64__) || (defined(__sparc__) && defined(__arch64__) && defined(__linux__))
+#if defined(__ia64__) || (defined(__sparc__) && defined(__arch64__) && defined(__linux__)) || (defined(__sun) && defined(__x86_64__))
assert(ret == NULL || (!check_placement && ret != NULL)
|| (check_placement && ret == addr));
#else
@@ -2305,9 +2280,6 @@ chunk_alloc_mmap_slow(size_t size, size_t alignment)
static void *
chunk_alloc_mmap(size_t size, size_t alignment)
{
-#ifdef JEMALLOC_USES_MAP_ALIGN
- return pages_map_align(size, alignment);
-#else
void *ret;
size_t offset;
@@ -2335,7 +2307,6 @@ chunk_alloc_mmap(size_t size, size_t alignment)
assert(ret != NULL);
return (ret);
-#endif
}
bool
@@ -5341,15 +5312,6 @@ MALLOC_OUT:
recycled_size = 0;
-#ifdef JEMALLOC_USES_MAP_ALIGN
- /*
- * When using MAP_ALIGN, the alignment parameter must be a power of two
- * multiple of the system pagesize, or mmap will fail.
- */
- assert((chunksize % pagesize) == 0);
- assert((1 << (ffs(chunksize / pagesize) - 1)) == (chunksize/pagesize));
-#endif
-
/* Various sanity checks that regard configuration. */
assert(quantum >= sizeof(void *));
assert(quantum <= pagesize);