< prev index next >

src/hotspot/share/oops/methodCounters.hpp

Print this page

 13  * accompanied this code).
 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_OOPS_METHODCOUNTERS_HPP
 26 #define SHARE_OOPS_METHODCOUNTERS_HPP
 27 
 28 #include "compiler/compilerDefinitions.hpp"
 29 #include "interpreter/invocationCounter.hpp"
 30 #include "oops/metadata.hpp"
 31 #include "utilities/align.hpp"
 32 

 33 class MethodTrainingData;
 34 
 35 class MethodCounters : public Metadata {
 36  friend class VMStructs;
 37  friend class JVMCIVMStructs;
 38 
 39  // Used by CDS. These classes need to access the private default constructor.
 40  template <class T> friend class CppVtableTesterA;
 41  template <class T> friend class CppVtableTesterB;
 42  template <class T> friend class CppVtableCloner;
 43 
 44  private:
 45   InvocationCounter _invocation_counter;         // Incremented before each activation of the method - used to trigger frequency-based optimizations
 46   InvocationCounter _backedge_counter;           // Incremented before each backedge taken - used to trigger frequency-based optimizations
 47 
 48   // Back pointer to the Method*
 49   Method* _method;
 50 
 51   Metadata*         _method_training_data;



 52   jlong             _prev_time;                   // Previous time the rate was acquired
 53   float             _rate;                        // Events (invocation and backedge counter increments) per millisecond
 54   int               _invoke_mask;                 // per-method Tier0InvokeNotifyFreqLog
 55   int               _backedge_mask;               // per-method Tier0BackedgeNotifyFreqLog
 56   int               _prev_event_count;            // Total number of events saved at previous callback



 57 #if COMPILER2_OR_JVMCI
 58   u2                _interpreter_throwout_count; // Count of times method was exited via exception while interpreting
 59 #endif
 60 #if INCLUDE_JVMTI
 61   u2                _number_of_breakpoints;      // fullspeed debugging support
 62 #endif
 63   u1                _highest_comp_level;          // Highest compile level this method has ever seen.
 64   u1                _highest_osr_comp_level;      // Same for OSR level
 65 
 66   MethodCounters(const methodHandle& mh);
 67   MethodCounters();
 68 
 69  public:
 70   virtual bool is_methodCounters() const { return true; }
 71   Method* method() const { return _method; }
 72   static MethodCounters* allocate_no_exception(const methodHandle& mh);
 73   static MethodCounters* allocate_with_exception(const methodHandle& mh, TRAPS);
 74 
 75   void deallocate_contents(ClassLoaderData* loader_data) {}
 76 
 77   static int method_counters_size() {
 78     return align_up((int)sizeof(MethodCounters), wordSize) / wordSize;
 79   }
 80   virtual int size() const {
 81     return method_counters_size();
 82   }
 83 
 84   MetaspaceObj::Type type() const { return MethodCountersType; }
 85   void metaspace_pointers_do(MetaspaceClosure* iter);
 86 
 87   void clear_counters();
 88 
 89 #if COMPILER2_OR_JVMCI
 90   void interpreter_throwout_increment() {
 91     if (_interpreter_throwout_count < 65534) {
 92       _interpreter_throwout_count++;
 93     }
 94   }
 95   u2  interpreter_throwout_count() const {

149   virtual const char* internal_name() const { return "{method counters}"; }
150 
151   Metadata* method_training_data_sentinel() {
152     return this;
153   }
154   MethodTrainingData* method_training_data() const {
155     return reinterpret_cast<MethodTrainingData*>(_method_training_data);
156   }
157   bool init_method_training_data(MethodTrainingData* td) {
158     MethodTrainingData* cur = method_training_data();
159     if (cur == td) {
160       return true;
161     }
162     if (cur == nullptr || cur == reinterpret_cast<MethodTrainingData*>(method_training_data_sentinel())) {
163       return AtomicAccess::cmpxchg(reinterpret_cast<MethodTrainingData**>(&_method_training_data), cur, td) == cur;
164     }
165     return false;
166   }
167 
168 #if INCLUDE_CDS













169   void remove_unshareable_info();
170   void restore_unshareable_info(TRAPS);
171 #endif
172 
173   // Printing
174   void print_on      (outputStream* st) const;
175   void print_value_on(outputStream* st) const;
176   void print_data_on(outputStream* st) const;
177 };
178 #endif // SHARE_OOPS_METHODCOUNTERS_HPP

 13  * accompanied this code).
 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_OOPS_METHODCOUNTERS_HPP
 26 #define SHARE_OOPS_METHODCOUNTERS_HPP
 27 
 28 #include "compiler/compilerDefinitions.hpp"
 29 #include "interpreter/invocationCounter.hpp"
 30 #include "oops/metadata.hpp"
 31 #include "utilities/align.hpp"
 32 
 33 class AOTCodeEntry;
 34 class MethodTrainingData;
 35 
 36 class MethodCounters : public Metadata {
 37  friend class VMStructs;
 38  friend class JVMCIVMStructs;
 39 
 40  // Used by CDS. These classes need to access the private default constructor.
 41  template <class T> friend class CppVtableTesterA;
 42  template <class T> friend class CppVtableTesterB;
 43  template <class T> friend class CppVtableCloner;
 44 
 45  private:
 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 frequency-based optimizations
 48 
 49   // Back pointer to the Method*
 50   Method* _method;
 51 
 52   Metadata*         _method_training_data;
 53 #if INCLUDE_CDS
 54   AOTCodeEntry*     _aot_preload_code_entry;      // AOT Code Cache entry for preload code
 55 #endif
 56   jlong             _prev_time;                   // Previous time the rate was acquired
 57   float             _rate;                        // Events (invocation and backedge counter increments) per millisecond
 58   int               _invoke_mask;                 // per-method Tier0InvokeNotifyFreqLog
 59   int               _backedge_mask;               // per-method Tier0BackedgeNotifyFreqLog
 60   int               _prev_event_count;            // Total number of events saved at previous callback
 61 #if INCLUDE_CDS
 62   int               _aot_code_invocation_count;   // AP4 and A4 AOT code invocations count
 63 #endif
 64 #if COMPILER2_OR_JVMCI
 65   u2                _interpreter_throwout_count; // Count of times method was exited via exception while interpreting
 66 #endif
 67 #if INCLUDE_JVMTI
 68   u2                _number_of_breakpoints;      // fullspeed debugging support
 69 #endif
 70   u1                _highest_comp_level;          // Highest compile level this method has ever seen.
 71   u1                _highest_osr_comp_level;      // Same for OSR level
 72 
 73   MethodCounters(const methodHandle& mh);
 74   MethodCounters();
 75 
 76  public:
 77   virtual bool is_methodCounters() const { return true; }
 78   Method* method() const { return _method; }
 79   static MethodCounters* allocate_no_exception(const methodHandle& mh);
 80   static MethodCounters* allocate_with_exception(const methodHandle& mh, TRAPS);
 81 
 82   void deallocate_contents(ClassLoaderData* loader_data) NOT_CDS_RETURN;
 83 
 84   static int method_counters_size() {
 85     return align_up((int)sizeof(MethodCounters), wordSize) / wordSize;
 86   }
 87   virtual int size() const {
 88     return method_counters_size();
 89   }
 90 
 91   MetaspaceObj::Type type() const { return MethodCountersType; }
 92   void metaspace_pointers_do(MetaspaceClosure* iter);
 93 
 94   void clear_counters();
 95 
 96 #if COMPILER2_OR_JVMCI
 97   void interpreter_throwout_increment() {
 98     if (_interpreter_throwout_count < 65534) {
 99       _interpreter_throwout_count++;
100     }
101   }
102   u2  interpreter_throwout_count() const {

156   virtual const char* internal_name() const { return "{method counters}"; }
157 
158   Metadata* method_training_data_sentinel() {
159     return this;
160   }
161   MethodTrainingData* method_training_data() const {
162     return reinterpret_cast<MethodTrainingData*>(_method_training_data);
163   }
164   bool init_method_training_data(MethodTrainingData* td) {
165     MethodTrainingData* cur = method_training_data();
166     if (cur == td) {
167       return true;
168     }
169     if (cur == nullptr || cur == reinterpret_cast<MethodTrainingData*>(method_training_data_sentinel())) {
170       return AtomicAccess::cmpxchg(reinterpret_cast<MethodTrainingData**>(&_method_training_data), cur, td) == cur;
171     }
172     return false;
173   }
174 
175 #if INCLUDE_CDS
176   static ByteSize aot_code_invocation_counter_offset()  {
177     return byte_offset_of(MethodCounters, _aot_code_invocation_count);
178   }
179 
180   int  aot_code_invocation_count() const         { return _aot_code_invocation_count;}
181   void set_aot_code_invocation_count(int count)  { _aot_code_invocation_count = count; }
182   bool aot_code_recompile_requested() const      { return (_aot_code_invocation_count & 1) != 0;}
183 
184   void set_aot_preload_code_entry(AOTCodeEntry* entry);
185   AOTCodeEntry* aot_preload_code_entry() const   {
186     return _aot_preload_code_entry;
187   }
188 
189   void remove_unshareable_info();
190   void restore_unshareable_info(TRAPS);
191 #endif
192 
193   // Printing
194   void print_on      (outputStream* st) const;
195   void print_value_on(outputStream* st) const;
196   void print_data_on(outputStream* st) const;
197 };
198 #endif // SHARE_OOPS_METHODCOUNTERS_HPP
< prev index next >