< prev index next >

src/hotspot/share/runtime/safepoint.hpp

Print this page

 60 // Implements roll-forward to safepoint (safepoint synchronization)
 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_LAZY_ROOT_PROCESSING,
 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_SYSTEM_DICTIONARY_RESIZE,
 79     SAFEPOINT_CLEANUP_REQUEST_OOPSTORAGE_CLEANUP,

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

127                                     uint64_t safepoint_count);
128 
129   static bool is_a_block_safe_state(JavaThreadState state) {
130     // Check that we have a valid thread_state before blocking for safepoints
131     switch(state) {
132       case _thread_in_vm:
133       case _thread_in_Java:        // From compiled code
134       case _thread_blocked_trans:
135         return true;
136       default:
137         return false;
138     }
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   static uint64_t safepoint_counter()             { return _safepoint_counter; }
148 
149 public:
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());
170   }

 60 // Implements roll-forward to safepoint (safepoint synchronization)
 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_LAZY_ROOT_PROCESSING,
 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_SYSTEM_DICTIONARY_RESIZE,
 79     SAFEPOINT_CLEANUP_REQUEST_OOPSTORAGE_CLEANUP,
 80     SAFEPOINT_CLEANUP_KEEPALIVES,
 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

128                                     uint64_t safepoint_count);
129 
130   static bool is_a_block_safe_state(JavaThreadState state) {
131     // Check that we have a valid thread_state before blocking for safepoints
132     switch(state) {
133       case _thread_in_vm:
134       case _thread_in_Java:        // From compiled code
135       case _thread_blocked_trans:
136         return true;
137       default:
138         return false;
139     }
140   }
141   // Called when a thread voluntarily blocks
142   static void block(JavaThread *thread);
143 
144   // Called from VMThread during handshakes.
145   // If true the VMThread may safely process the handshake operation for the JavaThread.
146   static bool handshake_safe(JavaThread *thread);
147 


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