src/share/vm/runtime/compilationPolicy.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/runtime

src/share/vm/runtime/compilationPolicy.cpp

Print this page




 495 void StackWalkCompPolicy::method_invocation_event(methodHandle m, JavaThread* thread) {
 496   const int comp_level = CompLevel_highest_tier;
 497   const int hot_count = m->invocation_count();
 498   reset_counter_for_invocation_event(m);
 499   const char* comment = "count";
 500 
 501   if (is_compilation_enabled() && m->code() == NULL && can_be_compiled(m, comp_level)) {
 502     ResourceMark rm(thread);
 503     frame       fr     = thread->last_frame();
 504     assert(fr.is_interpreted_frame(), "must be interpreted");
 505     assert(fr.interpreter_frame_method() == m(), "bad method");
 506 
 507     if (TraceCompilationPolicy) {
 508       tty->print("method invocation trigger: ");
 509       m->print_short_name(tty);
 510       tty->print(" ( interpreted " INTPTR_FORMAT ", size=%d ) ", p2i((address)m()), m->code_size());
 511     }
 512     RegisterMap reg_map(thread, false);
 513     javaVFrame* triggerVF = thread->last_java_vframe(&reg_map);
 514     // triggerVF is the frame that triggered its counter
 515     RFrame* first = new InterpretedRFrame(triggerVF->fr(), thread, m);
 516 
 517     if (first->top_method()->code() != NULL) {
 518       // called obsolete method/nmethod -- no need to recompile
 519       if (TraceCompilationPolicy) tty->print_cr(" --> " INTPTR_FORMAT, p2i(first->top_method()->code()));
 520     } else {
 521       if (TimeCompilationPolicy) accumulated_time()->start();
 522       GrowableArray<RFrame*>* stack = new GrowableArray<RFrame*>(50);
 523       stack->push(first);
 524       RFrame* top = findTopInlinableFrame(stack);
 525       if (TimeCompilationPolicy) accumulated_time()->stop();
 526       assert(top != NULL, "findTopInlinableFrame returned null");
 527       if (TraceCompilationPolicy) top->print();
 528       CompileBroker::compile_method(top->top_method(), InvocationEntryBci, comp_level,
 529                                     m, hot_count, comment, thread);
 530     }
 531   }
 532 }
 533 
 534 void StackWalkCompPolicy::method_back_branch_event(methodHandle m, int bci, JavaThread* thread) {
 535   const int comp_level = CompLevel_highest_tier;


 540     CompileBroker::compile_method(m, bci, comp_level, m, hot_count, comment, thread);
 541     NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, comp_level, true));)
 542   }
 543 }
 544 
 545 RFrame* StackWalkCompPolicy::findTopInlinableFrame(GrowableArray<RFrame*>* stack) {
 546   // go up the stack until finding a frame that (probably) won't be inlined
 547   // into its caller
 548   RFrame* current = stack->at(0); // current choice for stopping
 549   assert( current && !current->is_compiled(), "" );
 550   const char* msg = NULL;
 551 
 552   while (1) {
 553 
 554     // before going up the stack further, check if doing so would get us into
 555     // compiled code
 556     RFrame* next = senderOf(current, stack);
 557     if( !next )               // No next frame up the stack?
 558       break;                  // Then compile with current frame
 559 
 560     methodHandle m = current->top_method();
 561     methodHandle next_m = next->top_method();
 562 
 563     if (TraceCompilationPolicy && Verbose) {
 564       tty->print("[caller: ");
 565       next_m->print_short_name(tty);
 566       tty->print("] ");
 567     }
 568 
 569     if( !Inline ) {           // Inlining turned off
 570       msg = "Inlining turned off";
 571       break;
 572     }
 573     if (next_m->is_not_compilable()) { // Did fail to compile this before/
 574       msg = "caller not compilable";
 575       break;
 576     }
 577     if (next->num() > MaxRecompilationSearchLength) {
 578       // don't go up too high when searching for recompilees
 579       msg = "don't go up any further: > MaxRecompilationSearchLength";
 580       break;
 581     }


 627     if ((msg = shouldNotInline(m)) != NULL) {
 628       break;
 629     }
 630 
 631 
 632     // If the caller method is too big or something then we do not want to
 633     // compile it just to inline a method
 634     if (!can_be_compiled(next_m, CompLevel_any)) {
 635       msg = "caller cannot be compiled";
 636       break;
 637     }
 638 
 639     if( next_m->name() == vmSymbols::class_initializer_name() ) {
 640       msg = "do not compile class initializer (OSR ok)";
 641       break;
 642     }
 643 
 644     if (TraceCompilationPolicy && Verbose) {
 645       tty->print("\n\t     check caller: ");
 646       next_m->print_short_name(tty);
 647       tty->print(" ( interpreted " INTPTR_FORMAT ", size=%d ) ", p2i((address)next_m()), next_m->code_size());
 648     }
 649 
 650     current = next;
 651   }
 652 
 653   assert( !current || !current->is_compiled(), "" );
 654 
 655   if (TraceCompilationPolicy && msg) tty->print("(%s)\n", msg);
 656 
 657   return current;
 658 }
 659 
 660 RFrame* StackWalkCompPolicy::senderOf(RFrame* rf, GrowableArray<RFrame*>* stack) {
 661   RFrame* sender = rf->caller();
 662   if (sender && sender->num() == stack->length()) stack->push(sender);
 663   return sender;
 664 }
 665 
 666 
 667 const char* StackWalkCompPolicy::shouldInline(methodHandle m, float freq, int cnt) {




 495 void StackWalkCompPolicy::method_invocation_event(methodHandle m, JavaThread* thread) {
 496   const int comp_level = CompLevel_highest_tier;
 497   const int hot_count = m->invocation_count();
 498   reset_counter_for_invocation_event(m);
 499   const char* comment = "count";
 500 
 501   if (is_compilation_enabled() && m->code() == NULL && can_be_compiled(m, comp_level)) {
 502     ResourceMark rm(thread);
 503     frame       fr     = thread->last_frame();
 504     assert(fr.is_interpreted_frame(), "must be interpreted");
 505     assert(fr.interpreter_frame_method() == m(), "bad method");
 506 
 507     if (TraceCompilationPolicy) {
 508       tty->print("method invocation trigger: ");
 509       m->print_short_name(tty);
 510       tty->print(" ( interpreted " INTPTR_FORMAT ", size=%d ) ", p2i((address)m()), m->code_size());
 511     }
 512     RegisterMap reg_map(thread, false);
 513     javaVFrame* triggerVF = thread->last_java_vframe(&reg_map);
 514     // triggerVF is the frame that triggered its counter
 515     RFrame* first = new InterpretedRFrame(triggerVF->fr(), thread, m());
 516 
 517     if (first->top_method()->code() != NULL) {
 518       // called obsolete method/nmethod -- no need to recompile
 519       if (TraceCompilationPolicy) tty->print_cr(" --> " INTPTR_FORMAT, p2i(first->top_method()->code()));
 520     } else {
 521       if (TimeCompilationPolicy) accumulated_time()->start();
 522       GrowableArray<RFrame*>* stack = new GrowableArray<RFrame*>(50);
 523       stack->push(first);
 524       RFrame* top = findTopInlinableFrame(stack);
 525       if (TimeCompilationPolicy) accumulated_time()->stop();
 526       assert(top != NULL, "findTopInlinableFrame returned null");
 527       if (TraceCompilationPolicy) top->print();
 528       CompileBroker::compile_method(top->top_method(), InvocationEntryBci, comp_level,
 529                                     m, hot_count, comment, thread);
 530     }
 531   }
 532 }
 533 
 534 void StackWalkCompPolicy::method_back_branch_event(methodHandle m, int bci, JavaThread* thread) {
 535   const int comp_level = CompLevel_highest_tier;


 540     CompileBroker::compile_method(m, bci, comp_level, m, hot_count, comment, thread);
 541     NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, comp_level, true));)
 542   }
 543 }
 544 
 545 RFrame* StackWalkCompPolicy::findTopInlinableFrame(GrowableArray<RFrame*>* stack) {
 546   // go up the stack until finding a frame that (probably) won't be inlined
 547   // into its caller
 548   RFrame* current = stack->at(0); // current choice for stopping
 549   assert( current && !current->is_compiled(), "" );
 550   const char* msg = NULL;
 551 
 552   while (1) {
 553 
 554     // before going up the stack further, check if doing so would get us into
 555     // compiled code
 556     RFrame* next = senderOf(current, stack);
 557     if( !next )               // No next frame up the stack?
 558       break;                  // Then compile with current frame
 559 
 560     Method* m = current->top_method();
 561     Method* next_m = next->top_method();
 562 
 563     if (TraceCompilationPolicy && Verbose) {
 564       tty->print("[caller: ");
 565       next_m->print_short_name(tty);
 566       tty->print("] ");
 567     }
 568 
 569     if( !Inline ) {           // Inlining turned off
 570       msg = "Inlining turned off";
 571       break;
 572     }
 573     if (next_m->is_not_compilable()) { // Did fail to compile this before/
 574       msg = "caller not compilable";
 575       break;
 576     }
 577     if (next->num() > MaxRecompilationSearchLength) {
 578       // don't go up too high when searching for recompilees
 579       msg = "don't go up any further: > MaxRecompilationSearchLength";
 580       break;
 581     }


 627     if ((msg = shouldNotInline(m)) != NULL) {
 628       break;
 629     }
 630 
 631 
 632     // If the caller method is too big or something then we do not want to
 633     // compile it just to inline a method
 634     if (!can_be_compiled(next_m, CompLevel_any)) {
 635       msg = "caller cannot be compiled";
 636       break;
 637     }
 638 
 639     if( next_m->name() == vmSymbols::class_initializer_name() ) {
 640       msg = "do not compile class initializer (OSR ok)";
 641       break;
 642     }
 643 
 644     if (TraceCompilationPolicy && Verbose) {
 645       tty->print("\n\t     check caller: ");
 646       next_m->print_short_name(tty);
 647       tty->print(" ( interpreted " INTPTR_FORMAT ", size=%d ) ", p2i((address)next_m), next_m->code_size());
 648     }
 649 
 650     current = next;
 651   }
 652 
 653   assert( !current || !current->is_compiled(), "" );
 654 
 655   if (TraceCompilationPolicy && msg) tty->print("(%s)\n", msg);
 656 
 657   return current;
 658 }
 659 
 660 RFrame* StackWalkCompPolicy::senderOf(RFrame* rf, GrowableArray<RFrame*>* stack) {
 661   RFrame* sender = rf->caller();
 662   if (sender && sender->num() == stack->length()) stack->push(sender);
 663   return sender;
 664 }
 665 
 666 
 667 const char* StackWalkCompPolicy::shouldInline(methodHandle m, float freq, int cnt) {


src/share/vm/runtime/compilationPolicy.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File