< prev index next >

src/hotspot/share/runtime/thread.inline.hpp

Print this page
rev 48154 : 8191789: migrate more Thread-SMR stuff from thread.[ch]pp -> threadSMR.[ch]pp
Reviewed-by:


  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 #ifndef SHARE_VM_RUNTIME_THREAD_INLINE_HPP
  26 #define SHARE_VM_RUNTIME_THREAD_INLINE_HPP
  27 
  28 #include "runtime/atomic.hpp"
  29 #include "runtime/os.inline.hpp"
  30 #include "runtime/thread.hpp"
  31 #include "runtime/threadSMR.hpp"
  32 
  33 inline void Thread::set_suspend_flag(SuspendFlags f) {
  34   assert(sizeof(jint) == sizeof(_suspend_flags), "size mismatch");
  35   uint32_t flags;
  36   do {
  37     flags = _suspend_flags;
  38   }
  39   while (Atomic::cmpxchg((jint)(flags | f),
  40                          (volatile jint*)&_suspend_flags,
  41                          (jint)flags) != (jint)flags);
  42 }
  43 inline void Thread::clear_suspend_flag(SuspendFlags f) {
  44   assert(sizeof(jint) == sizeof(_suspend_flags), "size mismatch");
  45   uint32_t flags;
  46   do {
  47     flags = _suspend_flags;
  48   }
  49   while (Atomic::cmpxchg((jint)(flags & ~f),
  50                          (volatile jint*)&_suspend_flags,
  51                          (jint)flags) != (jint)flags);


 195 
 196 inline bool JavaThread::is_terminated() const {
 197   // Use load-acquire so that setting of _terminated by
 198   // JavaThread::exit() is seen more quickly.
 199   TerminatedTypes l_terminated = (TerminatedTypes)
 200       OrderAccess::load_acquire((volatile jint *) &_terminated);
 201   return check_is_terminated(l_terminated);
 202 }
 203 
 204 inline void JavaThread::set_terminated(TerminatedTypes t) {
 205   // use release-store so the setting of _terminated is seen more quickly
 206   OrderAccess::release_store((volatile jint *) &_terminated, (jint) t);
 207 }
 208 
 209 // special for Threads::remove() which is static:
 210 inline void JavaThread::set_terminated_value() {
 211   // use release-store so the setting of _terminated is seen more quickly
 212   OrderAccess::release_store((volatile jint *) &_terminated, (jint) _thread_terminated);
 213 }
 214 
 215 inline void Threads::add_smr_tlh_times(uint add_value) {
 216   Atomic::add(add_value, &_smr_tlh_times);
 217 }
 218 
 219 inline void Threads::inc_smr_tlh_cnt() {
 220   Atomic::inc(&_smr_tlh_cnt);
 221 }
 222 
 223 inline void Threads::update_smr_tlh_time_max(uint new_value) {
 224   while (true) {
 225     uint cur_value = _smr_tlh_time_max;
 226     if (new_value <= cur_value) {
 227       // No need to update max value so we're done.
 228       break;
 229     }
 230     if (Atomic::cmpxchg(new_value, &_smr_tlh_time_max, cur_value) == cur_value) {
 231       // Updated max value so we're done. Otherwise try it all again.
 232       break;
 233     }
 234   }
 235 }
 236 
 237 #endif // SHARE_VM_RUNTIME_THREAD_INLINE_HPP


  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 #ifndef SHARE_VM_RUNTIME_THREAD_INLINE_HPP
  26 #define SHARE_VM_RUNTIME_THREAD_INLINE_HPP
  27 
  28 #include "runtime/atomic.hpp"
  29 #include "runtime/os.inline.hpp"
  30 #include "runtime/thread.hpp"

  31 
  32 inline void Thread::set_suspend_flag(SuspendFlags f) {
  33   assert(sizeof(jint) == sizeof(_suspend_flags), "size mismatch");
  34   uint32_t flags;
  35   do {
  36     flags = _suspend_flags;
  37   }
  38   while (Atomic::cmpxchg((jint)(flags | f),
  39                          (volatile jint*)&_suspend_flags,
  40                          (jint)flags) != (jint)flags);
  41 }
  42 inline void Thread::clear_suspend_flag(SuspendFlags f) {
  43   assert(sizeof(jint) == sizeof(_suspend_flags), "size mismatch");
  44   uint32_t flags;
  45   do {
  46     flags = _suspend_flags;
  47   }
  48   while (Atomic::cmpxchg((jint)(flags & ~f),
  49                          (volatile jint*)&_suspend_flags,
  50                          (jint)flags) != (jint)flags);


 194 
 195 inline bool JavaThread::is_terminated() const {
 196   // Use load-acquire so that setting of _terminated by
 197   // JavaThread::exit() is seen more quickly.
 198   TerminatedTypes l_terminated = (TerminatedTypes)
 199       OrderAccess::load_acquire((volatile jint *) &_terminated);
 200   return check_is_terminated(l_terminated);
 201 }
 202 
 203 inline void JavaThread::set_terminated(TerminatedTypes t) {
 204   // use release-store so the setting of _terminated is seen more quickly
 205   OrderAccess::release_store((volatile jint *) &_terminated, (jint) t);
 206 }
 207 
 208 // special for Threads::remove() which is static:
 209 inline void JavaThread::set_terminated_value() {
 210   // use release-store so the setting of _terminated is seen more quickly
 211   OrderAccess::release_store((volatile jint *) &_terminated, (jint) _thread_terminated);
 212 }
 213 






















 214 #endif // SHARE_VM_RUNTIME_THREAD_INLINE_HPP
< prev index next >