< prev index next >

src/share/vm/gc/g1/sparsePRT.cpp

Print this page
rev 10742 : Make fields used in lock-free algorithms volatile


 263     }
 264     // Otherwise, try next entry.
 265     _tbl_ind++;
 266   }
 267   // Otherwise, there were no entry.
 268   return false;
 269 }
 270 
 271 bool RSHashTable::contains_card(RegionIdx_t region_index, CardIdx_t card_index) const {
 272   SparsePRTEntry* e = get_entry(region_index);
 273   return (e != NULL && e->contains_card(card_index));
 274 }
 275 
 276 size_t RSHashTable::mem_size() const {
 277   return sizeof(RSHashTable) +
 278     capacity() * (SparsePRTEntry::size() + sizeof(int));
 279 }
 280 
 281 // ----------------------------------------------------------------------
 282 
 283 SparsePRT* SparsePRT::_head_expanded_list = NULL;
 284 
 285 void SparsePRT::add_to_expanded_list(SparsePRT* sprt) {
 286   // We could expand multiple times in a pause -- only put on list once.
 287   if (sprt->expanded()) return;
 288   sprt->set_expanded(true);
 289   SparsePRT* hd = _head_expanded_list;
 290   while (true) {
 291     sprt->_next_expanded = hd;
 292     SparsePRT* res =
 293       (SparsePRT*)
 294       Atomic::cmpxchg_ptr(sprt, &_head_expanded_list, hd);
 295     if (res == hd) return;
 296     else hd = res;
 297   }
 298 }
 299 
 300 
 301 SparsePRT* SparsePRT::get_from_expanded_list() {
 302   SparsePRT* hd = _head_expanded_list;
 303   while (hd != NULL) {




 263     }
 264     // Otherwise, try next entry.
 265     _tbl_ind++;
 266   }
 267   // Otherwise, there were no entry.
 268   return false;
 269 }
 270 
 271 bool RSHashTable::contains_card(RegionIdx_t region_index, CardIdx_t card_index) const {
 272   SparsePRTEntry* e = get_entry(region_index);
 273   return (e != NULL && e->contains_card(card_index));
 274 }
 275 
 276 size_t RSHashTable::mem_size() const {
 277   return sizeof(RSHashTable) +
 278     capacity() * (SparsePRTEntry::size() + sizeof(int));
 279 }
 280 
 281 // ----------------------------------------------------------------------
 282 
 283 SparsePRT* volatile SparsePRT::_head_expanded_list = NULL;
 284 
 285 void SparsePRT::add_to_expanded_list(SparsePRT* sprt) {
 286   // We could expand multiple times in a pause -- only put on list once.
 287   if (sprt->expanded()) return;
 288   sprt->set_expanded(true);
 289   SparsePRT* hd = _head_expanded_list;
 290   while (true) {
 291     sprt->_next_expanded = hd;
 292     SparsePRT* res =
 293       (SparsePRT*)
 294       Atomic::cmpxchg_ptr(sprt, &_head_expanded_list, hd);
 295     if (res == hd) return;
 296     else hd = res;
 297   }
 298 }
 299 
 300 
 301 SparsePRT* SparsePRT::get_from_expanded_list() {
 302   SparsePRT* hd = _head_expanded_list;
 303   while (hd != NULL) {


< prev index next >