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();
113 void decr_number_of_breakpoints() { --_number_of_breakpoints; }
114 void clear_number_of_breakpoints() { _number_of_breakpoints = 0; }
115 #endif
116
117 int prev_event_count() const { return _prev_event_count; }
118 void set_prev_event_count(int count) { _prev_event_count = count; }
119 jlong prev_time() const { return _prev_time; }
120 void set_prev_time(jlong time) { _prev_time = time; }
121 float rate() const { return _rate; }
122 void set_rate(float rate) { _rate = rate; }
123
124 int highest_comp_level() const { return _highest_comp_level; }
125 void set_highest_comp_level(int level) { _highest_comp_level = (u1)level; }
126 int highest_osr_comp_level() const { return _highest_osr_comp_level; }
127 void set_highest_osr_comp_level(int level) { _highest_osr_comp_level = (u1)level; }
128
129 // invocation counter
130 InvocationCounter* invocation_counter() { return &_invocation_counter; }
131 InvocationCounter* backedge_counter() { return &_backedge_counter; }
132
133 static ByteSize invocation_counter_offset() {
134 return byte_offset_of(MethodCounters, _invocation_counter);
135 }
136
137 static ByteSize backedge_counter_offset() {
138 return byte_offset_of(MethodCounters, _backedge_counter);
139 }
140
141 static ByteSize invoke_mask_offset() {
142 return byte_offset_of(MethodCounters, _invoke_mask);
143 }
144
145 static ByteSize backedge_mask_offset() {
146 return byte_offset_of(MethodCounters, _backedge_mask);
147 }
148
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
|
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 int64_t _jit_code_invocation_count; // C2 code invocations count during training used as limit for AOT code invocation
49 int _aot_code_invocation_count; // C2 AOT code invocations count
50 int _aot_code_recompile_requested; // Request for JIT compilation to replace AOT code was made
51
52 // Back pointer to the Method*
53 Method* _method;
54
55 Metadata* _method_training_data;
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 COMPILER2_OR_JVMCI
62 u2 _interpreter_throwout_count; // Count of times method was exited via exception while interpreting
63 #endif
64 #if INCLUDE_JVMTI
65 u2 _number_of_breakpoints; // fullspeed debugging support
66 #endif
67 u1 _highest_comp_level; // Highest compile level this method has ever seen.
68 u1 _highest_osr_comp_level; // Same for OSR level
69
70 MethodCounters(const methodHandle& mh);
71 MethodCounters();
117 void decr_number_of_breakpoints() { --_number_of_breakpoints; }
118 void clear_number_of_breakpoints() { _number_of_breakpoints = 0; }
119 #endif
120
121 int prev_event_count() const { return _prev_event_count; }
122 void set_prev_event_count(int count) { _prev_event_count = count; }
123 jlong prev_time() const { return _prev_time; }
124 void set_prev_time(jlong time) { _prev_time = time; }
125 float rate() const { return _rate; }
126 void set_rate(float rate) { _rate = rate; }
127
128 int highest_comp_level() const { return _highest_comp_level; }
129 void set_highest_comp_level(int level) { _highest_comp_level = (u1)level; }
130 int highest_osr_comp_level() const { return _highest_osr_comp_level; }
131 void set_highest_osr_comp_level(int level) { _highest_osr_comp_level = (u1)level; }
132
133 // invocation counter
134 InvocationCounter* invocation_counter() { return &_invocation_counter; }
135 InvocationCounter* backedge_counter() { return &_backedge_counter; }
136
137 int64_t jit_code_invocation_count() const { return _jit_code_invocation_count; }
138 int aot_code_invocation_count() const { return _aot_code_invocation_count;}
139 int aot_code_recompile_requested() const { return _aot_code_recompile_requested;}
140
141 static ByteSize invocation_counter_offset() {
142 return byte_offset_of(MethodCounters, _invocation_counter);
143 }
144
145 static ByteSize backedge_counter_offset() {
146 return byte_offset_of(MethodCounters, _backedge_counter);
147 }
148
149 static ByteSize invoke_mask_offset() {
150 return byte_offset_of(MethodCounters, _invoke_mask);
151 }
152
153 static ByteSize backedge_mask_offset() {
154 return byte_offset_of(MethodCounters, _backedge_mask);
155 }
156
157 static ByteSize jit_code_invocation_counter_offset() {
158 return byte_offset_of(MethodCounters, _jit_code_invocation_count);
159 }
160
161 static ByteSize aot_code_invocation_counter_offset() {
162 return byte_offset_of(MethodCounters, _aot_code_invocation_count);
163 }
164
165 static ByteSize aot_code_recompile_requested_offset() {
166 return byte_offset_of(MethodCounters, _aot_code_recompile_requested);
167 }
168
169 virtual const char* internal_name() const { return "{method counters}"; }
170
171 Metadata* method_training_data_sentinel() {
172 return this;
173 }
174 MethodTrainingData* method_training_data() const {
175 return reinterpret_cast<MethodTrainingData*>(_method_training_data);
176 }
177 bool init_method_training_data(MethodTrainingData* td) {
178 MethodTrainingData* cur = method_training_data();
179 if (cur == td) {
180 return true;
181 }
182 if (cur == nullptr || cur == reinterpret_cast<MethodTrainingData*>(method_training_data_sentinel())) {
183 return AtomicAccess::cmpxchg(reinterpret_cast<MethodTrainingData**>(&_method_training_data), cur, td) == cur;
184 }
185 return false;
186 }
187
188 #if INCLUDE_CDS
|