1934 if (os::Aix::on_pase_V5R4_or_older()) { |
1934 if (os::Aix::on_pase_V5R4_or_older()) { |
1935 ShouldNotReachHere(); |
1935 ShouldNotReachHere(); |
1936 } |
1936 } |
1937 |
1937 |
1938 // Align size of shm up to 64K to avoid errors if we later try to change the page size. |
1938 // Align size of shm up to 64K to avoid errors if we later try to change the page size. |
1939 const size_t size = align_size_up(bytes, 64*K); |
1939 const size_t size = align_up(bytes, 64*K); |
1940 |
1940 |
1941 // Reserve the shared segment. |
1941 // Reserve the shared segment. |
1942 int shmid = shmget(IPC_PRIVATE, size, IPC_CREAT | S_IRUSR | S_IWUSR); |
1942 int shmid = shmget(IPC_PRIVATE, size, IPC_CREAT | S_IRUSR | S_IWUSR); |
1943 if (shmid == -1) { |
1943 if (shmid == -1) { |
1944 trcVerbose("shmget(.., " UINTX_FORMAT ", ..) failed (errno: %d).", size, errno); |
1944 trcVerbose("shmget(.., " UINTX_FORMAT ", ..) failed (errno: %d).", size, errno); |
2075 } else { |
2075 } else { |
2076 alignment_hint = os::vm_page_size(); |
2076 alignment_hint = os::vm_page_size(); |
2077 } |
2077 } |
2078 |
2078 |
2079 // Size shall always be a multiple of os::vm_page_size (esp. in 64K mode). |
2079 // Size shall always be a multiple of os::vm_page_size (esp. in 64K mode). |
2080 const size_t size = align_size_up(bytes, os::vm_page_size()); |
2080 const size_t size = align_up(bytes, os::vm_page_size()); |
2081 |
2081 |
2082 // alignment: Allocate memory large enough to include an aligned range of the right size and |
2082 // alignment: Allocate memory large enough to include an aligned range of the right size and |
2083 // cut off the leading and trailing waste pages. |
2083 // cut off the leading and trailing waste pages. |
2084 assert0(alignment_hint != 0 && is_aligned_to(alignment_hint, os::vm_page_size())); // see above |
2084 assert0(alignment_hint != 0 && is_aligned_to(alignment_hint, os::vm_page_size())); // see above |
2085 const size_t extra_size = size + alignment_hint; |
2085 const size_t extra_size = size + alignment_hint; |
2108 trcVerbose("mmap(" PTR_FORMAT ", " UINTX_FORMAT ", ..) failed (%d)", requested_addr, size, errno); |
2108 trcVerbose("mmap(" PTR_FORMAT ", " UINTX_FORMAT ", ..) failed (%d)", requested_addr, size, errno); |
2109 return NULL; |
2109 return NULL; |
2110 } |
2110 } |
2111 |
2111 |
2112 // Handle alignment. |
2112 // Handle alignment. |
2113 char* const addr_aligned = align_ptr_up(addr, alignment_hint); |
2113 char* const addr_aligned = align_up(addr, alignment_hint); |
2114 const size_t waste_pre = addr_aligned - addr; |
2114 const size_t waste_pre = addr_aligned - addr; |
2115 char* const addr_aligned_end = addr_aligned + size; |
2115 char* const addr_aligned_end = addr_aligned + size; |
2116 const size_t waste_post = extra_size - waste_pre - size; |
2116 const size_t waste_post = extra_size - waste_pre - size; |
2117 if (waste_pre > 0) { |
2117 if (waste_pre > 0) { |
2118 ::munmap(addr, waste_pre); |
2118 ::munmap(addr, waste_pre); |
2334 // Instead of mimicking the dangerous coding of the other platforms, here I |
2334 // Instead of mimicking the dangerous coding of the other platforms, here I |
2335 // just ignore the request address (release) or assert(debug). |
2335 // just ignore the request address (release) or assert(debug). |
2336 assert0(requested_addr == NULL); |
2336 assert0(requested_addr == NULL); |
2337 |
2337 |
2338 // Always round to os::vm_page_size(), which may be larger than 4K. |
2338 // Always round to os::vm_page_size(), which may be larger than 4K. |
2339 bytes = align_size_up(bytes, os::vm_page_size()); |
2339 bytes = align_up(bytes, os::vm_page_size()); |
2340 const size_t alignment_hint0 = |
2340 const size_t alignment_hint0 = |
2341 alignment_hint ? align_size_up(alignment_hint, os::vm_page_size()) : 0; |
2341 alignment_hint ? align_up(alignment_hint, os::vm_page_size()) : 0; |
2342 |
2342 |
2343 // In 4K mode always use mmap. |
2343 // In 4K mode always use mmap. |
2344 // In 64K mode allocate small sizes with mmap, large ones with 64K shmatted. |
2344 // In 64K mode allocate small sizes with mmap, large ones with 64K shmatted. |
2345 if (os::vm_page_size() == 4*K) { |
2345 if (os::vm_page_size() == 4*K) { |
2346 return reserve_mmaped_memory(bytes, requested_addr, alignment_hint); |
2346 return reserve_mmaped_memory(bytes, requested_addr, alignment_hint); |
2358 // Dynamically do different things for mmap/shmat. |
2358 // Dynamically do different things for mmap/shmat. |
2359 vmembk_t* const vmi = vmembk_find(addr); |
2359 vmembk_t* const vmi = vmembk_find(addr); |
2360 guarantee0(vmi); |
2360 guarantee0(vmi); |
2361 |
2361 |
2362 // Always round to os::vm_page_size(), which may be larger than 4K. |
2362 // Always round to os::vm_page_size(), which may be larger than 4K. |
2363 size = align_size_up(size, os::vm_page_size()); |
2363 size = align_up(size, os::vm_page_size()); |
2364 addr = align_ptr_up(addr, os::vm_page_size()); |
2364 addr = align_up(addr, os::vm_page_size()); |
2365 |
2365 |
2366 bool rc = false; |
2366 bool rc = false; |
2367 bool remove_bookkeeping = false; |
2367 bool remove_bookkeeping = false; |
2368 if (vmi->type == VMEM_SHMATED) { |
2368 if (vmi->type == VMEM_SHMATED) { |
2369 // For shmatted memory, we do: |
2369 // For shmatted memory, we do: |
2525 // available (and not reserved for something else). |
2525 // available (and not reserved for something else). |
2526 char* os::pd_attempt_reserve_memory_at(size_t bytes, char* requested_addr) { |
2526 char* os::pd_attempt_reserve_memory_at(size_t bytes, char* requested_addr) { |
2527 char* addr = NULL; |
2527 char* addr = NULL; |
2528 |
2528 |
2529 // Always round to os::vm_page_size(), which may be larger than 4K. |
2529 // Always round to os::vm_page_size(), which may be larger than 4K. |
2530 bytes = align_size_up(bytes, os::vm_page_size()); |
2530 bytes = align_up(bytes, os::vm_page_size()); |
2531 |
2531 |
2532 // In 4K mode always use mmap. |
2532 // In 4K mode always use mmap. |
2533 // In 64K mode allocate small sizes with mmap, large ones with 64K shmatted. |
2533 // In 64K mode allocate small sizes with mmap, large ones with 64K shmatted. |
2534 if (os::vm_page_size() == 4*K) { |
2534 if (os::vm_page_size() == 4*K) { |
2535 return reserve_mmaped_memory(bytes, requested_addr, 0); |
2535 return reserve_mmaped_memory(bytes, requested_addr, 0); |
4310 // Align the returned stack size such that the stack low address |
4310 // Align the returned stack size such that the stack low address |
4311 // is aligned to page size (Note: base is usually not and we do not care). |
4311 // is aligned to page size (Note: base is usually not and we do not care). |
4312 // We need to do this because caller code will assume stack low address is |
4312 // We need to do this because caller code will assume stack low address is |
4313 // page aligned and will place guard pages without checking. |
4313 // page aligned and will place guard pages without checking. |
4314 address low = bounds.base - bounds.size; |
4314 address low = bounds.base - bounds.size; |
4315 address low_aligned = (address)align_ptr_up(low, os::vm_page_size()); |
4315 address low_aligned = (address)align_up(low, os::vm_page_size()); |
4316 size_t s = bounds.base - low_aligned; |
4316 size_t s = bounds.base - low_aligned; |
4317 return s; |
4317 return s; |
4318 } |
4318 } |
4319 |
4319 |
4320 extern char** environ; |
4320 extern char** environ; |