< prev index next >

src/hotspot/share/runtime/threadSMR.hpp

Print this page
rev 54717 : imported patch 8223306


  69 //   oop thread_obj = ...;
  70 //   :
  71 //   JavaThread *jt = NULL;
  72 //   ThreadsListHandle tlh;
  73 //   jvmtiError err = JvmtiExport::cv_oop_to_JavaThread(tlh.list(), thread_obj, &jt);
  74 //   if (err != JVMTI_ERROR_NONE) {
  75 //     return err;
  76 //   }
  77 //   :  // do stuff with 'jt'...
  78 //
  79 // A JavaThread * that is included in the ThreadsList that is held by
  80 // a ThreadsListHandle is protected as long as the ThreadsListHandle
  81 // remains in scope. The target JavaThread * may have logically exited,
  82 // but that target JavaThread * will not be deleted until it is no
  83 // longer protected by a ThreadsListHandle.
  84 
  85 
  86 // SMR Support for the Threads class.
  87 //
  88 class ThreadsSMRSupport : AllStatic {

  89   friend class SafeThreadsListPtr;  // for _nested_thread_list_max, delete_notify(), release_stable_list_wake_up() access
  90 
  91   // The coordination between ThreadsSMRSupport::release_stable_list() and
  92   // ThreadsSMRSupport::smr_delete() uses the delete_lock in order to
  93   // reduce the traffic on the Threads_lock.
  94   static Monitor* delete_lock() { return ThreadsSMRDelete_lock; }
  95 
  96   // The '_cnt', '_max' and '_times" fields are enabled via
  97   // -XX:+EnableThreadSMRStatistics (see thread.cpp for a
  98   // description about each field):
  99   static uint                  _delete_lock_wait_cnt;
 100   static uint                  _delete_lock_wait_max;
 101   // The delete_notify flag is used for proper double-check
 102   // locking in order to reduce the traffic on the system wide
 103   // Thread-SMR delete_lock.
 104   static volatile uint         _delete_notify;
 105   static volatile uint         _deleted_thread_cnt;
 106   static volatile uint         _deleted_thread_time_max;
 107   static volatile uint         _deleted_thread_times;
 108   static ThreadsList           _bootstrap_list;


 141 
 142  public:
 143   static void add_thread(JavaThread *thread);
 144   static ThreadsList* get_java_thread_list();
 145   static bool is_a_protected_JavaThread_with_lock(JavaThread *thread);
 146   static bool is_bootstrap_list(ThreadsList* list);
 147   static void remove_thread(JavaThread *thread);
 148   static void smr_delete(JavaThread *thread);
 149   static void update_tlh_stats(uint millis);
 150 
 151   // Logging and printing support:
 152   static void log_statistics();
 153   static void print_info_elements_on(outputStream* st, ThreadsList* t_list);
 154   static void print_info_on(outputStream* st);
 155   static void print_info_on(const Thread* thread, outputStream* st);
 156 };
 157 
 158 // A fast list of JavaThreads.
 159 //
 160 class ThreadsList : public CHeapObj<mtThread> {

 161   friend class SafeThreadsListPtr;  // for {dec,inc}_nested_handle_cnt() access
 162   friend class ThreadsSMRSupport;  // for _nested_handle_cnt, {add,remove}_thread(), {,set_}next_list() access
 163 
 164   const uint _length;
 165   ThreadsList* _next_list;
 166   JavaThread *const *const _threads;
 167   volatile intx _nested_handle_cnt;
 168 
 169   template <class T>
 170   void threads_do_dispatch(T *cl, JavaThread *const thread) const;
 171 
 172   ThreadsList *next_list() const        { return _next_list; }
 173   void set_next_list(ThreadsList *list) { _next_list = list; }
 174 
 175   void inc_nested_handle_cnt();
 176   void dec_nested_handle_cnt();
 177 
 178   static ThreadsList* add_thread(ThreadsList* list, JavaThread* java_thread);
 179   static ThreadsList* remove_thread(ThreadsList* list, JavaThread* java_thread);
 180 




  69 //   oop thread_obj = ...;
  70 //   :
  71 //   JavaThread *jt = NULL;
  72 //   ThreadsListHandle tlh;
  73 //   jvmtiError err = JvmtiExport::cv_oop_to_JavaThread(tlh.list(), thread_obj, &jt);
  74 //   if (err != JVMTI_ERROR_NONE) {
  75 //     return err;
  76 //   }
  77 //   :  // do stuff with 'jt'...
  78 //
  79 // A JavaThread * that is included in the ThreadsList that is held by
  80 // a ThreadsListHandle is protected as long as the ThreadsListHandle
  81 // remains in scope. The target JavaThread * may have logically exited,
  82 // but that target JavaThread * will not be deleted until it is no
  83 // longer protected by a ThreadsListHandle.
  84 
  85 
  86 // SMR Support for the Threads class.
  87 //
  88 class ThreadsSMRSupport : AllStatic {
  89   friend class VMStructs;
  90   friend class SafeThreadsListPtr;  // for _nested_thread_list_max, delete_notify(), release_stable_list_wake_up() access
  91 
  92   // The coordination between ThreadsSMRSupport::release_stable_list() and
  93   // ThreadsSMRSupport::smr_delete() uses the delete_lock in order to
  94   // reduce the traffic on the Threads_lock.
  95   static Monitor* delete_lock() { return ThreadsSMRDelete_lock; }
  96 
  97   // The '_cnt', '_max' and '_times" fields are enabled via
  98   // -XX:+EnableThreadSMRStatistics (see thread.cpp for a
  99   // description about each field):
 100   static uint                  _delete_lock_wait_cnt;
 101   static uint                  _delete_lock_wait_max;
 102   // The delete_notify flag is used for proper double-check
 103   // locking in order to reduce the traffic on the system wide
 104   // Thread-SMR delete_lock.
 105   static volatile uint         _delete_notify;
 106   static volatile uint         _deleted_thread_cnt;
 107   static volatile uint         _deleted_thread_time_max;
 108   static volatile uint         _deleted_thread_times;
 109   static ThreadsList           _bootstrap_list;


 142 
 143  public:
 144   static void add_thread(JavaThread *thread);
 145   static ThreadsList* get_java_thread_list();
 146   static bool is_a_protected_JavaThread_with_lock(JavaThread *thread);
 147   static bool is_bootstrap_list(ThreadsList* list);
 148   static void remove_thread(JavaThread *thread);
 149   static void smr_delete(JavaThread *thread);
 150   static void update_tlh_stats(uint millis);
 151 
 152   // Logging and printing support:
 153   static void log_statistics();
 154   static void print_info_elements_on(outputStream* st, ThreadsList* t_list);
 155   static void print_info_on(outputStream* st);
 156   static void print_info_on(const Thread* thread, outputStream* st);
 157 };
 158 
 159 // A fast list of JavaThreads.
 160 //
 161 class ThreadsList : public CHeapObj<mtThread> {
 162   friend class VMStructs;
 163   friend class SafeThreadsListPtr;  // for {dec,inc}_nested_handle_cnt() access
 164   friend class ThreadsSMRSupport;  // for _nested_handle_cnt, {add,remove}_thread(), {,set_}next_list() access
 165 
 166   const uint _length;
 167   ThreadsList* _next_list;
 168   JavaThread *const *const _threads;
 169   volatile intx _nested_handle_cnt;
 170 
 171   template <class T>
 172   void threads_do_dispatch(T *cl, JavaThread *const thread) const;
 173 
 174   ThreadsList *next_list() const        { return _next_list; }
 175   void set_next_list(ThreadsList *list) { _next_list = list; }
 176 
 177   void inc_nested_handle_cnt();
 178   void dec_nested_handle_cnt();
 179 
 180   static ThreadsList* add_thread(ThreadsList* list, JavaThread* java_thread);
 181   static ThreadsList* remove_thread(ThreadsList* list, JavaThread* java_thread);
 182 


< prev index next >