comparison src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp @ 17947:1772223a25a2

8037112: gc/g1/TestHumongousAllocInitialMark.java caused SIGSEGV Reviewed-by: brutisso, mgerdin
author pliden
date Fri, 11 Apr 2014 11:00:12 +0200
parents f2110083203d
children 0982ec23da03
comparison
equal deleted inserted replaced
17946:997fd9660dd5 17947:1772223a25a2
87 Thread *current_thread = Thread::current(); 87 Thread *current_thread = Thread::current();
88 88
89 while (!_should_terminate) { 89 while (!_should_terminate) {
90 // wait until started is set. 90 // wait until started is set.
91 sleepBeforeNextCycle(); 91 sleepBeforeNextCycle();
92 if (_should_terminate) {
93 break;
94 }
95
92 { 96 {
93 ResourceMark rm; 97 ResourceMark rm;
94 HandleMark hm; 98 HandleMark hm;
95 double cycle_start = os::elapsedVTime(); 99 double cycle_start = os::elapsedVTime();
96 100
301 void ConcurrentMarkThread::yield() { 305 void ConcurrentMarkThread::yield() {
302 _sts.yield("Concurrent Mark"); 306 _sts.yield("Concurrent Mark");
303 } 307 }
304 308
305 void ConcurrentMarkThread::stop() { 309 void ConcurrentMarkThread::stop() {
306 // it is ok to take late safepoints here, if needed 310 {
307 MutexLockerEx mu(Terminator_lock); 311 MutexLockerEx ml(Terminator_lock);
308 _should_terminate = true; 312 _should_terminate = true;
309 while (!_has_terminated) { 313 }
310 Terminator_lock->wait(); 314
315 {
316 MutexLockerEx ml(CGC_lock, Mutex::_no_safepoint_check_flag);
317 CGC_lock->notify_all();
318 }
319
320 {
321 MutexLockerEx ml(Terminator_lock);
322 while (!_has_terminated) {
323 Terminator_lock->wait();
324 }
311 } 325 }
312 } 326 }
313 327
314 void ConcurrentMarkThread::print() const { 328 void ConcurrentMarkThread::print() const {
315 print_on(tty); 329 print_on(tty);
325 // We join here because we don't want to do the "shouldConcurrentMark()" 339 // We join here because we don't want to do the "shouldConcurrentMark()"
326 // below while the world is otherwise stopped. 340 // below while the world is otherwise stopped.
327 assert(!in_progress(), "should have been cleared"); 341 assert(!in_progress(), "should have been cleared");
328 342
329 MutexLockerEx x(CGC_lock, Mutex::_no_safepoint_check_flag); 343 MutexLockerEx x(CGC_lock, Mutex::_no_safepoint_check_flag);
330 while (!started()) { 344 while (!started() && !_should_terminate) {
331 CGC_lock->wait(Mutex::_no_safepoint_check_flag); 345 CGC_lock->wait(Mutex::_no_safepoint_check_flag);
332 } 346 }
333 set_in_progress(); 347
334 clear_started(); 348 if (started()) {
349 set_in_progress();
350 clear_started();
351 }
335 } 352 }
336 353
337 // Note: As is the case with CMS - this method, although exported 354 // Note: As is the case with CMS - this method, although exported
338 // by the ConcurrentMarkThread, which is a non-JavaThread, can only 355 // by the ConcurrentMarkThread, which is a non-JavaThread, can only
339 // be called by a JavaThread. Currently this is done at vm creation 356 // be called by a JavaThread. Currently this is done at vm creation