5888 // do an allocation at an address selected by the OS to get a good one. |
5888 // do an allocation at an address selected by the OS to get a good one. |
5889 const size_t large_allocation_size = os::large_page_size() * 4; |
5889 const size_t large_allocation_size = os::large_page_size() * 4; |
5890 char* result = os::reserve_memory_special(large_allocation_size, os::large_page_size(), NULL, false); |
5890 char* result = os::reserve_memory_special(large_allocation_size, os::large_page_size(), NULL, false); |
5891 if (result == NULL) { |
5891 if (result == NULL) { |
5892 if (VerboseInternalVMTests) { |
5892 if (VerboseInternalVMTests) { |
5893 gclog_or_tty->print("Failed to allocate control block with size "SIZE_FORMAT". Skipping remainder of test.", |
5893 gclog_or_tty->print("Failed to allocate control block with size " SIZE_FORMAT ". Skipping remainder of test.", |
5894 large_allocation_size); |
5894 large_allocation_size); |
5895 } |
5895 } |
5896 } else { |
5896 } else { |
5897 os::release_memory_special(result, large_allocation_size); |
5897 os::release_memory_special(result, large_allocation_size); |
5898 |
5898 |
5901 const size_t expected_allocation_size = os::large_page_size(); |
5901 const size_t expected_allocation_size = os::large_page_size(); |
5902 char* expected_location = result + os::large_page_size(); |
5902 char* expected_location = result + os::large_page_size(); |
5903 char* actual_location = os::reserve_memory_special(expected_allocation_size, os::large_page_size(), expected_location, false); |
5903 char* actual_location = os::reserve_memory_special(expected_allocation_size, os::large_page_size(), expected_location, false); |
5904 if (actual_location == NULL) { |
5904 if (actual_location == NULL) { |
5905 if (VerboseInternalVMTests) { |
5905 if (VerboseInternalVMTests) { |
5906 gclog_or_tty->print("Failed to allocate any memory at "PTR_FORMAT" size "SIZE_FORMAT". Skipping remainder of test.", |
5906 gclog_or_tty->print("Failed to allocate any memory at " PTR_FORMAT " size " SIZE_FORMAT ". Skipping remainder of test.", |
5907 expected_location, large_allocation_size); |
5907 expected_location, large_allocation_size); |
5908 } |
5908 } |
5909 } else { |
5909 } else { |
5910 // release memory |
5910 // release memory |
5911 os::release_memory_special(actual_location, expected_allocation_size); |
5911 os::release_memory_special(actual_location, expected_allocation_size); |
5912 // only now check, after releasing any memory to avoid any leaks. |
5912 // only now check, after releasing any memory to avoid any leaks. |
5913 assert(actual_location == expected_location, |
5913 assert(actual_location == expected_location, |
5914 err_msg("Failed to allocate memory at requested location "PTR_FORMAT" of size "SIZE_FORMAT", is "PTR_FORMAT" instead", |
5914 err_msg("Failed to allocate memory at requested location " PTR_FORMAT " of size " SIZE_FORMAT ", is " PTR_FORMAT " instead", |
5915 expected_location, expected_allocation_size, actual_location)); |
5915 expected_location, expected_allocation_size, actual_location)); |
5916 } |
5916 } |
5917 } |
5917 } |
5918 |
5918 |
5919 // restore globals |
5919 // restore globals |