< prev index next >

src/hotspot/share/oops/methodCounters.hpp

Print this page




  23  */
  24 
  25 #ifndef SHARE_VM_OOPS_METHODCOUNTERS_HPP
  26 #define SHARE_VM_OOPS_METHODCOUNTERS_HPP
  27 
  28 #include "oops/metadata.hpp"
  29 #include "compiler/compilerOracle.hpp"
  30 #include "interpreter/invocationCounter.hpp"
  31 #include "runtime/arguments.hpp"
  32 #include "utilities/align.hpp"
  33 
  34 class MethodCounters : public Metadata {
  35  friend class VMStructs;
  36  friend class JVMCIVMStructs;
  37  private:
  38   // If you add a new field that points to any metaspace object, you
  39   // must add this field to MethodCounters::metaspace_pointers_do().
  40 #if INCLUDE_AOT
  41   Method*           _method;                     // Back link to Method
  42 #endif
  43 #if defined(COMPILER2) || INCLUDE_JVMCI
  44   int               _interpreter_invocation_count; // Count of times invoked (reused as prev_event_count in tiered)
  45   u2                _interpreter_throwout_count; // Count of times method was exited via exception while interpreting
  46 #endif
  47 #if INCLUDE_JVMTI
  48   u2                _number_of_breakpoints;      // fullspeed debugging support
  49 #endif
  50   InvocationCounter _invocation_counter;         // Incremented before each activation of the method - used to trigger frequency-based optimizations
  51   InvocationCounter _backedge_counter;           // Incremented before each backedge taken - used to trigger frequencey-based optimizations
  52   // NMethod age is a counter for warm methods detection in the code cache sweeper.
  53   // The counter is reset by the sweeper and is decremented by some of the compiled
  54   // code. The counter values are interpreted as follows:
  55   // 1. (HotMethodDetection..INT_MAX] - initial value, no counters inserted
  56   // 2. [1..HotMethodDetectionLimit)  - the method is warm, the counter is used
  57   //                                    to figure out which methods can be flushed.
  58   // 3. (INT_MIN..0]                  - method is hot and will deopt and get
  59   //                                    recompiled without the counters
  60   int               _nmethod_age;
  61   int               _interpreter_invocation_limit;        // per-method InterpreterInvocationLimit
  62   int               _interpreter_backward_branch_limit;   // per-method InterpreterBackwardBranchLimit
  63   int               _interpreter_profile_limit;           // per-method InterpreterProfileLimit


 113 
 114  public:
 115   virtual bool is_methodCounters() const volatile { return true; }
 116 
 117   static MethodCounters* allocate(const methodHandle& mh, TRAPS);
 118 
 119   void deallocate_contents(ClassLoaderData* loader_data) {}
 120 
 121   AOT_ONLY(Method* method() const { return _method; })
 122 
 123   static int method_counters_size() {
 124     return align_up((int)sizeof(MethodCounters), wordSize) / wordSize;
 125   }
 126   virtual int size() const {
 127     return method_counters_size();
 128   }
 129   void metaspace_pointers_do(MetaspaceClosure* it);
 130   MetaspaceObj::Type type() const { return MethodCountersType; }
 131   void clear_counters();
 132 
 133 #if defined(COMPILER2) || INCLUDE_JVMCI
 134 
 135   int interpreter_invocation_count() {
 136     return _interpreter_invocation_count;
 137   }
 138   void set_interpreter_invocation_count(int count) {
 139     _interpreter_invocation_count = count;
 140   }
 141   int increment_interpreter_invocation_count() {
 142     return ++_interpreter_invocation_count;
 143   }
 144 
 145   void interpreter_throwout_increment() {
 146     if (_interpreter_throwout_count < 65534) {
 147       _interpreter_throwout_count++;
 148     }
 149   }
 150   int  interpreter_throwout_count() const {
 151     return _interpreter_throwout_count;
 152   }
 153   void set_interpreter_throwout_count(int count) {
 154     _interpreter_throwout_count = count;
 155   }
 156 
 157 #else // defined(COMPILER2) || INCLUDE_JVMCI
 158 
 159   int interpreter_invocation_count() {
 160     return 0;
 161   }
 162   void set_interpreter_invocation_count(int count) {
 163     assert(count == 0, "count must be 0");
 164   }
 165 
 166   int  interpreter_throwout_count() const {
 167     return 0;
 168   }
 169   void set_interpreter_throwout_count(int count) {
 170     assert(count == 0, "count must be 0");
 171   }
 172 
 173 #endif // defined(COMPILER2) || INCLUDE_JVMCI
 174 
 175 #if INCLUDE_JVMTI
 176   u2   number_of_breakpoints() const   { return _number_of_breakpoints; }
 177   void incr_number_of_breakpoints()    { ++_number_of_breakpoints; }
 178   void decr_number_of_breakpoints()    { --_number_of_breakpoints; }
 179   void clear_number_of_breakpoints()   { _number_of_breakpoints = 0; }
 180 #endif
 181 
 182 #ifdef TIERED
 183   jlong prev_time() const                        { return _prev_time; }
 184   void set_prev_time(jlong time)                 { _prev_time = time; }
 185   float rate() const                             { return _rate; }
 186   void set_rate(float rate)                      { _rate = rate; }
 187 #endif
 188 
 189   int highest_comp_level() const;
 190   void set_highest_comp_level(int level);
 191   int highest_osr_comp_level() const;
 192   void set_highest_osr_comp_level(int level);
 193 


 196   InvocationCounter* backedge_counter()   { return &_backedge_counter; }
 197 
 198   int nmethod_age() {
 199     return _nmethod_age;
 200   }
 201   void set_nmethod_age(int age) {
 202     _nmethod_age = age;
 203   }
 204   void reset_nmethod_age() {
 205     set_nmethod_age(HotMethodDetectionLimit);
 206   }
 207 
 208   static bool is_nmethod_hot(int age)       { return age <= 0; }
 209   static bool is_nmethod_warm(int age)      { return age < HotMethodDetectionLimit; }
 210   static bool is_nmethod_age_unset(int age) { return age > HotMethodDetectionLimit; }
 211 
 212   static ByteSize nmethod_age_offset() {
 213     return byte_offset_of(MethodCounters, _nmethod_age);
 214   }
 215 
 216 #if defined(COMPILER2) || INCLUDE_JVMCI
 217 
 218   static ByteSize interpreter_invocation_counter_offset() {
 219     return byte_offset_of(MethodCounters, _interpreter_invocation_count);
 220   }
 221 
 222   static int interpreter_invocation_counter_offset_in_bytes() {
 223     return offset_of(MethodCounters, _interpreter_invocation_count);
 224   }
 225 
 226 #else // defined(COMPILER2) || INCLUDE_JVMCI
 227 
 228   static ByteSize interpreter_invocation_counter_offset() {
 229     ShouldNotReachHere();
 230     return in_ByteSize(0);
 231   }
 232 
 233 #endif // defined(COMPILER2) || INCLUDE_JVMCI
 234 
 235   static ByteSize invocation_counter_offset()    {
 236     return byte_offset_of(MethodCounters, _invocation_counter);
 237   }
 238 
 239   static ByteSize backedge_counter_offset()      {
 240     return byte_offset_of(MethodCounters, _backedge_counter);
 241   }
 242 
 243   static ByteSize interpreter_invocation_limit_offset() {
 244     return byte_offset_of(MethodCounters, _interpreter_invocation_limit);
 245   }
 246 
 247   static ByteSize interpreter_backward_branch_limit_offset() {
 248     return byte_offset_of(MethodCounters, _interpreter_backward_branch_limit);
 249   }
 250 
 251   static ByteSize interpreter_profile_limit_offset() {
 252     return byte_offset_of(MethodCounters, _interpreter_profile_limit);
 253   }


  23  */
  24 
  25 #ifndef SHARE_VM_OOPS_METHODCOUNTERS_HPP
  26 #define SHARE_VM_OOPS_METHODCOUNTERS_HPP
  27 
  28 #include "oops/metadata.hpp"
  29 #include "compiler/compilerOracle.hpp"
  30 #include "interpreter/invocationCounter.hpp"
  31 #include "runtime/arguments.hpp"
  32 #include "utilities/align.hpp"
  33 
  34 class MethodCounters : public Metadata {
  35  friend class VMStructs;
  36  friend class JVMCIVMStructs;
  37  private:
  38   // If you add a new field that points to any metaspace object, you
  39   // must add this field to MethodCounters::metaspace_pointers_do().
  40 #if INCLUDE_AOT
  41   Method*           _method;                     // Back link to Method
  42 #endif
  43 #if COMPILER2_OR_JVMCI
  44   int               _interpreter_invocation_count; // Count of times invoked (reused as prev_event_count in tiered)
  45   u2                _interpreter_throwout_count; // Count of times method was exited via exception while interpreting
  46 #endif
  47 #if INCLUDE_JVMTI
  48   u2                _number_of_breakpoints;      // fullspeed debugging support
  49 #endif
  50   InvocationCounter _invocation_counter;         // Incremented before each activation of the method - used to trigger frequency-based optimizations
  51   InvocationCounter _backedge_counter;           // Incremented before each backedge taken - used to trigger frequencey-based optimizations
  52   // NMethod age is a counter for warm methods detection in the code cache sweeper.
  53   // The counter is reset by the sweeper and is decremented by some of the compiled
  54   // code. The counter values are interpreted as follows:
  55   // 1. (HotMethodDetection..INT_MAX] - initial value, no counters inserted
  56   // 2. [1..HotMethodDetectionLimit)  - the method is warm, the counter is used
  57   //                                    to figure out which methods can be flushed.
  58   // 3. (INT_MIN..0]                  - method is hot and will deopt and get
  59   //                                    recompiled without the counters
  60   int               _nmethod_age;
  61   int               _interpreter_invocation_limit;        // per-method InterpreterInvocationLimit
  62   int               _interpreter_backward_branch_limit;   // per-method InterpreterBackwardBranchLimit
  63   int               _interpreter_profile_limit;           // per-method InterpreterProfileLimit


 113 
 114  public:
 115   virtual bool is_methodCounters() const volatile { return true; }
 116 
 117   static MethodCounters* allocate(const methodHandle& mh, TRAPS);
 118 
 119   void deallocate_contents(ClassLoaderData* loader_data) {}
 120 
 121   AOT_ONLY(Method* method() const { return _method; })
 122 
 123   static int method_counters_size() {
 124     return align_up((int)sizeof(MethodCounters), wordSize) / wordSize;
 125   }
 126   virtual int size() const {
 127     return method_counters_size();
 128   }
 129   void metaspace_pointers_do(MetaspaceClosure* it);
 130   MetaspaceObj::Type type() const { return MethodCountersType; }
 131   void clear_counters();
 132 
 133 #if COMPILER2_OR_JVMCI
 134 
 135   int interpreter_invocation_count() {
 136     return _interpreter_invocation_count;
 137   }
 138   void set_interpreter_invocation_count(int count) {
 139     _interpreter_invocation_count = count;
 140   }
 141   int increment_interpreter_invocation_count() {
 142     return ++_interpreter_invocation_count;
 143   }
 144 
 145   void interpreter_throwout_increment() {
 146     if (_interpreter_throwout_count < 65534) {
 147       _interpreter_throwout_count++;
 148     }
 149   }
 150   int  interpreter_throwout_count() const {
 151     return _interpreter_throwout_count;
 152   }
 153   void set_interpreter_throwout_count(int count) {
 154     _interpreter_throwout_count = count;
 155   }
 156 
 157 #else // COMPILER2_OR_JVMCI
 158 
 159   int interpreter_invocation_count() {
 160     return 0;
 161   }
 162   void set_interpreter_invocation_count(int count) {
 163     assert(count == 0, "count must be 0");
 164   }
 165 
 166   int  interpreter_throwout_count() const {
 167     return 0;
 168   }
 169   void set_interpreter_throwout_count(int count) {
 170     assert(count == 0, "count must be 0");
 171   }
 172 
 173 #endif // COMPILER2_OR_JVMCI
 174 
 175 #if INCLUDE_JVMTI
 176   u2   number_of_breakpoints() const   { return _number_of_breakpoints; }
 177   void incr_number_of_breakpoints()    { ++_number_of_breakpoints; }
 178   void decr_number_of_breakpoints()    { --_number_of_breakpoints; }
 179   void clear_number_of_breakpoints()   { _number_of_breakpoints = 0; }
 180 #endif
 181 
 182 #ifdef TIERED
 183   jlong prev_time() const                        { return _prev_time; }
 184   void set_prev_time(jlong time)                 { _prev_time = time; }
 185   float rate() const                             { return _rate; }
 186   void set_rate(float rate)                      { _rate = rate; }
 187 #endif
 188 
 189   int highest_comp_level() const;
 190   void set_highest_comp_level(int level);
 191   int highest_osr_comp_level() const;
 192   void set_highest_osr_comp_level(int level);
 193 


 196   InvocationCounter* backedge_counter()   { return &_backedge_counter; }
 197 
 198   int nmethod_age() {
 199     return _nmethod_age;
 200   }
 201   void set_nmethod_age(int age) {
 202     _nmethod_age = age;
 203   }
 204   void reset_nmethod_age() {
 205     set_nmethod_age(HotMethodDetectionLimit);
 206   }
 207 
 208   static bool is_nmethod_hot(int age)       { return age <= 0; }
 209   static bool is_nmethod_warm(int age)      { return age < HotMethodDetectionLimit; }
 210   static bool is_nmethod_age_unset(int age) { return age > HotMethodDetectionLimit; }
 211 
 212   static ByteSize nmethod_age_offset() {
 213     return byte_offset_of(MethodCounters, _nmethod_age);
 214   }
 215 
 216 #if COMPILER2_OR_JVMCI
 217 
 218   static ByteSize interpreter_invocation_counter_offset() {
 219     return byte_offset_of(MethodCounters, _interpreter_invocation_count);
 220   }
 221 
 222   static int interpreter_invocation_counter_offset_in_bytes() {
 223     return offset_of(MethodCounters, _interpreter_invocation_count);
 224   }
 225 
 226 #else // COMPILER2_OR_JVMCI
 227 
 228   static ByteSize interpreter_invocation_counter_offset() {
 229     ShouldNotReachHere();
 230     return in_ByteSize(0);
 231   }
 232 
 233 #endif // COMPILER2_OR_JVMCI
 234 
 235   static ByteSize invocation_counter_offset()    {
 236     return byte_offset_of(MethodCounters, _invocation_counter);
 237   }
 238 
 239   static ByteSize backedge_counter_offset()      {
 240     return byte_offset_of(MethodCounters, _backedge_counter);
 241   }
 242 
 243   static ByteSize interpreter_invocation_limit_offset() {
 244     return byte_offset_of(MethodCounters, _interpreter_invocation_limit);
 245   }
 246 
 247   static ByteSize interpreter_backward_branch_limit_offset() {
 248     return byte_offset_of(MethodCounters, _interpreter_backward_branch_limit);
 249   }
 250 
 251   static ByteSize interpreter_profile_limit_offset() {
 252     return byte_offset_of(MethodCounters, _interpreter_profile_limit);
 253   }
< prev index next >