1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
diff -r 9259fdc3570c memory/jemalloc/jemalloc.c
--- a/memory/jemalloc/jemalloc.c Wed Jan 27 16:20:05 2010 -0800
+++ b/memory/jemalloc/jemalloc.c Wed Jan 27 23:03:56 2010 -0600
@@ -373,7 +373,7 @@
static const bool __isthreaded = true;
#endif
-#if defined(MOZ_MEMORY_SOLARIS) && defined(MAP_ALIGN) && !defined(JEMALLOC_NEVER_USES_MAP_ALIGN)
+#if defined(MOZ_MEMORY_SOLARIS) || defined(MOZ_MEMORY_LINUX) || defined(MOZ_MEMORY_BSD)
#define JEMALLOC_USES_MAP_ALIGN /* Required on Solaris 10. Might improve performance elsewhere. */
#endif
@@ -2178,20 +2178,31 @@
* We don't use MAP_FIXED here, because it can cause the *replacement*
* of existing mappings, and we only want to create new mappings.
*/
-#ifdef MALLOC_PAGEFILE
- if (pfd != -1) {
- ret = mmap((void *)alignment, size, PROT_READ | PROT_WRITE, MAP_PRIVATE |
- MAP_NOSYNC | MAP_ALIGN, pfd, 0);
- } else
-#endif
- {
- ret = mmap((void *)alignment, size, PROT_READ | PROT_WRITE, MAP_PRIVATE |
- MAP_NOSYNC | MAP_ALIGN | MAP_ANON, -1, 0);
- }
+ ret = mmap(NULL, size + alignment, PROT_READ | PROT_WRITE, MAP_PRIVATE |
+ MAP_NOSYNC| MAP_ANON, -1, 0);
assert(ret != NULL);
if (ret == MAP_FAILED)
ret = NULL;
+ else {
+ uintptr_t aligned_ret;
+ size_t extra_size;
+
+ aligned_ret = (uintptr_t)ret + alignment - 1;
+ aligned_ret &= ~(alignment - 1);
+ extra_size = aligned_ret - (uintptr_t)ret;
+ munmap(ret, extra_size);
+ munmap(ret + extra_size + size, alignment - extra_size);
+ ret = (void *)aligned_ret;
+#ifdef MALLOC_PAGEFILE
+ if (pfd != -1) {
+ ret = mmap(ret, size, PROT_READ | PROT_WRITE, MAP_PRIVATE |
+ MAP_NOSYNC | MAP_FIXED, pfd, 0);
+ }
+ if (ret == MAP_FAILED)
+ ret = NULL;
+#endif
+ }
return (ret);
}
#endif
|