468 if (TraceOnStackReplacement) {
469 ResourceMark rm;
470 tty->print(osr != NULL ? "Reused OSR entry for " : "Requesting OSR entry for ");
471 method->print_short_name(tty);
472 tty->print_cr(" at bci %d", bci);
473 }
474 }
475 #endif // !PRODUCT
476
477 // SimpleCompPolicy - compile current method
478
479 void SimpleCompPolicy::method_invocation_event(const methodHandle& m, JavaThread* thread) {
480 const int comp_level = CompLevel_highest_tier;
481 const int hot_count = m->invocation_count();
482 reset_counter_for_invocation_event(m);
483 const char* comment = "count";
484
485 if (is_compilation_enabled() && can_be_compiled(m, comp_level)) {
486 nmethod* nm = m->code();
487 if (nm == NULL ) {
488 CompileBroker::compile_method(m, InvocationEntryBci, comp_level, m, hot_count, comment, thread);
489 }
490 }
491 }
492
493 void SimpleCompPolicy::method_back_branch_event(const methodHandle& m, int bci, JavaThread* thread) {
494 const int comp_level = CompLevel_highest_tier;
495 const int hot_count = m->backedge_count();
496 const char* comment = "backedge_count";
497
498 if (is_compilation_enabled() && can_be_osr_compiled(m, comp_level)) {
499 CompileBroker::compile_method(m, bci, comp_level, m, hot_count, comment, thread);
500 NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, comp_level, true));)
501 }
502 }
503 // StackWalkCompPolicy - walk up stack to find a suitable method to compile
504
505 #ifdef COMPILER2
506 const char* StackWalkCompPolicy::_msg = NULL;
507
508
509 // Consider m for compilation
510 void StackWalkCompPolicy::method_invocation_event(const methodHandle& m, JavaThread* thread) {
511 const int comp_level = CompLevel_highest_tier;
512 const int hot_count = m->invocation_count();
513 reset_counter_for_invocation_event(m);
514 const char* comment = "count";
515
516 if (is_compilation_enabled() && m->code() == NULL && can_be_compiled(m, comp_level)) {
517 ResourceMark rm(thread);
518 frame fr = thread->last_frame();
519 assert(fr.is_interpreted_frame(), "must be interpreted");
524 m->print_short_name(tty);
525 tty->print(" ( interpreted " INTPTR_FORMAT ", size=%d ) ", p2i((address)m()), m->code_size());
526 }
527 RegisterMap reg_map(thread, false);
528 javaVFrame* triggerVF = thread->last_java_vframe(®_map);
529 // triggerVF is the frame that triggered its counter
530 RFrame* first = new InterpretedRFrame(triggerVF->fr(), thread, m());
531
532 if (first->top_method()->code() != NULL) {
533 // called obsolete method/nmethod -- no need to recompile
534 if (TraceCompilationPolicy) tty->print_cr(" --> " INTPTR_FORMAT, p2i(first->top_method()->code()));
535 } else {
536 if (TimeCompilationPolicy) accumulated_time()->start();
537 GrowableArray<RFrame*>* stack = new GrowableArray<RFrame*>(50);
538 stack->push(first);
539 RFrame* top = findTopInlinableFrame(stack);
540 if (TimeCompilationPolicy) accumulated_time()->stop();
541 assert(top != NULL, "findTopInlinableFrame returned null");
542 if (TraceCompilationPolicy) top->print();
543 CompileBroker::compile_method(top->top_method(), InvocationEntryBci, comp_level,
544 m, hot_count, comment, thread);
545 }
546 }
547 }
548
549 void StackWalkCompPolicy::method_back_branch_event(const methodHandle& m, int bci, JavaThread* thread) {
550 const int comp_level = CompLevel_highest_tier;
551 const int hot_count = m->backedge_count();
552 const char* comment = "backedge_count";
553
554 if (is_compilation_enabled() && can_be_osr_compiled(m, comp_level)) {
555 CompileBroker::compile_method(m, bci, comp_level, m, hot_count, comment, thread);
556 NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, comp_level, true));)
557 }
558 }
559
560 RFrame* StackWalkCompPolicy::findTopInlinableFrame(GrowableArray<RFrame*>* stack) {
561 // go up the stack until finding a frame that (probably) won't be inlined
562 // into its caller
563 RFrame* current = stack->at(0); // current choice for stopping
564 assert( current && !current->is_compiled(), "" );
565 const char* msg = NULL;
566
567 while (1) {
568
569 // before going up the stack further, check if doing so would get us into
570 // compiled code
571 RFrame* next = senderOf(current, stack);
572 if( !next ) // No next frame up the stack?
573 break; // Then compile with current frame
574
575 Method* m = current->top_method();
|
468 if (TraceOnStackReplacement) {
469 ResourceMark rm;
470 tty->print(osr != NULL ? "Reused OSR entry for " : "Requesting OSR entry for ");
471 method->print_short_name(tty);
472 tty->print_cr(" at bci %d", bci);
473 }
474 }
475 #endif // !PRODUCT
476
477 // SimpleCompPolicy - compile current method
478
479 void SimpleCompPolicy::method_invocation_event(const methodHandle& m, JavaThread* thread) {
480 const int comp_level = CompLevel_highest_tier;
481 const int hot_count = m->invocation_count();
482 reset_counter_for_invocation_event(m);
483 const char* comment = "count";
484
485 if (is_compilation_enabled() && can_be_compiled(m, comp_level)) {
486 nmethod* nm = m->code();
487 if (nm == NULL ) {
488 CompileBroker::compile_method(m, InvocationEntryBci, comp_level, m, hot_count, comment, false, thread);
489 }
490 }
491 }
492
493 void SimpleCompPolicy::method_back_branch_event(const methodHandle& m, int bci, JavaThread* thread) {
494 const int comp_level = CompLevel_highest_tier;
495 const int hot_count = m->backedge_count();
496 const char* comment = "backedge_count";
497
498 if (is_compilation_enabled() && can_be_osr_compiled(m, comp_level)) {
499 CompileBroker::compile_method(m, bci, comp_level, m, hot_count, comment, false, thread);
500 NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, comp_level, true));)
501 }
502 }
503 // StackWalkCompPolicy - walk up stack to find a suitable method to compile
504
505 #ifdef COMPILER2
506 const char* StackWalkCompPolicy::_msg = NULL;
507
508
509 // Consider m for compilation
510 void StackWalkCompPolicy::method_invocation_event(const methodHandle& m, JavaThread* thread) {
511 const int comp_level = CompLevel_highest_tier;
512 const int hot_count = m->invocation_count();
513 reset_counter_for_invocation_event(m);
514 const char* comment = "count";
515
516 if (is_compilation_enabled() && m->code() == NULL && can_be_compiled(m, comp_level)) {
517 ResourceMark rm(thread);
518 frame fr = thread->last_frame();
519 assert(fr.is_interpreted_frame(), "must be interpreted");
524 m->print_short_name(tty);
525 tty->print(" ( interpreted " INTPTR_FORMAT ", size=%d ) ", p2i((address)m()), m->code_size());
526 }
527 RegisterMap reg_map(thread, false);
528 javaVFrame* triggerVF = thread->last_java_vframe(®_map);
529 // triggerVF is the frame that triggered its counter
530 RFrame* first = new InterpretedRFrame(triggerVF->fr(), thread, m());
531
532 if (first->top_method()->code() != NULL) {
533 // called obsolete method/nmethod -- no need to recompile
534 if (TraceCompilationPolicy) tty->print_cr(" --> " INTPTR_FORMAT, p2i(first->top_method()->code()));
535 } else {
536 if (TimeCompilationPolicy) accumulated_time()->start();
537 GrowableArray<RFrame*>* stack = new GrowableArray<RFrame*>(50);
538 stack->push(first);
539 RFrame* top = findTopInlinableFrame(stack);
540 if (TimeCompilationPolicy) accumulated_time()->stop();
541 assert(top != NULL, "findTopInlinableFrame returned null");
542 if (TraceCompilationPolicy) top->print();
543 CompileBroker::compile_method(top->top_method(), InvocationEntryBci, comp_level,
544 m, hot_count, comment, false, thread);
545 }
546 }
547 }
548
549 void StackWalkCompPolicy::method_back_branch_event(const methodHandle& m, int bci, JavaThread* thread) {
550 const int comp_level = CompLevel_highest_tier;
551 const int hot_count = m->backedge_count();
552 const char* comment = "backedge_count";
553
554 if (is_compilation_enabled() && can_be_osr_compiled(m, comp_level)) {
555 CompileBroker::compile_method(m, bci, comp_level, m, hot_count, comment, false, thread);
556 NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, comp_level, true));)
557 }
558 }
559
560 RFrame* StackWalkCompPolicy::findTopInlinableFrame(GrowableArray<RFrame*>* stack) {
561 // go up the stack until finding a frame that (probably) won't be inlined
562 // into its caller
563 RFrame* current = stack->at(0); // current choice for stopping
564 assert( current && !current->is_compiled(), "" );
565 const char* msg = NULL;
566
567 while (1) {
568
569 // before going up the stack further, check if doing so would get us into
570 // compiled code
571 RFrame* next = senderOf(current, stack);
572 if( !next ) // No next frame up the stack?
573 break; // Then compile with current frame
574
575 Method* m = current->top_method();
|