7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "gc/shared/taskqueue.hpp"
27 #include "oops/oop.inline.hpp"
28 #include "logging/log.hpp"
29 #include "runtime/atomic.hpp"
30 #include "runtime/os.hpp"
31 #include "runtime/thread.inline.hpp"
32 #include "utilities/debug.hpp"
33 #include "utilities/stack.inline.hpp"
34
35 #ifdef TRACESPINNING
36 uint ParallelTaskTerminator::_total_yields = 0;
37 uint ParallelTaskTerminator::_total_spins = 0;
38 uint ParallelTaskTerminator::_total_peeks = 0;
39 #endif
40
41 #if TASKQUEUE_STATS
42 const char * const TaskQueueStats::_names[last_stat_id] = {
43 "qpush", "qpop", "qpop-s", "qattempt", "qsteal", "opush", "omax"
44 };
45
46 TaskQueueStats & TaskQueueStats::operator +=(const TaskQueueStats & addend)
230
231 void ParallelTaskTerminator::reset_for_reuse() {
232 if (_offered_termination != 0) {
233 assert(_offered_termination == _n_threads,
234 "Terminator may still be in use");
235 _offered_termination = 0;
236 }
237 }
238
239 #ifdef ASSERT
240 bool ObjArrayTask::is_valid() const {
241 return _obj != NULL && _obj->is_objArray() && _index >= 0 &&
242 _index < objArrayOop(_obj)->length();
243 }
244 #endif // ASSERT
245
246 void ParallelTaskTerminator::reset_for_reuse(uint n_threads) {
247 reset_for_reuse();
248 _n_threads = n_threads;
249 }
|
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "gc/shared/taskqueue.hpp"
27 #include "gc/shared/owstTaskTerminator.hpp"
28 #include "oops/oop.inline.hpp"
29 #include "logging/log.hpp"
30 #include "runtime/atomic.hpp"
31 #include "runtime/os.hpp"
32 #include "runtime/thread.inline.hpp"
33 #include "utilities/debug.hpp"
34 #include "utilities/stack.inline.hpp"
35
36 #ifdef TRACESPINNING
37 uint ParallelTaskTerminator::_total_yields = 0;
38 uint ParallelTaskTerminator::_total_spins = 0;
39 uint ParallelTaskTerminator::_total_peeks = 0;
40 #endif
41
42 #if TASKQUEUE_STATS
43 const char * const TaskQueueStats::_names[last_stat_id] = {
44 "qpush", "qpop", "qpop-s", "qattempt", "qsteal", "opush", "omax"
45 };
46
47 TaskQueueStats & TaskQueueStats::operator +=(const TaskQueueStats & addend)
231
232 void ParallelTaskTerminator::reset_for_reuse() {
233 if (_offered_termination != 0) {
234 assert(_offered_termination == _n_threads,
235 "Terminator may still be in use");
236 _offered_termination = 0;
237 }
238 }
239
240 #ifdef ASSERT
241 bool ObjArrayTask::is_valid() const {
242 return _obj != NULL && _obj->is_objArray() && _index >= 0 &&
243 _index < objArrayOop(_obj)->length();
244 }
245 #endif // ASSERT
246
247 void ParallelTaskTerminator::reset_for_reuse(uint n_threads) {
248 reset_for_reuse();
249 _n_threads = n_threads;
250 }
251
252 TaskTerminator::TaskTerminator(uint n_threads, TaskQueueSetSuper* queue_set) :
253 _terminator(UseOWSTTaskTerminator ? new OWSTTaskTerminator(n_threads, queue_set)
254 : new ParallelTaskTerminator(n_threads, queue_set)) {
255 }
256
257 TaskTerminator::~TaskTerminator() {
258 if (_terminator != NULL) {
259 delete _terminator;
260 }
261 }
262
263 // Move assignment
264 TaskTerminator& TaskTerminator::operator=(const TaskTerminator& o) {
265 if (_terminator != NULL) {
266 delete _terminator;
267 }
268 _terminator = o.terminator();
269 const_cast<TaskTerminator&>(o)._terminator = NULL;
270 return *this;
271 }
272
|