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

src/share/vm/runtime/compilationPolicy.cpp

Print this page




 379           tty->print_cr("back branch count = %d", count);
 380         }
 381       }
 382     }
 383   }
 384 }
 385 
 386 void NonTieredCompPolicy::trace_osr_request(methodHandle method, nmethod* osr, int bci) {
 387   if (TraceOnStackReplacement) {
 388     ResourceMark rm;
 389     tty->print(osr != NULL ? "Reused OSR entry for " : "Requesting OSR entry for ");
 390     method->print_short_name(tty);
 391     tty->print_cr(" at bci %d", bci);
 392   }
 393 }
 394 #endif // !PRODUCT
 395 
 396 // SimpleCompPolicy - compile current method
 397 
 398 void SimpleCompPolicy::method_invocation_event( methodHandle m, TRAPS) {
 399   assert(UseCompiler || CompileTheWorld, "UseCompiler should be set by now.");
 400 
 401   int hot_count = m->invocation_count();
 402   reset_counter_for_invocation_event(m);
 403   const char* comment = "count";
 404 
 405   if (is_compilation_enabled() && can_be_compiled(m)) {
 406     nmethod* nm = m->code();
 407     if (nm == NULL ) {
 408       const char* comment = "count";
 409       CompileBroker::compile_method(m, InvocationEntryBci, CompLevel_highest_tier,
 410                                     m, hot_count, comment, CHECK);
 411     }
 412   }
 413 }
 414 
 415 void SimpleCompPolicy::method_back_branch_event(methodHandle m, int bci, TRAPS) {
 416   assert(UseCompiler || CompileTheWorld, "UseCompiler should be set by now.");
 417 
 418   int hot_count = m->backedge_count();
 419   const char* comment = "backedge_count";
 420 
 421   if (is_compilation_enabled() && !m->is_not_osr_compilable() && can_be_compiled(m)) {
 422     CompileBroker::compile_method(m, bci, CompLevel_highest_tier,
 423                                   m, hot_count, comment, CHECK);
 424     NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, CompLevel_highest_tier, true));)
 425   }
 426 }
 427 // StackWalkCompPolicy - walk up stack to find a suitable method to compile
 428 
 429 #ifdef COMPILER2
 430 const char* StackWalkCompPolicy::_msg = NULL;
 431 
 432 
 433 // Consider m for compilation
 434 void StackWalkCompPolicy::method_invocation_event(methodHandle m, TRAPS) {
 435   assert(UseCompiler || CompileTheWorld, "UseCompiler should be set by now.");
 436 
 437   int hot_count = m->invocation_count();
 438   reset_counter_for_invocation_event(m);
 439   const char* comment = "count";
 440 
 441   if (is_compilation_enabled() && m->code() == NULL && can_be_compiled(m)) {
 442     ResourceMark rm(THREAD);
 443     JavaThread *thread = (JavaThread*)THREAD;
 444     frame       fr     = thread->last_frame();
 445     assert(fr.is_interpreted_frame(), "must be interpreted");
 446     assert(fr.interpreter_frame_method() == m(), "bad method");
 447 
 448     if (TraceCompilationPolicy) {
 449       tty->print("method invocation trigger: ");
 450       m->print_short_name(tty);
 451       tty->print(" ( interpreted " INTPTR_FORMAT ", size=%d ) ", (address)m(), m->code_size());
 452     }
 453     RegisterMap reg_map(thread, false);
 454     javaVFrame* triggerVF = thread->last_java_vframe(&reg_map);
 455     // triggerVF is the frame that triggered its counter
 456     RFrame* first = new InterpretedRFrame(triggerVF->fr(), thread, m);
 457 
 458     if (first->top_method()->code() != NULL) {
 459       // called obsolete method/nmethod -- no need to recompile
 460       if (TraceCompilationPolicy) tty->print_cr(" --> " INTPTR_FORMAT, first->top_method()->code());
 461     } else {
 462       if (TimeCompilationPolicy) accumulated_time()->start();
 463       GrowableArray<RFrame*>* stack = new GrowableArray<RFrame*>(50);
 464       stack->push(first);
 465       RFrame* top = findTopInlinableFrame(stack);
 466       if (TimeCompilationPolicy) accumulated_time()->stop();
 467       assert(top != NULL, "findTopInlinableFrame returned null");
 468       if (TraceCompilationPolicy) top->print();
 469       CompileBroker::compile_method(top->top_method(), InvocationEntryBci, CompLevel_highest_tier,
 470                                     m, hot_count, comment, CHECK);
 471     }
 472   }
 473 }
 474 
 475 void StackWalkCompPolicy::method_back_branch_event(methodHandle m, int bci, TRAPS) {
 476   assert(UseCompiler || CompileTheWorld, "UseCompiler should be set by now.");
 477 
 478   int hot_count = m->backedge_count();
 479   const char* comment = "backedge_count";
 480 
 481   if (is_compilation_enabled() && !m->is_not_osr_compilable() && can_be_compiled(m)) {
 482     CompileBroker::compile_method(m, bci, CompLevel_highest_tier, m, hot_count, comment, CHECK);
 483 
 484     NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, CompLevel_highest_tier, true));)
 485   }
 486 }
 487 
 488 RFrame* StackWalkCompPolicy::findTopInlinableFrame(GrowableArray<RFrame*>* stack) {
 489   // go up the stack until finding a frame that (probably) won't be inlined
 490   // into its caller
 491   RFrame* current = stack->at(0); // current choice for stopping
 492   assert( current && !current->is_compiled(), "" );
 493   const char* msg = NULL;
 494 
 495   while (1) {
 496 
 497     // before going up the stack further, check if doing so would get us into




 379           tty->print_cr("back branch count = %d", count);
 380         }
 381       }
 382     }
 383   }
 384 }
 385 
 386 void NonTieredCompPolicy::trace_osr_request(methodHandle method, nmethod* osr, int bci) {
 387   if (TraceOnStackReplacement) {
 388     ResourceMark rm;
 389     tty->print(osr != NULL ? "Reused OSR entry for " : "Requesting OSR entry for ");
 390     method->print_short_name(tty);
 391     tty->print_cr(" at bci %d", bci);
 392   }
 393 }
 394 #endif // !PRODUCT
 395 
 396 // SimpleCompPolicy - compile current method
 397 
 398 void SimpleCompPolicy::method_invocation_event( methodHandle m, TRAPS) {


 399   int hot_count = m->invocation_count();
 400   reset_counter_for_invocation_event(m);
 401   const char* comment = "count";
 402 
 403   if (is_compilation_enabled() && can_be_compiled(m)) {
 404     nmethod* nm = m->code();
 405     if (nm == NULL ) {
 406       const char* comment = "count";
 407       CompileBroker::compile_method(m, InvocationEntryBci, CompLevel_highest_tier,
 408                                     m, hot_count, comment, CHECK);
 409     }
 410   }
 411 }
 412 
 413 void SimpleCompPolicy::method_back_branch_event(methodHandle m, int bci, TRAPS) {


 414   int hot_count = m->backedge_count();
 415   const char* comment = "backedge_count";
 416 
 417   if (is_compilation_enabled() && !m->is_not_osr_compilable() && can_be_compiled(m)) {
 418     CompileBroker::compile_method(m, bci, CompLevel_highest_tier,
 419                                   m, hot_count, comment, CHECK);
 420     NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, CompLevel_highest_tier, true));)
 421   }
 422 }
 423 // StackWalkCompPolicy - walk up stack to find a suitable method to compile
 424 
 425 #ifdef COMPILER2
 426 const char* StackWalkCompPolicy::_msg = NULL;
 427 
 428 
 429 // Consider m for compilation
 430 void StackWalkCompPolicy::method_invocation_event(methodHandle m, TRAPS) {


 431   int hot_count = m->invocation_count();
 432   reset_counter_for_invocation_event(m);
 433   const char* comment = "count";
 434 
 435   if (is_compilation_enabled() && m->code() == NULL && can_be_compiled(m)) {
 436     ResourceMark rm(THREAD);
 437     JavaThread *thread = (JavaThread*)THREAD;
 438     frame       fr     = thread->last_frame();
 439     assert(fr.is_interpreted_frame(), "must be interpreted");
 440     assert(fr.interpreter_frame_method() == m(), "bad method");
 441 
 442     if (TraceCompilationPolicy) {
 443       tty->print("method invocation trigger: ");
 444       m->print_short_name(tty);
 445       tty->print(" ( interpreted " INTPTR_FORMAT ", size=%d ) ", (address)m(), m->code_size());
 446     }
 447     RegisterMap reg_map(thread, false);
 448     javaVFrame* triggerVF = thread->last_java_vframe(&reg_map);
 449     // triggerVF is the frame that triggered its counter
 450     RFrame* first = new InterpretedRFrame(triggerVF->fr(), thread, m);
 451 
 452     if (first->top_method()->code() != NULL) {
 453       // called obsolete method/nmethod -- no need to recompile
 454       if (TraceCompilationPolicy) tty->print_cr(" --> " INTPTR_FORMAT, first->top_method()->code());
 455     } else {
 456       if (TimeCompilationPolicy) accumulated_time()->start();
 457       GrowableArray<RFrame*>* stack = new GrowableArray<RFrame*>(50);
 458       stack->push(first);
 459       RFrame* top = findTopInlinableFrame(stack);
 460       if (TimeCompilationPolicy) accumulated_time()->stop();
 461       assert(top != NULL, "findTopInlinableFrame returned null");
 462       if (TraceCompilationPolicy) top->print();
 463       CompileBroker::compile_method(top->top_method(), InvocationEntryBci, CompLevel_highest_tier,
 464                                     m, hot_count, comment, CHECK);
 465     }
 466   }
 467 }
 468 
 469 void StackWalkCompPolicy::method_back_branch_event(methodHandle m, int bci, TRAPS) {


 470   int hot_count = m->backedge_count();
 471   const char* comment = "backedge_count";
 472 
 473   if (is_compilation_enabled() && !m->is_not_osr_compilable() && can_be_compiled(m)) {
 474     CompileBroker::compile_method(m, bci, CompLevel_highest_tier, m, hot_count, comment, CHECK);
 475 
 476     NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, CompLevel_highest_tier, true));)
 477   }
 478 }
 479 
 480 RFrame* StackWalkCompPolicy::findTopInlinableFrame(GrowableArray<RFrame*>* stack) {
 481   // go up the stack until finding a frame that (probably) won't be inlined
 482   // into its caller
 483   RFrame* current = stack->at(0); // current choice for stopping
 484   assert( current && !current->is_compiled(), "" );
 485   const char* msg = NULL;
 486 
 487   while (1) {
 488 
 489     // before going up the stack further, check if doing so would get us into


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