327 |
327 |
328 // Check alignment constraints |
328 // Check alignment constraints |
329 if ((((size_t)base + noaccess_prefix) & (alignment - 1)) != 0) { |
329 if ((((size_t)base + noaccess_prefix) & (alignment - 1)) != 0) { |
330 // Base not aligned, retry |
330 // Base not aligned, retry |
331 if (!os::release_memory(base, size)) fatal("os::release_memory failed"); |
331 if (!os::release_memory(base, size)) fatal("os::release_memory failed"); |
332 // Reserve size large enough to do manual alignment and |
332 // Make sure that size is aligned |
333 // increase size to a multiple of the desired alignment |
|
334 size = align_size_up(size, alignment); |
333 size = align_size_up(size, alignment); |
335 size_t extra_size = size + alignment; |
334 base = os::reserve_memory_aligned(size, alignment); |
336 do { |
|
337 char* extra_base = os::reserve_memory(extra_size, NULL, alignment); |
|
338 if (extra_base == NULL) return; |
|
339 // Do manual alignement |
|
340 base = (char*) align_size_up((uintptr_t) extra_base, alignment); |
|
341 assert(base >= extra_base, "just checking"); |
|
342 // Re-reserve the region at the aligned base address. |
|
343 os::release_memory(extra_base, extra_size); |
|
344 base = os::reserve_memory(size, base); |
|
345 } while (base == NULL); |
|
346 |
335 |
347 if (requested_address != 0 && |
336 if (requested_address != 0 && |
348 failed_to_reserve_as_requested(base, requested_address, size, false)) { |
337 failed_to_reserve_as_requested(base, requested_address, size, false)) { |
349 // As a result of the alignment constraints, the allocated base differs |
338 // As a result of the alignment constraints, the allocated base differs |
350 // from the requested address. Return back to the caller who can |
339 // from the requested address. Return back to the caller who can |