Lines 318-332
Link Here
|
318 |
static void * |
318 |
static void * |
319 |
MapPages(void *addr, size_t size) |
319 |
MapPages(void *addr, size_t size) |
320 |
{ |
320 |
{ |
|
|
321 |
#if defined(__ia64__) |
322 |
/* |
323 |
* The JS engine assumes that all allocated pointers have their high 17 bits clear, |
324 |
* which ia64's mmap doesn't support directly. However, we can emulate it by passing |
325 |
* mmap an "addr" parameter with those bits clear. The mmap will return that address, |
326 |
* or the nearest available memory above that address, providing a near-guarantee |
327 |
* that those bits are clear. If they are not, we return NULL below to indicate |
328 |
* out-of-memory. |
329 |
* |
330 |
* The addr is chosen as 0x0000070000000000, which still allows about 120TB of virtual |
331 |
* address space. |
332 |
* |
333 |
* See Bug 589735 for more information. |
334 |
*/ |
335 |
#endif |
336 |
|
321 |
/* |
337 |
/* |
322 |
* We don't use MAP_FIXED here, because it can cause the *replacement* |
338 |
* We don't use MAP_FIXED here, because it can cause the *replacement* |
323 |
* of existing mappings, and we only want to create new mappings. |
339 |
* of existing mappings, and we only want to create new mappings. |
324 |
*/ |
340 |
*/ |
|
|
341 |
#if defined(__ia64__) |
342 |
void *p = mmap(addr ? addr : (void*)0x0000070000000000, |
343 |
size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, |
344 |
-1, 0); |
345 |
#else |
325 |
void *p = mmap(addr, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, |
346 |
void *p = mmap(addr, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, |
326 |
-1, 0); |
347 |
-1, 0); |
|
|
348 |
#endif |
327 |
if (p == MAP_FAILED) |
349 |
if (p == MAP_FAILED) |
328 |
return NULL; |
350 |
return NULL; |
|
|
351 |
#if defined(__ia64__) |
352 |
/* |
353 |
* If the caller requested a specific memory location, verify that's what mmap returned. |
354 |
* Otherwise: If the allocated memory doesn't have its upper 17 bits clear, consider it |
355 |
* as out of memory. |
356 |
*/ |
357 |
if (addr && p != addr |
358 |
|| !addr && ((long long)p & 0xffff800000000000)) { |
359 |
#else |
360 |
/* If the caller requested a specific memory location, verify that's what mmap returned. */ |
329 |
if (addr && p != addr) { |
361 |
if (addr && p != addr) { |
|
|
362 |
#endif |
330 |
/* We succeeded in mapping memory, but not in the right place. */ |
363 |
/* We succeeded in mapping memory, but not in the right place. */ |
331 |
JS_ALWAYS_TRUE(munmap(p, size) == 0); |
364 |
JS_ALWAYS_TRUE(munmap(p, size) == 0); |
332 |
return NULL; |
365 |
return NULL; |