summaryrefslogtreecommitdiffstats
path: root/memory/mozjemalloc/jemalloc.c
diff options
context:
space:
mode:
authorJMadgwick <james.madgwick@outlook.com>2020-03-05 21:03:44 +0000
committerwolfbeast <mcwerewolf@wolfbeast.com>2020-04-14 13:18:48 +0200
commit64a7c9e2d2f8c9ebdc4c70c16c630cebbd5abe53 (patch)
treebb1ec37d987918be07f551b956ba3887c1c7d523 /memory/mozjemalloc/jemalloc.c
parent514ff21cbab5c638d9c347ed261a14e8bd5295e6 (diff)
downloadUXP-64a7c9e2d2f8c9ebdc4c70c16c630cebbd5abe53.tar
UXP-64a7c9e2d2f8c9ebdc4c70c16c630cebbd5abe53.tar.gz
UXP-64a7c9e2d2f8c9ebdc4c70c16c630cebbd5abe53.tar.lz
UXP-64a7c9e2d2f8c9ebdc4c70c16c630cebbd5abe53.tar.xz
UXP-64a7c9e2d2f8c9ebdc4c70c16c630cebbd5abe53.zip
Issue #1471 - Fix building on sparc64 Linux
Correct various pre-processor defines for sparc64 and in mozjemalloc use the JS arm64 allocator on Linux/sparc64. This corrects build problems opn Linux sparc64 and is in line with bugzilla bug #1275204.
Diffstat (limited to 'memory/mozjemalloc/jemalloc.c')
-rw-r--r--memory/mozjemalloc/jemalloc.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/memory/mozjemalloc/jemalloc.c b/memory/mozjemalloc/jemalloc.c
index 50ba22889..47a5a9f5c 100644
--- a/memory/mozjemalloc/jemalloc.c
+++ b/memory/mozjemalloc/jemalloc.c
@@ -1966,7 +1966,7 @@ static void *
pages_map(void *addr, size_t size)
{
void *ret;
-#if defined(__ia64__)
+#if defined(__ia64__) || (defined(__sparc__) && defined(__arch64__) && defined(__linux__))
/*
* 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,6 +1987,28 @@ pages_map(void *addr, size_t size)
}
#endif
+#if defined(__sparc__) && defined(__arch64__) && defined(__linux__)
+ const uintptr_t start = 0x0000070000000000ULL;
+ const uintptr_t end = 0x0000800000000000ULL;
+
+ /* Copied from js/src/gc/Memory.cpp and adapted for this source */
+
+ uintptr_t hint;
+ void* region = MAP_FAILED;
+ for (hint = start; region == MAP_FAILED && hint + size <= end; hint += chunksize) {
+ region = mmap((void*)hint, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
+ if (region != MAP_FAILED) {
+ if (((size_t) region + (size - 1)) & 0xffff800000000000) {
+ if (munmap(region, size)) {
+ MOZ_ASSERT(errno == ENOMEM);
+ }
+ region = MAP_FAILED;
+ }
+ }
+ }
+ ret = region;
+#else
+
/*
* We don't use MAP_FIXED here, because it can cause the *replacement*
* of existing mappings, and we only want to create new mappings.
@@ -1995,10 +2017,11 @@ pages_map(void *addr, size_t size)
MAP_PRIVATE | MAP_ANON, -1, 0);
assert(ret != NULL);
+#endif
if (ret == MAP_FAILED) {
ret = NULL;
}
-#if defined(__ia64__)
+#if defined(__ia64__) || (defined(__sparc__) && defined(__arch64__) && defined(__linux__))
/*
* If the allocated memory doesn't have its upper 17 bits clear, consider it
* as out of memory.
@@ -2031,7 +2054,7 @@ pages_map(void *addr, size_t size)
MozTagAnonymousMemory(ret, size, "jemalloc");
}
-#if defined(__ia64__)
+#if defined(__ia64__) || (defined(__sparc__) && defined(__arch64__) && defined(__linux__))
assert(ret == NULL || (!check_placement && ret != NULL)
|| (check_placement && ret == addr));
#else