227 void ParallelTaskTerminator::print_termination_counts() {
228 log_trace(gc, task)("ParallelTaskTerminator Total yields: %u"
229 " Total spins: %u Total peeks: %u",
230 total_yields(),
231 total_spins(),
232 total_peeks());
233 }
234 #endif
235
236 bool ParallelTaskTerminator::complete_or_exit_termination() {
237 // If termination is ever reached, terminator should stay in such state,
238 // so that all threads see the same state
239 uint current_offered = _offered_termination;
240 uint expected_value;
241 do {
242 if (current_offered == _n_threads) {
243 assert(!peek_in_queue_set(), "Precondition");
244 return true;
245 }
246 expected_value = current_offered;
247 } while ((current_offered = Atomic::cmpxchg(current_offered - 1, &_offered_termination, current_offered)) != expected_value);
248
249 assert(_offered_termination < _n_threads, "Invariant");
250 return false;
251 }
252
253 void ParallelTaskTerminator::reset_for_reuse() {
254 if (_offered_termination != 0) {
255 assert(_offered_termination == _n_threads,
256 "Terminator may still be in use");
257 _offered_termination = 0;
258 }
259 }
260
261 #ifdef ASSERT
262 bool ObjArrayTask::is_valid() const {
263 return _obj != NULL && _obj->is_objArray() && _index >= 0 &&
264 _index < objArrayOop(_obj)->length();
265 }
266 #endif // ASSERT
267
|
227 void ParallelTaskTerminator::print_termination_counts() {
228 log_trace(gc, task)("ParallelTaskTerminator Total yields: %u"
229 " Total spins: %u Total peeks: %u",
230 total_yields(),
231 total_spins(),
232 total_peeks());
233 }
234 #endif
235
236 bool ParallelTaskTerminator::complete_or_exit_termination() {
237 // If termination is ever reached, terminator should stay in such state,
238 // so that all threads see the same state
239 uint current_offered = _offered_termination;
240 uint expected_value;
241 do {
242 if (current_offered == _n_threads) {
243 assert(!peek_in_queue_set(), "Precondition");
244 return true;
245 }
246 expected_value = current_offered;
247 } while ((current_offered = Atomic::cmpxchg(&_offered_termination, current_offered, current_offered - 1)) != expected_value);
248
249 assert(_offered_termination < _n_threads, "Invariant");
250 return false;
251 }
252
253 void ParallelTaskTerminator::reset_for_reuse() {
254 if (_offered_termination != 0) {
255 assert(_offered_termination == _n_threads,
256 "Terminator may still be in use");
257 _offered_termination = 0;
258 }
259 }
260
261 #ifdef ASSERT
262 bool ObjArrayTask::is_valid() const {
263 return _obj != NULL && _obj->is_objArray() && _index >= 0 &&
264 _index < objArrayOop(_obj)->length();
265 }
266 #endif // ASSERT
267
|