src/hotspot/share/runtime/safepoint.hpp
changeset 52672 bbfa1b3aaf7e
parent 52518 6f18c23b0185
child 52673 61b3b58a1d1d
equal deleted inserted replaced
52671:600fca45232b 52672:bbfa1b3aaf7e
    99   // An even value means there is no ongoing safepoint operations.
    99   // An even value means there is no ongoing safepoint operations.
   100   // The counter is incremented ONLY at the beginning and end of each
   100   // The counter is incremented ONLY at the beginning and end of each
   101   // safepoint. The fact that Threads_lock is held throughout each pair of
   101   // safepoint. The fact that Threads_lock is held throughout each pair of
   102   // increments (at the beginning and end of each safepoint) guarantees
   102   // increments (at the beginning and end of each safepoint) guarantees
   103   // race freedom.
   103   // race freedom.
   104 public:
   104   static volatile uint64_t _safepoint_counter;
   105   static volatile int _safepoint_counter;
   105 
   106 private:
   106 private:
   107   static long         _end_of_last_safepoint;     // Time of last safepoint in milliseconds
   107   static long              _end_of_last_safepoint;     // Time of last safepoint in milliseconds
   108   static julong       _coalesced_vmop_count;     // coalesced vmop count
   108   static julong            _coalesced_vmop_count;     // coalesced vmop count
   109 
   109 
   110   // Statistics
   110   // Statistics
   111   static void begin_statistics(int nof_threads, int nof_running);
   111   static void begin_statistics(int nof_threads, int nof_running);
   112   static void update_statistics_on_spin_end();
   112   static void update_statistics_on_spin_end();
   113   static void update_statistics_on_sync_end(jlong end_time);
   113   static void update_statistics_on_sync_end(jlong end_time);
   130   static bool safepoint_safe(JavaThread *thread, JavaThreadState state);
   130   static bool safepoint_safe(JavaThread *thread, JavaThreadState state);
   131 
   131 
   132   static void check_for_lazy_critical_native(JavaThread *thread, JavaThreadState state);
   132   static void check_for_lazy_critical_native(JavaThread *thread, JavaThreadState state);
   133 
   133 
   134   // Query
   134   // Query
   135   inline static bool is_at_safepoint()   { return _state == _synchronized;  }
   135   inline static bool is_at_safepoint()       { return _state == _synchronized; }
   136   inline static bool is_synchronizing()  { return _state == _synchronizing;  }
   136   inline static bool is_synchronizing()      { return _state == _synchronizing; }
   137   inline static int safepoint_counter()  { return _safepoint_counter; }
   137   inline static uint64_t safepoint_counter() { return _safepoint_counter; }
   138 
   138 
   139   inline static void increment_jni_active_count() {
   139   inline static void increment_jni_active_count() {
   140     assert_locked_or_safepoint(Safepoint_lock);
   140     assert_locked_or_safepoint(Safepoint_lock);
   141     _current_jni_active_count++;
   141     _current_jni_active_count++;
   142   }
   142   }
   174   static void set_is_not_at_safepoint()                    { _state = _not_synchronized; }
   174   static void set_is_not_at_safepoint()                    { _state = _not_synchronized; }
   175 
   175 
   176   // Assembly support
   176   // Assembly support
   177   static address address_of_state()                        { return (address)&_state; }
   177   static address address_of_state()                        { return (address)&_state; }
   178 
   178 
   179   static address safepoint_counter_addr()                  { return (address)&_safepoint_counter; }
   179   // Only used for making sure that no safepoint has happened in
   180 
   180   // JNI_FastGetField. Therefore only the low 32-bits are needed
       
   181   // even if this is a 64-bit counter.
       
   182   static address safepoint_counter_addr() {
       
   183 #ifdef VM_LITTLE_ENDIAN
       
   184     return (address)&_safepoint_counter;
       
   185 #else /* BIG */
       
   186     // Return pointer to the 32 LSB:
       
   187     return (address) (((uint32_t*)(&_safepoint_counter)) + 1);
       
   188 #endif
       
   189   }
   181 };
   190 };
   182 
   191 
   183 // Some helper assert macros for safepoint checks.
   192 // Some helper assert macros for safepoint checks.
   184 
   193 
   185 #define assert_at_safepoint()                                           \
   194 #define assert_at_safepoint()                                           \