< prev index next >

src/hotspot/share/gc/g1/heapRegionSet.cpp

Print this page




  73   _verify_in_progress = false;
  74 }
  75 
  76 void HeapRegionSetBase::print_on(outputStream* out, bool print_contents) {
  77   out->cr();
  78   out->print_cr("Set: %s (" PTR_FORMAT ")", name(), p2i(this));
  79   out->print_cr("  Region Type         : %s", _checker->get_description());
  80   out->print_cr("  Length              : %14u", length());
  81 }
  82 
  83 HeapRegionSetBase::HeapRegionSetBase(const char* name, HeapRegionSetChecker* checker)
  84   : _checker(checker), _length(0), _name(name), _verify_in_progress(false)
  85 {
  86 }
  87 
  88 void FreeRegionList::set_unrealistically_long_length(uint len) {
  89   guarantee(_unrealistically_long_length == 0, "should only be set once");
  90   _unrealistically_long_length = len;
  91 }
  92 






  93 void FreeRegionList::remove_all() {
  94   check_mt_safety();
  95   verify_optional();
  96 
  97   HeapRegion* curr = _head;
  98   while (curr != NULL) {
  99     verify_region(curr);
 100 
 101     HeapRegion* next = curr->next();
 102     curr->set_next(NULL);
 103     curr->set_prev(NULL);
 104     curr->set_containing_set(NULL);
 105 
 106     decrease_length(curr->node_index());
 107 
 108     curr = next;
 109   }
 110   clear();
 111 
 112   verify_optional();
 113 }
 114 
 115 void FreeRegionList::add_ordered(FreeRegionList* from_list) {
 116   check_mt_safety();
 117   from_list->check_mt_safety();
 118 
 119   verify_optional();
 120   from_list->verify_optional();
 121 
 122   if (from_list->is_empty()) {
 123     return;
 124   }
 125 
 126   if (_node_info != NULL && from_list->_node_info != NULL) {
 127     _node_info->add(from_list->_node_info);
 128   }
 129 
 130   #ifdef ASSERT
 131   FreeRegionListIterator iter(from_list);
 132   while (iter.more_available()) {
 133     HeapRegion* hr = iter.get_next();
 134     // In set_containing_set() we check that we either set the value
 135     // from NULL to non-NULL or vice versa to catch bugs. So, we have
 136     // to NULL it first before setting it to the value.
 137     hr->set_containing_set(NULL);
 138     hr->set_containing_set(this);
 139   }
 140   #endif // ASSERT









































 141 
 142   if (is_empty()) {
 143     assert_free_region_list(length() == 0 && _tail == NULL, "invariant");
 144     _head = from_list->_head;
 145     _tail = from_list->_tail;
 146   } else {
 147     HeapRegion* curr_to = _head;
 148     HeapRegion* curr_from = from_list->_head;
 149 
 150     while (curr_from != NULL) {
 151       while (curr_to != NULL && curr_to->hrm_index() < curr_from->hrm_index()) {
 152         curr_to = curr_to->next();
 153       }
 154 
 155       if (curr_to == NULL) {
 156         // The rest of the from list should be added as tail
 157         _tail->set_next(curr_from);
 158         curr_from->set_prev(_tail);
 159         curr_from = NULL;
 160       } else {
 161         HeapRegion* next_from = curr_from->next();
 162 
 163         curr_from->set_next(curr_to);
 164         curr_from->set_prev(curr_to->prev());
 165         if (curr_to->prev() == NULL) {
 166           _head = curr_from;
 167         } else {
 168           curr_to->prev()->set_next(curr_from);
 169         }
 170         curr_to->set_prev(curr_from);
 171 
 172         curr_from = next_from;
 173       }
 174     }
 175 
 176     if (_tail->hrm_index() < from_list->_tail->hrm_index()) {
 177       _tail = from_list->_tail;
 178     }
 179   }
 180 
 181   _length += from_list->length();
 182   from_list->clear();
 183 
 184   verify_optional();
 185   from_list->verify_optional();
 186 }
 187 
 188 void FreeRegionList::remove_starting_at(HeapRegion* first, uint num_regions) {
 189   check_mt_safety();
 190   assert_free_region_list(num_regions >= 1, "pre-condition");
 191   assert_free_region_list(!is_empty(), "pre-condition");
 192 
 193   verify_optional();
 194   DEBUG_ONLY(uint old_length = length();)
 195 
 196   HeapRegion* curr = first;
 197   uint count = 0;
 198   while (count < num_regions) {
 199     verify_region(curr);
 200     HeapRegion* next = curr->next();
 201     HeapRegion* prev = curr->prev();
 202 
 203     assert(count < num_regions,
 204            "[%s] should not come across more regions "
 205            "pending for removal than num_regions: %u",




  73   _verify_in_progress = false;
  74 }
  75 
  76 void HeapRegionSetBase::print_on(outputStream* out, bool print_contents) {
  77   out->cr();
  78   out->print_cr("Set: %s (" PTR_FORMAT ")", name(), p2i(this));
  79   out->print_cr("  Region Type         : %s", _checker->get_description());
  80   out->print_cr("  Length              : %14u", length());
  81 }
  82 
  83 HeapRegionSetBase::HeapRegionSetBase(const char* name, HeapRegionSetChecker* checker)
  84   : _checker(checker), _length(0), _name(name), _verify_in_progress(false)
  85 {
  86 }
  87 
  88 void FreeRegionList::set_unrealistically_long_length(uint len) {
  89   guarantee(_unrealistically_long_length == 0, "should only be set once");
  90   _unrealistically_long_length = len;
  91 }
  92 
  93 void FreeRegionList::abandon() {
  94   check_mt_safety();
  95   clear();
  96   verify_optional();
  97 }
  98 
  99 void FreeRegionList::remove_all() {
 100   check_mt_safety();
 101   verify_optional();
 102 
 103   HeapRegion* curr = _head;
 104   while (curr != NULL) {
 105     verify_region(curr);
 106 
 107     HeapRegion* next = curr->next();
 108     curr->set_next(NULL);
 109     curr->set_prev(NULL);
 110     curr->set_containing_set(NULL);
 111 
 112     decrease_length(curr->node_index());
 113 
 114     curr = next;
 115   }
 116   clear();
 117 
 118   verify_optional();
 119 }
 120 
 121 void FreeRegionList::add_list_common_start(FreeRegionList* from_list) {
 122   check_mt_safety();
 123   from_list->check_mt_safety();

 124   verify_optional();
 125   from_list->verify_optional();
 126 
 127   if (from_list->is_empty()) {
 128     return;
 129   }
 130 
 131   if (_node_info != NULL && from_list->_node_info != NULL) {
 132     _node_info->add(from_list->_node_info);
 133   }
 134 
 135   #ifdef ASSERT
 136   FreeRegionListIterator iter(from_list);
 137   while (iter.more_available()) {
 138     HeapRegion* hr = iter.get_next();
 139     // In set_containing_set() we check that we either set the value
 140     // from NULL to non-NULL or vice versa to catch bugs. So, we have
 141     // to NULL it first before setting it to the value.
 142     hr->set_containing_set(NULL);
 143     hr->set_containing_set(this);
 144   }
 145   #endif // ASSERT
 146 }
 147 
 148 void FreeRegionList::add_list_common_end(FreeRegionList* from_list) {
 149   _length += from_list->length();
 150   from_list->clear();
 151 
 152   verify_optional();
 153   from_list->verify_optional();
 154 }
 155 
 156 void FreeRegionList::append_ordered(FreeRegionList* from_list) {
 157   add_list_common_start(from_list);
 158 
 159   if (from_list->is_empty()) {
 160     return;
 161   }
 162 
 163   if (is_empty()) {
 164     // Make from_list the current list.
 165     assert_free_region_list(length() == 0 && _tail == NULL, "invariant");
 166     _head = from_list->_head;
 167     _tail = from_list->_tail;
 168   } else {
 169     // Add the from_list to the end of the current list.
 170     assert(_tail->hrm_index() < from_list->_head->hrm_index(), "Should be sorted %u < %u",
 171            _tail->hrm_index(), from_list->_head->hrm_index());
 172 
 173     _tail->set_next(from_list->_head);
 174     from_list->_head->set_prev(_tail);
 175     _tail = from_list->_tail;
 176   }
 177 
 178   add_list_common_end(from_list);
 179 }
 180 
 181 void FreeRegionList::add_ordered(FreeRegionList* from_list) {
 182   add_list_common_start(from_list);
 183 
 184   if (from_list->is_empty()) {
 185     return;
 186   }
 187 
 188   if (is_empty()) {
 189     assert_free_region_list(length() == 0 && _tail == NULL, "invariant");
 190     _head = from_list->_head;
 191     _tail = from_list->_tail;
 192   } else {
 193     HeapRegion* curr_to = _head;
 194     HeapRegion* curr_from = from_list->_head;
 195 
 196     while (curr_from != NULL) {
 197       while (curr_to != NULL && curr_to->hrm_index() < curr_from->hrm_index()) {
 198         curr_to = curr_to->next();
 199       }
 200 
 201       if (curr_to == NULL) {
 202         // The rest of the from list should be added as tail
 203         _tail->set_next(curr_from);
 204         curr_from->set_prev(_tail);
 205         curr_from = NULL;
 206       } else {
 207         HeapRegion* next_from = curr_from->next();
 208 
 209         curr_from->set_next(curr_to);
 210         curr_from->set_prev(curr_to->prev());
 211         if (curr_to->prev() == NULL) {
 212           _head = curr_from;
 213         } else {
 214           curr_to->prev()->set_next(curr_from);
 215         }
 216         curr_to->set_prev(curr_from);
 217 
 218         curr_from = next_from;
 219       }
 220     }
 221 
 222     if (_tail->hrm_index() < from_list->_tail->hrm_index()) {
 223       _tail = from_list->_tail;
 224     }
 225   }
 226 
 227   add_list_common_end(from_list);




 228 }
 229 
 230 void FreeRegionList::remove_starting_at(HeapRegion* first, uint num_regions) {
 231   check_mt_safety();
 232   assert_free_region_list(num_regions >= 1, "pre-condition");
 233   assert_free_region_list(!is_empty(), "pre-condition");
 234 
 235   verify_optional();
 236   DEBUG_ONLY(uint old_length = length();)
 237 
 238   HeapRegion* curr = first;
 239   uint count = 0;
 240   while (count < num_regions) {
 241     verify_region(curr);
 242     HeapRegion* next = curr->next();
 243     HeapRegion* prev = curr->prev();
 244 
 245     assert(count < num_regions,
 246            "[%s] should not come across more regions "
 247            "pending for removal than num_regions: %u",


< prev index next >