< prev index next >

src/hotspot/share/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_OOPS_METHODCOUNTERS_HPP
 26 #define SHARE_OOPS_METHODCOUNTERS_HPP
 27 
 28 #include "oops/metadata.hpp"
 29 #include "compiler/compilerDefinitions.hpp"
 30 #include "compiler/compilerOracle.hpp"
 31 #include "interpreter/invocationCounter.hpp"
 32 #include "utilities/align.hpp"
 33 


 34 class MethodCounters : public Metadata {
 35  friend class VMStructs;
 36  friend class JVMCIVMStructs;






 37  private:
 38   InvocationCounter _invocation_counter;         // Incremented before each activation of the method - used to trigger frequency-based optimizations
 39   InvocationCounter _backedge_counter;           // Incremented before each backedge taken - used to trigger frequency-based optimizations
 40   jlong             _prev_time;                   // Previous time the rate was acquired
 41   float             _rate;                        // Events (invocation and backedge counter increments) per millisecond
 42   int               _invoke_mask;                 // per-method Tier0InvokeNotifyFreqLog
 43   int               _backedge_mask;               // per-method Tier0BackedgeNotifyFreqLog
 44   int               _prev_event_count;            // Total number of events saved at previous callback





 45 #if COMPILER2_OR_JVMCI
 46   u2                _interpreter_throwout_count; // Count of times method was exited via exception while interpreting
 47 #endif
 48 #if INCLUDE_JVMTI
 49   u2                _number_of_breakpoints;      // fullspeed debugging support
 50 #endif
 51   u1                _highest_comp_level;          // Highest compile level this method has ever seen.
 52   u1                _highest_osr_comp_level;      // Same for OSR level
 53 
 54   MethodCounters(const methodHandle& mh);


 55  public:
 56   virtual bool is_methodCounters() const { return true; }
 57 


 58   static MethodCounters* allocate_no_exception(const methodHandle& mh);
 59   static MethodCounters* allocate_with_exception(const methodHandle& mh, TRAPS);
 60 
 61   void deallocate_contents(ClassLoaderData* loader_data) {}
 62 
 63   static int method_counters_size() {
 64     return align_up((int)sizeof(MethodCounters), wordSize) / wordSize;
 65   }
 66   virtual int size() const {
 67     return method_counters_size();
 68   }
 69   MetaspaceObj::Type type() const { return MethodCountersType; }


 70   void clear_counters();
 71 
 72 #if COMPILER2_OR_JVMCI
 73   void interpreter_throwout_increment() {
 74     if (_interpreter_throwout_count < 65534) {
 75       _interpreter_throwout_count++;
 76     }
 77   }
 78   u2  interpreter_throwout_count() const {
 79     return _interpreter_throwout_count;
 80   }
 81   void set_interpreter_throwout_count(u2 count) {
 82     _interpreter_throwout_count = count;
 83   }
 84 #else // COMPILER2_OR_JVMCI
 85   u2  interpreter_throwout_count() const {
 86     return 0;
 87   }
 88   void set_interpreter_throwout_count(u2 count) {
 89     assert(count == 0, "count must be 0");

113   InvocationCounter* invocation_counter() { return &_invocation_counter; }
114   InvocationCounter* backedge_counter()   { return &_backedge_counter; }
115 
116   static ByteSize invocation_counter_offset()    {
117     return byte_offset_of(MethodCounters, _invocation_counter);
118   }
119 
120   static ByteSize backedge_counter_offset()      {
121     return byte_offset_of(MethodCounters, _backedge_counter);
122   }
123 
124   static ByteSize invoke_mask_offset() {
125     return byte_offset_of(MethodCounters, _invoke_mask);
126   }
127 
128   static ByteSize backedge_mask_offset() {
129     return byte_offset_of(MethodCounters, _backedge_mask);
130   }
131 
132   virtual const char* internal_name() const { return "{method counters}"; }
133   virtual void print_value_on(outputStream* st) const;
134 















135 };
136 #endif // SHARE_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_OOPS_METHODCOUNTERS_HPP
 26 #define SHARE_OOPS_METHODCOUNTERS_HPP
 27 
 28 #include "oops/metadata.hpp"
 29 #include "compiler/compilerDefinitions.hpp"
 30 #include "compiler/compilerOracle.hpp"
 31 #include "interpreter/invocationCounter.hpp"
 32 #include "utilities/align.hpp"
 33 
 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   MethodTrainingData* _method_training_data;
 53   jlong               _prev_time;                   // Previous time the rate was acquired
 54   float               _rate;                        // Events (invocation and backedge counter increments) per millisecond
 55   int                 _invoke_mask;                 // per-method Tier0InvokeNotifyFreqLog
 56   int                 _backedge_mask;               // per-method Tier0BackedgeNotifyFreqLog
 57   int                 _prev_event_count;            // Total number of events saved at previous callback
 58 #if COMPILER2_OR_JVMCI
 59   u2                  _interpreter_throwout_count; // Count of times method was exited via exception while interpreting
 60 #endif
 61 #if INCLUDE_JVMTI
 62   u2                  _number_of_breakpoints;      // fullspeed debugging support
 63 #endif
 64   u1                  _highest_comp_level;          // Highest compile level this method has ever seen.
 65   u1                  _highest_osr_comp_level;      // Same for OSR level
 66 
 67   MethodCounters(const methodHandle& mh);
 68   MethodCounters();
 69 
 70  public:
 71   virtual bool is_methodCounters() const { return true; }
 72 
 73   Method* method() const { return _method; }
 74 
 75   static MethodCounters* allocate_no_exception(const methodHandle& mh);
 76   static MethodCounters* allocate_with_exception(const methodHandle& mh, TRAPS);
 77 
 78   void deallocate_contents(ClassLoaderData* loader_data) {}
 79 
 80   static int method_counters_size() {
 81     return align_up((int)sizeof(MethodCounters), wordSize) / wordSize;
 82   }
 83   virtual int size() const {
 84     return method_counters_size();
 85   }
 86   MetaspaceObj::Type type() const { return MethodCountersType; }
 87   virtual void metaspace_pointers_do(MetaspaceClosure* iter);
 88 
 89   void clear_counters();
 90 
 91 #if COMPILER2_OR_JVMCI
 92   void interpreter_throwout_increment() {
 93     if (_interpreter_throwout_count < 65534) {
 94       _interpreter_throwout_count++;
 95     }
 96   }
 97   u2  interpreter_throwout_count() const {
 98     return _interpreter_throwout_count;
 99   }
100   void set_interpreter_throwout_count(u2 count) {
101     _interpreter_throwout_count = count;
102   }
103 #else // COMPILER2_OR_JVMCI
104   u2  interpreter_throwout_count() const {
105     return 0;
106   }
107   void set_interpreter_throwout_count(u2 count) {
108     assert(count == 0, "count must be 0");

132   InvocationCounter* invocation_counter() { return &_invocation_counter; }
133   InvocationCounter* backedge_counter()   { return &_backedge_counter; }
134 
135   static ByteSize invocation_counter_offset()    {
136     return byte_offset_of(MethodCounters, _invocation_counter);
137   }
138 
139   static ByteSize backedge_counter_offset()      {
140     return byte_offset_of(MethodCounters, _backedge_counter);
141   }
142 
143   static ByteSize invoke_mask_offset() {
144     return byte_offset_of(MethodCounters, _invoke_mask);
145   }
146 
147   static ByteSize backedge_mask_offset() {
148     return byte_offset_of(MethodCounters, _backedge_mask);
149   }
150 
151   virtual const char* internal_name() const { return "{method counters}"; }

152 
153   MethodTrainingData* method_training_data() const { return _method_training_data; }
154   bool init_method_training_data(MethodTrainingData* tdata) {
155     return (_method_training_data == tdata ||
156             Atomic::replace_if_null(&_method_training_data, tdata));
157   }
158 
159 #if INCLUDE_CDS
160   void remove_unshareable_info();
161   void restore_unshareable_info(TRAPS);
162 #endif
163 
164   // Printing
165   void print_on      (outputStream* st) const;
166   void print_value_on(outputStream* st) const;
167   void print_data_on(outputStream* st) const;
168 };
169 #endif // SHARE_OOPS_METHODCOUNTERS_HPP
< prev index next >