< prev index next >

src/os/windows/vm/os_windows.cpp

Print this page




5867 // If -XX:+VerboseInternalVMTests is enabled, print some explanatory messages.
5868 void TestReserveMemorySpecial_test() {
5869   if (!UseLargePages) {
5870     if (VerboseInternalVMTests) {
5871       gclog_or_tty->print("Skipping test because large pages are disabled");
5872     }
5873     return;
5874   }
5875   // save current value of globals
5876   bool old_use_large_pages_individual_allocation = UseLargePagesIndividualAllocation;
5877   bool old_use_numa_interleaving = UseNUMAInterleaving;
5878 
5879   // set globals to make sure we hit the correct code path
5880   UseLargePagesIndividualAllocation = UseNUMAInterleaving = false;
5881 
5882   // do an allocation at an address selected by the OS to get a good one.
5883   const size_t large_allocation_size = os::large_page_size() * 4;
5884   char* result = os::reserve_memory_special(large_allocation_size, os::large_page_size(), NULL, false);
5885   if (result == NULL) {
5886     if (VerboseInternalVMTests) {
5887       gclog_or_tty->print("Failed to allocate control block with size "SIZE_FORMAT". Skipping remainder of test.",
5888                           large_allocation_size);
5889     }
5890   } else {
5891     os::release_memory_special(result, large_allocation_size);
5892 
5893     // allocate another page within the recently allocated memory area which seems to be a good location. At least
5894     // we managed to get it once.
5895     const size_t expected_allocation_size = os::large_page_size();
5896     char* expected_location = result + os::large_page_size();
5897     char* actual_location = os::reserve_memory_special(expected_allocation_size, os::large_page_size(), expected_location, false);
5898     if (actual_location == NULL) {
5899       if (VerboseInternalVMTests) {
5900         gclog_or_tty->print("Failed to allocate any memory at "PTR_FORMAT" size "SIZE_FORMAT". Skipping remainder of test.",
5901                             expected_location, large_allocation_size);
5902       }
5903     } else {
5904       // release memory
5905       os::release_memory_special(actual_location, expected_allocation_size);
5906       // only now check, after releasing any memory to avoid any leaks.
5907       assert(actual_location == expected_location,
5908              err_msg("Failed to allocate memory at requested location "PTR_FORMAT" of size "SIZE_FORMAT", is "PTR_FORMAT" instead",
5909              expected_location, expected_allocation_size, actual_location));
5910     }
5911   }
5912 
5913   // restore globals
5914   UseLargePagesIndividualAllocation = old_use_large_pages_individual_allocation;
5915   UseNUMAInterleaving = old_use_numa_interleaving;
5916 }
5917 #endif // PRODUCT


5867 // If -XX:+VerboseInternalVMTests is enabled, print some explanatory messages.
5868 void TestReserveMemorySpecial_test() {
5869   if (!UseLargePages) {
5870     if (VerboseInternalVMTests) {
5871       gclog_or_tty->print("Skipping test because large pages are disabled");
5872     }
5873     return;
5874   }
5875   // save current value of globals
5876   bool old_use_large_pages_individual_allocation = UseLargePagesIndividualAllocation;
5877   bool old_use_numa_interleaving = UseNUMAInterleaving;
5878 
5879   // set globals to make sure we hit the correct code path
5880   UseLargePagesIndividualAllocation = UseNUMAInterleaving = false;
5881 
5882   // do an allocation at an address selected by the OS to get a good one.
5883   const size_t large_allocation_size = os::large_page_size() * 4;
5884   char* result = os::reserve_memory_special(large_allocation_size, os::large_page_size(), NULL, false);
5885   if (result == NULL) {
5886     if (VerboseInternalVMTests) {
5887       gclog_or_tty->print("Failed to allocate control block with size " SIZE_FORMAT ". Skipping remainder of test.",
5888                           large_allocation_size);
5889     }
5890   } else {
5891     os::release_memory_special(result, large_allocation_size);
5892 
5893     // allocate another page within the recently allocated memory area which seems to be a good location. At least
5894     // we managed to get it once.
5895     const size_t expected_allocation_size = os::large_page_size();
5896     char* expected_location = result + os::large_page_size();
5897     char* actual_location = os::reserve_memory_special(expected_allocation_size, os::large_page_size(), expected_location, false);
5898     if (actual_location == NULL) {
5899       if (VerboseInternalVMTests) {
5900         gclog_or_tty->print("Failed to allocate any memory at " PTR_FORMAT " size " SIZE_FORMAT ". Skipping remainder of test.",
5901                             expected_location, large_allocation_size);
5902       }
5903     } else {
5904       // release memory
5905       os::release_memory_special(actual_location, expected_allocation_size);
5906       // only now check, after releasing any memory to avoid any leaks.
5907       assert(actual_location == expected_location,
5908              err_msg("Failed to allocate memory at requested location " PTR_FORMAT " of size " SIZE_FORMAT ", is " PTR_FORMAT " instead",
5909              expected_location, expected_allocation_size, actual_location));
5910     }
5911   }
5912 
5913   // restore globals
5914   UseLargePagesIndividualAllocation = old_use_large_pages_individual_allocation;
5915   UseNUMAInterleaving = old_use_numa_interleaving;
5916 }
5917 #endif // PRODUCT
< prev index next >