hotspot/src/share/vm/runtime/safepoint.hpp
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 1 489c9b5090e2
child 5042 f86707fd195a
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1997-2007 Sun Microsystems, Inc.  All Rights Reserved.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
// Safepoint synchronization
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
////
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
// The VMThread or CMS_thread uses the SafepointSynchronize::begin/end
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
// methods to enter/exit a safepoint region. The begin method will roll
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
// all JavaThreads forward to a safepoint.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
// JavaThreads must use the ThreadSafepointState abstraction (defined in
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// thread.hpp) to indicate that that they are at a safepoint.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
// The Mutex/Condition variable and ObjectLocker classes calls the enter/
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
// exit safepoint methods, when a thread is blocked/restarted. Hence, all mutex exter/
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
// exit points *must* be at a safepoint.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
class ThreadSafepointState;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
class SnippetCache;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
class nmethod;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
// Implements roll-forward to safepoint (safepoint synchronization)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
class SafepointSynchronize : AllStatic {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  enum SynchronizeState {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
      _not_synchronized = 0,                   // Threads not synchronized at a safepoint
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
                                               // Keep this value 0. See the coment in do_call_back()
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
      _synchronizing    = 1,                   // Synchronizing in progress
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
      _synchronized     = 2                    // All Java threads are stopped at a safepoint. Only VM thread is running
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  enum SafepointingThread {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
      _null_thread  = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
      _vm_thread    = 1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
      _other_thread = 2
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  enum SafepointTimeoutReason {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
    _spinning_timeout = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
    _blocking_timeout = 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  typedef struct {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    int    _vmop_type;                         // type of VM operation triggers the safepoint
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
    int    _nof_total_threads;                 // total number of Java threads
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
    int    _nof_initial_running_threads;       // total number of initially seen running threads
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
    int    _nof_threads_wait_to_block;         // total number of threads waiting for to block
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
    bool   _page_armed;                        // true if polling page is armed, false otherwise
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
    int    _nof_threads_hit_page_trap;         // total number of threads hitting the page trap
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
    jlong  _time_to_spin;                      // total time in millis spent in spinning
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
    jlong  _time_to_wait_to_block;             // total time in millis spent in waiting for to block
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
    jlong  _time_to_sync;                      // total time in millis spent in getting to _synchronized
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
    jlong  _time_to_exec_vmop;                 // total time in millis spent in vm operation itself
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
    jlong  _time_elapsed_since_last_safepoint; // time elasped since last safepoint
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  } SafepointStats;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  static volatile SynchronizeState _state;     // Threads might read this flag directly, without acquireing the Threads_lock
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  static volatile int _waiting_to_block;       // No. of threads we are waiting for to block.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  // This counter is used for fast versions of jni_Get<Primitive>Field.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  // An even value means there is no ongoing safepoint operations.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  // The counter is incremented ONLY at the beginning and end of each
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  // safepoint. The fact that Threads_lock is held throughout each pair of
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  // increments (at the beginning and end of each safepoint) guarantees
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  // race freedom.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  static volatile int _safepoint_counter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  static jlong   _last_safepoint;      // Time of last safepoint
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  // statistics
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  static SafepointStats*  _safepoint_stats;     // array of SafepointStats struct
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  static int              _cur_stat_index;      // current index to the above array
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  static julong           _safepoint_reasons[]; // safepoint count for each VM op
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  static julong           _coalesced_vmop_count;// coalesced vmop count
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  static jlong            _max_sync_time;       // maximum sync time in nanos
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  static void begin_statistics(int nof_threads, int nof_running);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  static void update_statistics_on_spin_end();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  static void update_statistics_on_sync_end(jlong end_time);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  static void end_statistics(jlong end_time);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  static void print_statistics();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  inline static void inc_page_trap_count() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    Atomic::inc(&_safepoint_stats[_cur_stat_index]._nof_threads_hit_page_trap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  // For debug long safepoint
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  static void print_safepoint_timeout(SafepointTimeoutReason timeout_reason);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  // Main entry points
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  // Roll all threads forward to safepoint. Must be called by the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  // VMThread or CMS_thread.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  static void begin();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  static void end();                    // Start all suspended threads again...
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  static bool safepoint_safe(JavaThread *thread, JavaThreadState state);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  // Query
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  inline static bool is_at_safepoint()   { return _state == _synchronized;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  inline static bool is_synchronizing()  { return _state == _synchronizing;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  inline static bool do_call_back() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
    return (_state != _not_synchronized);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  // Called when a thread volantary blocks
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  static void   block(JavaThread *thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  static void   signal_thread_at_safepoint()              { _waiting_to_block--; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  // Exception handling for page polling
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  static void handle_polling_page_exception(JavaThread *thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  // VM Thread interface for determining safepoint rate
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  static long last_non_safepoint_interval()               { return os::javaTimeMillis() - _last_safepoint; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  static bool is_cleanup_needed();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  static void do_cleanup_tasks();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  // debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  static void print_state()                                PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  static void safepoint_msg(const char* format, ...)       PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  static void deferred_initialize_stat();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  static void print_stat_on_exit();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  inline static void inc_vmop_coalesced_count() { _coalesced_vmop_count++; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  static void set_is_at_safepoint()                        { _state = _synchronized; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  static void set_is_not_at_safepoint()                    { _state = _not_synchronized; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  // assembly support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  static address address_of_state()                        { return (address)&_state; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  static address safepoint_counter_addr()                  { return (address)&_safepoint_counter; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
// State class for a thread suspended at a safepoint
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
class ThreadSafepointState: public CHeapObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  // These states are maintained by VM thread while threads are being brought
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  // to a safepoint.  After SafepointSynchronize::end(), they are reset to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  // _running.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  enum suspend_type {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
    _running                =  0, // Thread state not yet determined (i.e., not at a safepoint yet)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
    _at_safepoint           =  1, // Thread at a safepoint (f.ex., when blocked on a lock)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
    _call_back              =  2  // Keep executing and wait for callback (if thread is in interpreted or vm)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  volatile bool _at_poll_safepoint;  // At polling page safepoint (NOT a poll return safepoint)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  // Thread has called back the safepoint code (for debugging)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  bool                           _has_called_back;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  JavaThread *                   _thread;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  volatile suspend_type          _type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  ThreadSafepointState(JavaThread *thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  // examine/roll-forward/restart
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  void examine_state_of_thread();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  void roll_forward(suspend_type type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  void restart();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  // Query
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  JavaThread*  thread() const         { return _thread; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  suspend_type type() const           { return _type; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  bool         is_running() const     { return (_type==_running); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  // Support for safepoint timeout (debugging)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  bool has_called_back() const                   { return _has_called_back; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  void set_has_called_back(bool val)             { _has_called_back = val; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  bool              is_at_poll_safepoint() { return _at_poll_safepoint; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  void              set_at_poll_safepoint(bool val) { _at_poll_safepoint = val; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  void handle_polling_page_exception();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  // debugging
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  void print_on(outputStream* st) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  void print() const                        { print_on(tty); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  // Initialize
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  static void create(JavaThread *thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  static void destroy(JavaThread *thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  void safepoint_msg(const char* format, ...) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
    if (ShowSafepointMsgs) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
      va_list ap;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
      va_start(ap, format);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
      tty->vprint_cr(format, ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
      va_end(ap);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
// CounterDecay
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
// Interates through invocation counters and decrements them. This
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
// is done at each safepoint.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
class CounterDecay : public AllStatic {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  static jlong _last_timestamp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  static  void decay();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  static  bool is_decay_needed() { return (os::javaTimeMillis() - _last_timestamp) > CounterDecayMinIntervalLength; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
};