< prev index next >

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

Print this page
rev 47674 : Port 09.17.Thread_SMR_logging_update from JDK9 to JDK10
rev 47675 : sspitsyn, dcubed, eosterlund CR - minor changes prior to OpenJDK review.
rev 47676 : eosterlund, stefank CR - refactor code into threadSMR.cpp and threadSMR.hpp
rev 47677 : eosterlund CR - need more inline fixes.
rev 47678 : eosterlund, stefank CR - more inline and style cleanups
rev 47680 : Rebase to 2017.10.25 PIT snapshot.


  70   clear_suspend_flag(_trace_flag);
  71 }
  72 
  73 inline jlong Thread::cooked_allocated_bytes() {
  74   jlong allocated_bytes = OrderAccess::load_acquire(&_allocated_bytes);
  75   if (UseTLAB) {
  76     size_t used_bytes = tlab().used_bytes();
  77     if (used_bytes <= ThreadLocalAllocBuffer::max_size_in_bytes()) {
  78       // Comparing used_bytes with the maximum allowed size will ensure
  79       // that we don't add the used bytes from a semi-initialized TLAB
  80       // ending up with incorrect values. There is still a race between
  81       // incrementing _allocated_bytes and clearing the TLAB, that might
  82       // cause double counting in rare cases.
  83       return allocated_bytes + used_bytes;
  84     }
  85   }
  86   return allocated_bytes;
  87 }
  88 
  89 inline ThreadsList* Thread::cmpxchg_threads_hazard_ptr(ThreadsList* exchange_value, ThreadsList* compare_value) {
  90   return (ThreadsList*)Atomic::cmpxchg_ptr(exchange_value, (void* volatile*)&_threads_hazard_ptr, compare_value);
  91 }
  92 
  93 inline ThreadsList* Thread::get_threads_hazard_ptr() {
  94   return (ThreadsList*)OrderAccess::load_ptr_acquire((void* volatile*)&_threads_hazard_ptr);
  95 }
  96 
  97 inline void Thread::set_threads_hazard_ptr(ThreadsList* new_list) {
  98   OrderAccess::release_store_ptr_fence((void* volatile*)&_threads_hazard_ptr, (void*)new_list);
  99 }
 100 
 101 inline void JavaThread::set_ext_suspended() {
 102   set_suspend_flag (_ext_suspended);
 103 }
 104 inline void JavaThread::clear_ext_suspended() {
 105   clear_suspend_flag(_ext_suspended);
 106 }
 107 
 108 inline void JavaThread::set_external_suspend() {
 109   set_suspend_flag(_external_suspend);
 110 }
 111 inline void JavaThread::clear_external_suspend() {
 112   clear_suspend_flag(_external_suspend);
 113 }
 114 
 115 inline void JavaThread::set_deopt_suspend() {
 116   set_suspend_flag(_deopt_suspend);
 117 }
 118 inline void JavaThread::clear_deopt_suspend() {


 173 }
 174 
 175 inline bool JavaThread::is_exiting() const {
 176   // Use load-acquire so that setting of _terminated by
 177   // JavaThread::exit() is seen more quickly.
 178   TerminatedTypes l_terminated = (TerminatedTypes)
 179       OrderAccess::load_acquire((volatile jint *) &_terminated);
 180   return l_terminated == _thread_exiting || check_is_terminated(l_terminated);
 181 }
 182 
 183 inline bool JavaThread::is_terminated() {
 184   // Use load-acquire so that setting of _terminated by
 185   // JavaThread::exit() is seen more quickly.
 186   TerminatedTypes l_terminated = (TerminatedTypes)
 187       OrderAccess::load_acquire((volatile jint *) &_terminated);
 188   return check_is_terminated(_terminated);
 189 }
 190 
 191 inline void JavaThread::set_terminated(TerminatedTypes t) {
 192   // use release-store so the setting of _terminated is seen more quickly
 193   OrderAccess::release_store((volatile jint *) &_terminated, t);
 194 }
 195 
 196 // special for Threads::remove() which is static:
 197 inline void JavaThread::set_terminated_value() {
 198   // use release-store so the setting of _terminated is seen more quickly
 199   OrderAccess::release_store((volatile jint *) &_terminated, _thread_terminated);
 200 }
 201 
 202 template <class T>
 203 inline void Threads::threads_do_smr(T *tc, Thread *self) {
 204   ThreadsListHandle handle(self);
 205   handle.threads_do(tc);
 206 }
 207 
 208 inline ThreadsList* Threads::get_smr_java_thread_list() {
 209   return (ThreadsList*)OrderAccess::load_ptr_acquire((void* volatile*)&_smr_java_thread_list);
 210 }
 211 
 212 inline ThreadsList* Threads::xchg_smr_java_thread_list(ThreadsList* new_list) {
 213   return (ThreadsList*)Atomic::xchg_ptr((void*)new_list, (volatile void*)&_smr_java_thread_list);
 214 }
 215 
 216 inline void Threads::inc_smr_deleted_thread_cnt() {
 217   Atomic::inc(&_smr_deleted_thread_cnt);
 218 }
 219 
 220 inline void Threads::update_smr_deleted_thread_time_max(jint new_value) {
 221   while (true) {
 222     jint cur_value = _smr_deleted_thread_time_max;
 223     if (new_value <= cur_value) {
 224       // No need to update max value so we're done.
 225       break;
 226     }
 227     if (Atomic::cmpxchg(new_value, &_smr_deleted_thread_time_max, cur_value) == cur_value) {
 228       // Updated max value so we're done. Otherwise try it all again.
 229       break;
 230     }
 231   }
 232 }
 233 




  70   clear_suspend_flag(_trace_flag);
  71 }
  72 
  73 inline jlong Thread::cooked_allocated_bytes() {
  74   jlong allocated_bytes = OrderAccess::load_acquire(&_allocated_bytes);
  75   if (UseTLAB) {
  76     size_t used_bytes = tlab().used_bytes();
  77     if (used_bytes <= ThreadLocalAllocBuffer::max_size_in_bytes()) {
  78       // Comparing used_bytes with the maximum allowed size will ensure
  79       // that we don't add the used bytes from a semi-initialized TLAB
  80       // ending up with incorrect values. There is still a race between
  81       // incrementing _allocated_bytes and clearing the TLAB, that might
  82       // cause double counting in rare cases.
  83       return allocated_bytes + used_bytes;
  84     }
  85   }
  86   return allocated_bytes;
  87 }
  88 
  89 inline ThreadsList* Thread::cmpxchg_threads_hazard_ptr(ThreadsList* exchange_value, ThreadsList* compare_value) {
  90   return (ThreadsList*)Atomic::cmpxchg(exchange_value, &_threads_hazard_ptr, compare_value);
  91 }
  92 
  93 inline ThreadsList* Thread::get_threads_hazard_ptr() {
  94   return (ThreadsList*)OrderAccess::load_acquire(&_threads_hazard_ptr);
  95 }
  96 
  97 inline void Thread::set_threads_hazard_ptr(ThreadsList* new_list) {
  98   OrderAccess::release_store_fence(&_threads_hazard_ptr, new_list);
  99 }
 100 
 101 inline void JavaThread::set_ext_suspended() {
 102   set_suspend_flag (_ext_suspended);
 103 }
 104 inline void JavaThread::clear_ext_suspended() {
 105   clear_suspend_flag(_ext_suspended);
 106 }
 107 
 108 inline void JavaThread::set_external_suspend() {
 109   set_suspend_flag(_external_suspend);
 110 }
 111 inline void JavaThread::clear_external_suspend() {
 112   clear_suspend_flag(_external_suspend);
 113 }
 114 
 115 inline void JavaThread::set_deopt_suspend() {
 116   set_suspend_flag(_deopt_suspend);
 117 }
 118 inline void JavaThread::clear_deopt_suspend() {


 173 }
 174 
 175 inline bool JavaThread::is_exiting() const {
 176   // Use load-acquire so that setting of _terminated by
 177   // JavaThread::exit() is seen more quickly.
 178   TerminatedTypes l_terminated = (TerminatedTypes)
 179       OrderAccess::load_acquire((volatile jint *) &_terminated);
 180   return l_terminated == _thread_exiting || check_is_terminated(l_terminated);
 181 }
 182 
 183 inline bool JavaThread::is_terminated() {
 184   // Use load-acquire so that setting of _terminated by
 185   // JavaThread::exit() is seen more quickly.
 186   TerminatedTypes l_terminated = (TerminatedTypes)
 187       OrderAccess::load_acquire((volatile jint *) &_terminated);
 188   return check_is_terminated(_terminated);
 189 }
 190 
 191 inline void JavaThread::set_terminated(TerminatedTypes t) {
 192   // use release-store so the setting of _terminated is seen more quickly
 193   OrderAccess::release_store((volatile jint *) &_terminated, (jint) t);
 194 }
 195 
 196 // special for Threads::remove() which is static:
 197 inline void JavaThread::set_terminated_value() {
 198   // use release-store so the setting of _terminated is seen more quickly
 199   OrderAccess::release_store((volatile jint *) &_terminated, (jint) _thread_terminated);
 200 }
 201 
 202 template <class T>
 203 inline void Threads::threads_do_smr(T *tc, Thread *self) {
 204   ThreadsListHandle handle(self);
 205   handle.threads_do(tc);
 206 }
 207 
 208 inline ThreadsList* Threads::get_smr_java_thread_list() {
 209   return (ThreadsList*)OrderAccess::load_acquire(&_smr_java_thread_list);
 210 }
 211 
 212 inline ThreadsList* Threads::xchg_smr_java_thread_list(ThreadsList* new_list) {
 213   return (ThreadsList*)Atomic::xchg(new_list, &_smr_java_thread_list);
 214 }
 215 
 216 inline void Threads::inc_smr_deleted_thread_cnt() {
 217   Atomic::inc(&_smr_deleted_thread_cnt);
 218 }
 219 
 220 inline void Threads::update_smr_deleted_thread_time_max(jint new_value) {
 221   while (true) {
 222     jint cur_value = _smr_deleted_thread_time_max;
 223     if (new_value <= cur_value) {
 224       // No need to update max value so we're done.
 225       break;
 226     }
 227     if (Atomic::cmpxchg(new_value, &_smr_deleted_thread_time_max, cur_value) == cur_value) {
 228       // Updated max value so we're done. Otherwise try it all again.
 229       break;
 230     }
 231   }
 232 }
 233 


< prev index next >