comparison src/share/vm/utilities/workgroup.cpp @ 17949:487f09bf44e0

8040803: G1: Concurrent mark hangs when mark stack overflows Reviewed-by: brutisso, ehelin
author pliden
date Wed, 14 May 2014 13:32:44 +0200
parents 78bbf4d43a14
children
comparison
equal deleted inserted replaced
17948:e4d318eea75a 17949:487f09bf44e0
376 376
377 // *** WorkGangBarrierSync 377 // *** WorkGangBarrierSync
378 378
379 WorkGangBarrierSync::WorkGangBarrierSync() 379 WorkGangBarrierSync::WorkGangBarrierSync()
380 : _monitor(Mutex::safepoint, "work gang barrier sync", true), 380 : _monitor(Mutex::safepoint, "work gang barrier sync", true),
381 _n_workers(0), _n_completed(0), _should_reset(false) { 381 _n_workers(0), _n_completed(0), _should_reset(false), _aborted(false) {
382 } 382 }
383 383
384 WorkGangBarrierSync::WorkGangBarrierSync(uint n_workers, const char* name) 384 WorkGangBarrierSync::WorkGangBarrierSync(uint n_workers, const char* name)
385 : _monitor(Mutex::safepoint, name, true), 385 : _monitor(Mutex::safepoint, name, true),
386 _n_workers(n_workers), _n_completed(0), _should_reset(false) { 386 _n_workers(n_workers), _n_completed(0), _should_reset(false), _aborted(false) {
387 } 387 }
388 388
389 void WorkGangBarrierSync::set_n_workers(uint n_workers) { 389 void WorkGangBarrierSync::set_n_workers(uint n_workers) {
390 _n_workers = n_workers; 390 _n_workers = n_workers;
391 _n_completed = 0; 391 _n_completed = 0;
392 _should_reset = false; 392 _should_reset = false;
393 } 393 _aborted = false;
394 394 }
395 void WorkGangBarrierSync::enter() { 395
396 bool WorkGangBarrierSync::enter() {
396 MutexLockerEx x(monitor(), Mutex::_no_safepoint_check_flag); 397 MutexLockerEx x(monitor(), Mutex::_no_safepoint_check_flag);
397 if (should_reset()) { 398 if (should_reset()) {
398 // The should_reset() was set and we are the first worker to enter 399 // The should_reset() was set and we are the first worker to enter
399 // the sync barrier. We will zero the n_completed() count which 400 // the sync barrier. We will zero the n_completed() count which
400 // effectively resets the barrier. 401 // effectively resets the barrier.
413 // should_reset() flag and the barrier will be reset the first 414 // should_reset() flag and the barrier will be reset the first
414 // time a worker enters it again. 415 // time a worker enters it again.
415 set_should_reset(true); 416 set_should_reset(true);
416 monitor()->notify_all(); 417 monitor()->notify_all();
417 } else { 418 } else {
418 while (n_completed() != n_workers()) { 419 while (n_completed() != n_workers() && !aborted()) {
419 monitor()->wait(/* no_safepoint_check */ true); 420 monitor()->wait(/* no_safepoint_check */ true);
420 } 421 }
421 } 422 }
423 return !aborted();
424 }
425
426 void WorkGangBarrierSync::abort() {
427 MutexLockerEx x(monitor(), Mutex::_no_safepoint_check_flag);
428 set_aborted();
429 monitor()->notify_all();
422 } 430 }
423 431
424 // SubTasksDone functions. 432 // SubTasksDone functions.
425 433
426 SubTasksDone::SubTasksDone(uint n) : 434 SubTasksDone::SubTasksDone(uint n) :