src/hotspot/os/windows/os_windows.cpp
changeset 52396 e292e94b448a
parent 52302 912b79d983d9
child 52460 f1bb77833b59
equal deleted inserted replaced
52395:5ca10e4e052c 52396:e292e94b448a
  5555 // This is of course only some dodgy assumption, there is no guarantee that the vicinity of
  5555 // This is of course only some dodgy assumption, there is no guarantee that the vicinity of
  5556 // the previously allocated memory is available for allocation. The only actual failure
  5556 // the previously allocated memory is available for allocation. The only actual failure
  5557 // that is reported is when the test tries to allocate at a particular location but gets a
  5557 // that is reported is when the test tries to allocate at a particular location but gets a
  5558 // different valid one. A NULL return value at this point is not considered an error but may
  5558 // different valid one. A NULL return value at this point is not considered an error but may
  5559 // be legitimate.
  5559 // be legitimate.
  5560 // If -XX:+VerboseInternalVMTests is enabled, print some explanatory messages.
       
  5561 void TestReserveMemorySpecial_test() {
  5560 void TestReserveMemorySpecial_test() {
  5562   if (!UseLargePages) {
  5561   if (!UseLargePages) {
  5563     if (VerboseInternalVMTests) {
       
  5564       tty->print("Skipping test because large pages are disabled");
       
  5565     }
       
  5566     return;
  5562     return;
  5567   }
  5563   }
  5568   // save current value of globals
  5564   // save current value of globals
  5569   bool old_use_large_pages_individual_allocation = UseLargePagesIndividualAllocation;
  5565   bool old_use_large_pages_individual_allocation = UseLargePagesIndividualAllocation;
  5570   bool old_use_numa_interleaving = UseNUMAInterleaving;
  5566   bool old_use_numa_interleaving = UseNUMAInterleaving;
  5574 
  5570 
  5575   // do an allocation at an address selected by the OS to get a good one.
  5571   // do an allocation at an address selected by the OS to get a good one.
  5576   const size_t large_allocation_size = os::large_page_size() * 4;
  5572   const size_t large_allocation_size = os::large_page_size() * 4;
  5577   char* result = os::reserve_memory_special(large_allocation_size, os::large_page_size(), NULL, false);
  5573   char* result = os::reserve_memory_special(large_allocation_size, os::large_page_size(), NULL, false);
  5578   if (result == NULL) {
  5574   if (result == NULL) {
  5579     if (VerboseInternalVMTests) {
       
  5580       tty->print("Failed to allocate control block with size " SIZE_FORMAT ". Skipping remainder of test.",
       
  5581                           large_allocation_size);
       
  5582     }
       
  5583   } else {
  5575   } else {
  5584     os::release_memory_special(result, large_allocation_size);
  5576     os::release_memory_special(result, large_allocation_size);
  5585 
  5577 
  5586     // allocate another page within the recently allocated memory area which seems to be a good location. At least
  5578     // allocate another page within the recently allocated memory area which seems to be a good location. At least
  5587     // we managed to get it once.
  5579     // we managed to get it once.
  5588     const size_t expected_allocation_size = os::large_page_size();
  5580     const size_t expected_allocation_size = os::large_page_size();
  5589     char* expected_location = result + os::large_page_size();
  5581     char* expected_location = result + os::large_page_size();
  5590     char* actual_location = os::reserve_memory_special(expected_allocation_size, os::large_page_size(), expected_location, false);
  5582     char* actual_location = os::reserve_memory_special(expected_allocation_size, os::large_page_size(), expected_location, false);
  5591     if (actual_location == NULL) {
  5583     if (actual_location == NULL) {
  5592       if (VerboseInternalVMTests) {
       
  5593         tty->print("Failed to allocate any memory at " PTR_FORMAT " size " SIZE_FORMAT ". Skipping remainder of test.",
       
  5594                             expected_location, large_allocation_size);
       
  5595       }
       
  5596     } else {
  5584     } else {
  5597       // release memory
  5585       // release memory
  5598       os::release_memory_special(actual_location, expected_allocation_size);
  5586       os::release_memory_special(actual_location, expected_allocation_size);
  5599       // only now check, after releasing any memory to avoid any leaks.
  5587       // only now check, after releasing any memory to avoid any leaks.
  5600       assert(actual_location == expected_location,
  5588       assert(actual_location == expected_location,