171 // Set carry flags in the counters (in Method* and MDO). |
171 // Set carry flags in the counters (in Method* and MDO). |
172 inline void handle_counter_overflow(Method* method); |
172 inline void handle_counter_overflow(Method* method); |
173 // Call and loop predicates determine whether a transition to a higher compilation |
173 // Call and loop predicates determine whether a transition to a higher compilation |
174 // level should be performed (pointers to predicate functions are passed to common_TF(). |
174 // level should be performed (pointers to predicate functions are passed to common_TF(). |
175 // Predicates also take compiler load into account. |
175 // Predicates also take compiler load into account. |
176 typedef bool (TieredThresholdPolicy::*Predicate)(int i, int b, CompLevel cur_level, Method* method); |
176 typedef bool (TieredThresholdPolicy::*Predicate)(int i, int b, CompLevel cur_level, const methodHandle& method); |
177 bool call_predicate(int i, int b, CompLevel cur_level, Method* method); |
177 bool call_predicate(int i, int b, CompLevel cur_level, const methodHandle& method); |
178 bool loop_predicate(int i, int b, CompLevel cur_level, Method* method); |
178 bool loop_predicate(int i, int b, CompLevel cur_level, const methodHandle& method); |
179 // Common transition function. Given a predicate determines if a method should transition to another level. |
179 // Common transition function. Given a predicate determines if a method should transition to another level. |
180 CompLevel common(Predicate p, Method* method, CompLevel cur_level, bool disable_feedback = false); |
180 CompLevel common(Predicate p, const methodHandle& method, CompLevel cur_level, bool disable_feedback = false); |
181 // Transition functions. |
181 // Transition functions. |
182 // call_event determines if a method should be compiled at a different |
182 // call_event determines if a method should be compiled at a different |
183 // level with a regular invocation entry. |
183 // level with a regular invocation entry. |
184 CompLevel call_event(Method* method, CompLevel cur_level, JavaThread* thread); |
184 CompLevel call_event(const methodHandle& method, CompLevel cur_level, JavaThread* thread); |
185 // loop_event checks if a method should be OSR compiled at a different |
185 // loop_event checks if a method should be OSR compiled at a different |
186 // level. |
186 // level. |
187 CompLevel loop_event(Method* method, CompLevel cur_level, JavaThread* thread); |
187 CompLevel loop_event(const methodHandle& method, CompLevel cur_level, JavaThread* thread); |
188 void print_counters(const char* prefix, const methodHandle& mh); |
188 void print_counters(const char* prefix, Method* m); |
189 // Has a method been long around? |
189 // Has a method been long around? |
190 // We don't remove old methods from the compile queue even if they have |
190 // We don't remove old methods from the compile queue even if they have |
191 // very low activity (see select_task()). |
191 // very low activity (see select_task()). |
192 inline bool is_old(Method* method); |
192 inline bool is_old(Method* method); |
193 // Was a given method inactive for a given number of milliseconds. |
193 // Was a given method inactive for a given number of milliseconds. |
203 // Compute threshold scaling coefficient |
203 // Compute threshold scaling coefficient |
204 inline double threshold_scale(CompLevel level, int feedback_k); |
204 inline double threshold_scale(CompLevel level, int feedback_k); |
205 // If a method is old enough and is still in the interpreter we would want to |
205 // If a method is old enough and is still in the interpreter we would want to |
206 // start profiling without waiting for the compiled method to arrive. This function |
206 // start profiling without waiting for the compiled method to arrive. This function |
207 // determines whether we should do that. |
207 // determines whether we should do that. |
208 inline bool should_create_mdo(Method* method, CompLevel cur_level); |
208 inline bool should_create_mdo(const methodHandle& method, CompLevel cur_level); |
209 // Create MDO if necessary. |
209 // Create MDO if necessary. |
210 void create_mdo(const methodHandle& mh, JavaThread* thread); |
210 void create_mdo(const methodHandle& mh, JavaThread* thread); |
211 // Is method profiled enough? |
211 // Is method profiled enough? |
212 bool is_method_profiled(Method* method); |
212 bool is_method_profiled(const methodHandle& method); |
213 |
213 |
214 double _increase_threshold_at_ratio; |
214 double _increase_threshold_at_ratio; |
215 |
215 |
216 bool maybe_switch_to_aot(const methodHandle& mh, CompLevel cur_level, CompLevel next_level, JavaThread* thread); |
216 bool maybe_switch_to_aot(const methodHandle& mh, CompLevel cur_level, CompLevel next_level, JavaThread* thread); |
217 |
217 |
219 int c2_count() const { return _c2_count; } |
219 int c2_count() const { return _c2_count; } |
220 void set_c1_count(int x) { _c1_count = x; } |
220 void set_c1_count(int x) { _c1_count = x; } |
221 void set_c2_count(int x) { _c2_count = x; } |
221 void set_c2_count(int x) { _c2_count = x; } |
222 |
222 |
223 enum EventType { CALL, LOOP, COMPILE, REMOVE_FROM_QUEUE, UPDATE_IN_QUEUE, REPROFILE, MAKE_NOT_ENTRANT }; |
223 enum EventType { CALL, LOOP, COMPILE, REMOVE_FROM_QUEUE, UPDATE_IN_QUEUE, REPROFILE, MAKE_NOT_ENTRANT }; |
224 void print_event(EventType type, const methodHandle& mh, const methodHandle& imh, int bci, CompLevel level); |
224 void print_event(EventType type, Method* m, Method* im, int bci, CompLevel level); |
225 // Check if the method can be compiled, change level if necessary |
225 // Check if the method can be compiled, change level if necessary |
226 void compile(const methodHandle& mh, int bci, CompLevel level, JavaThread* thread); |
226 void compile(const methodHandle& mh, int bci, CompLevel level, JavaThread* thread); |
227 // Simple methods are as good being compiled with C1 as C2. |
227 // Simple methods are as good being compiled with C1 as C2. |
228 // This function tells if it's such a function. |
228 // This function tells if it's such a function. |
229 inline static bool is_trivial(Method* method); |
229 inline static bool is_trivial(Method* method); |
230 // Force method to be compiled at CompLevel_simple? |
230 // Force method to be compiled at CompLevel_simple? |
231 inline bool force_comp_at_level_simple(Method* method); |
231 inline bool force_comp_at_level_simple(const methodHandle& method); |
232 |
232 |
233 // Predicate helpers are used by .*_predicate() methods as well as others. |
233 // Predicate helpers are used by .*_predicate() methods as well as others. |
234 // They check the given counter values, multiplied by the scale against the thresholds. |
234 // They check the given counter values, multiplied by the scale against the thresholds. |
235 inline bool call_predicate_helper(Method* method, CompLevel cur_level, int i, int b, double scale); |
235 inline bool call_predicate_helper(const methodHandle& method, CompLevel cur_level, int i, int b, double scale); |
236 inline bool loop_predicate_helper(Method* method, CompLevel cur_level, int i, int b, double scale); |
236 inline bool loop_predicate_helper(const methodHandle& method, CompLevel cur_level, int i, int b, double scale); |
237 |
237 |
238 // Get a compilation level for a given method. |
238 // Get a compilation level for a given method. |
239 static CompLevel comp_level(Method* method); |
239 static CompLevel comp_level(Method* method); |
240 void method_invocation_event(const methodHandle& method, const methodHandle& inlinee, |
240 void method_invocation_event(const methodHandle& method, const methodHandle& inlinee, |
241 CompLevel level, CompiledMethod* nm, JavaThread* thread); |
241 CompLevel level, CompiledMethod* nm, JavaThread* thread); |