< prev index next >

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

Print this page
rev 57895 : [mq]: 8215297-remove-ptt
rev 57896 : imported patch 8215297-some-cleanup

*** 1,7 **** --- 1,8 ---- /* * Copyright (c) 2018, 2019, Red Hat, Inc. All rights reserved. + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 23,38 **** --- 24,99 ---- */ #include "precompiled.hpp" #include "gc/shared/owstTaskTerminator.hpp" + #include "gc/shared/taskqueue.hpp" #include "logging/log.hpp" + #ifdef TRACESPINNING + uint OWSTTaskTerminator::_total_yields = 0; + uint OWSTTaskTerminator::_total_spins = 0; + uint OWSTTaskTerminator::_total_peeks = 0; + #endif + + OWSTTaskTerminator::OWSTTaskTerminator(uint n_threads, TaskQueueSetSuper* queue_set) : + _n_threads(n_threads), + _queue_set(queue_set), + _offered_termination(0), + _spin_master(NULL) { + + _blocker = new Monitor(Mutex::leaf, "OWSTTaskTerminator", false, Monitor::_safepoint_check_never); + } + + OWSTTaskTerminator::~OWSTTaskTerminator() { + 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 OWSTTaskTerminator::peek_in_queue_set() { + return _queue_set->peek(); + } + #endif + + void OWSTTaskTerminator::yield() { + assert(_offered_termination <= _n_threads, "Invariant"); + os::naked_yield(); + } + + #ifdef TRACESPINNING + void OWSTTaskTerminator::print_termination_counts() { + log_trace(gc, task)("TaskTerminator Yields: %u Spins: %u Peeks: %u", + total_yields(), total_spins(), total_peeks()); + } + #endif + + void OWSTTaskTerminator::reset_for_reuse() { + if (_offered_termination != 0) { + assert(_offered_termination == _n_threads, + "Terminator may still be in use"); + _offered_termination = 0; + } + } + + void OWSTTaskTerminator::reset_for_reuse(uint n_threads) { + reset_for_reuse(); + _n_threads = n_threads; + } + bool OWSTTaskTerminator::exit_termination(size_t tasks, TerminatorTerminator* terminator) { return tasks > 0 || (terminator != NULL && terminator->should_exit_termination()); } + size_t OWSTTaskTerminator::tasks_in_queue_set() const { + return _queue_set->tasks(); + } + bool OWSTTaskTerminator::offer_termination(TerminatorTerminator* terminator) { assert(_n_threads > 0, "Initialization is incorrect"); assert(_offered_termination < _n_threads, "Invariant"); assert(_blocker != NULL, "Invariant");
< prev index next >