107 (UseCompiler && AlwaysCompileLoopMethods && m->has_loops() && CompileBroker::should_compile_new_jobs()); // eagerly compile loop methods |
107 (UseCompiler && AlwaysCompileLoopMethods && m->has_loops() && CompileBroker::should_compile_new_jobs()); // eagerly compile loop methods |
108 } |
108 } |
109 |
109 |
110 // Returns true if m is allowed to be compiled |
110 // Returns true if m is allowed to be compiled |
111 bool CompilationPolicy::can_be_compiled(methodHandle m, int comp_level) { |
111 bool CompilationPolicy::can_be_compiled(methodHandle m, int comp_level) { |
|
112 // allow any levels for WhiteBox |
|
113 assert(WhiteBoxAPI || comp_level == CompLevel_all || is_compile(comp_level), "illegal compilation level"); |
|
114 |
112 if (m->is_abstract()) return false; |
115 if (m->is_abstract()) return false; |
113 if (DontCompileHugeMethods && m->code_size() > HugeMethodLimit) return false; |
116 if (DontCompileHugeMethods && m->code_size() > HugeMethodLimit) return false; |
114 |
117 |
115 // Math intrinsics should never be compiled as this can lead to |
118 // Math intrinsics should never be compiled as this can lead to |
116 // monotonicity problems because the interpreter will prefer the |
119 // monotonicity problems because the interpreter will prefer the |
120 // modes. |
123 // modes. |
121 if (!AbstractInterpreter::can_be_compiled(m)) { |
124 if (!AbstractInterpreter::can_be_compiled(m)) { |
122 return false; |
125 return false; |
123 } |
126 } |
124 if (comp_level == CompLevel_all) { |
127 if (comp_level == CompLevel_all) { |
125 return !m->is_not_compilable(CompLevel_simple) && !m->is_not_compilable(CompLevel_full_optimization); |
128 if (TieredCompilation) { |
|
129 // enough to be compilable at any level for tiered |
|
130 return !m->is_not_compilable(CompLevel_simple) || !m->is_not_compilable(CompLevel_full_optimization); |
|
131 } else { |
|
132 // must be compilable at available level for non-tiered |
|
133 return !m->is_not_compilable(CompLevel_highest_tier); |
|
134 } |
126 } else if (is_compile(comp_level)) { |
135 } else if (is_compile(comp_level)) { |
127 return !m->is_not_compilable(comp_level); |
136 return !m->is_not_compilable(comp_level); |
128 } |
137 } |
129 return false; |
138 return false; |
130 } |
139 } |
434 const int comp_level = CompLevel_highest_tier; |
443 const int comp_level = CompLevel_highest_tier; |
435 const int hot_count = m->invocation_count(); |
444 const int hot_count = m->invocation_count(); |
436 reset_counter_for_invocation_event(m); |
445 reset_counter_for_invocation_event(m); |
437 const char* comment = "count"; |
446 const char* comment = "count"; |
438 |
447 |
439 if (is_compilation_enabled() && can_be_compiled(m)) { |
448 if (is_compilation_enabled() && can_be_compiled(m, comp_level)) { |
440 nmethod* nm = m->code(); |
449 nmethod* nm = m->code(); |
441 if (nm == NULL ) { |
450 if (nm == NULL ) { |
442 CompileBroker::compile_method(m, InvocationEntryBci, comp_level, m, hot_count, comment, thread); |
451 CompileBroker::compile_method(m, InvocationEntryBci, comp_level, m, hot_count, comment, thread); |
443 } |
452 } |
444 } |
453 } |
447 void SimpleCompPolicy::method_back_branch_event(methodHandle m, int bci, JavaThread* thread) { |
456 void SimpleCompPolicy::method_back_branch_event(methodHandle m, int bci, JavaThread* thread) { |
448 const int comp_level = CompLevel_highest_tier; |
457 const int comp_level = CompLevel_highest_tier; |
449 const int hot_count = m->backedge_count(); |
458 const int hot_count = m->backedge_count(); |
450 const char* comment = "backedge_count"; |
459 const char* comment = "backedge_count"; |
451 |
460 |
452 if (is_compilation_enabled() && !m->is_not_osr_compilable(comp_level) && can_be_compiled(m)) { |
461 if (is_compilation_enabled() && !m->is_not_osr_compilable(comp_level) && can_be_compiled(m, comp_level)) { |
453 CompileBroker::compile_method(m, bci, comp_level, m, hot_count, comment, thread); |
462 CompileBroker::compile_method(m, bci, comp_level, m, hot_count, comment, thread); |
454 NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, comp_level, true));) |
463 NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, comp_level, true));) |
455 } |
464 } |
456 } |
465 } |
457 // StackWalkCompPolicy - walk up stack to find a suitable method to compile |
466 // StackWalkCompPolicy - walk up stack to find a suitable method to compile |
465 const int comp_level = CompLevel_highest_tier; |
474 const int comp_level = CompLevel_highest_tier; |
466 const int hot_count = m->invocation_count(); |
475 const int hot_count = m->invocation_count(); |
467 reset_counter_for_invocation_event(m); |
476 reset_counter_for_invocation_event(m); |
468 const char* comment = "count"; |
477 const char* comment = "count"; |
469 |
478 |
470 if (is_compilation_enabled() && m->code() == NULL && can_be_compiled(m)) { |
479 if (is_compilation_enabled() && m->code() == NULL && can_be_compiled(m, comp_level)) { |
471 ResourceMark rm(thread); |
480 ResourceMark rm(thread); |
472 frame fr = thread->last_frame(); |
481 frame fr = thread->last_frame(); |
473 assert(fr.is_interpreted_frame(), "must be interpreted"); |
482 assert(fr.is_interpreted_frame(), "must be interpreted"); |
474 assert(fr.interpreter_frame_method() == m(), "bad method"); |
483 assert(fr.interpreter_frame_method() == m(), "bad method"); |
475 |
484 |
503 void StackWalkCompPolicy::method_back_branch_event(methodHandle m, int bci, JavaThread* thread) { |
512 void StackWalkCompPolicy::method_back_branch_event(methodHandle m, int bci, JavaThread* thread) { |
504 const int comp_level = CompLevel_highest_tier; |
513 const int comp_level = CompLevel_highest_tier; |
505 const int hot_count = m->backedge_count(); |
514 const int hot_count = m->backedge_count(); |
506 const char* comment = "backedge_count"; |
515 const char* comment = "backedge_count"; |
507 |
516 |
508 if (is_compilation_enabled() && !m->is_not_osr_compilable(comp_level) && can_be_compiled(m)) { |
517 if (is_compilation_enabled() && !m->is_not_osr_compilable(comp_level) && can_be_compiled(m, comp_level)) { |
509 CompileBroker::compile_method(m, bci, comp_level, m, hot_count, comment, thread); |
518 CompileBroker::compile_method(m, bci, comp_level, m, hot_count, comment, thread); |
510 NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, comp_level, true));) |
519 NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, comp_level, true));) |
511 } |
520 } |
512 } |
521 } |
513 |
522 |
598 } |
607 } |
599 |
608 |
600 |
609 |
601 // If the caller method is too big or something then we do not want to |
610 // If the caller method is too big or something then we do not want to |
602 // compile it just to inline a method |
611 // compile it just to inline a method |
603 if (!can_be_compiled(next_m)) { |
612 if (!can_be_compiled(next_m, CompLevel_any)) { |
604 msg = "caller cannot be compiled"; |
613 msg = "caller cannot be compiled"; |
605 break; |
614 break; |
606 } |
615 } |
607 |
616 |
608 if( next_m->name() == vmSymbols::class_initializer_name() ) { |
617 if( next_m->name() == vmSymbols::class_initializer_name() ) { |