97 * where $i$ is the number of method invocations, $b$ number of backedges and $s$ is the scaling |
97 * where $i$ is the number of method invocations, $b$ number of backedges and $s$ is the scaling |
98 * coefficient that will be discussed further. |
98 * coefficient that will be discussed further. |
99 * The intuition is to equalize the time that is spend profiling each method. |
99 * The intuition is to equalize the time that is spend profiling each method. |
100 * The same predicate is used to control the transition from level 3 to level 4 (C2). It should be |
100 * The same predicate is used to control the transition from level 3 to level 4 (C2). It should be |
101 * noted though that the thresholds are relative. Moreover i and b for the 0->3 transition come |
101 * noted though that the thresholds are relative. Moreover i and b for the 0->3 transition come |
102 * from methodOop and for 3->4 transition they come from MDO (since profiled invocations are |
102 * from Method* and for 3->4 transition they come from MDO (since profiled invocations are |
103 * counted separately). |
103 * counted separately). |
104 * |
104 * |
105 * OSR transitions are controlled simply with b > TierXBackEdgeThreshold * s predicates. |
105 * OSR transitions are controlled simply with b > TierXBackEdgeThreshold * s predicates. |
106 * |
106 * |
107 * - Tier?LoadFeedback options are used to automatically scale the predicates described above depending |
107 * - Tier?LoadFeedback options are used to automatically scale the predicates described above depending |
166 // Predicates also take compiler load into account. |
166 // Predicates also take compiler load into account. |
167 typedef bool (AdvancedThresholdPolicy::*Predicate)(int i, int b, CompLevel cur_level); |
167 typedef bool (AdvancedThresholdPolicy::*Predicate)(int i, int b, CompLevel cur_level); |
168 bool call_predicate(int i, int b, CompLevel cur_level); |
168 bool call_predicate(int i, int b, CompLevel cur_level); |
169 bool loop_predicate(int i, int b, CompLevel cur_level); |
169 bool loop_predicate(int i, int b, CompLevel cur_level); |
170 // Common transition function. Given a predicate determines if a method should transition to another level. |
170 // Common transition function. Given a predicate determines if a method should transition to another level. |
171 CompLevel common(Predicate p, methodOop method, CompLevel cur_level, bool disable_feedback = false); |
171 CompLevel common(Predicate p, Method* method, CompLevel cur_level, bool disable_feedback = false); |
172 // Transition functions. |
172 // Transition functions. |
173 // call_event determines if a method should be compiled at a different |
173 // call_event determines if a method should be compiled at a different |
174 // level with a regular invocation entry. |
174 // level with a regular invocation entry. |
175 CompLevel call_event(methodOop method, CompLevel cur_level); |
175 CompLevel call_event(Method* method, CompLevel cur_level); |
176 // loop_event checks if a method should be OSR compiled at a different |
176 // loop_event checks if a method should be OSR compiled at a different |
177 // level. |
177 // level. |
178 CompLevel loop_event(methodOop method, CompLevel cur_level); |
178 CompLevel loop_event(Method* method, CompLevel cur_level); |
179 // Has a method been long around? |
179 // Has a method been long around? |
180 // We don't remove old methods from the compile queue even if they have |
180 // We don't remove old methods from the compile queue even if they have |
181 // very low activity (see select_task()). |
181 // very low activity (see select_task()). |
182 inline bool is_old(methodOop method); |
182 inline bool is_old(Method* method); |
183 // Was a given method inactive for a given number of milliseconds. |
183 // Was a given method inactive for a given number of milliseconds. |
184 // If it is, we would remove it from the queue (see select_task()). |
184 // If it is, we would remove it from the queue (see select_task()). |
185 inline bool is_stale(jlong t, jlong timeout, methodOop m); |
185 inline bool is_stale(jlong t, jlong timeout, Method* m); |
186 // Compute the weight of the method for the compilation scheduling |
186 // Compute the weight of the method for the compilation scheduling |
187 inline double weight(methodOop method); |
187 inline double weight(Method* method); |
188 // Apply heuristics and return true if x should be compiled before y |
188 // Apply heuristics and return true if x should be compiled before y |
189 inline bool compare_methods(methodOop x, methodOop y); |
189 inline bool compare_methods(Method* x, Method* y); |
190 // Compute event rate for a given method. The rate is the number of event (invocations + backedges) |
190 // Compute event rate for a given method. The rate is the number of event (invocations + backedges) |
191 // per millisecond. |
191 // per millisecond. |
192 inline void update_rate(jlong t, methodOop m); |
192 inline void update_rate(jlong t, Method* m); |
193 // Compute threshold scaling coefficient |
193 // Compute threshold scaling coefficient |
194 inline double threshold_scale(CompLevel level, int feedback_k); |
194 inline double threshold_scale(CompLevel level, int feedback_k); |
195 // If a method is old enough and is still in the interpreter we would want to |
195 // If a method is old enough and is still in the interpreter we would want to |
196 // start profiling without waiting for the compiled method to arrive. This function |
196 // start profiling without waiting for the compiled method to arrive. This function |
197 // determines whether we should do that. |
197 // determines whether we should do that. |
198 inline bool should_create_mdo(methodOop method, CompLevel cur_level); |
198 inline bool should_create_mdo(Method* method, CompLevel cur_level); |
199 // Create MDO if necessary. |
199 // Create MDO if necessary. |
200 void create_mdo(methodHandle mh, JavaThread* thread); |
200 void create_mdo(methodHandle mh, JavaThread* thread); |
201 // Is method profiled enough? |
201 // Is method profiled enough? |
202 bool is_method_profiled(methodOop method); |
202 bool is_method_profiled(Method* method); |
203 |
203 |
204 protected: |
204 protected: |
205 void print_specific(EventType type, methodHandle mh, methodHandle imh, int bci, CompLevel level); |
205 void print_specific(EventType type, methodHandle mh, methodHandle imh, int bci, CompLevel level); |
206 |
206 |
207 void set_start_time(jlong t) { _start_time = t; } |
207 void set_start_time(jlong t) { _start_time = t; } |