Wed, 11 Sep 2013 12:03:41 +0200
Merge
1.1 --- a/src/os/windows/vm/os_windows.cpp Wed Sep 11 08:57:02 2013 +0200 1.2 +++ b/src/os/windows/vm/os_windows.cpp Wed Sep 11 12:03:41 2013 +0200 1.3 @@ -3189,9 +3189,12 @@ 1.4 return p_buf; 1.5 1.6 } else { 1.7 + if (TracePageSizes && Verbose) { 1.8 + tty->print_cr("Reserving large pages in a single large chunk."); 1.9 + } 1.10 // normal policy just allocate it all at once 1.11 DWORD flag = MEM_RESERVE | MEM_COMMIT | MEM_LARGE_PAGES; 1.12 - char * res = (char *)VirtualAlloc(NULL, bytes, flag, prot); 1.13 + char * res = (char *)VirtualAlloc(addr, bytes, flag, prot); 1.14 if (res != NULL) { 1.15 address pc = CALLER_PC; 1.16 MemTracker::record_virtual_memory_reserve_and_commit((address)res, bytes, mtNone, pc); 1.17 @@ -5714,7 +5717,66 @@ 1.18 #endif 1.19 1.20 #ifndef PRODUCT 1.21 + 1.22 +// test the code path in reserve_memory_special() that tries to allocate memory in a single 1.23 +// contiguous memory block at a particular address. 1.24 +// The test first tries to find a good approximate address to allocate at by using the same 1.25 +// method to allocate some memory at any address. The test then tries to allocate memory in 1.26 +// the vicinity (not directly after it to avoid possible by-chance use of that location) 1.27 +// This is of course only some dodgy assumption, there is no guarantee that the vicinity of 1.28 +// the previously allocated memory is available for allocation. The only actual failure 1.29 +// that is reported is when the test tries to allocate at a particular location but gets a 1.30 +// different valid one. A NULL return value at this point is not considered an error but may 1.31 +// be legitimate. 1.32 +// If -XX:+VerboseInternalVMTests is enabled, print some explanatory messages. 1.33 void TestReserveMemorySpecial_test() { 1.34 - // No tests available for this platform 1.35 -} 1.36 -#endif 1.37 + if (!UseLargePages) { 1.38 + if (VerboseInternalVMTests) { 1.39 + gclog_or_tty->print("Skipping test because large pages are disabled"); 1.40 + } 1.41 + return; 1.42 + } 1.43 + // save current value of globals 1.44 + bool old_use_large_pages_individual_allocation = UseLargePagesIndividualAllocation; 1.45 + bool old_use_numa_interleaving = UseNUMAInterleaving; 1.46 + 1.47 + // set globals to make sure we hit the correct code path 1.48 + UseLargePagesIndividualAllocation = UseNUMAInterleaving = false; 1.49 + 1.50 + // do an allocation at an address selected by the OS to get a good one. 1.51 + const size_t large_allocation_size = os::large_page_size() * 4; 1.52 + char* result = os::reserve_memory_special(large_allocation_size, os::large_page_size(), NULL, false); 1.53 + if (result == NULL) { 1.54 + if (VerboseInternalVMTests) { 1.55 + gclog_or_tty->print("Failed to allocate control block with size "SIZE_FORMAT". Skipping remainder of test.", 1.56 + large_allocation_size); 1.57 + } 1.58 + } else { 1.59 + os::release_memory_special(result, large_allocation_size); 1.60 + 1.61 + // allocate another page within the recently allocated memory area which seems to be a good location. At least 1.62 + // we managed to get it once. 1.63 + const size_t expected_allocation_size = os::large_page_size(); 1.64 + char* expected_location = result + os::large_page_size(); 1.65 + char* actual_location = os::reserve_memory_special(expected_allocation_size, os::large_page_size(), expected_location, false); 1.66 + if (actual_location == NULL) { 1.67 + if (VerboseInternalVMTests) { 1.68 + gclog_or_tty->print("Failed to allocate any memory at "PTR_FORMAT" size "SIZE_FORMAT". Skipping remainder of test.", 1.69 + expected_location, large_allocation_size); 1.70 + } 1.71 + } else { 1.72 + // release memory 1.73 + os::release_memory_special(actual_location, expected_allocation_size); 1.74 + // only now check, after releasing any memory to avoid any leaks. 1.75 + assert(actual_location == expected_location, 1.76 + err_msg("Failed to allocate memory at requested location "PTR_FORMAT" of size "SIZE_FORMAT", is "PTR_FORMAT" instead", 1.77 + expected_location, expected_allocation_size, actual_location)); 1.78 + } 1.79 + } 1.80 + 1.81 + // restore globals 1.82 + UseLargePagesIndividualAllocation = old_use_large_pages_individual_allocation; 1.83 + UseNUMAInterleaving = old_use_numa_interleaving; 1.84 +} 1.85 +#endif // PRODUCT 1.86 +
2.1 --- a/src/share/vm/gc_implementation/g1/concurrentMark.cpp Wed Sep 11 08:57:02 2013 +0200 2.2 +++ b/src/share/vm/gc_implementation/g1/concurrentMark.cpp Wed Sep 11 12:03:41 2013 +0200 2.3 @@ -481,9 +481,8 @@ 2.4 2.5 ConcurrentMark::ConcurrentMark(G1CollectedHeap* g1h, ReservedSpace heap_rs) : 2.6 _g1h(g1h), 2.7 - _markBitMap1(MinObjAlignment - 1), 2.8 - _markBitMap2(MinObjAlignment - 1), 2.9 - 2.10 + _markBitMap1(log2_intptr(MinObjAlignment)), 2.11 + _markBitMap2(log2_intptr(MinObjAlignment)), 2.12 _parallel_marking_threads(0), 2.13 _max_parallel_marking_threads(0), 2.14 _sleep_factor(0.0),
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/test/gc/TestObjectAlignment.java Wed Sep 11 12:03:41 2013 +0200 3.3 @@ -0,0 +1,65 @@ 3.4 +/* 3.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.7 + * 3.8 + * This code is free software; you can redistribute it and/or modify it 3.9 + * under the terms of the GNU General Public License version 2 only, as 3.10 + * published by the Free Software Foundation. 3.11 + * 3.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 3.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 3.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 3.15 + * version 2 for more details (a copy is included in the LICENSE file that 3.16 + * accompanied this code). 3.17 + * 3.18 + * You should have received a copy of the GNU General Public License version 3.19 + * 2 along with this work; if not, write to the Free Software Foundation, 3.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 3.21 + * 3.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 3.23 + * or visit www.oracle.com if you need additional information or have any 3.24 + * questions. 3.25 + */ 3.26 + 3.27 +/** 3.28 + * @test TestObjectAlignment 3.29 + * @key gc 3.30 + * @bug 8021823 3.31 + * @summary G1: Concurrent marking crashes with -XX:ObjectAlignmentInBytes>=32 in 64bit VMs 3.32 + * @library /testlibrary 3.33 + * @run main/othervm TestObjectAlignment -Xmx20M -XX:+ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=8 3.34 + * @run main/othervm TestObjectAlignment -Xmx20M -XX:+ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=16 3.35 + * @run main/othervm TestObjectAlignment -Xmx20M -XX:+ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=32 3.36 + * @run main/othervm TestObjectAlignment -Xmx20M -XX:+ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=64 3.37 + * @run main/othervm TestObjectAlignment -Xmx20M -XX:+ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=128 3.38 + * @run main/othervm TestObjectAlignment -Xmx20M -XX:+ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=256 3.39 + * @run main/othervm TestObjectAlignment -Xmx20M -XX:-ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=8 3.40 + * @run main/othervm TestObjectAlignment -Xmx20M -XX:-ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=16 3.41 + * @run main/othervm TestObjectAlignment -Xmx20M -XX:-ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=32 3.42 + * @run main/othervm TestObjectAlignment -Xmx20M -XX:-ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=64 3.43 + * @run main/othervm TestObjectAlignment -Xmx20M -XX:-ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=128 3.44 + * @run main/othervm TestObjectAlignment -Xmx20M -XX:-ExplicitGCInvokesConcurrent -XX:+IgnoreUnrecognizedVMOptions -XX:ObjectAlignmentInBytes=256 3.45 + */ 3.46 + 3.47 +import com.oracle.java.testlibrary.ProcessTools; 3.48 +import com.oracle.java.testlibrary.OutputAnalyzer; 3.49 + 3.50 +public class TestObjectAlignment { 3.51 + 3.52 + public static byte[] garbage; 3.53 + 3.54 + private static boolean runsOn32bit() { 3.55 + return System.getProperty("sun.arch.data.model").equals("32"); 3.56 + } 3.57 + 3.58 + public static void main(String[] args) throws Exception { 3.59 + if (runsOn32bit()) { 3.60 + // 32 bit VMs do not allow setting ObjectAlignmentInBytes, so there is nothing to test. We still get called. 3.61 + return; 3.62 + } 3.63 + for (int i = 0; i < 10; i++) { 3.64 + garbage = new byte[1000]; 3.65 + System.gc(); 3.66 + } 3.67 + } 3.68 +}