41 #ifdef TIERED |
41 #ifdef TIERED |
42 |
42 |
43 #include "c1/c1_Compiler.hpp" |
43 #include "c1/c1_Compiler.hpp" |
44 #include "opto/c2compiler.hpp" |
44 #include "opto/c2compiler.hpp" |
45 |
45 |
46 bool TieredThresholdPolicy::call_predicate_helper(Method* method, CompLevel cur_level, int i, int b, double scale) { |
46 bool TieredThresholdPolicy::call_predicate_helper(const methodHandle& method, CompLevel cur_level, int i, int b, double scale) { |
47 double threshold_scaling; |
47 double threshold_scaling; |
48 if (CompilerOracle::has_option_value(method, "CompileThresholdScaling", threshold_scaling)) { |
48 if (CompilerOracle::has_option_value(method, "CompileThresholdScaling", threshold_scaling)) { |
49 scale *= threshold_scaling; |
49 scale *= threshold_scaling; |
50 } |
50 } |
51 switch(cur_level) { |
51 switch(cur_level) { |
130 return (CompLevel)nm->comp_level(); |
130 return (CompLevel)nm->comp_level(); |
131 } |
131 } |
132 return CompLevel_none; |
132 return CompLevel_none; |
133 } |
133 } |
134 |
134 |
135 void TieredThresholdPolicy::print_counters(const char* prefix, const methodHandle& mh) { |
135 void TieredThresholdPolicy::print_counters(const char* prefix, Method* m) { |
136 int invocation_count = mh->invocation_count(); |
136 int invocation_count = m->invocation_count(); |
137 int backedge_count = mh->backedge_count(); |
137 int backedge_count = m->backedge_count(); |
138 MethodData* mdh = mh->method_data(); |
138 MethodData* mdh = m->method_data(); |
139 int mdo_invocations = 0, mdo_backedges = 0; |
139 int mdo_invocations = 0, mdo_backedges = 0; |
140 int mdo_invocations_start = 0, mdo_backedges_start = 0; |
140 int mdo_invocations_start = 0, mdo_backedges_start = 0; |
141 if (mdh != NULL) { |
141 if (mdh != NULL) { |
142 mdo_invocations = mdh->invocation_count(); |
142 mdo_invocations = mdh->invocation_count(); |
143 mdo_backedges = mdh->backedge_count(); |
143 mdo_backedges = mdh->backedge_count(); |
147 tty->print(" %stotal=%d,%d %smdo=%d(%d),%d(%d)", prefix, |
147 tty->print(" %stotal=%d,%d %smdo=%d(%d),%d(%d)", prefix, |
148 invocation_count, backedge_count, prefix, |
148 invocation_count, backedge_count, prefix, |
149 mdo_invocations, mdo_invocations_start, |
149 mdo_invocations, mdo_invocations_start, |
150 mdo_backedges, mdo_backedges_start); |
150 mdo_backedges, mdo_backedges_start); |
151 tty->print(" %smax levels=%d,%d", prefix, |
151 tty->print(" %smax levels=%d,%d", prefix, |
152 mh->highest_comp_level(), mh->highest_osr_comp_level()); |
152 m->highest_comp_level(), m->highest_osr_comp_level()); |
153 } |
153 } |
154 |
154 |
155 // Print an event. |
155 // Print an event. |
156 void TieredThresholdPolicy::print_event(EventType type, const methodHandle& mh, const methodHandle& imh, |
156 void TieredThresholdPolicy::print_event(EventType type, Method* m, Method* im, |
157 int bci, CompLevel level) { |
157 int bci, CompLevel level) { |
158 bool inlinee_event = mh() != imh(); |
158 bool inlinee_event = m != im; |
159 |
159 |
160 ttyLocker tty_lock; |
160 ttyLocker tty_lock; |
161 tty->print("%lf: [", os::elapsedTime()); |
161 tty->print("%lf: [", os::elapsedTime()); |
162 |
162 |
163 switch(type) { |
163 switch(type) { |
187 } |
187 } |
188 |
188 |
189 tty->print(" level=%d ", level); |
189 tty->print(" level=%d ", level); |
190 |
190 |
191 ResourceMark rm; |
191 ResourceMark rm; |
192 char *method_name = mh->name_and_sig_as_C_string(); |
192 char *method_name = m->name_and_sig_as_C_string(); |
193 tty->print("[%s", method_name); |
193 tty->print("[%s", method_name); |
194 if (inlinee_event) { |
194 if (inlinee_event) { |
195 char *inlinee_name = imh->name_and_sig_as_C_string(); |
195 char *inlinee_name = im->name_and_sig_as_C_string(); |
196 tty->print(" [%s]] ", inlinee_name); |
196 tty->print(" [%s]] ", inlinee_name); |
197 } |
197 } |
198 else tty->print("] "); |
198 else tty->print("] "); |
199 tty->print("@%d queues=%d,%d", bci, CompileBroker::queue_size(CompLevel_full_profile), |
199 tty->print("@%d queues=%d,%d", bci, CompileBroker::queue_size(CompLevel_full_profile), |
200 CompileBroker::queue_size(CompLevel_full_optimization)); |
200 CompileBroker::queue_size(CompLevel_full_optimization)); |
201 |
201 |
202 tty->print(" rate="); |
202 tty->print(" rate="); |
203 if (mh->prev_time() == 0) tty->print("n/a"); |
203 if (m->prev_time() == 0) tty->print("n/a"); |
204 else tty->print("%f", mh->rate()); |
204 else tty->print("%f", m->rate()); |
205 |
205 |
206 tty->print(" k=%.2lf,%.2lf", threshold_scale(CompLevel_full_profile, Tier3LoadFeedback), |
206 tty->print(" k=%.2lf,%.2lf", threshold_scale(CompLevel_full_profile, Tier3LoadFeedback), |
207 threshold_scale(CompLevel_full_optimization, Tier4LoadFeedback)); |
207 threshold_scale(CompLevel_full_optimization, Tier4LoadFeedback)); |
208 |
208 |
209 if (type != COMPILE) { |
209 if (type != COMPILE) { |
210 print_counters("", mh); |
210 print_counters("", m); |
211 if (inlinee_event) { |
211 if (inlinee_event) { |
212 print_counters("inlinee ", imh); |
212 print_counters("inlinee ", im); |
213 } |
213 } |
214 tty->print(" compilable="); |
214 tty->print(" compilable="); |
215 bool need_comma = false; |
215 bool need_comma = false; |
216 if (!mh->is_not_compilable(CompLevel_full_profile)) { |
216 if (!m->is_not_compilable(CompLevel_full_profile)) { |
217 tty->print("c1"); |
217 tty->print("c1"); |
218 need_comma = true; |
218 need_comma = true; |
219 } |
219 } |
220 if (!mh->is_not_osr_compilable(CompLevel_full_profile)) { |
220 if (!m->is_not_osr_compilable(CompLevel_full_profile)) { |
221 if (need_comma) tty->print(","); |
221 if (need_comma) tty->print(","); |
222 tty->print("c1-osr"); |
222 tty->print("c1-osr"); |
223 need_comma = true; |
223 need_comma = true; |
224 } |
224 } |
225 if (!mh->is_not_compilable(CompLevel_full_optimization)) { |
225 if (!m->is_not_compilable(CompLevel_full_optimization)) { |
226 if (need_comma) tty->print(","); |
226 if (need_comma) tty->print(","); |
227 tty->print("c2"); |
227 tty->print("c2"); |
228 need_comma = true; |
228 need_comma = true; |
229 } |
229 } |
230 if (!mh->is_not_osr_compilable(CompLevel_full_optimization)) { |
230 if (!m->is_not_osr_compilable(CompLevel_full_optimization)) { |
231 if (need_comma) tty->print(","); |
231 if (need_comma) tty->print(","); |
232 tty->print("c2-osr"); |
232 tty->print("c2-osr"); |
233 } |
233 } |
234 tty->print(" status="); |
234 tty->print(" status="); |
235 if (mh->queued_for_compilation()) { |
235 if (m->queued_for_compilation()) { |
236 tty->print("in-queue"); |
236 tty->print("in-queue"); |
237 } else tty->print("idle"); |
237 } else tty->print("idle"); |
238 } |
238 } |
239 tty->print_cr("]"); |
239 tty->print_cr("]"); |
240 } |
240 } |
374 // chance of such compilations timing out. |
374 // chance of such compilations timing out. |
375 max_task = max_blocking_task; |
375 max_task = max_blocking_task; |
376 max_method = max_task->method(); |
376 max_method = max_task->method(); |
377 } |
377 } |
378 |
378 |
|
379 methodHandle max_method_h(Thread::current(), max_method); |
|
380 |
379 if (max_task != NULL && max_task->comp_level() == CompLevel_full_profile && |
381 if (max_task != NULL && max_task->comp_level() == CompLevel_full_profile && |
380 TieredStopAtLevel > CompLevel_full_profile && |
382 TieredStopAtLevel > CompLevel_full_profile && |
381 max_method != NULL && is_method_profiled(max_method)) { |
383 max_method != NULL && is_method_profiled(max_method_h)) { |
382 max_task->set_comp_level(CompLevel_limited_profile); |
384 max_task->set_comp_level(CompLevel_limited_profile); |
383 |
385 |
384 if (CompileBroker::compilation_is_complete(max_method, max_task->osr_bci(), CompLevel_limited_profile)) { |
386 if (CompileBroker::compilation_is_complete(max_method_h, max_task->osr_bci(), CompLevel_limited_profile)) { |
385 if (PrintTieredEvents) { |
387 if (PrintTieredEvents) { |
386 print_event(REMOVE_FROM_QUEUE, max_method, max_method, max_task->osr_bci(), (CompLevel)max_task->comp_level()); |
388 print_event(REMOVE_FROM_QUEUE, max_method, max_method, max_task->osr_bci(), (CompLevel)max_task->comp_level()); |
387 } |
389 } |
388 compile_queue->remove_and_mark_stale(max_task); |
390 compile_queue->remove_and_mark_stale(max_task); |
389 max_method->clear_queued_for_compilation(); |
391 max_method->clear_queued_for_compilation(); |
399 } |
401 } |
400 |
402 |
401 void TieredThresholdPolicy::reprofile(ScopeDesc* trap_scope, bool is_osr) { |
403 void TieredThresholdPolicy::reprofile(ScopeDesc* trap_scope, bool is_osr) { |
402 for (ScopeDesc* sd = trap_scope;; sd = sd->sender()) { |
404 for (ScopeDesc* sd = trap_scope;; sd = sd->sender()) { |
403 if (PrintTieredEvents) { |
405 if (PrintTieredEvents) { |
404 methodHandle mh(sd->method()); |
406 print_event(REPROFILE, sd->method(), sd->method(), InvocationEntryBci, CompLevel_none); |
405 print_event(REPROFILE, mh, mh, InvocationEntryBci, CompLevel_none); |
|
406 } |
407 } |
407 MethodData* mdo = sd->method()->method_data(); |
408 MethodData* mdo = sd->method()->method_data(); |
408 if (mdo != NULL) { |
409 if (mdo != NULL) { |
409 mdo->reset_start_counters(); |
410 mdo->reset_start_counters(); |
410 } |
411 } |
428 if (method() != inlinee()) { |
429 if (method() != inlinee()) { |
429 handle_counter_overflow(inlinee()); |
430 handle_counter_overflow(inlinee()); |
430 } |
431 } |
431 |
432 |
432 if (PrintTieredEvents) { |
433 if (PrintTieredEvents) { |
433 print_event(bci == InvocationEntryBci ? CALL : LOOP, method, inlinee, bci, comp_level); |
434 print_event(bci == InvocationEntryBci ? CALL : LOOP, method(), inlinee(), bci, comp_level); |
434 } |
435 } |
435 |
436 |
436 if (bci == InvocationEntryBci) { |
437 if (bci == InvocationEntryBci) { |
437 method_invocation_event(method, inlinee, comp_level, nm, thread); |
438 method_invocation_event(method, inlinee, comp_level, nm, thread); |
438 } else { |
439 } else { |
479 return; |
480 return; |
480 } |
481 } |
481 if (level == CompLevel_aot) { |
482 if (level == CompLevel_aot) { |
482 if (mh->has_aot_code()) { |
483 if (mh->has_aot_code()) { |
483 if (PrintTieredEvents) { |
484 if (PrintTieredEvents) { |
484 print_event(COMPILE, mh, mh, bci, level); |
485 print_event(COMPILE, mh(), mh(), bci, level); |
485 } |
486 } |
486 MutexLocker ml(Compile_lock); |
487 MutexLocker ml(Compile_lock); |
487 NoSafepointVerifier nsv; |
488 NoSafepointVerifier nsv; |
488 if (mh->has_aot_code() && mh->code() != mh->aot_code()) { |
489 if (mh->has_aot_code() && mh->code() != mh->aot_code()) { |
489 mh->aot_code()->make_entrant(); |
490 mh->aot_code()->make_entrant(); |
523 if (bci != InvocationEntryBci && mh->is_not_osr_compilable(level)) { |
524 if (bci != InvocationEntryBci && mh->is_not_osr_compilable(level)) { |
524 return; |
525 return; |
525 } |
526 } |
526 if (!CompileBroker::compilation_is_in_queue(mh)) { |
527 if (!CompileBroker::compilation_is_in_queue(mh)) { |
527 if (PrintTieredEvents) { |
528 if (PrintTieredEvents) { |
528 print_event(COMPILE, mh, mh, bci, level); |
529 print_event(COMPILE, mh(), mh(), bci, level); |
529 } |
530 } |
530 int hot_count = (bci == InvocationEntryBci) ? mh->invocation_count() : mh->backedge_count(); |
531 int hot_count = (bci == InvocationEntryBci) ? mh->invocation_count() : mh->backedge_count(); |
531 update_rate(os::javaTimeMillis(), mh()); |
532 update_rate(os::javaTimeMillis(), mh()); |
532 CompileBroker::compile_method(mh, bci, level, mh, hot_count, CompileTask::Reason_Tiered, thread); |
533 CompileBroker::compile_method(mh, bci, level, mh, hot_count, CompileTask::Reason_Tiered, thread); |
533 } |
534 } |
608 } |
609 } |
609 return false; |
610 return false; |
610 } |
611 } |
611 |
612 |
612 // Is method profiled enough? |
613 // Is method profiled enough? |
613 bool TieredThresholdPolicy::is_method_profiled(Method* method) { |
614 bool TieredThresholdPolicy::is_method_profiled(const methodHandle& method) { |
614 MethodData* mdo = method->method_data(); |
615 MethodData* mdo = method->method_data(); |
615 if (mdo != NULL) { |
616 if (mdo != NULL) { |
616 int i = mdo->invocation_count_delta(); |
617 int i = mdo->invocation_count_delta(); |
617 int b = mdo->backedge_count_delta(); |
618 int b = mdo->backedge_count_delta(); |
618 return call_predicate_helper(method, CompilationModeFlag::disable_intermediate() ? CompLevel_none : CompLevel_full_profile, i, b, 1); |
619 return call_predicate_helper(method, CompilationModeFlag::disable_intermediate() ? CompLevel_none : CompLevel_full_profile, i, b, 1); |
645 // compilation level should be performed (pointers to predicate functions |
646 // compilation level should be performed (pointers to predicate functions |
646 // are passed to common()). |
647 // are passed to common()). |
647 // Tier?LoadFeedback is basically a coefficient that determines of |
648 // Tier?LoadFeedback is basically a coefficient that determines of |
648 // how many methods per compiler thread can be in the queue before |
649 // how many methods per compiler thread can be in the queue before |
649 // the threshold values double. |
650 // the threshold values double. |
650 bool TieredThresholdPolicy::loop_predicate(int i, int b, CompLevel cur_level, Method* method) { |
651 bool TieredThresholdPolicy::loop_predicate(int i, int b, CompLevel cur_level, const methodHandle& method) { |
651 double k = 1; |
652 double k = 1; |
652 switch(cur_level) { |
653 switch(cur_level) { |
653 case CompLevel_aot: { |
654 case CompLevel_aot: { |
654 k = CompilationModeFlag::disable_intermediate() ? 1 : threshold_scale(CompLevel_full_profile, Tier3LoadFeedback); |
655 k = CompilationModeFlag::disable_intermediate() ? 1 : threshold_scale(CompLevel_full_profile, Tier3LoadFeedback); |
655 break; |
656 break; |
670 break; |
671 break; |
671 } |
672 } |
672 default: |
673 default: |
673 return true; |
674 return true; |
674 } |
675 } |
675 return loop_predicate_helper(method, cur_level, i, b, k); |
676 return loop_predicate_helper(method, cur_level, i, b, k); |
676 } |
677 } |
677 |
678 |
678 bool TieredThresholdPolicy::call_predicate(int i, int b, CompLevel cur_level, Method* method) { |
679 bool TieredThresholdPolicy::call_predicate(int i, int b, CompLevel cur_level, const methodHandle& method) { |
679 double k = 1; |
680 double k = 1; |
680 switch(cur_level) { |
681 switch(cur_level) { |
681 case CompLevel_aot: { |
682 case CompLevel_aot: { |
682 k = CompilationModeFlag::disable_intermediate() ? 1 : threshold_scale(CompLevel_full_profile, Tier3LoadFeedback); |
683 k = CompilationModeFlag::disable_intermediate() ? 1 : threshold_scale(CompLevel_full_profile, Tier3LoadFeedback); |
683 break; |
684 break; |
703 return call_predicate_helper(method, cur_level, i, b, k); |
704 return call_predicate_helper(method, cur_level, i, b, k); |
704 } |
705 } |
705 |
706 |
706 // Determine is a method is mature. |
707 // Determine is a method is mature. |
707 bool TieredThresholdPolicy::is_mature(Method* method) { |
708 bool TieredThresholdPolicy::is_mature(Method* method) { |
708 if (is_trivial(method) || force_comp_at_level_simple(method)) return true; |
709 methodHandle mh(Thread::current(), method); |
|
710 if (is_trivial(method) || force_comp_at_level_simple(mh)) return true; |
709 MethodData* mdo = method->method_data(); |
711 MethodData* mdo = method->method_data(); |
710 if (mdo != NULL) { |
712 if (mdo != NULL) { |
711 int i = mdo->invocation_count(); |
713 int i = mdo->invocation_count(); |
712 int b = mdo->backedge_count(); |
714 int b = mdo->backedge_count(); |
713 double k = ProfileMaturityPercentage / 100.0; |
715 double k = ProfileMaturityPercentage / 100.0; |
714 CompLevel main_profile_level = CompilationModeFlag::disable_intermediate() ? CompLevel_none : CompLevel_full_profile; |
716 CompLevel main_profile_level = CompilationModeFlag::disable_intermediate() ? CompLevel_none : CompLevel_full_profile; |
715 return call_predicate_helper(method, main_profile_level, i, b, k) || loop_predicate_helper(method, main_profile_level, i, b, k); |
717 return call_predicate_helper(mh, main_profile_level, i, b, k) || loop_predicate_helper(mh, main_profile_level, i, b, k); |
716 } |
718 } |
717 return false; |
719 return false; |
718 } |
720 } |
719 |
721 |
720 // If a method is old enough and is still in the interpreter we would want to |
722 // If a method is old enough and is still in the interpreter we would want to |
721 // start profiling without waiting for the compiled method to arrive. |
723 // start profiling without waiting for the compiled method to arrive. |
722 // We also take the load on compilers into the account. |
724 // We also take the load on compilers into the account. |
723 bool TieredThresholdPolicy::should_create_mdo(Method* method, CompLevel cur_level) { |
725 bool TieredThresholdPolicy::should_create_mdo(const methodHandle& method, CompLevel cur_level) { |
724 if (cur_level != CompLevel_none || force_comp_at_level_simple(method)) { |
726 if (cur_level != CompLevel_none || force_comp_at_level_simple(method)) { |
725 return false; |
727 return false; |
726 } |
728 } |
727 int i = method->invocation_count(); |
729 int i = method->invocation_count(); |
728 int b = method->backedge_count(); |
730 int b = method->backedge_count(); |
797 * are possible. |
799 * are possible. |
798 * |
800 * |
799 */ |
801 */ |
800 |
802 |
801 // Common transition function. Given a predicate determines if a method should transition to another level. |
803 // Common transition function. Given a predicate determines if a method should transition to another level. |
802 CompLevel TieredThresholdPolicy::common(Predicate p, Method* method, CompLevel cur_level, bool disable_feedback) { |
804 CompLevel TieredThresholdPolicy::common(Predicate p, const methodHandle& method, CompLevel cur_level, bool disable_feedback) { |
803 CompLevel next_level = cur_level; |
805 CompLevel next_level = cur_level; |
804 int i = method->invocation_count(); |
806 int i = method->invocation_count(); |
805 int b = method->backedge_count(); |
807 int b = method->backedge_count(); |
806 |
808 |
807 if (force_comp_at_level_simple(method)) { |
809 if (force_comp_at_level_simple(method)) { |
808 next_level = CompLevel_simple; |
810 next_level = CompLevel_simple; |
809 } else { |
811 } else { |
810 if (!CompilationModeFlag::disable_intermediate() && is_trivial(method)) { |
812 if (!CompilationModeFlag::disable_intermediate() && is_trivial(method())) { |
811 next_level = CompLevel_simple; |
813 next_level = CompLevel_simple; |
812 } else { |
814 } else { |
813 switch(cur_level) { |
815 switch(cur_level) { |
814 default: break; |
816 default: break; |
815 case CompLevel_aot: |
817 case CompLevel_aot: |
924 } |
926 } |
925 return MIN2(next_level, CompilationModeFlag::quick_only() ? CompLevel_simple : (CompLevel)TieredStopAtLevel); |
927 return MIN2(next_level, CompilationModeFlag::quick_only() ? CompLevel_simple : (CompLevel)TieredStopAtLevel); |
926 } |
928 } |
927 |
929 |
928 // Determine if a method should be compiled with a normal entry point at a different level. |
930 // Determine if a method should be compiled with a normal entry point at a different level. |
929 CompLevel TieredThresholdPolicy::call_event(Method* method, CompLevel cur_level, JavaThread* thread) { |
931 CompLevel TieredThresholdPolicy::call_event(const methodHandle& method, CompLevel cur_level, JavaThread* thread) { |
930 CompLevel osr_level = MIN2((CompLevel) method->highest_osr_comp_level(), |
932 CompLevel osr_level = MIN2((CompLevel) method->highest_osr_comp_level(), |
931 common(&TieredThresholdPolicy::loop_predicate, method, cur_level, true)); |
933 common(&TieredThresholdPolicy::loop_predicate, method, cur_level, true)); |
932 CompLevel next_level = common(&TieredThresholdPolicy::call_predicate, method, cur_level); |
934 CompLevel next_level = common(&TieredThresholdPolicy::call_predicate, method, cur_level); |
933 |
935 |
934 // If OSR method level is greater than the regular method level, the levels should be |
936 // If OSR method level is greater than the regular method level, the levels should be |
945 } |
947 } |
946 return next_level; |
948 return next_level; |
947 } |
949 } |
948 |
950 |
949 // Determine if we should do an OSR compilation of a given method. |
951 // Determine if we should do an OSR compilation of a given method. |
950 CompLevel TieredThresholdPolicy::loop_event(Method* method, CompLevel cur_level, JavaThread* thread) { |
952 CompLevel TieredThresholdPolicy::loop_event(const methodHandle& method, CompLevel cur_level, JavaThread* thread) { |
951 CompLevel next_level = common(&TieredThresholdPolicy::loop_predicate, method, cur_level, true); |
953 CompLevel next_level = common(&TieredThresholdPolicy::loop_predicate, method, cur_level, true); |
952 if (cur_level == CompLevel_none) { |
954 if (cur_level == CompLevel_none) { |
953 // If there is a live OSR method that means that we deopted to the interpreter |
955 // If there is a live OSR method that means that we deopted to the interpreter |
954 // for the transition. |
956 // for the transition. |
955 CompLevel osr_level = MIN2((CompLevel)method->highest_osr_comp_level(), next_level); |
957 CompLevel osr_level = MIN2((CompLevel)method->highest_osr_comp_level(), next_level); |
981 |
983 |
982 |
984 |
983 // Handle the invocation event. |
985 // Handle the invocation event. |
984 void TieredThresholdPolicy::method_invocation_event(const methodHandle& mh, const methodHandle& imh, |
986 void TieredThresholdPolicy::method_invocation_event(const methodHandle& mh, const methodHandle& imh, |
985 CompLevel level, CompiledMethod* nm, JavaThread* thread) { |
987 CompLevel level, CompiledMethod* nm, JavaThread* thread) { |
986 if (should_create_mdo(mh(), level)) { |
988 if (should_create_mdo(mh, level)) { |
987 create_mdo(mh, thread); |
989 create_mdo(mh, thread); |
988 } |
990 } |
989 CompLevel next_level = call_event(mh(), level, thread); |
991 CompLevel next_level = call_event(mh, level, thread); |
990 if (next_level != level) { |
992 if (next_level != level) { |
991 if (maybe_switch_to_aot(mh, level, next_level, thread)) { |
993 if (maybe_switch_to_aot(mh, level, next_level, thread)) { |
992 // No JITting necessary |
994 // No JITting necessary |
993 return; |
995 return; |
994 } |
996 } |
1000 |
1002 |
1001 // Handle the back branch event. Notice that we can compile the method |
1003 // Handle the back branch event. Notice that we can compile the method |
1002 // with a regular entry from here. |
1004 // with a regular entry from here. |
1003 void TieredThresholdPolicy::method_back_branch_event(const methodHandle& mh, const methodHandle& imh, |
1005 void TieredThresholdPolicy::method_back_branch_event(const methodHandle& mh, const methodHandle& imh, |
1004 int bci, CompLevel level, CompiledMethod* nm, JavaThread* thread) { |
1006 int bci, CompLevel level, CompiledMethod* nm, JavaThread* thread) { |
1005 if (should_create_mdo(mh(), level)) { |
1007 if (should_create_mdo(mh, level)) { |
1006 create_mdo(mh, thread); |
1008 create_mdo(mh, thread); |
1007 } |
1009 } |
1008 // Check if MDO should be created for the inlined method |
1010 // Check if MDO should be created for the inlined method |
1009 if (should_create_mdo(imh(), level)) { |
1011 if (should_create_mdo(imh, level)) { |
1010 create_mdo(imh, thread); |
1012 create_mdo(imh, thread); |
1011 } |
1013 } |
1012 |
1014 |
1013 if (is_compilation_enabled()) { |
1015 if (is_compilation_enabled()) { |
1014 CompLevel next_osr_level = loop_event(imh(), level, thread); |
1016 CompLevel next_osr_level = loop_event(imh, level, thread); |
1015 CompLevel max_osr_level = (CompLevel)imh->highest_osr_comp_level(); |
1017 CompLevel max_osr_level = (CompLevel)imh->highest_osr_comp_level(); |
1016 // At the very least compile the OSR version |
1018 // At the very least compile the OSR version |
1017 if (!CompileBroker::compilation_is_in_queue(imh) && (next_osr_level != level)) { |
1019 if (!CompileBroker::compilation_is_in_queue(imh) && (next_osr_level != level)) { |
1018 compile(imh, bci, next_osr_level, thread); |
1020 compile(imh, bci, next_osr_level, thread); |
1019 } |
1021 } |
1030 } |
1032 } |
1031 } else { |
1033 } else { |
1032 // Current loop event level is not AOT |
1034 // Current loop event level is not AOT |
1033 guarantee(nm != NULL, "Should have nmethod here"); |
1035 guarantee(nm != NULL, "Should have nmethod here"); |
1034 cur_level = comp_level(mh()); |
1036 cur_level = comp_level(mh()); |
1035 next_level = call_event(mh(), cur_level, thread); |
1037 next_level = call_event(mh, cur_level, thread); |
1036 |
1038 |
1037 if (max_osr_level == CompLevel_full_optimization) { |
1039 if (max_osr_level == CompLevel_full_optimization) { |
1038 // The inlinee OSRed to full opt, we need to modify the enclosing method to avoid deopts |
1040 // The inlinee OSRed to full opt, we need to modify the enclosing method to avoid deopts |
1039 bool make_not_entrant = false; |
1041 bool make_not_entrant = false; |
1040 if (nm->is_osr_method()) { |
1042 if (nm->is_osr_method()) { |
1066 } |
1068 } |
1067 } |
1069 } |
1068 } |
1070 } |
1069 } else { |
1071 } else { |
1070 cur_level = comp_level(mh()); |
1072 cur_level = comp_level(mh()); |
1071 next_level = call_event(mh(), cur_level, thread); |
1073 next_level = call_event(mh, cur_level, thread); |
1072 if (next_level != cur_level) { |
1074 if (next_level != cur_level) { |
1073 if (!maybe_switch_to_aot(mh, cur_level, next_level, thread) && !CompileBroker::compilation_is_in_queue(mh)) { |
1075 if (!maybe_switch_to_aot(mh, cur_level, next_level, thread) && !CompileBroker::compilation_is_in_queue(mh)) { |
1074 compile(mh, InvocationEntryBci, next_level, thread); |
1076 compile(mh, InvocationEntryBci, next_level, thread); |
1075 } |
1077 } |
1076 } |
1078 } |