< prev index next >

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

Print this page

514 
515   guarantee(num_committed == _num_committed, "Found %u committed regions, but should be %u", num_committed, _num_committed);
516   _free_list.verify();
517 }
518 
519 #ifndef PRODUCT
520 void HeapRegionManager::verify_optional() {
521   verify();
522 }
523 #endif // PRODUCT
524 
525 HeapRegionClaimer::HeapRegionClaimer(uint n_workers) :
526     _n_workers(n_workers), _n_regions(G1CollectedHeap::heap()->_hrm->_allocated_heapregions_length), _claims(NULL) {
527   assert(n_workers > 0, "Need at least one worker.");
528   uint* new_claims = NEW_C_HEAP_ARRAY(uint, _n_regions, mtGC);
529   memset(new_claims, Unclaimed, sizeof(*_claims) * _n_regions);
530   _claims = new_claims;
531 }
532 
533 HeapRegionClaimer::~HeapRegionClaimer() {
534   if (_claims != NULL) {
535     FREE_C_HEAP_ARRAY(uint, _claims);
536   }
537 }
538 
539 uint HeapRegionClaimer::offset_for_worker(uint worker_id) const {
540   assert(worker_id < _n_workers, "Invalid worker_id.");
541   return _n_regions * worker_id / _n_workers;
542 }
543 
544 bool HeapRegionClaimer::is_region_claimed(uint region_index) const {
545   assert(region_index < _n_regions, "Invalid index.");
546   return _claims[region_index] == Claimed;
547 }
548 
549 bool HeapRegionClaimer::claim_region(uint region_index) {
550   assert(region_index < _n_regions, "Invalid index.");
551   uint old_val = Atomic::cmpxchg(Claimed, &_claims[region_index], Unclaimed);
552   return old_val == Unclaimed;
553 }

514 
515   guarantee(num_committed == _num_committed, "Found %u committed regions, but should be %u", num_committed, _num_committed);
516   _free_list.verify();
517 }
518 
519 #ifndef PRODUCT
520 void HeapRegionManager::verify_optional() {
521   verify();
522 }
523 #endif // PRODUCT
524 
525 HeapRegionClaimer::HeapRegionClaimer(uint n_workers) :
526     _n_workers(n_workers), _n_regions(G1CollectedHeap::heap()->_hrm->_allocated_heapregions_length), _claims(NULL) {
527   assert(n_workers > 0, "Need at least one worker.");
528   uint* new_claims = NEW_C_HEAP_ARRAY(uint, _n_regions, mtGC);
529   memset(new_claims, Unclaimed, sizeof(*_claims) * _n_regions);
530   _claims = new_claims;
531 }
532 
533 HeapRegionClaimer::~HeapRegionClaimer() {
534   FREE_C_HEAP_ARRAY(uint, _claims);


535 }
536 
537 uint HeapRegionClaimer::offset_for_worker(uint worker_id) const {
538   assert(worker_id < _n_workers, "Invalid worker_id.");
539   return _n_regions * worker_id / _n_workers;
540 }
541 
542 bool HeapRegionClaimer::is_region_claimed(uint region_index) const {
543   assert(region_index < _n_regions, "Invalid index.");
544   return _claims[region_index] == Claimed;
545 }
546 
547 bool HeapRegionClaimer::claim_region(uint region_index) {
548   assert(region_index < _n_regions, "Invalid index.");
549   uint old_val = Atomic::cmpxchg(Claimed, &_claims[region_index], Unclaimed);
550   return old_val == Unclaimed;
551 }
< prev index next >