< prev index next >

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

Print this page
rev 47862 : imported patch 10.07.open.rebase_20171110.dcubed
rev 47865 : dholmes CR: Fix indents, trailing spaces and various typos. Add descriptions for the '_cnt', '_max' and '_times" fields, add impl notes to document the type choices.
rev 47866 : robinw CR: Fix some inefficient code, update some comments, fix some indents, and add some 'const' specifiers.


 175 // The release make sure this store is done after storing the handshake
 176 // operation or global state
 177 inline void JavaThread::set_polling_page(void* poll_value) {
 178   OrderAccess::release_store(polling_page_addr(), poll_value);
 179 }
 180 
 181 // The aqcquire make sure reading of polling page is done before
 182 // the reading the handshake operation or the global state
 183 inline volatile void* JavaThread::get_polling_page() {
 184   return OrderAccess::load_acquire(polling_page_addr());
 185 }
 186 
 187 inline bool JavaThread::is_exiting() const {
 188   // Use load-acquire so that setting of _terminated by
 189   // JavaThread::exit() is seen more quickly.
 190   TerminatedTypes l_terminated = (TerminatedTypes)
 191       OrderAccess::load_acquire((volatile jint *) &_terminated);
 192   return l_terminated == _thread_exiting || check_is_terminated(l_terminated);
 193 }
 194 
 195 inline bool JavaThread::is_terminated() {
 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(_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 template <class T>
 215 inline void Threads::threads_do_smr(T *tc, Thread *self) {
 216   ThreadsListHandle handle(self);
 217   handle.threads_do(tc);
 218 }
 219 
 220 inline ThreadsList* Threads::get_smr_java_thread_list() {
 221   return (ThreadsList*)OrderAccess::load_acquire(&_smr_java_thread_list);
 222 }
 223 
 224 inline ThreadsList* Threads::xchg_smr_java_thread_list(ThreadsList* new_list) {
 225   return (ThreadsList*)Atomic::xchg(new_list, &_smr_java_thread_list);
 226 }
 227 
 228 inline void Threads::inc_smr_deleted_thread_cnt() {
 229   Atomic::inc(&_smr_deleted_thread_cnt);
 230 }
 231 
 232 inline void Threads::update_smr_deleted_thread_time_max(jint new_value) {
 233   while (true) {
 234     jint cur_value = _smr_deleted_thread_time_max;
 235     if (new_value <= cur_value) {
 236       // No need to update max value so we're done.
 237       break;
 238     }
 239     if (Atomic::cmpxchg(new_value, &_smr_deleted_thread_time_max, cur_value) == cur_value) {
 240       // Updated max value so we're done. Otherwise try it all again.
 241       break;
 242     }
 243   }
 244 }
 245 
 246 inline void Threads::add_smr_deleted_thread_times(jint add_value) {
 247   Atomic::add(add_value, &_smr_deleted_thread_times);
 248 }
 249 
 250 inline void Threads::inc_smr_tlh_cnt() {
 251   Atomic::inc(&_smr_tlh_cnt);
 252 }
 253 
 254 inline void Threads::update_smr_tlh_time_max(jint new_value) {
 255   while (true) {
 256     jint cur_value = _smr_tlh_time_max;
 257     if (new_value <= cur_value) {
 258       // No need to update max value so we're done.
 259       break;
 260     }
 261     if (Atomic::cmpxchg(new_value, &_smr_tlh_time_max, cur_value) == cur_value) {
 262       // Updated max value so we're done. Otherwise try it all again.
 263       break;
 264     }
 265   }
 266 }
 267 
 268 inline void Threads::add_smr_tlh_times(jint add_value) {
 269   Atomic::add(add_value, &_smr_tlh_times);
 270 }
 271 
 272 #endif // SHARE_VM_RUNTIME_THREAD_INLINE_HPP


 175 // The release make sure this store is done after storing the handshake
 176 // operation or global state
 177 inline void JavaThread::set_polling_page(void* poll_value) {
 178   OrderAccess::release_store(polling_page_addr(), poll_value);
 179 }
 180 
 181 // The aqcquire make sure reading of polling page is done before
 182 // the reading the handshake operation or the global state
 183 inline volatile void* JavaThread::get_polling_page() {
 184   return OrderAccess::load_acquire(polling_page_addr());
 185 }
 186 
 187 inline bool JavaThread::is_exiting() const {
 188   // Use load-acquire so that setting of _terminated by
 189   // JavaThread::exit() is seen more quickly.
 190   TerminatedTypes l_terminated = (TerminatedTypes)
 191       OrderAccess::load_acquire((volatile jint *) &_terminated);
 192   return l_terminated == _thread_exiting || check_is_terminated(l_terminated);
 193 }
 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 template <class T>
 215 inline void Threads::threads_do_smr(T *tc, Thread *self) {
 216   ThreadsListHandle handle(self);
 217   handle.threads_do(tc);
 218 }
 219 
 220 inline ThreadsList* Threads::get_smr_java_thread_list() {
 221   return (ThreadsList*)OrderAccess::load_acquire(&_smr_java_thread_list);
 222 }
 223 
 224 inline ThreadsList* Threads::xchg_smr_java_thread_list(ThreadsList* new_list) {
 225   return (ThreadsList*)Atomic::xchg(new_list, &_smr_java_thread_list);
 226 }
 227 
 228 inline void Threads::inc_smr_deleted_thread_cnt() {
 229   Atomic::inc(&_smr_deleted_thread_cnt);
 230 }
 231 
 232 inline void Threads::update_smr_deleted_thread_time_max(uint new_value) {
 233   while (true) {
 234     uint cur_value = _smr_deleted_thread_time_max;
 235     if (new_value <= cur_value) {
 236       // No need to update max value so we're done.
 237       break;
 238     }
 239     if (Atomic::cmpxchg(new_value, &_smr_deleted_thread_time_max, cur_value) == cur_value) {
 240       // Updated max value so we're done. Otherwise try it all again.
 241       break;
 242     }
 243   }
 244 }
 245 
 246 inline void Threads::add_smr_deleted_thread_times(uint add_value) {
 247   Atomic::add(add_value, &_smr_deleted_thread_times);
 248 }
 249 
 250 inline void Threads::inc_smr_tlh_cnt() {
 251   Atomic::inc(&_smr_tlh_cnt);
 252 }
 253 
 254 inline void Threads::update_smr_tlh_time_max(uint new_value) {
 255   while (true) {
 256     uint cur_value = _smr_tlh_time_max;
 257     if (new_value <= cur_value) {
 258       // No need to update max value so we're done.
 259       break;
 260     }
 261     if (Atomic::cmpxchg(new_value, &_smr_tlh_time_max, cur_value) == cur_value) {
 262       // Updated max value so we're done. Otherwise try it all again.
 263       break;
 264     }
 265   }
 266 }
 267 
 268 inline void Threads::add_smr_tlh_times(uint add_value) {
 269   Atomic::add(add_value, &_smr_tlh_times);
 270 }
 271 
 272 #endif // SHARE_VM_RUNTIME_THREAD_INLINE_HPP
< prev index next >