83 _blocker->lock_without_safepoint_check();
84 }
85 } else {
86 _blocker->wait(true, WorkStealingSleepMillis);
87
88 if (_offered_termination == _n_threads) {
89 _blocker->unlock();
90 return true;
91 }
92 }
93
94 if (((terminator == NULL || terminator->should_force_termination()) && peek_in_queue_set()) ||
95 (terminator != NULL && terminator->should_exit_termination())) {
96 _offered_termination --;
97 _blocker->unlock();
98 return false;
99 }
100 }
101 }
102
103 bool ShenandoahTaskTerminator::do_spin_master_work(TerminatorTerminator* terminator) {
104 uint yield_count = 0;
105 // Number of hard spin loops done since last yield
106 uint hard_spin_count = 0;
107 // Number of iterations in the hard spin loop.
108 uint hard_spin_limit = WorkStealingHardSpins;
109
110 // If WorkStealingSpinToYieldRatio is 0, no hard spinning is done.
111 // If it is greater than 0, then start with a small number
112 // of spins and increase number with each turn at spinning until
113 // the count of hard spins exceeds WorkStealingSpinToYieldRatio.
114 // Then do a yield() call and start spinning afresh.
115 if (WorkStealingSpinToYieldRatio > 0) {
116 hard_spin_limit = WorkStealingHardSpins >> WorkStealingSpinToYieldRatio;
117 hard_spin_limit = MAX2(hard_spin_limit, 1U);
118 }
119 // Remember the initial spin limit.
120 uint hard_spin_start = hard_spin_limit;
121
122 // Loop waiting for all threads to offer termination or
|
83 _blocker->lock_without_safepoint_check();
84 }
85 } else {
86 _blocker->wait(true, WorkStealingSleepMillis);
87
88 if (_offered_termination == _n_threads) {
89 _blocker->unlock();
90 return true;
91 }
92 }
93
94 if (((terminator == NULL || terminator->should_force_termination()) && peek_in_queue_set()) ||
95 (terminator != NULL && terminator->should_exit_termination())) {
96 _offered_termination --;
97 _blocker->unlock();
98 return false;
99 }
100 }
101 }
102
103 #if TASKQUEUE_STATS
104 void ShenandoahObjToScanQueueSet::print_taskqueue_stats_hdr(outputStream* const st) {
105 st->print_raw_cr("GC Task Stats");
106 st->print_raw("thr "); TaskQueueStats::print_header(1, st); st->cr();
107 st->print_raw("--- "); TaskQueueStats::print_header(2, st); st->cr();
108 }
109
110 void ShenandoahObjToScanQueueSet::print_taskqueue_stats() {
111 if (! ShenandoahLogTrace) {
112 return;
113 }
114 ResourceMark rm;
115 outputStream* st = gclog_or_tty;
116 print_taskqueue_stats_hdr(st);
117
118 TaskQueueStats totals;
119 const uint n = size();
120 for (uint i = 0; i < n; ++i) {
121 st->print(UINT32_FORMAT_W(3), i);
122 queue(i)->stats.print(st);
123 st->cr();
124 totals += queue(i)->stats;
125 }
126 st->print("tot "); totals.print(st); st->cr();
127 DEBUG_ONLY(totals.verify());
128 }
129
130 void ShenandoahObjToScanQueueSet::reset_taskqueue_stats() {
131 const uint n = size();
132 for (uint i = 0; i < n; ++i) {
133 queue(i)->stats.reset();
134 }
135 }
136 #endif // TASKQUEUE_STATS
137
138
139 bool ShenandoahTaskTerminator::do_spin_master_work(TerminatorTerminator* terminator) {
140 uint yield_count = 0;
141 // Number of hard spin loops done since last yield
142 uint hard_spin_count = 0;
143 // Number of iterations in the hard spin loop.
144 uint hard_spin_limit = WorkStealingHardSpins;
145
146 // If WorkStealingSpinToYieldRatio is 0, no hard spinning is done.
147 // If it is greater than 0, then start with a small number
148 // of spins and increase number with each turn at spinning until
149 // the count of hard spins exceeds WorkStealingSpinToYieldRatio.
150 // Then do a yield() call and start spinning afresh.
151 if (WorkStealingSpinToYieldRatio > 0) {
152 hard_spin_limit = WorkStealingHardSpins >> WorkStealingSpinToYieldRatio;
153 hard_spin_limit = MAX2(hard_spin_limit, 1U);
154 }
155 // Remember the initial spin limit.
156 uint hard_spin_start = hard_spin_limit;
157
158 // Loop waiting for all threads to offer termination or
|