< prev index next >

src/hotspot/os/windows/os_windows.cpp

Print this page
rev 52333 : imported patch 8213058


5540       strncat(agent_entry_name, lib_name, name_len);
5541     }
5542   } else {
5543     strcpy(agent_entry_name, sym_name);
5544   }
5545   return agent_entry_name;
5546 }
5547 
5548 #ifndef PRODUCT
5549 
5550 // test the code path in reserve_memory_special() that tries to allocate memory in a single
5551 // contiguous memory block at a particular address.
5552 // The test first tries to find a good approximate address to allocate at by using the same
5553 // method to allocate some memory at any address. The test then tries to allocate memory in
5554 // the vicinity (not directly after it to avoid possible by-chance use of that location)
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
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
5559 // be legitimate.
5560 // If -XX:+VerboseInternalVMTests is enabled, print some explanatory messages.
5561 void TestReserveMemorySpecial_test() {
5562   if (!UseLargePages) {
5563     if (VerboseInternalVMTests) {
5564       tty->print("Skipping test because large pages are disabled");
5565     }
5566     return;
5567   }
5568   // save current value of globals
5569   bool old_use_large_pages_individual_allocation = UseLargePagesIndividualAllocation;
5570   bool old_use_numa_interleaving = UseNUMAInterleaving;
5571 
5572   // set globals to make sure we hit the correct code path
5573   UseLargePagesIndividualAllocation = UseNUMAInterleaving = false;
5574 
5575   // 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;
5577   char* result = os::reserve_memory_special(large_allocation_size, os::large_page_size(), NULL, false);
5578   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 {
5584     os::release_memory_special(result, large_allocation_size);
5585 
5586     // 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.
5588     const size_t expected_allocation_size = os::large_page_size();
5589     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);
5591     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 {
5597       // release memory
5598       os::release_memory_special(actual_location, expected_allocation_size);
5599       // only now check, after releasing any memory to avoid any leaks.
5600       assert(actual_location == expected_location,
5601              "Failed to allocate memory at requested location " PTR_FORMAT " of size " SIZE_FORMAT ", is " PTR_FORMAT " instead",
5602              expected_location, expected_allocation_size, actual_location);
5603     }
5604   }
5605 
5606   // restore globals
5607   UseLargePagesIndividualAllocation = old_use_large_pages_individual_allocation;
5608   UseNUMAInterleaving = old_use_numa_interleaving;
5609 }
5610 #endif // PRODUCT
5611 
5612 /*
5613   All the defined signal names for Windows.
5614 
5615   NOTE that not all of these names are accepted by FindSignal!




5540       strncat(agent_entry_name, lib_name, name_len);
5541     }
5542   } else {
5543     strcpy(agent_entry_name, sym_name);
5544   }
5545   return agent_entry_name;
5546 }
5547 
5548 #ifndef PRODUCT
5549 
5550 // test the code path in reserve_memory_special() that tries to allocate memory in a single
5551 // contiguous memory block at a particular address.
5552 // The test first tries to find a good approximate address to allocate at by using the same
5553 // method to allocate some memory at any address. The test then tries to allocate memory in
5554 // the vicinity (not directly after it to avoid possible by-chance use of that location)
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
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
5559 // be legitimate.

5560 void TestReserveMemorySpecial_test() {
5561   if (!UseLargePages) {



5562     return;
5563   }
5564   // save current value of globals
5565   bool old_use_large_pages_individual_allocation = UseLargePagesIndividualAllocation;
5566   bool old_use_numa_interleaving = UseNUMAInterleaving;
5567 
5568   // set globals to make sure we hit the correct code path
5569   UseLargePagesIndividualAllocation = UseNUMAInterleaving = false;
5570 
5571   // do an allocation at an address selected by the OS to get a good one.
5572   const size_t large_allocation_size = os::large_page_size() * 4;
5573   char* result = os::reserve_memory_special(large_allocation_size, os::large_page_size(), NULL, false);
5574   if (result == NULL) {




5575   } else {
5576     os::release_memory_special(result, large_allocation_size);
5577 
5578     // allocate another page within the recently allocated memory area which seems to be a good location. At least
5579     // we managed to get it once.
5580     const size_t expected_allocation_size = os::large_page_size();
5581     char* expected_location = result + os::large_page_size();
5582     char* actual_location = os::reserve_memory_special(expected_allocation_size, os::large_page_size(), expected_location, false);
5583     if (actual_location == NULL) {




5584     } else {
5585       // release memory
5586       os::release_memory_special(actual_location, expected_allocation_size);
5587       // only now check, after releasing any memory to avoid any leaks.
5588       assert(actual_location == expected_location,
5589              "Failed to allocate memory at requested location " PTR_FORMAT " of size " SIZE_FORMAT ", is " PTR_FORMAT " instead",
5590              expected_location, expected_allocation_size, actual_location);
5591     }
5592   }
5593 
5594   // restore globals
5595   UseLargePagesIndividualAllocation = old_use_large_pages_individual_allocation;
5596   UseNUMAInterleaving = old_use_numa_interleaving;
5597 }
5598 #endif // PRODUCT
5599 
5600 /*
5601   All the defined signal names for Windows.
5602 
5603   NOTE that not all of these names are accepted by FindSignal!


< prev index next >