2534 // We want the parallel threads to start their collection
2535 // set iteration at different collection set regions to
2536 // avoid contention.
2537 // If we have:
2538 // n collection set regions
2539 // p threads
2540 // Then thread t will start at region floor ((t * n) / p)
2541
2542 result = g1_policy()->collection_set();
2543 uint cs_size = g1_policy()->cset_region_length();
2544 uint active_workers = workers()->active_workers();
2545
2546 uint end_ind = (cs_size * worker_i) / active_workers;
2547 uint start_ind = 0;
2548
2549 if (worker_i > 0 &&
2550 _worker_cset_start_region_time_stamp[worker_i - 1] == gc_time_stamp) {
2551 // Previous workers starting region is valid
2552 // so let's iterate from there
2553 start_ind = (cs_size * (worker_i - 1)) / active_workers;
2554 result = _worker_cset_start_region[worker_i - 1];
2555 }
2556
2557 for (uint i = start_ind; i < end_ind; i++) {
2558 result = result->next_in_collection_set();
2559 }
2560
2561 // Note: the calculated starting heap region may be NULL
2562 // (when the collection set is empty).
2563 assert(result == NULL || result->in_collection_set(), "sanity");
2564 assert(_worker_cset_start_region_time_stamp[worker_i] != gc_time_stamp,
2565 "should be updated only once per pause");
2566 _worker_cset_start_region[worker_i] = result;
2567 OrderAccess::storestore();
2568 _worker_cset_start_region_time_stamp[worker_i] = gc_time_stamp;
2569 return result;
2570 }
2571
2572 void G1CollectedHeap::collection_set_iterate(HeapRegionClosure* cl) {
2573 HeapRegion* r = g1_policy()->collection_set();
|
2534 // We want the parallel threads to start their collection
2535 // set iteration at different collection set regions to
2536 // avoid contention.
2537 // If we have:
2538 // n collection set regions
2539 // p threads
2540 // Then thread t will start at region floor ((t * n) / p)
2541
2542 result = g1_policy()->collection_set();
2543 uint cs_size = g1_policy()->cset_region_length();
2544 uint active_workers = workers()->active_workers();
2545
2546 uint end_ind = (cs_size * worker_i) / active_workers;
2547 uint start_ind = 0;
2548
2549 if (worker_i > 0 &&
2550 _worker_cset_start_region_time_stamp[worker_i - 1] == gc_time_stamp) {
2551 // Previous workers starting region is valid
2552 // so let's iterate from there
2553 start_ind = (cs_size * (worker_i - 1)) / active_workers;
2554 OrderAccess::loadload();
2555 result = _worker_cset_start_region[worker_i - 1];
2556 }
2557
2558 for (uint i = start_ind; i < end_ind; i++) {
2559 result = result->next_in_collection_set();
2560 }
2561
2562 // Note: the calculated starting heap region may be NULL
2563 // (when the collection set is empty).
2564 assert(result == NULL || result->in_collection_set(), "sanity");
2565 assert(_worker_cset_start_region_time_stamp[worker_i] != gc_time_stamp,
2566 "should be updated only once per pause");
2567 _worker_cset_start_region[worker_i] = result;
2568 OrderAccess::storestore();
2569 _worker_cset_start_region_time_stamp[worker_i] = gc_time_stamp;
2570 return result;
2571 }
2572
2573 void G1CollectedHeap::collection_set_iterate(HeapRegionClosure* cl) {
2574 HeapRegion* r = g1_policy()->collection_set();
|