< prev index next >

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

Print this page
rev 11040 : 8150393: Maintain the set of survivor regions in an array between GCs
Reviewed-by:

*** 55,64 **** --- 55,65 ---- #include "runtime/atomic.inline.hpp" #include "runtime/handles.inline.hpp" #include "runtime/java.hpp" #include "runtime/prefetch.inline.hpp" #include "services/memTracker.hpp" + #include "utilities/growableArray.hpp" // Concurrent marking bit map wrapper G1CMBitMapRO::G1CMBitMapRO(int shifter) : _bm(),
*** 259,282 **** _saved_index = -1; } G1CMRootRegions::G1CMRootRegions() : _young_list(NULL), _cm(NULL), _scan_in_progress(false), ! _should_abort(false), _next_survivor(NULL) { } void G1CMRootRegions::init(G1CollectedHeap* g1h, G1ConcurrentMark* cm) { _young_list = g1h->young_list(); _cm = cm; } void G1CMRootRegions::prepare_for_scan() { assert(!scan_in_progress(), "pre-condition"); // Currently, only survivors can be root regions. ! assert(_next_survivor == NULL, "pre-condition"); ! _next_survivor = _young_list->first_survivor_region(); ! _scan_in_progress = (_next_survivor != NULL); _should_abort = false; } HeapRegion* G1CMRootRegions::claim_next() { if (_should_abort) { --- 260,282 ---- _saved_index = -1; } G1CMRootRegions::G1CMRootRegions() : _young_list(NULL), _cm(NULL), _scan_in_progress(false), ! _should_abort(false), _claimed_survivor_index(0) { } void G1CMRootRegions::init(G1CollectedHeap* g1h, G1ConcurrentMark* cm) { _young_list = g1h->young_list(); _cm = cm; } void G1CMRootRegions::prepare_for_scan() { assert(!scan_in_progress(), "pre-condition"); // Currently, only survivors can be root regions. ! _claimed_survivor_index = 0; ! _scan_in_progress = true; _should_abort = false; } HeapRegion* G1CMRootRegions::claim_next() { if (_should_abort) {
*** 284,314 **** // force the caller to bail out of their loop. return NULL; } // Currently, only survivors can be root regions. ! HeapRegion* res = _next_survivor; ! if (res != NULL) { ! MutexLockerEx x(RootRegionScan_lock, Mutex::_no_safepoint_check_flag); ! // Read it again in case it changed while we were waiting for the lock. ! res = _next_survivor; ! if (res != NULL) { ! if (res == _young_list->last_survivor_region()) { ! // We just claimed the last survivor so store NULL to indicate ! // that we're done. ! _next_survivor = NULL; ! } else { ! _next_survivor = res->get_next_young_region(); ! } ! } else { ! // Someone else claimed the last survivor while we were trying ! // to take the lock so nothing else to do. ! } ! } ! assert(res == NULL || res->is_survivor(), "post-condition"); ! return res; } void G1CMRootRegions::notify_scan_done() { MutexLockerEx x(RootRegionScan_lock, Mutex::_no_safepoint_check_flag); _scan_in_progress = false; --- 284,304 ---- // force the caller to bail out of their loop. return NULL; } // Currently, only survivors can be root regions. ! const GrowableArray<HeapRegion*>* survivor_regions = _young_list->survivor_regions(); ! // The claimed survivor index is a 1-based index into the survivor regions array ! // this allows us to initialize the index to 0 and avoid signed overflow issues. ! int claimed_index = Atomic::add(1, &_claimed_survivor_index); ! assert(claimed_index > 0, "%d must always be positive", claimed_index); ! claimed_index--; ! if (claimed_index < survivor_regions->length()) { ! return survivor_regions->at(claimed_index); ! } ! return NULL; } void G1CMRootRegions::notify_scan_done() { MutexLockerEx x(RootRegionScan_lock, Mutex::_no_safepoint_check_flag); _scan_in_progress = false;
*** 322,334 **** void G1CMRootRegions::scan_finished() { assert(scan_in_progress(), "pre-condition"); // Currently, only survivors can be root regions. if (!_should_abort) { ! assert(_next_survivor == NULL, "we should have claimed all survivors"); } - _next_survivor = NULL; notify_scan_done(); } bool G1CMRootRegions::wait_until_scan_finished() { --- 312,325 ---- void G1CMRootRegions::scan_finished() { assert(scan_in_progress(), "pre-condition"); // Currently, only survivors can be root regions. if (!_should_abort) { ! assert(_claimed_survivor_index >= _young_list->survivor_regions()->length(), ! "we should have claimed all survivors, claimed index = %d, length = %d", ! _claimed_survivor_index, _young_list->survivor_regions()->length()); } notify_scan_done(); } bool G1CMRootRegions::wait_until_scan_finished() {
< prev index next >