< prev index next >

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

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


 466     prev_end = hr->end();
 467   }
 468   for (uint i = _allocated_heapregions_length; i < max_length(); i++) {
 469     guarantee(_regions.get_by_index(i) == NULL, "invariant i: %u", i);
 470   }
 471 
 472   guarantee(num_committed == _num_committed, "Found %u committed regions, but should be %u", num_committed, _num_committed);
 473   _free_list.verify();
 474 }
 475 
 476 #ifndef PRODUCT
 477 void HeapRegionManager::verify_optional() {
 478   verify();
 479 }
 480 #endif // PRODUCT
 481 
 482 HeapRegionClaimer::HeapRegionClaimer(uint n_workers) :
 483     _n_workers(n_workers), _n_regions(G1CollectedHeap::heap()->_hrm._allocated_heapregions_length), _claims(NULL) {
 484   assert(n_workers > 0, "Need at least one worker.");
 485   _claims = NEW_C_HEAP_ARRAY(uint, _n_regions, mtGC);
 486   memset(_claims, Unclaimed, sizeof(*_claims) * _n_regions);
 487 }
 488 
 489 HeapRegionClaimer::~HeapRegionClaimer() {
 490   if (_claims != NULL) {
 491     FREE_C_HEAP_ARRAY(uint, _claims);
 492   }
 493 }
 494 
 495 uint HeapRegionClaimer::start_region_for_worker(uint worker_id) const {
 496   assert(worker_id < _n_workers, "Invalid worker_id.");
 497   return _n_regions * worker_id / _n_workers;
 498 }
 499 
 500 bool HeapRegionClaimer::is_region_claimed(uint region_index) const {
 501   assert(region_index < _n_regions, "Invalid index.");
 502   return _claims[region_index] == Claimed;
 503 }
 504 
 505 bool HeapRegionClaimer::claim_region(uint region_index) {
 506   assert(region_index < _n_regions, "Invalid index.");


 466     prev_end = hr->end();
 467   }
 468   for (uint i = _allocated_heapregions_length; i < max_length(); i++) {
 469     guarantee(_regions.get_by_index(i) == NULL, "invariant i: %u", i);
 470   }
 471 
 472   guarantee(num_committed == _num_committed, "Found %u committed regions, but should be %u", num_committed, _num_committed);
 473   _free_list.verify();
 474 }
 475 
 476 #ifndef PRODUCT
 477 void HeapRegionManager::verify_optional() {
 478   verify();
 479 }
 480 #endif // PRODUCT
 481 
 482 HeapRegionClaimer::HeapRegionClaimer(uint n_workers) :
 483     _n_workers(n_workers), _n_regions(G1CollectedHeap::heap()->_hrm._allocated_heapregions_length), _claims(NULL) {
 484   assert(n_workers > 0, "Need at least one worker.");
 485   _claims = NEW_C_HEAP_ARRAY(uint, _n_regions, mtGC);
 486   memset((uint*)_claims, Unclaimed, sizeof(*_claims) * _n_regions);
 487 }
 488 
 489 HeapRegionClaimer::~HeapRegionClaimer() {
 490   if (_claims != NULL) {
 491     FREE_C_HEAP_ARRAY(uint, _claims);
 492   }
 493 }
 494 
 495 uint HeapRegionClaimer::start_region_for_worker(uint worker_id) const {
 496   assert(worker_id < _n_workers, "Invalid worker_id.");
 497   return _n_regions * worker_id / _n_workers;
 498 }
 499 
 500 bool HeapRegionClaimer::is_region_claimed(uint region_index) const {
 501   assert(region_index < _n_regions, "Invalid index.");
 502   return _claims[region_index] == Claimed;
 503 }
 504 
 505 bool HeapRegionClaimer::claim_region(uint region_index) {
 506   assert(region_index < _n_regions, "Invalid index.");
< prev index next >