< prev index next >

src/hotspot/share/gc/shared/taskTerminator.cpp

Print this page
rev 59131 : imported patch assert_empty

*** 37,57 **** _blocker = new Monitor(Mutex::leaf, "TaskTerminator", false, Monitor::_safepoint_check_never); } TaskTerminator::~TaskTerminator() { ! assert(_offered_termination == 0 || !peek_in_queue_set(), "Precondition"); ! assert(_offered_termination == 0 || _offered_termination == _n_threads, "Terminated or aborted" ); assert(_spin_master == NULL, "Should have been reset"); assert(_blocker != NULL, "Can not be NULL"); delete _blocker; } #ifdef ASSERT ! bool TaskTerminator::peek_in_queue_set() { ! return _queue_set->peek(); } #endif void TaskTerminator::yield() { assert(_offered_termination <= _n_threads, "Invariant"); --- 37,59 ---- _blocker = new Monitor(Mutex::leaf, "TaskTerminator", false, Monitor::_safepoint_check_never); } TaskTerminator::~TaskTerminator() { ! if (_offered_termination != 0) { ! assert(_offered_termination == _n_threads, "Must be terminated or aborted"); ! assert_queue_set_empty(); ! } assert(_spin_master == NULL, "Should have been reset"); assert(_blocker != NULL, "Can not be NULL"); delete _blocker; } #ifdef ASSERT ! void TaskTerminator::assert_queue_set_empty() const { ! _queue_set->assert_empty(); } #endif void TaskTerminator::yield() { assert(_offered_termination <= _n_threads, "Invariant");
*** 85,105 **** assert(_blocker != NULL, "Invariant"); // Single worker, done if (_n_threads == 1) { _offered_termination = 1; ! assert(!peek_in_queue_set(), "Precondition"); return true; } _blocker->lock_without_safepoint_check(); _offered_termination++; // All arrived, done if (_offered_termination == _n_threads) { _blocker->notify_all(); _blocker->unlock(); ! assert(!peek_in_queue_set(), "Precondition"); return true; } Thread* the_thread = Thread::current(); while (true) { --- 87,107 ---- assert(_blocker != NULL, "Invariant"); // Single worker, done if (_n_threads == 1) { _offered_termination = 1; ! assert_queue_set_empty(); return true; } _blocker->lock_without_safepoint_check(); _offered_termination++; // All arrived, done if (_offered_termination == _n_threads) { _blocker->notify_all(); _blocker->unlock(); ! assert_queue_set_empty(); return true; } Thread* the_thread = Thread::current(); while (true) {
*** 108,135 **** _blocker->unlock(); if (do_spin_master_work(terminator)) { assert(_offered_termination == _n_threads, "termination condition"); ! assert(!peek_in_queue_set(), "Precondition"); return true; } else { _blocker->lock_without_safepoint_check(); // There is possibility that termination is reached between dropping the lock // before returning from do_spin_master_work() and acquiring lock above. if (_offered_termination == _n_threads) { _blocker->unlock(); ! assert(!peek_in_queue_set(), "Precondition"); return true; } } } else { _blocker->wait_without_safepoint_check(WorkStealingSleepMillis); if (_offered_termination == _n_threads) { _blocker->unlock(); ! assert(!peek_in_queue_set(), "Precondition"); return true; } } size_t tasks = tasks_in_queue_set(); --- 110,137 ---- _blocker->unlock(); if (do_spin_master_work(terminator)) { assert(_offered_termination == _n_threads, "termination condition"); ! assert_queue_set_empty(); return true; } else { _blocker->lock_without_safepoint_check(); // There is possibility that termination is reached between dropping the lock // before returning from do_spin_master_work() and acquiring lock above. if (_offered_termination == _n_threads) { _blocker->unlock(); ! assert_queue_set_empty(); return true; } } } else { _blocker->wait_without_safepoint_check(WorkStealingSleepMillis); if (_offered_termination == _n_threads) { _blocker->unlock(); ! assert_queue_set_empty(); return true; } } size_t tasks = tasks_in_queue_set();
< prev index next >