1 |
axs 14/01/20 16:39:52 |
2 |
|
3 |
Added: spidermonkey-17-ia64-mmap.patch |
4 |
Log: |
5 |
backport mmap patch to fix ia64 on spidermonkey-17 |
6 |
|
7 |
(Portage version: 2.2.7/cvs/Linux x86_64, signed Manifest commit with key 2B6559ED) |
8 |
|
9 |
Revision Changes Path |
10 |
1.1 dev-lang/spidermonkey/files/spidermonkey-17-ia64-mmap.patch |
11 |
|
12 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/spidermonkey/files/spidermonkey-17-ia64-mmap.patch?rev=1.1&view=markup |
13 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-lang/spidermonkey/files/spidermonkey-17-ia64-mmap.patch?rev=1.1&content-type=text/plain |
14 |
|
15 |
Index: spidermonkey-17-ia64-mmap.patch |
16 |
=================================================================== |
17 |
--- a/js/src/gc/Memory.cpp 2013-02-11 17:33:22.000000000 -0500 |
18 |
+++ b/js/src/gc/Memory.cpp 2014-01-08 12:36:29.406851422 -0500 |
19 |
@@ -302,10 +302,46 @@ |
20 |
void |
21 |
InitMemorySubsystem() |
22 |
{ |
23 |
+#if !defined(__ia64__) |
24 |
if (size_t(sysconf(_SC_PAGESIZE)) != PageSize) |
25 |
MOZ_CRASH(); |
26 |
+#endif |
27 |
} |
28 |
|
29 |
+static inline void * |
30 |
+MapMemory(size_t length, int prot, int flags, int fd, off_t offset) |
31 |
+{ |
32 |
+#if defined(__ia64__) |
33 |
+ /* |
34 |
+ * The JS engine assumes that all allocated pointers have their high 17 bits clear, |
35 |
+ * which ia64's mmap doesn't support directly. However, we can emulate it by passing |
36 |
+ * mmap an "addr" parameter with those bits clear. The mmap will return that address, |
37 |
+ * or the nearest available memory above that address, providing a near-guarantee |
38 |
+ * that those bits are clear. If they are not, we return NULL below to indicate |
39 |
+ * out-of-memory. |
40 |
+ * |
41 |
+ * The addr is chosen as 0x0000070000000000, which still allows about 120TB of virtual |
42 |
+ * address space. |
43 |
+ * |
44 |
+ * See Bug 589735 for more information. |
45 |
+ */ |
46 |
+ void *region = mmap((void*)0x0000070000000000, length, prot, flags, fd, offset); |
47 |
+ if (region == MAP_FAILED) |
48 |
+ return MAP_FAILED; |
49 |
+ /* |
50 |
+ * If the allocated memory doesn't have its upper 17 bits clear, consider it |
51 |
+ * as out of memory. |
52 |
+ */ |
53 |
+ if ((uintptr_t(region) + (length - 1)) & 0xffff800000000000) { |
54 |
+ JS_ALWAYS_TRUE(0 == munmap(region, length)); |
55 |
+ return MAP_FAILED; |
56 |
+ } |
57 |
+ return region; |
58 |
+#else |
59 |
+ return mmap(NULL, length, prot, flags, fd, offset); |
60 |
+#endif |
61 |
+} |
62 |
+ |
63 |
void * |
64 |
MapAlignedPages(size_t size, size_t alignment) |
65 |
{ |
66 |
@@ -319,12 +353,15 @@ |
67 |
|
68 |
/* Special case: If we want page alignment, no further work is needed. */ |
69 |
if (alignment == PageSize) { |
70 |
- return mmap(NULL, size, prot, flags, -1, 0); |
71 |
+ void *region = MapMemory(size, prot, flags, -1, 0); |
72 |
+ if (region == MAP_FAILED) |
73 |
+ return NULL; |
74 |
+ return region; |
75 |
} |
76 |
|
77 |
/* Overallocate and unmap the region's edges. */ |
78 |
size_t reqSize = Min(size + 2 * alignment, 2 * size); |
79 |
- void *region = mmap(NULL, reqSize, prot, flags, -1, 0); |
80 |
+ void *region = MapMemory(reqSize, prot, flags, -1, 0); |
81 |
if (region == MAP_FAILED) |
82 |
return NULL; |