Mercurial > hg > truffle
comparison src/os/windows/vm/os_windows.cpp @ 17474:6fa574bfd32a
Merge
author | chegar |
---|---|
date | Thu, 03 Oct 2013 19:13:12 +0100 |
parents | 179cd89fb279 |
children | cefad50507d8 2cfad8cc3bab 5656140324ed 0e6af9b390af |
comparison
equal
deleted
inserted
replaced
17473:9b4ce069642e | 17474:6fa574bfd32a |
---|---|
3187 } | 3187 } |
3188 | 3188 |
3189 return p_buf; | 3189 return p_buf; |
3190 | 3190 |
3191 } else { | 3191 } else { |
3192 if (TracePageSizes && Verbose) { | |
3193 tty->print_cr("Reserving large pages in a single large chunk."); | |
3194 } | |
3192 // normal policy just allocate it all at once | 3195 // normal policy just allocate it all at once |
3193 DWORD flag = MEM_RESERVE | MEM_COMMIT | MEM_LARGE_PAGES; | 3196 DWORD flag = MEM_RESERVE | MEM_COMMIT | MEM_LARGE_PAGES; |
3194 char * res = (char *)VirtualAlloc(NULL, bytes, flag, prot); | 3197 char * res = (char *)VirtualAlloc(addr, bytes, flag, prot); |
3195 if (res != NULL) { | 3198 if (res != NULL) { |
3196 address pc = CALLER_PC; | 3199 address pc = CALLER_PC; |
3197 MemTracker::record_virtual_memory_reserve_and_commit((address)res, bytes, mtNone, pc); | 3200 MemTracker::record_virtual_memory_reserve_and_commit((address)res, bytes, mtNone, pc); |
3198 } | 3201 } |
3199 | 3202 |
3914 #ifndef PRODUCT | 3917 #ifndef PRODUCT |
3915 if(Verbose && PrintMiscellaneous) | 3918 if(Verbose && PrintMiscellaneous) |
3916 tty->print("[Memory Serialize Page address: " INTPTR_FORMAT "]\n", (intptr_t)mem_serialize_page); | 3919 tty->print("[Memory Serialize Page address: " INTPTR_FORMAT "]\n", (intptr_t)mem_serialize_page); |
3917 #endif | 3920 #endif |
3918 } | 3921 } |
3919 | |
3920 os::large_page_init(); | |
3921 | 3922 |
3922 // Setup Windows Exceptions | 3923 // Setup Windows Exceptions |
3923 | 3924 |
3924 // for debugging float code generation bugs | 3925 // for debugging float code generation bugs |
3925 if (ForceFloatExceptions) { | 3926 if (ForceFloatExceptions) { |
5427 if (is_absolute_path) { | 5428 if (is_absolute_path) { |
5428 // Need to strip path, prefix and suffix | 5429 // Need to strip path, prefix and suffix |
5429 if ((start = strrchr(lib_name, *os::file_separator())) != NULL) { | 5430 if ((start = strrchr(lib_name, *os::file_separator())) != NULL) { |
5430 lib_name = ++start; | 5431 lib_name = ++start; |
5431 } else { | 5432 } else { |
5432 // Need to check for C: | 5433 // Need to check for drive prefix |
5433 if ((start = strchr(lib_name, ':')) != NULL) { | 5434 if ((start = strchr(lib_name, ':')) != NULL) { |
5434 lib_name = ++start; | 5435 lib_name = ++start; |
5435 } | 5436 } |
5436 } | 5437 } |
5437 if (len <= (prefix_len + suffix_len)) { | 5438 if (len <= (prefix_len + suffix_len)) { |
5712 } | 5713 } |
5713 | 5714 |
5714 #endif | 5715 #endif |
5715 | 5716 |
5716 #ifndef PRODUCT | 5717 #ifndef PRODUCT |
5718 | |
5719 // test the code path in reserve_memory_special() that tries to allocate memory in a single | |
5720 // contiguous memory block at a particular address. | |
5721 // The test first tries to find a good approximate address to allocate at by using the same | |
5722 // method to allocate some memory at any address. The test then tries to allocate memory in | |
5723 // the vicinity (not directly after it to avoid possible by-chance use of that location) | |
5724 // This is of course only some dodgy assumption, there is no guarantee that the vicinity of | |
5725 // the previously allocated memory is available for allocation. The only actual failure | |
5726 // that is reported is when the test tries to allocate at a particular location but gets a | |
5727 // different valid one. A NULL return value at this point is not considered an error but may | |
5728 // be legitimate. | |
5729 // If -XX:+VerboseInternalVMTests is enabled, print some explanatory messages. | |
5717 void TestReserveMemorySpecial_test() { | 5730 void TestReserveMemorySpecial_test() { |
5718 // No tests available for this platform | 5731 if (!UseLargePages) { |
5719 } | 5732 if (VerboseInternalVMTests) { |
5720 #endif | 5733 gclog_or_tty->print("Skipping test because large pages are disabled"); |
5734 } | |
5735 return; | |
5736 } | |
5737 // save current value of globals | |
5738 bool old_use_large_pages_individual_allocation = UseLargePagesIndividualAllocation; | |
5739 bool old_use_numa_interleaving = UseNUMAInterleaving; | |
5740 | |
5741 // set globals to make sure we hit the correct code path | |
5742 UseLargePagesIndividualAllocation = UseNUMAInterleaving = false; | |
5743 | |
5744 // do an allocation at an address selected by the OS to get a good one. | |
5745 const size_t large_allocation_size = os::large_page_size() * 4; | |
5746 char* result = os::reserve_memory_special(large_allocation_size, os::large_page_size(), NULL, false); | |
5747 if (result == NULL) { | |
5748 if (VerboseInternalVMTests) { | |
5749 gclog_or_tty->print("Failed to allocate control block with size "SIZE_FORMAT". Skipping remainder of test.", | |
5750 large_allocation_size); | |
5751 } | |
5752 } else { | |
5753 os::release_memory_special(result, large_allocation_size); | |
5754 | |
5755 // allocate another page within the recently allocated memory area which seems to be a good location. At least | |
5756 // we managed to get it once. | |
5757 const size_t expected_allocation_size = os::large_page_size(); | |
5758 char* expected_location = result + os::large_page_size(); | |
5759 char* actual_location = os::reserve_memory_special(expected_allocation_size, os::large_page_size(), expected_location, false); | |
5760 if (actual_location == NULL) { | |
5761 if (VerboseInternalVMTests) { | |
5762 gclog_or_tty->print("Failed to allocate any memory at "PTR_FORMAT" size "SIZE_FORMAT". Skipping remainder of test.", | |
5763 expected_location, large_allocation_size); | |
5764 } | |
5765 } else { | |
5766 // release memory | |
5767 os::release_memory_special(actual_location, expected_allocation_size); | |
5768 // only now check, after releasing any memory to avoid any leaks. | |
5769 assert(actual_location == expected_location, | |
5770 err_msg("Failed to allocate memory at requested location "PTR_FORMAT" of size "SIZE_FORMAT", is "PTR_FORMAT" instead", | |
5771 expected_location, expected_allocation_size, actual_location)); | |
5772 } | |
5773 } | |
5774 | |
5775 // restore globals | |
5776 UseLargePagesIndividualAllocation = old_use_large_pages_individual_allocation; | |
5777 UseNUMAInterleaving = old_use_numa_interleaving; | |
5778 } | |
5779 #endif // PRODUCT | |
5780 |