422 if (hr->startsHumongous()) {
423 prev_end = hr->orig_end();
424 } else {
425 prev_end = hr->end();
426 }
427 }
428 for (uint i = _allocated_heapregions_length; i < max_length(); i++) {
429 guarantee(_regions.get_by_index(i) == NULL, err_msg("invariant i: %u", i));
430 }
431
432 guarantee(num_committed == _num_committed, err_msg("Found %u committed regions, but should be %u", num_committed, _num_committed));
433 _free_list.verify();
434 }
435
436 #ifndef PRODUCT
437 void HeapRegionManager::verify_optional() {
438 verify();
439 }
440 #endif // PRODUCT
441
|
422 if (hr->startsHumongous()) {
423 prev_end = hr->orig_end();
424 } else {
425 prev_end = hr->end();
426 }
427 }
428 for (uint i = _allocated_heapregions_length; i < max_length(); i++) {
429 guarantee(_regions.get_by_index(i) == NULL, err_msg("invariant i: %u", i));
430 }
431
432 guarantee(num_committed == _num_committed, err_msg("Found %u committed regions, but should be %u", num_committed, _num_committed));
433 _free_list.verify();
434 }
435
436 #ifndef PRODUCT
437 void HeapRegionManager::verify_optional() {
438 verify();
439 }
440 #endif // PRODUCT
441
442 void HeapRegionClaimer::initialize(uint n_workers) {
443 assert(n_workers > 0, "Need at least one worker.");
444 assert(_claims == NULL, "Must initialize only once.");
445 _n_workers = n_workers;
446 _n_regions = G1CollectedHeap::heap()->_hrm._allocated_heapregions_length;
447 _claims = NEW_C_HEAP_ARRAY(uint, _n_regions, mtGC);
448 memset(_claims, Unclaimed, sizeof(*_claims) * _n_regions);
449 }
450
451 uint HeapRegionClaimer::start_region_for_worker(uint worker_id) const {
452 assert(_n_workers != 0, "Must initialize before use.");
453 assert(worker_id < _n_workers, "Invalid worker_id.");
454 return _n_regions * worker_id / _n_workers;
455 }
456
457 bool HeapRegionClaimer::is_region_claimed(uint region_index) const {
458 assert(_claims != NULL, "Must initialize before use.");
459 assert(region_index < _n_regions, "Invalid index.");
460 return _claims[region_index] == Claimed;
461 }
462
463 bool HeapRegionClaimer::claim_region(uint region_index) {
464 assert(_claims != NULL, "Must initialize before use.");
465 assert(region_index < _n_regions, "Invalid index.");
466 if (Atomic::cmpxchg(Claimed, &_claims[region_index], Unclaimed) == Unclaimed) {
467 return true;
468 }
469 return false;
470 }
|