src/share/vm/oops/methodCounters.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hs-comp-code-aging Sdiff src/share/vm/oops

src/share/vm/oops/methodCounters.hpp

Print this page




  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_OOPS_METHODCOUNTERS_HPP
  26 #define SHARE_VM_OOPS_METHODCOUNTERS_HPP
  27 
  28 #include "oops/metadata.hpp"
  29 #include "interpreter/invocationCounter.hpp"
  30 
  31 class MethodCounters: public MetaspaceObj {
  32  friend class VMStructs;
  33  private:









  34   int               _interpreter_invocation_count; // Count of times invoked (reused as prev_event_count in tiered)
  35   u2                _interpreter_throwout_count; // Count of times method was exited via exception while interpreting
  36   u2                _number_of_breakpoints;      // fullspeed debugging support
  37   InvocationCounter _invocation_counter;         // Incremented before each activation of the method - used to trigger frequency-based optimizations
  38   InvocationCounter _backedge_counter;           // Incremented before each backedge taken - used to trigger frequencey-based optimizations
  39 
  40 #ifdef TIERED
  41   float             _rate;                        // Events (invocation and backedge counter increments) per millisecond
  42   jlong             _prev_time;                   // Previous time the rate was acquired
  43 #endif
  44 
  45   MethodCounters() : _interpreter_invocation_count(0),

  46                      _interpreter_throwout_count(0),
  47                      _number_of_breakpoints(0)
  48 #ifdef TIERED
  49                    , _rate(0),
  50                      _prev_time(0)
  51 #endif
  52   {
  53     invocation_counter()->init();
  54     backedge_counter()->init();




  55   }
  56 
  57  public:
  58   static MethodCounters* allocate(ClassLoaderData* loader_data, TRAPS);
  59 
  60   void deallocate_contents(ClassLoaderData* loader_data) {}
  61   DEBUG_ONLY(bool on_stack() { return false; })  // for template
  62 
  63   static int size() { return sizeof(MethodCounters) / wordSize; }
  64 
  65   bool is_klass() const { return false; }
  66 
  67   void clear_counters();
  68 
  69   int interpreter_invocation_count() {
  70     return _interpreter_invocation_count;
  71   }
  72   void set_interpreter_invocation_count(int count) {
  73     _interpreter_invocation_count = count;
  74   }


  87   void set_interpreter_throwout_count(int count) {
  88     _interpreter_throwout_count = count;
  89   }
  90 
  91   u2   number_of_breakpoints() const   { return _number_of_breakpoints; }
  92   void incr_number_of_breakpoints()    { ++_number_of_breakpoints; }
  93   void decr_number_of_breakpoints()    { --_number_of_breakpoints; }
  94   void clear_number_of_breakpoints()   { _number_of_breakpoints = 0; }
  95 
  96 #ifdef TIERED
  97   jlong prev_time() const                        { return _prev_time; }
  98   void set_prev_time(jlong time)                 { _prev_time = time; }
  99   float rate() const                             { return _rate; }
 100   void set_rate(float rate)                      { _rate = rate; }
 101 #endif
 102 
 103   // invocation counter
 104   InvocationCounter* invocation_counter() { return &_invocation_counter; }
 105   InvocationCounter* backedge_counter()   { return &_backedge_counter; }
 106 


















 107   static ByteSize interpreter_invocation_counter_offset() {
 108     return byte_offset_of(MethodCounters, _interpreter_invocation_count);
 109   }
 110 
 111   static ByteSize invocation_counter_offset()    {
 112     return byte_offset_of(MethodCounters, _invocation_counter);
 113   }
 114 
 115   static ByteSize backedge_counter_offset()      {
 116     return byte_offset_of(MethodCounters, _backedge_counter);
 117   }
 118 
 119   static int interpreter_invocation_counter_offset_in_bytes() {
 120     return offset_of(MethodCounters, _interpreter_invocation_count);
 121   }
 122 
 123 };
 124 #endif //SHARE_VM_OOPS_METHODCOUNTERS_HPP


  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_OOPS_METHODCOUNTERS_HPP
  26 #define SHARE_VM_OOPS_METHODCOUNTERS_HPP
  27 
  28 #include "oops/metadata.hpp"
  29 #include "interpreter/invocationCounter.hpp"
  30 
  31 class MethodCounters: public MetaspaceObj {
  32  friend class VMStructs;
  33  private:
  34   // NMethod age is a counter for warm methods detection in the code cache sweeper.
  35   // The counter is reset by the sweeper and is decremented by some of the compiled
  36   // code. The counter values are interpreted as follows:
  37   // 1. (HotMethodDetection..INT_MAX] - initial value, no counters inserted
  38   // 2. (1..HotMethodDetectionLimit)  - the method is warm, the counter is used
  39   //                                    to figure out which methods can be flushed.
  40   // 3. (INT_MIN..0]                  - method is hot and will deopt and get
  41   //                                    recompiled without the counters
  42   int               _nmethod_age;
  43   int               _interpreter_invocation_count; // Count of times invoked (reused as prev_event_count in tiered)
  44   u2                _interpreter_throwout_count; // Count of times method was exited via exception while interpreting
  45   u2                _number_of_breakpoints;      // fullspeed debugging support
  46   InvocationCounter _invocation_counter;         // Incremented before each activation of the method - used to trigger frequency-based optimizations
  47   InvocationCounter _backedge_counter;           // Incremented before each backedge taken - used to trigger frequencey-based optimizations
  48 
  49 #ifdef TIERED
  50   float             _rate;                        // Events (invocation and backedge counter increments) per millisecond
  51   jlong             _prev_time;                   // Previous time the rate was acquired
  52 #endif
  53 
  54   MethodCounters() : _nmethod_age(INT_MAX),
  55                      _interpreter_invocation_count(0),
  56                      _interpreter_throwout_count(0),
  57                      _number_of_breakpoints(0)
  58 #ifdef TIERED
  59                    , _rate(0),
  60                      _prev_time(0)
  61 #endif
  62   {
  63     invocation_counter()->init();
  64     backedge_counter()->init();
  65 
  66     if (StressCodeAging) {
  67       set_nmethod_age(HotMethodDetectionLimit);
  68     }
  69   }
  70 
  71  public:
  72   static MethodCounters* allocate(ClassLoaderData* loader_data, TRAPS);
  73 
  74   void deallocate_contents(ClassLoaderData* loader_data) {}
  75   DEBUG_ONLY(bool on_stack() { return false; })  // for template
  76 
  77   static int size() { return sizeof(MethodCounters) / wordSize; }
  78 
  79   bool is_klass() const { return false; }
  80 
  81   void clear_counters();
  82 
  83   int interpreter_invocation_count() {
  84     return _interpreter_invocation_count;
  85   }
  86   void set_interpreter_invocation_count(int count) {
  87     _interpreter_invocation_count = count;
  88   }


 101   void set_interpreter_throwout_count(int count) {
 102     _interpreter_throwout_count = count;
 103   }
 104 
 105   u2   number_of_breakpoints() const   { return _number_of_breakpoints; }
 106   void incr_number_of_breakpoints()    { ++_number_of_breakpoints; }
 107   void decr_number_of_breakpoints()    { --_number_of_breakpoints; }
 108   void clear_number_of_breakpoints()   { _number_of_breakpoints = 0; }
 109 
 110 #ifdef TIERED
 111   jlong prev_time() const                        { return _prev_time; }
 112   void set_prev_time(jlong time)                 { _prev_time = time; }
 113   float rate() const                             { return _rate; }
 114   void set_rate(float rate)                      { _rate = rate; }
 115 #endif
 116 
 117   // invocation counter
 118   InvocationCounter* invocation_counter() { return &_invocation_counter; }
 119   InvocationCounter* backedge_counter()   { return &_backedge_counter; }
 120 
 121   int nmethod_age() {
 122     return _nmethod_age;
 123   }
 124   void set_nmethod_age(int age) {
 125     _nmethod_age = age;
 126   }
 127   void reset_nmethod_age() {
 128     set_nmethod_age(HotMethodDetectionLimit);
 129   }
 130 
 131   static bool is_nmethod_hot(int age)       { return age <= 0; }
 132   static bool is_nmethod_warm(int age)      { return age < HotMethodDetectionLimit; }
 133   static bool is_nmethod_age_unset(int age) { return age > HotMethodDetectionLimit; }
 134   static bool should_nmethod_age(int age);
 135   static ByteSize nmethod_age_offset() {
 136     return byte_offset_of(MethodCounters, _nmethod_age);
 137   }
 138 
 139   static ByteSize interpreter_invocation_counter_offset() {
 140     return byte_offset_of(MethodCounters, _interpreter_invocation_count);
 141   }
 142 
 143   static ByteSize invocation_counter_offset()    {
 144     return byte_offset_of(MethodCounters, _invocation_counter);
 145   }
 146 
 147   static ByteSize backedge_counter_offset()      {
 148     return byte_offset_of(MethodCounters, _backedge_counter);
 149   }
 150 
 151   static int interpreter_invocation_counter_offset_in_bytes() {
 152     return offset_of(MethodCounters, _interpreter_invocation_count);
 153   }
 154 
 155 };
 156 #endif //SHARE_VM_OOPS_METHODCOUNTERS_HPP
src/share/vm/oops/methodCounters.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File