|
Lines 236-260
MapAlignedPages(size_t size, size_t alig
Link Here
|
| 236 |
return p; |
236 |
return p; |
| 237 |
} |
237 |
} |
| 238 |
|
238 |
|
| 239 |
# else /* JS_GC_HAS_MAP_ALIGN */ |
239 |
# else /* JS_GC_HAS_MAP_ALIGN */ |
| 240 |
|
240 |
|
| 241 |
static void * |
241 |
static void * |
| 242 |
MapPages(void *addr, size_t size) |
242 |
MapPages(void *addr, size_t size) |
| 243 |
{ |
243 |
{ |
|
|
244 |
#if defined(__ia64__) |
| 245 |
/* |
| 246 |
* The JS engine assumes that all allocated pointers have their high 17 bits clear, |
| 247 |
* which ia64's mmap doesn't support directly. However, we can emulate it by passing |
| 248 |
* mmap an "addr" parameter with those bits clear. The mmap will return that address, |
| 249 |
* or the nearest available memory above that address, providing a near-guarantee |
| 250 |
* that those bits are clear. If they are not, we return NULL below to indicate |
| 251 |
* out-of-memory. |
| 252 |
* |
| 253 |
* The addr is chosen as 0x0000070000000000, which still allows about 120TB of virtual |
| 254 |
* address space. |
| 255 |
* |
| 256 |
* See Bug 589735 for more information. |
| 257 |
*/ |
| 258 |
#endif |
| 259 |
|
| 244 |
/* |
260 |
/* |
| 245 |
* We don't use MAP_FIXED here, because it can cause the *replacement* |
261 |
* We don't use MAP_FIXED here, because it can cause the *replacement* |
| 246 |
* of existing mappings, and we only want to create new mappings. |
262 |
* of existing mappings, and we only want to create new mappings. |
| 247 |
*/ |
263 |
*/ |
|
|
264 |
#if defined(__ia64__) |
| 265 |
void *p = mmap(addr ? addr : (void*)0x0000070000000000, |
| 266 |
size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, |
| 267 |
-1, 0); |
| 268 |
#else |
| 248 |
void *p = mmap(addr, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, |
269 |
void *p = mmap(addr, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, |
| 249 |
-1, 0); |
270 |
-1, 0); |
|
|
271 |
#endif |
| 250 |
if (p == MAP_FAILED) |
272 |
if (p == MAP_FAILED) |
| 251 |
return NULL; |
273 |
return NULL; |
|
|
274 |
#if defined(__ia64__) |
| 275 |
/* |
| 276 |
* If the caller requested a specific memory location, verify that's what mmap returned. |
| 277 |
* Otherwise: If the allocated memory doesn't have its upper 17 bits clear, consider it |
| 278 |
* as out of memory. |
| 279 |
*/ |
| 280 |
if (addr && p != addr |
| 281 |
|| !addr && ((long long)p & 0xffff800000000000)) { |
| 282 |
#else |
| 283 |
/* If the caller requested a specific memory location, verify that's what mmap returned. */ |
| 252 |
if (addr && p != addr) { |
284 |
if (addr && p != addr) { |
|
|
285 |
#endif |
| 253 |
/* We succeeded in mapping memory, but not in the right place. */ |
286 |
/* We succeeded in mapping memory, but not in the right place. */ |
| 254 |
JS_ALWAYS_TRUE(munmap(p, size) == 0); |
287 |
JS_ALWAYS_TRUE(munmap(p, size) == 0); |
| 255 |
return NULL; |
288 |
return NULL; |
| 256 |
} |
289 |
} |
| 257 |
return p; |
290 |
return p; |
| 258 |
} |
291 |
} |
| 259 |
|
292 |
|
| 260 |
# endif /* !JS_GC_HAS_MAP_ALIGN */ |
293 |
# endif /* !JS_GC_HAS_MAP_ALIGN */ |