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