hotspot/src/share/vm/runtime/compilationPolicy.cpp
changeset 13891 35dabd293e56
parent 13728 882756847a04
child 14391 df0a1573d5bd
equal deleted inserted replaced
13890:f07d553b677f 13891:35dabd293e56
   392 #endif // !PRODUCT
   392 #endif // !PRODUCT
   393 
   393 
   394 // SimpleCompPolicy - compile current method
   394 // SimpleCompPolicy - compile current method
   395 
   395 
   396 void SimpleCompPolicy::method_invocation_event(methodHandle m, JavaThread* thread) {
   396 void SimpleCompPolicy::method_invocation_event(methodHandle m, JavaThread* thread) {
   397   int hot_count = m->invocation_count();
   397   const int comp_level = CompLevel_highest_tier;
       
   398   const int hot_count = m->invocation_count();
   398   reset_counter_for_invocation_event(m);
   399   reset_counter_for_invocation_event(m);
   399   const char* comment = "count";
   400   const char* comment = "count";
   400 
   401 
   401   if (is_compilation_enabled() && can_be_compiled(m)) {
   402   if (is_compilation_enabled() && can_be_compiled(m)) {
   402     nmethod* nm = m->code();
   403     nmethod* nm = m->code();
   403     if (nm == NULL ) {
   404     if (nm == NULL ) {
   404       const char* comment = "count";
   405       CompileBroker::compile_method(m, InvocationEntryBci, comp_level, m, hot_count, comment, thread);
   405       CompileBroker::compile_method(m, InvocationEntryBci, CompLevel_highest_tier,
       
   406                                     m, hot_count, comment, thread);
       
   407     }
   406     }
   408   }
   407   }
   409 }
   408 }
   410 
   409 
   411 void SimpleCompPolicy::method_back_branch_event(methodHandle m, int bci, JavaThread* thread) {
   410 void SimpleCompPolicy::method_back_branch_event(methodHandle m, int bci, JavaThread* thread) {
   412   int hot_count = m->backedge_count();
   411   const int comp_level = CompLevel_highest_tier;
       
   412   const int hot_count = m->backedge_count();
   413   const char* comment = "backedge_count";
   413   const char* comment = "backedge_count";
   414 
   414 
   415   if (is_compilation_enabled() && !m->is_not_osr_compilable() && can_be_compiled(m)) {
   415   if (is_compilation_enabled() && !m->is_not_osr_compilable(comp_level) && can_be_compiled(m)) {
   416     CompileBroker::compile_method(m, bci, CompLevel_highest_tier,
   416     CompileBroker::compile_method(m, bci, comp_level, m, hot_count, comment, thread);
   417                                   m, hot_count, comment, thread);
   417     NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, comp_level, true));)
   418     NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, CompLevel_highest_tier, true));)
       
   419   }
   418   }
   420 }
   419 }
   421 // StackWalkCompPolicy - walk up stack to find a suitable method to compile
   420 // StackWalkCompPolicy - walk up stack to find a suitable method to compile
   422 
   421 
   423 #ifdef COMPILER2
   422 #ifdef COMPILER2
   424 const char* StackWalkCompPolicy::_msg = NULL;
   423 const char* StackWalkCompPolicy::_msg = NULL;
   425 
   424 
   426 
   425 
   427 // Consider m for compilation
   426 // Consider m for compilation
   428 void StackWalkCompPolicy::method_invocation_event(methodHandle m, JavaThread* thread) {
   427 void StackWalkCompPolicy::method_invocation_event(methodHandle m, JavaThread* thread) {
   429   int hot_count = m->invocation_count();
   428   const int comp_level = CompLevel_highest_tier;
       
   429   const int hot_count = m->invocation_count();
   430   reset_counter_for_invocation_event(m);
   430   reset_counter_for_invocation_event(m);
   431   const char* comment = "count";
   431   const char* comment = "count";
   432 
   432 
   433   if (is_compilation_enabled() && m->code() == NULL && can_be_compiled(m)) {
   433   if (is_compilation_enabled() && m->code() == NULL && can_be_compiled(m)) {
   434     ResourceMark rm(thread);
   434     ResourceMark rm(thread);
   455       stack->push(first);
   455       stack->push(first);
   456       RFrame* top = findTopInlinableFrame(stack);
   456       RFrame* top = findTopInlinableFrame(stack);
   457       if (TimeCompilationPolicy) accumulated_time()->stop();
   457       if (TimeCompilationPolicy) accumulated_time()->stop();
   458       assert(top != NULL, "findTopInlinableFrame returned null");
   458       assert(top != NULL, "findTopInlinableFrame returned null");
   459       if (TraceCompilationPolicy) top->print();
   459       if (TraceCompilationPolicy) top->print();
   460       CompileBroker::compile_method(top->top_method(), InvocationEntryBci, CompLevel_highest_tier,
   460       CompileBroker::compile_method(top->top_method(), InvocationEntryBci, comp_level,
   461                                     m, hot_count, comment, thread);
   461                                     m, hot_count, comment, thread);
   462     }
   462     }
   463   }
   463   }
   464 }
   464 }
   465 
   465 
   466 void StackWalkCompPolicy::method_back_branch_event(methodHandle m, int bci, JavaThread* thread) {
   466 void StackWalkCompPolicy::method_back_branch_event(methodHandle m, int bci, JavaThread* thread) {
   467   int hot_count = m->backedge_count();
   467   const int comp_level = CompLevel_highest_tier;
       
   468   const int hot_count = m->backedge_count();
   468   const char* comment = "backedge_count";
   469   const char* comment = "backedge_count";
   469 
   470 
   470   if (is_compilation_enabled() && !m->is_not_osr_compilable() && can_be_compiled(m)) {
   471   if (is_compilation_enabled() && !m->is_not_osr_compilable(comp_level) && can_be_compiled(m)) {
   471     CompileBroker::compile_method(m, bci, CompLevel_highest_tier, m, hot_count, comment, thread);
   472     CompileBroker::compile_method(m, bci, comp_level, m, hot_count, comment, thread);
   472 
   473     NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, comp_level, true));)
   473     NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, CompLevel_highest_tier, true));)
       
   474   }
   474   }
   475 }
   475 }
   476 
   476 
   477 RFrame* StackWalkCompPolicy::findTopInlinableFrame(GrowableArray<RFrame*>* stack) {
   477 RFrame* StackWalkCompPolicy::findTopInlinableFrame(GrowableArray<RFrame*>* stack) {
   478   // go up the stack until finding a frame that (probably) won't be inlined
   478   // go up the stack until finding a frame that (probably) won't be inlined