src/hotspot/share/runtime/safepoint.hpp
changeset 50966 f939a67fea30
parent 49816 a3e79f97e86b
child 52518 6f18c23b0185
equal deleted inserted replaced
50965:29eaf3feab30 50966:f939a67fea30
    87     SAFEPOINT_CLEANUP_SYSTEM_DICTIONARY_RESIZE,
    87     SAFEPOINT_CLEANUP_SYSTEM_DICTIONARY_RESIZE,
    88     // Leave this one last.
    88     // Leave this one last.
    89     SAFEPOINT_CLEANUP_NUM_TASKS
    89     SAFEPOINT_CLEANUP_NUM_TASKS
    90   };
    90   };
    91 
    91 
    92   typedef struct {
       
    93     float  _time_stamp;                        // record when the current safepoint occurs in seconds
       
    94     int    _vmop_type;                         // type of VM operation triggers the safepoint
       
    95     int    _nof_total_threads;                 // total number of Java threads
       
    96     int    _nof_initial_running_threads;       // total number of initially seen running threads
       
    97     int    _nof_threads_wait_to_block;         // total number of threads waiting for to block
       
    98     int    _nof_threads_hit_page_trap;         // total number of threads hitting the page trap
       
    99     jlong  _time_to_spin;                      // total time in millis spent in spinning
       
   100     jlong  _time_to_wait_to_block;             // total time in millis spent in waiting for to block
       
   101     jlong  _time_to_do_cleanups;               // total time in millis spent in performing cleanups
       
   102     jlong  _time_to_sync;                      // total time in millis spent in getting to _synchronized
       
   103     jlong  _time_to_exec_vmop;                 // total time in millis spent in vm operation itself
       
   104   } SafepointStats;
       
   105 
       
   106  private:
    92  private:
   107   static volatile SynchronizeState _state;     // Threads might read this flag directly, without acquiring the Threads_lock
    93   static volatile SynchronizeState _state;     // Threads might read this flag directly, without acquiring the Threads_lock
   108   static volatile int _waiting_to_block;       // number of threads we are waiting for to block
    94   static volatile int _waiting_to_block;       // number of threads we are waiting for to block
   109   static int _current_jni_active_count;        // Counts the number of active critical natives during the safepoint
    95   static int _current_jni_active_count;        // Counts the number of active critical natives during the safepoint
   110   static int _defer_thr_suspend_loop_count;    // Iterations before blocking VM threads
    96   static int _defer_thr_suspend_loop_count;    // Iterations before blocking VM threads
   116   // increments (at the beginning and end of each safepoint) guarantees
   102   // increments (at the beginning and end of each safepoint) guarantees
   117   // race freedom.
   103   // race freedom.
   118 public:
   104 public:
   119   static volatile int _safepoint_counter;
   105   static volatile int _safepoint_counter;
   120 private:
   106 private:
   121   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
   122 
   109 
   123   // Statistics
   110   // Statistics
   124   static jlong            _safepoint_begin_time;     // time when safepoint begins
       
   125   static SafepointStats*  _safepoint_stats;          // array of SafepointStats struct
       
   126   static int              _cur_stat_index;           // current index to the above array
       
   127   static julong           _safepoint_reasons[];      // safepoint count for each VM op
       
   128   static julong           _coalesced_vmop_count;     // coalesced vmop count
       
   129   static jlong            _max_sync_time;            // maximum sync time in nanos
       
   130   static jlong            _max_vmop_time;            // maximum vm operation time in nanos
       
   131   static float            _ts_of_current_safepoint;  // time stamp of current safepoint in seconds
       
   132 
       
   133   static void begin_statistics(int nof_threads, int nof_running);
   111   static void begin_statistics(int nof_threads, int nof_running);
   134   static void update_statistics_on_spin_end();
   112   static void update_statistics_on_spin_end();
   135   static void update_statistics_on_sync_end(jlong end_time);
   113   static void update_statistics_on_sync_end(jlong end_time);
   136   static void update_statistics_on_cleanup_end(jlong end_time);
   114   static void update_statistics_on_cleanup_end(jlong end_time);
   137   static void end_statistics(jlong end_time);
   115   static void end_statistics(jlong end_time);
   138   static void print_statistics();
   116   static void print_statistics();
   139   inline static void inc_page_trap_count() {
       
   140     Atomic::inc(&_safepoint_stats[_cur_stat_index]._nof_threads_hit_page_trap);
       
   141   }
       
   142 
   117 
   143   // For debug long safepoint
   118   // For debug long safepoint
   144   static void print_safepoint_timeout(SafepointTimeoutReason timeout_reason);
   119   static void print_safepoint_timeout(SafepointTimeoutReason timeout_reason);
   145 
   120 
   146 public:
   121 public:
   190     return _end_of_last_safepoint;
   165     return _end_of_last_safepoint;
   191   }
   166   }
   192   static bool is_cleanup_needed();
   167   static bool is_cleanup_needed();
   193   static void do_cleanup_tasks();
   168   static void do_cleanup_tasks();
   194 
   169 
   195   static void deferred_initialize_stat();
       
   196   static void print_stat_on_exit();
   170   static void print_stat_on_exit();
   197   inline static void inc_vmop_coalesced_count() { _coalesced_vmop_count++; }
   171   inline static void inc_vmop_coalesced_count() { _coalesced_vmop_count++; }
   198 
   172 
   199   static void set_is_at_safepoint()                        { _state = _synchronized; }
   173   static void set_is_at_safepoint()                        { _state = _synchronized; }
   200   static void set_is_not_at_safepoint()                    { _state = _not_synchronized; }
   174   static void set_is_not_at_safepoint()                    { _state = _not_synchronized; }