134 } |
134 } |
135 } else if (is_compile(comp_level)) { |
135 } else if (is_compile(comp_level)) { |
136 return !m->is_not_compilable(comp_level); |
136 return !m->is_not_compilable(comp_level); |
137 } |
137 } |
138 return false; |
138 return false; |
|
139 } |
|
140 |
|
141 // Returns true if m is allowed to be osr compiled |
|
142 bool CompilationPolicy::can_be_osr_compiled(methodHandle m, int comp_level) { |
|
143 bool result = false; |
|
144 if (comp_level == CompLevel_all) { |
|
145 if (TieredCompilation) { |
|
146 // enough to be osr compilable at any level for tiered |
|
147 result = !m->is_not_osr_compilable(CompLevel_simple) || !m->is_not_osr_compilable(CompLevel_full_optimization); |
|
148 } else { |
|
149 // must be osr compilable at available level for non-tiered |
|
150 result = !m->is_not_osr_compilable(CompLevel_highest_tier); |
|
151 } |
|
152 } else if (is_compile(comp_level)) { |
|
153 result = !m->is_not_osr_compilable(comp_level); |
|
154 } |
|
155 return (result && can_be_compiled(m, comp_level)); |
139 } |
156 } |
140 |
157 |
141 bool CompilationPolicy::is_compilation_enabled() { |
158 bool CompilationPolicy::is_compilation_enabled() { |
142 // NOTE: CompileBroker::should_compile_new_jobs() checks for UseCompiler |
159 // NOTE: CompileBroker::should_compile_new_jobs() checks for UseCompiler |
143 return !delay_compilation_during_startup() && CompileBroker::should_compile_new_jobs(); |
160 return !delay_compilation_during_startup() && CompileBroker::should_compile_new_jobs(); |
456 void SimpleCompPolicy::method_back_branch_event(methodHandle m, int bci, JavaThread* thread) { |
473 void SimpleCompPolicy::method_back_branch_event(methodHandle m, int bci, JavaThread* thread) { |
457 const int comp_level = CompLevel_highest_tier; |
474 const int comp_level = CompLevel_highest_tier; |
458 const int hot_count = m->backedge_count(); |
475 const int hot_count = m->backedge_count(); |
459 const char* comment = "backedge_count"; |
476 const char* comment = "backedge_count"; |
460 |
477 |
461 if (is_compilation_enabled() && !m->is_not_osr_compilable(comp_level) && can_be_compiled(m, comp_level)) { |
478 if (is_compilation_enabled() && can_be_osr_compiled(m, comp_level)) { |
462 CompileBroker::compile_method(m, bci, comp_level, m, hot_count, comment, thread); |
479 CompileBroker::compile_method(m, bci, comp_level, m, hot_count, comment, thread); |
463 NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, comp_level, true));) |
480 NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, comp_level, true));) |
464 } |
481 } |
465 } |
482 } |
466 // StackWalkCompPolicy - walk up stack to find a suitable method to compile |
483 // StackWalkCompPolicy - walk up stack to find a suitable method to compile |
512 void StackWalkCompPolicy::method_back_branch_event(methodHandle m, int bci, JavaThread* thread) { |
529 void StackWalkCompPolicy::method_back_branch_event(methodHandle m, int bci, JavaThread* thread) { |
513 const int comp_level = CompLevel_highest_tier; |
530 const int comp_level = CompLevel_highest_tier; |
514 const int hot_count = m->backedge_count(); |
531 const int hot_count = m->backedge_count(); |
515 const char* comment = "backedge_count"; |
532 const char* comment = "backedge_count"; |
516 |
533 |
517 if (is_compilation_enabled() && !m->is_not_osr_compilable(comp_level) && can_be_compiled(m, comp_level)) { |
534 if (is_compilation_enabled() && can_be_osr_compiled(m, comp_level)) { |
518 CompileBroker::compile_method(m, bci, comp_level, m, hot_count, comment, thread); |
535 CompileBroker::compile_method(m, bci, comp_level, m, hot_count, comment, thread); |
519 NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, comp_level, true));) |
536 NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, comp_level, true));) |
520 } |
537 } |
521 } |
538 } |
522 |
539 |