< prev index next >

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

Print this page
rev 47400 : [mq]: cmpxchg_ptr


 276   return (e != NULL && e->contains_card(card_index));
 277 }
 278 
 279 size_t RSHashTable::mem_size() const {
 280   return sizeof(RSHashTable) +
 281     _num_entries * (SparsePRTEntry::size() + sizeof(int));
 282 }
 283 
 284 // ----------------------------------------------------------------------
 285 
 286 SparsePRT* volatile SparsePRT::_head_expanded_list = NULL;
 287 
 288 void SparsePRT::add_to_expanded_list(SparsePRT* sprt) {
 289   // We could expand multiple times in a pause -- only put on list once.
 290   if (sprt->expanded()) return;
 291   sprt->set_expanded(true);
 292   SparsePRT* hd = _head_expanded_list;
 293   while (true) {
 294     sprt->_next_expanded = hd;
 295     SparsePRT* res =
 296       (SparsePRT*)
 297       Atomic::cmpxchg_ptr(sprt, &_head_expanded_list, hd);
 298     if (res == hd) return;
 299     else hd = res;
 300   }
 301 }
 302 
 303 
 304 SparsePRT* SparsePRT::get_from_expanded_list() {
 305   SparsePRT* hd = _head_expanded_list;
 306   while (hd != NULL) {
 307     SparsePRT* next = hd->next_expanded();
 308     SparsePRT* res =
 309       (SparsePRT*)
 310       Atomic::cmpxchg_ptr(next, &_head_expanded_list, hd);
 311     if (res == hd) {
 312       hd->set_next_expanded(NULL);
 313       return hd;
 314     } else {
 315       hd = res;
 316     }
 317   }
 318   return NULL;
 319 }
 320 
 321 void SparsePRT::reset_for_cleanup_tasks() {
 322   _head_expanded_list = NULL;
 323 }
 324 
 325 void SparsePRT::do_cleanup_work(SparsePRTCleanupTask* sprt_cleanup_task) {
 326   if (should_be_on_expanded_list()) {
 327     sprt_cleanup_task->add(this);
 328   }
 329 }
 330 




 276   return (e != NULL && e->contains_card(card_index));
 277 }
 278 
 279 size_t RSHashTable::mem_size() const {
 280   return sizeof(RSHashTable) +
 281     _num_entries * (SparsePRTEntry::size() + sizeof(int));
 282 }
 283 
 284 // ----------------------------------------------------------------------
 285 
 286 SparsePRT* volatile SparsePRT::_head_expanded_list = NULL;
 287 
 288 void SparsePRT::add_to_expanded_list(SparsePRT* sprt) {
 289   // We could expand multiple times in a pause -- only put on list once.
 290   if (sprt->expanded()) return;
 291   sprt->set_expanded(true);
 292   SparsePRT* hd = _head_expanded_list;
 293   while (true) {
 294     sprt->_next_expanded = hd;
 295     SparsePRT* res =
 296       Atomic::cmpxchg(sprt, &_head_expanded_list, hd);

 297     if (res == hd) return;
 298     else hd = res;
 299   }
 300 }
 301 
 302 
 303 SparsePRT* SparsePRT::get_from_expanded_list() {
 304   SparsePRT* hd = _head_expanded_list;
 305   while (hd != NULL) {
 306     SparsePRT* next = hd->next_expanded();
 307     SparsePRT* res =
 308       Atomic::cmpxchg(next, &_head_expanded_list, hd);

 309     if (res == hd) {
 310       hd->set_next_expanded(NULL);
 311       return hd;
 312     } else {
 313       hd = res;
 314     }
 315   }
 316   return NULL;
 317 }
 318 
 319 void SparsePRT::reset_for_cleanup_tasks() {
 320   _head_expanded_list = NULL;
 321 }
 322 
 323 void SparsePRT::do_cleanup_work(SparsePRTCleanupTask* sprt_cleanup_task) {
 324   if (should_be_on_expanded_list()) {
 325     sprt_cleanup_task->add(this);
 326   }
 327 }
 328 


< prev index next >