hotspot/src/share/vm/runtime/compilationPolicy.cpp
changeset 38218 f5ba1dea04eb
parent 38139 cf6f5c1b7205
child 43455 96560cffef4d
equal deleted inserted replaced
38217:7ecc47b7df3d 38218:f5ba1dea04eb
   128       // even before classes are initialized.
   128       // even before classes are initialized.
   129       return;
   129       return;
   130     }
   130     }
   131     CompileBroker::compile_method(selected_method, InvocationEntryBci,
   131     CompileBroker::compile_method(selected_method, InvocationEntryBci,
   132         CompilationPolicy::policy()->initial_compile_level(),
   132         CompilationPolicy::policy()->initial_compile_level(),
   133         methodHandle(), 0, "must_be_compiled", CHECK);
   133         methodHandle(), 0, CompileTask::Reason_MustBeCompiled, CHECK);
   134   }
   134   }
   135 }
   135 }
   136 
   136 
   137 // Returns true if m is allowed to be compiled
   137 // Returns true if m is allowed to be compiled
   138 bool CompilationPolicy::can_be_compiled(methodHandle m, int comp_level) {
   138 bool CompilationPolicy::can_be_compiled(methodHandle m, int comp_level) {
   506 
   506 
   507 void SimpleCompPolicy::method_invocation_event(const methodHandle& m, JavaThread* thread) {
   507 void SimpleCompPolicy::method_invocation_event(const methodHandle& m, JavaThread* thread) {
   508   const int comp_level = CompLevel_highest_tier;
   508   const int comp_level = CompLevel_highest_tier;
   509   const int hot_count = m->invocation_count();
   509   const int hot_count = m->invocation_count();
   510   reset_counter_for_invocation_event(m);
   510   reset_counter_for_invocation_event(m);
   511   const char* comment = "count";
       
   512 
   511 
   513   if (is_compilation_enabled() && can_be_compiled(m, comp_level)) {
   512   if (is_compilation_enabled() && can_be_compiled(m, comp_level)) {
   514     CompiledMethod* nm = m->code();
   513     CompiledMethod* nm = m->code();
   515     if (nm == NULL ) {
   514     if (nm == NULL ) {
   516       CompileBroker::compile_method(m, InvocationEntryBci, comp_level, m, hot_count, comment, thread);
   515       CompileBroker::compile_method(m, InvocationEntryBci, comp_level, m, hot_count, CompileTask::Reason_InvocationCount, thread);
   517     }
   516     }
   518   }
   517   }
   519 }
   518 }
   520 
   519 
   521 void SimpleCompPolicy::method_back_branch_event(const methodHandle& m, int bci, JavaThread* thread) {
   520 void SimpleCompPolicy::method_back_branch_event(const methodHandle& m, int bci, JavaThread* thread) {
   522   const int comp_level = CompLevel_highest_tier;
   521   const int comp_level = CompLevel_highest_tier;
   523   const int hot_count = m->backedge_count();
   522   const int hot_count = m->backedge_count();
   524   const char* comment = "backedge_count";
       
   525 
   523 
   526   if (is_compilation_enabled() && can_be_osr_compiled(m, comp_level)) {
   524   if (is_compilation_enabled() && can_be_osr_compiled(m, comp_level)) {
   527     CompileBroker::compile_method(m, bci, comp_level, m, hot_count, comment, thread);
   525     CompileBroker::compile_method(m, bci, comp_level, m, hot_count, CompileTask::Reason_BackedgeCount, thread);
   528     NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, comp_level, true));)
   526     NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, comp_level, true));)
   529   }
   527   }
   530 }
   528 }
   531 // StackWalkCompPolicy - walk up stack to find a suitable method to compile
   529 // StackWalkCompPolicy - walk up stack to find a suitable method to compile
   532 
   530 
   537 // Consider m for compilation
   535 // Consider m for compilation
   538 void StackWalkCompPolicy::method_invocation_event(const methodHandle& m, JavaThread* thread) {
   536 void StackWalkCompPolicy::method_invocation_event(const methodHandle& m, JavaThread* thread) {
   539   const int comp_level = CompLevel_highest_tier;
   537   const int comp_level = CompLevel_highest_tier;
   540   const int hot_count = m->invocation_count();
   538   const int hot_count = m->invocation_count();
   541   reset_counter_for_invocation_event(m);
   539   reset_counter_for_invocation_event(m);
   542   const char* comment = "count";
       
   543 
   540 
   544   if (is_compilation_enabled() && m->code() == NULL && can_be_compiled(m, comp_level)) {
   541   if (is_compilation_enabled() && m->code() == NULL && can_be_compiled(m, comp_level)) {
   545     ResourceMark rm(thread);
   542     ResourceMark rm(thread);
   546     frame       fr     = thread->last_frame();
   543     frame       fr     = thread->last_frame();
   547     assert(fr.is_interpreted_frame(), "must be interpreted");
   544     assert(fr.is_interpreted_frame(), "must be interpreted");
   567       RFrame* top = findTopInlinableFrame(stack);
   564       RFrame* top = findTopInlinableFrame(stack);
   568       if (TimeCompilationPolicy) accumulated_time()->stop();
   565       if (TimeCompilationPolicy) accumulated_time()->stop();
   569       assert(top != NULL, "findTopInlinableFrame returned null");
   566       assert(top != NULL, "findTopInlinableFrame returned null");
   570       if (TraceCompilationPolicy) top->print();
   567       if (TraceCompilationPolicy) top->print();
   571       CompileBroker::compile_method(top->top_method(), InvocationEntryBci, comp_level,
   568       CompileBroker::compile_method(top->top_method(), InvocationEntryBci, comp_level,
   572                                     m, hot_count, comment, thread);
   569                                     m, hot_count, CompileTask::Reason_InvocationCount, thread);
   573     }
   570     }
   574   }
   571   }
   575 }
   572 }
   576 
   573 
   577 void StackWalkCompPolicy::method_back_branch_event(const methodHandle& m, int bci, JavaThread* thread) {
   574 void StackWalkCompPolicy::method_back_branch_event(const methodHandle& m, int bci, JavaThread* thread) {
   578   const int comp_level = CompLevel_highest_tier;
   575   const int comp_level = CompLevel_highest_tier;
   579   const int hot_count = m->backedge_count();
   576   const int hot_count = m->backedge_count();
   580   const char* comment = "backedge_count";
       
   581 
   577 
   582   if (is_compilation_enabled() && can_be_osr_compiled(m, comp_level)) {
   578   if (is_compilation_enabled() && can_be_osr_compiled(m, comp_level)) {
   583     CompileBroker::compile_method(m, bci, comp_level, m, hot_count, comment, thread);
   579     CompileBroker::compile_method(m, bci, comp_level, m, hot_count, CompileTask::Reason_BackedgeCount, thread);
   584     NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, comp_level, true));)
   580     NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, comp_level, true));)
   585   }
   581   }
   586 }
   582 }
   587 
   583 
   588 RFrame* StackWalkCompPolicy::findTopInlinableFrame(GrowableArray<RFrame*>* stack) {
   584 RFrame* StackWalkCompPolicy::findTopInlinableFrame(GrowableArray<RFrame*>* stack) {