< prev index next >

src/hotspot/share/runtime/safepoint.hpp

Print this page




  61 //
  62 class SafepointSynchronize : AllStatic {
  63  public:
  64   enum SynchronizeState {
  65       _not_synchronized = 0,                   // Threads not synchronized at a safepoint. Keep this value 0.
  66       _synchronizing    = 1,                   // Synchronizing in progress
  67       _synchronized     = 2                    // All Java threads are running in native, blocked in OS or stopped at safepoint.
  68                                                // VM thread and any NonJavaThread may be running.
  69   };
  70 
  71   // The enums are listed in the order of the tasks when done serially.
  72   enum SafepointCleanupTasks {
  73     SAFEPOINT_CLEANUP_DEFLATE_MONITORS,
  74     SAFEPOINT_CLEANUP_UPDATE_INLINE_CACHES,
  75     SAFEPOINT_CLEANUP_COMPILATION_POLICY,
  76     SAFEPOINT_CLEANUP_SYMBOL_TABLE_REHASH,
  77     SAFEPOINT_CLEANUP_STRING_TABLE_REHASH,
  78     SAFEPOINT_CLEANUP_CLD_PURGE,
  79     SAFEPOINT_CLEANUP_SYSTEM_DICTIONARY_RESIZE,
  80     SAFEPOINT_CLEANUP_REQUEST_OOPSTORAGE_CLEANUP,

  81     // Leave this one last.
  82     SAFEPOINT_CLEANUP_NUM_TASKS
  83   };
  84 
  85  private:
  86   friend class SafepointMechanism;
  87   friend class ThreadSafepointState;
  88   friend class HandshakeState;
  89   friend class SafepointStateTracker;
  90 
  91   // Threads might read this flag directly, without acquiring the Threads_lock:
  92   static volatile SynchronizeState _state;
  93   // Number of threads we are waiting for to block:
  94   static int              _waiting_to_block;
  95   // Counts the number of active critical natives during the safepoint:
  96   static int              _current_jni_active_count;
  97 
  98   // This counter is used for fast versions of jni_Get<Primitive>Field.
  99   // An even value means there are no ongoing safepoint operations.
 100   // The counter is incremented ONLY at the beginning and end of each


 126   // Helper methods for safepoint procedure:
 127   static void arm_safepoint();
 128   static int synchronize_threads(jlong safepoint_limit_time, int nof_threads, int* initial_running);
 129   static void disarm_safepoint();
 130   static void increment_jni_active_count();
 131   static void decrement_waiting_to_block();
 132   static bool thread_not_running(ThreadSafepointState *cur_state);
 133 
 134   // Used in safepoint_safe to do a stable load of the thread state.
 135   static bool try_stable_load_state(JavaThreadState *state,
 136                                     JavaThread *thread,
 137                                     uint64_t safepoint_count);
 138 
 139   // Called when a thread voluntarily blocks
 140   static void block(JavaThread *thread);
 141 
 142   // Called from VMThread during handshakes.
 143   // If true the VMThread may safely process the handshake operation for the JavaThread.
 144   static bool handshake_safe(JavaThread *thread);
 145 
 146   static uint64_t safepoint_counter()             { return _safepoint_counter; }
 147 
 148 public:


 149 
 150   static void init(Thread* vmthread);
 151 
 152   // Roll all threads forward to safepoint. Must be called by the VMThread.
 153   static void begin();
 154   static void end();                    // Start all suspended threads again...
 155 
 156   // The value for a not set safepoint id.
 157   static const uint64_t InactiveSafepointCounter;
 158 
 159   // Query
 160   static bool is_at_safepoint()                   { return _state == _synchronized; }
 161   static bool is_synchronizing()                  { return _state == _synchronizing; }
 162 
 163   static uint64_t safepoint_id() {
 164     return _safepoint_id;
 165   }
 166 
 167   static SafepointStateTracker safepoint_state_tracker() {
 168     return SafepointStateTracker(safepoint_id(), is_at_safepoint());




  61 //
  62 class SafepointSynchronize : AllStatic {
  63  public:
  64   enum SynchronizeState {
  65       _not_synchronized = 0,                   // Threads not synchronized at a safepoint. Keep this value 0.
  66       _synchronizing    = 1,                   // Synchronizing in progress
  67       _synchronized     = 2                    // All Java threads are running in native, blocked in OS or stopped at safepoint.
  68                                                // VM thread and any NonJavaThread may be running.
  69   };
  70 
  71   // The enums are listed in the order of the tasks when done serially.
  72   enum SafepointCleanupTasks {
  73     SAFEPOINT_CLEANUP_DEFLATE_MONITORS,
  74     SAFEPOINT_CLEANUP_UPDATE_INLINE_CACHES,
  75     SAFEPOINT_CLEANUP_COMPILATION_POLICY,
  76     SAFEPOINT_CLEANUP_SYMBOL_TABLE_REHASH,
  77     SAFEPOINT_CLEANUP_STRING_TABLE_REHASH,
  78     SAFEPOINT_CLEANUP_CLD_PURGE,
  79     SAFEPOINT_CLEANUP_SYSTEM_DICTIONARY_RESIZE,
  80     SAFEPOINT_CLEANUP_REQUEST_OOPSTORAGE_CLEANUP,
  81     SAFEPOINT_CLEANUP_KEEPALIVES,
  82     // Leave this one last.
  83     SAFEPOINT_CLEANUP_NUM_TASKS
  84   };
  85 
  86  private:
  87   friend class SafepointMechanism;
  88   friend class ThreadSafepointState;
  89   friend class HandshakeState;
  90   friend class SafepointStateTracker;
  91 
  92   // Threads might read this flag directly, without acquiring the Threads_lock:
  93   static volatile SynchronizeState _state;
  94   // Number of threads we are waiting for to block:
  95   static int              _waiting_to_block;
  96   // Counts the number of active critical natives during the safepoint:
  97   static int              _current_jni_active_count;
  98 
  99   // This counter is used for fast versions of jni_Get<Primitive>Field.
 100   // An even value means there are no ongoing safepoint operations.
 101   // The counter is incremented ONLY at the beginning and end of each


 127   // Helper methods for safepoint procedure:
 128   static void arm_safepoint();
 129   static int synchronize_threads(jlong safepoint_limit_time, int nof_threads, int* initial_running);
 130   static void disarm_safepoint();
 131   static void increment_jni_active_count();
 132   static void decrement_waiting_to_block();
 133   static bool thread_not_running(ThreadSafepointState *cur_state);
 134 
 135   // Used in safepoint_safe to do a stable load of the thread state.
 136   static bool try_stable_load_state(JavaThreadState *state,
 137                                     JavaThread *thread,
 138                                     uint64_t safepoint_count);
 139 
 140   // Called when a thread voluntarily blocks
 141   static void block(JavaThread *thread);
 142 
 143   // Called from VMThread during handshakes.
 144   // If true the VMThread may safely process the handshake operation for the JavaThread.
 145   static bool handshake_safe(JavaThread *thread);
 146 


 147 public:
 148 
 149   static uint64_t safepoint_counter()             { return _safepoint_counter; }
 150 
 151   static void init(Thread* vmthread);
 152 
 153   // Roll all threads forward to safepoint. Must be called by the VMThread.
 154   static void begin();
 155   static void end();                    // Start all suspended threads again...
 156 
 157   // The value for a not set safepoint id.
 158   static const uint64_t InactiveSafepointCounter;
 159 
 160   // Query
 161   static bool is_at_safepoint()                   { return _state == _synchronized; }
 162   static bool is_synchronizing()                  { return _state == _synchronizing; }
 163 
 164   static uint64_t safepoint_id() {
 165     return _safepoint_id;
 166   }
 167 
 168   static SafepointStateTracker safepoint_state_tracker() {
 169     return SafepointStateTracker(safepoint_id(), is_at_safepoint());


< prev index next >