355 // Read it again in case it changed while we were waiting for the lock. 356 res = _next_survivor; 357 if (res != NULL) { 358 if (res == _young_list->last_survivor_region()) { 359 // We just claimed the last survivor so store NULL to indicate 360 // that we're done. 361 _next_survivor = NULL; 362 } else { 363 _next_survivor = res->get_next_young_region(); 364 } 365 } else { 366 // Someone else claimed the last survivor while we were trying 367 // to take the lock so nothing else to do. 368 } 369 } 370 assert(res == NULL || res->is_survivor(), "post-condition"); 371 372 return res; 373 } 374 375 void CMRootRegions::scan_finished() { 376 assert(scan_in_progress(), "pre-condition"); 377 378 // Currently, only survivors can be root regions. 379 if (!_should_abort) { 380 assert(_next_survivor == NULL, "we should have claimed all survivors"); 381 } 382 _next_survivor = NULL; 383 384 { 385 MutexLockerEx x(RootRegionScan_lock, Mutex::_no_safepoint_check_flag); 386 _scan_in_progress = false; 387 RootRegionScan_lock->notify_all(); 388 } 389 } 390 391 bool CMRootRegions::wait_until_scan_finished() { 392 if (!scan_in_progress()) return false; 393 394 { | 355 // Read it again in case it changed while we were waiting for the lock. 356 res = _next_survivor; 357 if (res != NULL) { 358 if (res == _young_list->last_survivor_region()) { 359 // We just claimed the last survivor so store NULL to indicate 360 // that we're done. 361 _next_survivor = NULL; 362 } else { 363 _next_survivor = res->get_next_young_region(); 364 } 365 } else { 366 // Someone else claimed the last survivor while we were trying 367 // to take the lock so nothing else to do. 368 } 369 } 370 assert(res == NULL || res->is_survivor(), "post-condition"); 371 372 return res; 373 } 374 375 void CMRootRegions::cancel_scan() { 376 MutexLockerEx x(RootRegionScan_lock, Mutex::_no_safepoint_check_flag); 377 _scan_in_progress = false; 378 RootRegionScan_lock->notify_all(); 379 } 380 381 void CMRootRegions::scan_finished() { 382 assert(scan_in_progress(), "pre-condition"); 383 384 // Currently, only survivors can be root regions. 385 if (!_should_abort) { 386 assert(_next_survivor == NULL, "we should have claimed all survivors"); 387 } 388 _next_survivor = NULL; 389 390 { 391 MutexLockerEx x(RootRegionScan_lock, Mutex::_no_safepoint_check_flag); 392 _scan_in_progress = false; 393 RootRegionScan_lock->notify_all(); 394 } 395 } 396 397 bool CMRootRegions::wait_until_scan_finished() { 398 if (!scan_in_progress()) return false; 399 400 { |