1.1 --- a/src/share/vm/gc_implementation/g1/heapRegionSets.cpp Thu Mar 06 11:11:04 2014 +0100 1.2 +++ b/src/share/vm/gc_implementation/g1/heapRegionSets.cpp Fri Mar 14 10:15:46 2014 +0100 1.3 @@ -24,7 +24,7 @@ 1.4 1.5 #include "precompiled.hpp" 1.6 #include "gc_implementation/g1/heapRegionRemSet.hpp" 1.7 -#include "gc_implementation/g1/heapRegionSets.hpp" 1.8 +#include "gc_implementation/g1/heapRegionSet.hpp" 1.9 1.10 // Note on the check_mt_safety() methods below: 1.11 // 1.12 @@ -37,30 +37,34 @@ 1.13 // for the "master" heap region sets / lists, the check_mt_safety() 1.14 // method should include the VM thread / STW case. 1.15 1.16 -//////////////////// FreeRegionList //////////////////// 1.17 +void FreeRegionList::verify_list() { 1.18 + HeapRegion* curr = head(); 1.19 + HeapRegion* prev1 = NULL; 1.20 + HeapRegion* prev0 = NULL; 1.21 + uint count = 0; 1.22 + size_t capacity = 0; 1.23 + while (curr != NULL) { 1.24 + verify_region(curr); 1.25 1.26 -const char* FreeRegionList::verify_region_extra(HeapRegion* hr) { 1.27 - if (hr->is_young()) { 1.28 - return "the region should not be young"; 1.29 + count++; 1.30 + guarantee(count < _unrealistically_long_length, 1.31 + hrs_err_msg("[%s] the calculated length: %u seems very long, is there maybe a cycle? curr: "PTR_FORMAT" prev0: "PTR_FORMAT" " "prev1: "PTR_FORMAT" length: %u", name(), count, curr, prev0, prev1, length())); 1.32 + 1.33 + capacity += curr->capacity(); 1.34 + 1.35 + prev1 = prev0; 1.36 + prev0 = curr; 1.37 + curr = curr->next(); 1.38 } 1.39 - // The superclass will check that the region is empty and 1.40 - // not humongous. 1.41 - return HeapRegionLinkedList::verify_region_extra(hr); 1.42 + 1.43 + guarantee(tail() == prev0, err_msg("Expected %s to end with %u but it ended with %u.", name(), tail()->hrs_index(), prev0->hrs_index())); 1.44 + 1.45 + guarantee(length() == count, err_msg("%s count mismatch. Expected %u, actual %u.", name(), length(), count)); 1.46 + guarantee(total_capacity_bytes() == capacity, err_msg("%s capacity mismatch. Expected " SIZE_FORMAT ", actual " SIZE_FORMAT, 1.47 + name(), total_capacity_bytes(), capacity)); 1.48 } 1.49 1.50 -//////////////////// MasterFreeRegionList //////////////////// 1.51 - 1.52 -const char* MasterFreeRegionList::verify_region_extra(HeapRegion* hr) { 1.53 - // We should reset the RSet for parallel iteration before we add it 1.54 - // to the master free list so that it is ready when the region is 1.55 - // re-allocated. 1.56 - if (!hr->rem_set()->verify_ready_for_par_iteration()) { 1.57 - return "the region's RSet should be ready for parallel iteration"; 1.58 - } 1.59 - return FreeRegionList::verify_region_extra(hr); 1.60 -} 1.61 - 1.62 -bool MasterFreeRegionList::check_mt_safety() { 1.63 +void MasterFreeRegionListMtSafeChecker::check() { 1.64 // Master Free List MT safety protocol: 1.65 // (a) If we're at a safepoint, operations on the master free list 1.66 // should be invoked by either the VM thread (which will serialize 1.67 @@ -71,45 +75,21 @@ 1.68 1.69 if (SafepointSynchronize::is_at_safepoint()) { 1.70 guarantee(Thread::current()->is_VM_thread() || 1.71 - FreeList_lock->owned_by_self(), 1.72 - hrs_ext_msg(this, "master free list MT safety protocol " 1.73 - "at a safepoint")); 1.74 + FreeList_lock->owned_by_self(), "master free list MT safety protocol at a safepoint"); 1.75 } else { 1.76 - guarantee(Heap_lock->owned_by_self(), 1.77 - hrs_ext_msg(this, "master free list MT safety protocol " 1.78 - "outside a safepoint")); 1.79 + guarantee(Heap_lock->owned_by_self(), "master free list MT safety protocol outside a safepoint"); 1.80 } 1.81 - 1.82 - return FreeRegionList::check_mt_safety(); 1.83 } 1.84 1.85 -//////////////////// SecondaryFreeRegionList //////////////////// 1.86 - 1.87 -bool SecondaryFreeRegionList::check_mt_safety() { 1.88 +void SecondaryFreeRegionListMtSafeChecker::check() { 1.89 // Secondary Free List MT safety protocol: 1.90 // Operations on the secondary free list should always be invoked 1.91 // while holding the SecondaryFreeList_lock. 1.92 1.93 - guarantee(SecondaryFreeList_lock->owned_by_self(), 1.94 - hrs_ext_msg(this, "secondary free list MT safety protocol")); 1.95 - 1.96 - return FreeRegionList::check_mt_safety(); 1.97 + guarantee(SecondaryFreeList_lock->owned_by_self(), "secondary free list MT safety protocol"); 1.98 } 1.99 1.100 -//////////////////// OldRegionSet //////////////////// 1.101 - 1.102 -const char* OldRegionSet::verify_region_extra(HeapRegion* hr) { 1.103 - if (hr->is_young()) { 1.104 - return "the region should not be young"; 1.105 - } 1.106 - // The superclass will check that the region is not empty and not 1.107 - // humongous. 1.108 - return HeapRegionSet::verify_region_extra(hr); 1.109 -} 1.110 - 1.111 -//////////////////// MasterOldRegionSet //////////////////// 1.112 - 1.113 -bool MasterOldRegionSet::check_mt_safety() { 1.114 +void OldRegionSetMtSafeChecker::check() { 1.115 // Master Old Set MT safety protocol: 1.116 // (a) If we're at a safepoint, operations on the master old set 1.117 // should be invoked: 1.118 @@ -124,35 +104,16 @@ 1.119 // should be invoked while holding the Heap_lock. 1.120 1.121 if (SafepointSynchronize::is_at_safepoint()) { 1.122 - guarantee(Thread::current()->is_VM_thread() || 1.123 - _phase == HRSPhaseEvacuation && FreeList_lock->owned_by_self() || 1.124 - _phase == HRSPhaseCleanup && OldSets_lock->owned_by_self(), 1.125 - hrs_ext_msg(this, "master old set MT safety protocol " 1.126 - "at a safepoint")); 1.127 + guarantee(Thread::current()->is_VM_thread() 1.128 + || FreeList_lock->owned_by_self() || OldSets_lock->owned_by_self(), 1.129 + "master old set MT safety protocol at a safepoint"); 1.130 } else { 1.131 - guarantee(Heap_lock->owned_by_self(), 1.132 - hrs_ext_msg(this, "master old set MT safety protocol " 1.133 - "outside a safepoint")); 1.134 + guarantee(Heap_lock->owned_by_self(), "master old set MT safety protocol outside a safepoint"); 1.135 } 1.136 - 1.137 - return OldRegionSet::check_mt_safety(); 1.138 } 1.139 1.140 -//////////////////// HumongousRegionSet //////////////////// 1.141 - 1.142 -const char* HumongousRegionSet::verify_region_extra(HeapRegion* hr) { 1.143 - if (hr->is_young()) { 1.144 - return "the region should not be young"; 1.145 - } 1.146 - // The superclass will check that the region is not empty and 1.147 - // humongous. 1.148 - return HeapRegionSet::verify_region_extra(hr); 1.149 -} 1.150 - 1.151 -//////////////////// MasterHumongousRegionSet //////////////////// 1.152 - 1.153 -bool MasterHumongousRegionSet::check_mt_safety() { 1.154 - // Master Humongous Set MT safety protocol: 1.155 +void HumongousRegionSetMtSafeChecker::check() { 1.156 + // Humongous Set MT safety protocol: 1.157 // (a) If we're at a safepoint, operations on the master humongous 1.158 // set should be invoked by either the VM thread (which will 1.159 // serialize them) or by the GC workers while holding the 1.160 @@ -163,13 +124,9 @@ 1.161 if (SafepointSynchronize::is_at_safepoint()) { 1.162 guarantee(Thread::current()->is_VM_thread() || 1.163 OldSets_lock->owned_by_self(), 1.164 - hrs_ext_msg(this, "master humongous set MT safety protocol " 1.165 - "at a safepoint")); 1.166 + "master humongous set MT safety protocol at a safepoint"); 1.167 } else { 1.168 guarantee(Heap_lock->owned_by_self(), 1.169 - hrs_ext_msg(this, "master humongous set MT safety protocol " 1.170 - "outside a safepoint")); 1.171 + "master humongous set MT safety protocol outside a safepoint"); 1.172 } 1.173 - 1.174 - return HumongousRegionSet::check_mt_safety(); 1.175 }