1.1 --- a/src/share/vm/gc_implementation/g1/heapRegionSet.inline.hpp Thu Mar 06 11:11:04 2014 +0100 1.2 +++ b/src/share/vm/gc_implementation/g1/heapRegionSet.inline.hpp Fri Mar 14 10:15:46 2014 +0100 1.3 @@ -27,87 +27,32 @@ 1.4 1.5 #include "gc_implementation/g1/heapRegionSet.hpp" 1.6 1.7 -//////////////////// HeapRegionSetBase //////////////////// 1.8 +inline void HeapRegionSetBase::add(HeapRegion* hr) { 1.9 + check_mt_safety(); 1.10 + assert(hr->containing_set() == NULL, hrs_ext_msg(this, "should not already have a containing set %u")); 1.11 + assert(hr->next() == NULL, hrs_ext_msg(this, "should not already be linked")); 1.12 1.13 -inline void HeapRegionSetBase::update_for_addition(HeapRegion* hr) { 1.14 - // Assumes the caller has already verified the region. 1.15 - 1.16 - _length += 1; 1.17 - _region_num += hr->region_num(); 1.18 - _total_used_bytes += hr->used(); 1.19 + _count.increment(1u, hr->capacity()); 1.20 + hr->set_containing_set(this); 1.21 + verify_region(hr); 1.22 } 1.23 1.24 -inline void HeapRegionSetBase::add_internal(HeapRegion* hr) { 1.25 - hrs_assert_region_ok(this, hr, NULL); 1.26 - assert(hr->next() == NULL, hrs_ext_msg(this, "should not already be linked")); 1.27 - 1.28 - update_for_addition(hr); 1.29 - hr->set_containing_set(this); 1.30 -} 1.31 - 1.32 -inline void HeapRegionSetBase::update_for_removal(HeapRegion* hr) { 1.33 - // Assumes the caller has already verified the region. 1.34 - assert(_length > 0, hrs_ext_msg(this, "pre-condition")); 1.35 - _length -= 1; 1.36 - 1.37 - uint region_num_diff = hr->region_num(); 1.38 - assert(region_num_diff <= _region_num, 1.39 - hrs_err_msg("[%s] region's region num: %u " 1.40 - "should be <= region num: %u", 1.41 - name(), region_num_diff, _region_num)); 1.42 - _region_num -= region_num_diff; 1.43 - 1.44 - size_t used_bytes = hr->used(); 1.45 - assert(used_bytes <= _total_used_bytes, 1.46 - hrs_err_msg("[%s] region's used bytes: "SIZE_FORMAT" " 1.47 - "should be <= used bytes: "SIZE_FORMAT, 1.48 - name(), used_bytes, _total_used_bytes)); 1.49 - _total_used_bytes -= used_bytes; 1.50 -} 1.51 - 1.52 -inline void HeapRegionSetBase::remove_internal(HeapRegion* hr) { 1.53 - hrs_assert_region_ok(this, hr, this); 1.54 +inline void HeapRegionSetBase::remove(HeapRegion* hr) { 1.55 + check_mt_safety(); 1.56 + verify_region(hr); 1.57 assert(hr->next() == NULL, hrs_ext_msg(this, "should already be unlinked")); 1.58 1.59 hr->set_containing_set(NULL); 1.60 - update_for_removal(hr); 1.61 + assert(_count.length() > 0, hrs_ext_msg(this, "pre-condition")); 1.62 + _count.decrement(1u, hr->capacity()); 1.63 } 1.64 1.65 -//////////////////// HeapRegionSet //////////////////// 1.66 - 1.67 -inline void HeapRegionSet::add(HeapRegion* hr) { 1.68 - hrs_assert_mt_safety_ok(this); 1.69 - // add_internal() will verify the region. 1.70 - add_internal(hr); 1.71 -} 1.72 - 1.73 -inline void HeapRegionSet::remove(HeapRegion* hr) { 1.74 - hrs_assert_mt_safety_ok(this); 1.75 - // remove_internal() will verify the region. 1.76 - remove_internal(hr); 1.77 -} 1.78 - 1.79 -inline void HeapRegionSet::remove_with_proxy(HeapRegion* hr, 1.80 - HeapRegionSet* proxy_set) { 1.81 - // No need to fo the MT safety check here given that this method 1.82 - // does not update the contents of the set but instead accumulates 1.83 - // the changes in proxy_set which is assumed to be thread-local. 1.84 - hrs_assert_sets_match(this, proxy_set); 1.85 - hrs_assert_region_ok(this, hr, this); 1.86 - 1.87 - hr->set_containing_set(NULL); 1.88 - proxy_set->update_for_addition(hr); 1.89 -} 1.90 - 1.91 -//////////////////// HeapRegionLinkedList //////////////////// 1.92 - 1.93 -inline void HeapRegionLinkedList::add_as_head(HeapRegion* hr) { 1.94 - hrs_assert_mt_safety_ok(this); 1.95 +inline void FreeRegionList::add_as_head(HeapRegion* hr) { 1.96 assert((length() == 0 && _head == NULL && _tail == NULL) || 1.97 (length() > 0 && _head != NULL && _tail != NULL), 1.98 hrs_ext_msg(this, "invariant")); 1.99 - // add_internal() will verify the region. 1.100 - add_internal(hr); 1.101 + // add() will verify the region and check mt safety. 1.102 + add(hr); 1.103 1.104 // Now link the region. 1.105 if (_head != NULL) { 1.106 @@ -118,13 +63,13 @@ 1.107 _head = hr; 1.108 } 1.109 1.110 -inline void HeapRegionLinkedList::add_as_tail(HeapRegion* hr) { 1.111 - hrs_assert_mt_safety_ok(this); 1.112 +inline void FreeRegionList::add_as_tail(HeapRegion* hr) { 1.113 + check_mt_safety(); 1.114 assert((length() == 0 && _head == NULL && _tail == NULL) || 1.115 (length() > 0 && _head != NULL && _tail != NULL), 1.116 hrs_ext_msg(this, "invariant")); 1.117 - // add_internal() will verify the region. 1.118 - add_internal(hr); 1.119 + // add() will verify the region and check mt safety 1.120 + add(hr); 1.121 1.122 // Now link the region. 1.123 if (_tail != NULL) { 1.124 @@ -135,8 +80,7 @@ 1.125 _tail = hr; 1.126 } 1.127 1.128 -inline HeapRegion* HeapRegionLinkedList::remove_head() { 1.129 - hrs_assert_mt_safety_ok(this); 1.130 +inline HeapRegion* FreeRegionList::remove_head() { 1.131 assert(!is_empty(), hrs_ext_msg(this, "the list should not be empty")); 1.132 assert(length() > 0 && _head != NULL && _tail != NULL, 1.133 hrs_ext_msg(this, "invariant")); 1.134 @@ -149,14 +93,13 @@ 1.135 } 1.136 hr->set_next(NULL); 1.137 1.138 - // remove_internal() will verify the region. 1.139 - remove_internal(hr); 1.140 + // remove() will verify the region and check mt safety 1.141 + remove(hr); 1.142 return hr; 1.143 } 1.144 1.145 -inline HeapRegion* HeapRegionLinkedList::remove_head_or_null() { 1.146 - hrs_assert_mt_safety_ok(this); 1.147 - 1.148 +inline HeapRegion* FreeRegionList::remove_head_or_null() { 1.149 + check_mt_safety(); 1.150 if (!is_empty()) { 1.151 return remove_head(); 1.152 } else {