106 if (C->eliminate_boxing() && callee_method->is_boxing_method()) {
107 return true;
108 }
109 return false;
110 }
111
112 /**
113 * Force inlining unboxing accessor.
114 */
115 static bool is_unboxing_method(ciMethod* callee_method, Compile* C) {
116 return C->eliminate_boxing() && callee_method->is_unboxing_method();
117 }
118
119 // positive filter: should callee be inlined?
120 bool InlineTree::should_inline(ciMethod* callee_method, ciMethod* caller_method,
121 int caller_bci, ciCallProfile& profile,
122 WarmCallInfo* wci_result) {
123 // Allows targeted inlining
124 if(callee_method->should_inline()) {
125 *wci_result = *(WarmCallInfo::always_hot());
126 if (PrintInlining && Verbose) {
127 CompileTask::print_inline_indent(inline_level());
128 tty->print_cr("Inlined method is hot: ");
129 }
130 set_msg("force inline by CompilerOracle");
131 return true;
132 }
133
134 int size = callee_method->code_size_for_inlining();
135
136 // Check for too many throws (and not too huge)
137 if(callee_method->interpreter_throwout_count() > InlineThrowCount &&
138 size < InlineThrowMaxSize ) {
139 wci_result->set_profit(wci_result->profit() * 100);
140 if (PrintInlining && Verbose) {
141 CompileTask::print_inline_indent(inline_level());
142 tty->print_cr("Inlined method with many throws (throws=%d):", callee_method->interpreter_throwout_count());
143 }
144 set_msg("many throws");
145 return true;
146 }
147
148 if (!UseOldInlining) {
149 set_msg("!UseOldInlining");
150 return true; // size and frequency are represented in a new way
151 }
152
153 int default_max_inline_size = C->max_inline_size();
154 int inline_small_code_size = InlineSmallCode / 4;
155 int max_inline_size = default_max_inline_size;
156
157 int call_site_count = method()->scale_count(profile.count());
158 int invoke_count = method()->interpreter_invocation_count();
159
160 assert(invoke_count != 0, "require invocation count greater than zero");
474 if ( callee->is_native()) return "native method";
475 if ( callee->is_abstract()) return "abstract method";
476 if (!callee->can_be_compiled()) return "not compilable (disabled)";
477 if (!callee->has_balanced_monitors()) return "not compilable (unbalanced monitors)";
478 if ( callee->get_flow_analysis()->failing()) return "not compilable (flow analysis failed)";
479 return NULL;
480 }
481
482 //------------------------------print_inlining---------------------------------
483 void InlineTree::print_inlining(ciMethod* callee_method, int caller_bci,
484 bool success) const {
485 const char* inline_msg = msg();
486 assert(inline_msg != NULL, "just checking");
487 if (C->log() != NULL) {
488 if (success) {
489 C->log()->inline_success(inline_msg);
490 } else {
491 C->log()->inline_fail(inline_msg);
492 }
493 }
494 if (PrintInlining) {
495 C->print_inlining(callee_method, inline_level(), caller_bci, inline_msg);
496 if (callee_method == NULL) tty->print(" callee not monotonic or profiled");
497 if (Verbose && callee_method) {
498 const InlineTree *top = this;
499 while( top->caller_tree() != NULL ) { top = top->caller_tree(); }
500 //tty->print(" bcs: %d+%d invoked: %d", top->count_inline_bcs(), callee_method->code_size(), callee_method->interpreter_invocation_count());
501 }
502 }
503 }
504
505 //------------------------------ok_to_inline-----------------------------------
506 WarmCallInfo* InlineTree::ok_to_inline(ciMethod* callee_method, JVMState* jvms, ciCallProfile& profile, WarmCallInfo* initial_wci, bool& should_delay) {
507 assert(callee_method != NULL, "caller checks for optimized virtual!");
508 assert(!should_delay, "should be initialized to false");
509 #ifdef ASSERT
510 // Make sure the incoming jvms has the same information content as me.
511 // This means that we can eventually make this whole class AllStatic.
512 if (jvms->caller() == NULL) {
513 assert(_caller_jvms == NULL, "redundant instance state");
514 } else {
523 if (!pass_initial_checks(caller_method, caller_bci, callee_method)) {
524 set_msg("failed initial checks");
525 print_inlining(callee_method, caller_bci, false /* !success */);
526 return NULL;
527 }
528
529 // Do some parse checks.
530 set_msg(check_can_parse(callee_method));
531 if (msg() != NULL) {
532 print_inlining(callee_method, caller_bci, false /* !success */);
533 return NULL;
534 }
535
536 // Check if inlining policy says no.
537 WarmCallInfo wci = *(initial_wci);
538 bool success = try_to_inline(callee_method, caller_method, caller_bci,
539 profile, &wci, should_delay);
540
541 #ifndef PRODUCT
542 if (UseOldInlining && InlineWarmCalls
543 && (PrintOpto || PrintOptoInlining || PrintInlining)) {
544 bool cold = wci.is_cold();
545 bool hot = !cold && wci.is_hot();
546 bool old_cold = !success;
547 if (old_cold != cold || (Verbose || WizardMode)) {
548 if (msg() == NULL) {
549 set_msg("OK");
550 }
551 tty->print(" OldInlining= %4s : %s\n WCI=",
552 old_cold ? "cold" : "hot", msg());
553 wci.print();
554 }
555 }
556 #endif
557 if (UseOldInlining) {
558 if (success) {
559 wci = *(WarmCallInfo::always_hot());
560 } else {
561 wci = *(WarmCallInfo::always_cold());
562 }
563 }
600
601 return freq;
602 }
603
604 //------------------------------build_inline_tree_for_callee-------------------
605 InlineTree *InlineTree::build_inline_tree_for_callee( ciMethod* callee_method, JVMState* caller_jvms, int caller_bci) {
606 float recur_frequency = _site_invoke_ratio * compute_callee_frequency(caller_bci);
607 // Attempt inlining.
608 InlineTree* old_ilt = callee_at(caller_bci, callee_method);
609 if (old_ilt != NULL) {
610 return old_ilt;
611 }
612 int max_inline_level_adjust = 0;
613 if (caller_jvms->method() != NULL) {
614 if (caller_jvms->method()->is_compiled_lambda_form())
615 max_inline_level_adjust += 1; // don't count actions in MH or indy adapter frames
616 else if (callee_method->is_method_handle_intrinsic() ||
617 callee_method->is_compiled_lambda_form()) {
618 max_inline_level_adjust += 1; // don't count method handle calls from java.lang.invoke implem
619 }
620 if (max_inline_level_adjust != 0 && PrintInlining && (Verbose || WizardMode)) {
621 CompileTask::print_inline_indent(inline_level());
622 tty->print_cr(" \\-> discounting inline depth");
623 }
624 if (max_inline_level_adjust != 0 && C->log()) {
625 int id1 = C->log()->identify(caller_jvms->method());
626 int id2 = C->log()->identify(callee_method);
627 C->log()->elem("inline_level_discount caller='%d' callee='%d'", id1, id2);
628 }
629 }
630 InlineTree* ilt = new InlineTree(C, this, callee_method, caller_jvms, caller_bci, recur_frequency, _max_inline_level + max_inline_level_adjust);
631 _subtrees.append(ilt);
632
633 NOT_PRODUCT( _count_inlines += 1; )
634
635 return ilt;
636 }
637
638
639 //---------------------------------------callee_at-----------------------------
640 InlineTree *InlineTree::callee_at(int bci, ciMethod* callee) const {
|
106 if (C->eliminate_boxing() && callee_method->is_boxing_method()) {
107 return true;
108 }
109 return false;
110 }
111
112 /**
113 * Force inlining unboxing accessor.
114 */
115 static bool is_unboxing_method(ciMethod* callee_method, Compile* C) {
116 return C->eliminate_boxing() && callee_method->is_unboxing_method();
117 }
118
119 // positive filter: should callee be inlined?
120 bool InlineTree::should_inline(ciMethod* callee_method, ciMethod* caller_method,
121 int caller_bci, ciCallProfile& profile,
122 WarmCallInfo* wci_result) {
123 // Allows targeted inlining
124 if(callee_method->should_inline()) {
125 *wci_result = *(WarmCallInfo::always_hot());
126 if (C->print_inlining() && Verbose) {
127 CompileTask::print_inline_indent(inline_level());
128 tty->print_cr("Inlined method is hot: ");
129 }
130 set_msg("force inline by CompilerOracle");
131 return true;
132 }
133
134 int size = callee_method->code_size_for_inlining();
135
136 // Check for too many throws (and not too huge)
137 if(callee_method->interpreter_throwout_count() > InlineThrowCount &&
138 size < InlineThrowMaxSize ) {
139 wci_result->set_profit(wci_result->profit() * 100);
140 if (C->print_inlining() && Verbose) {
141 CompileTask::print_inline_indent(inline_level());
142 tty->print_cr("Inlined method with many throws (throws=%d):", callee_method->interpreter_throwout_count());
143 }
144 set_msg("many throws");
145 return true;
146 }
147
148 if (!UseOldInlining) {
149 set_msg("!UseOldInlining");
150 return true; // size and frequency are represented in a new way
151 }
152
153 int default_max_inline_size = C->max_inline_size();
154 int inline_small_code_size = InlineSmallCode / 4;
155 int max_inline_size = default_max_inline_size;
156
157 int call_site_count = method()->scale_count(profile.count());
158 int invoke_count = method()->interpreter_invocation_count();
159
160 assert(invoke_count != 0, "require invocation count greater than zero");
474 if ( callee->is_native()) return "native method";
475 if ( callee->is_abstract()) return "abstract method";
476 if (!callee->can_be_compiled()) return "not compilable (disabled)";
477 if (!callee->has_balanced_monitors()) return "not compilable (unbalanced monitors)";
478 if ( callee->get_flow_analysis()->failing()) return "not compilable (flow analysis failed)";
479 return NULL;
480 }
481
482 //------------------------------print_inlining---------------------------------
483 void InlineTree::print_inlining(ciMethod* callee_method, int caller_bci,
484 bool success) const {
485 const char* inline_msg = msg();
486 assert(inline_msg != NULL, "just checking");
487 if (C->log() != NULL) {
488 if (success) {
489 C->log()->inline_success(inline_msg);
490 } else {
491 C->log()->inline_fail(inline_msg);
492 }
493 }
494 if (C->print_inlining()) {
495 C->print_inlining(callee_method, inline_level(), caller_bci, inline_msg);
496 if (callee_method == NULL) tty->print(" callee not monotonic or profiled");
497 if (Verbose && callee_method) {
498 const InlineTree *top = this;
499 while( top->caller_tree() != NULL ) { top = top->caller_tree(); }
500 //tty->print(" bcs: %d+%d invoked: %d", top->count_inline_bcs(), callee_method->code_size(), callee_method->interpreter_invocation_count());
501 }
502 }
503 }
504
505 //------------------------------ok_to_inline-----------------------------------
506 WarmCallInfo* InlineTree::ok_to_inline(ciMethod* callee_method, JVMState* jvms, ciCallProfile& profile, WarmCallInfo* initial_wci, bool& should_delay) {
507 assert(callee_method != NULL, "caller checks for optimized virtual!");
508 assert(!should_delay, "should be initialized to false");
509 #ifdef ASSERT
510 // Make sure the incoming jvms has the same information content as me.
511 // This means that we can eventually make this whole class AllStatic.
512 if (jvms->caller() == NULL) {
513 assert(_caller_jvms == NULL, "redundant instance state");
514 } else {
523 if (!pass_initial_checks(caller_method, caller_bci, callee_method)) {
524 set_msg("failed initial checks");
525 print_inlining(callee_method, caller_bci, false /* !success */);
526 return NULL;
527 }
528
529 // Do some parse checks.
530 set_msg(check_can_parse(callee_method));
531 if (msg() != NULL) {
532 print_inlining(callee_method, caller_bci, false /* !success */);
533 return NULL;
534 }
535
536 // Check if inlining policy says no.
537 WarmCallInfo wci = *(initial_wci);
538 bool success = try_to_inline(callee_method, caller_method, caller_bci,
539 profile, &wci, should_delay);
540
541 #ifndef PRODUCT
542 if (UseOldInlining && InlineWarmCalls
543 && (PrintOpto || C->print_inlining())) {
544 bool cold = wci.is_cold();
545 bool hot = !cold && wci.is_hot();
546 bool old_cold = !success;
547 if (old_cold != cold || (Verbose || WizardMode)) {
548 if (msg() == NULL) {
549 set_msg("OK");
550 }
551 tty->print(" OldInlining= %4s : %s\n WCI=",
552 old_cold ? "cold" : "hot", msg());
553 wci.print();
554 }
555 }
556 #endif
557 if (UseOldInlining) {
558 if (success) {
559 wci = *(WarmCallInfo::always_hot());
560 } else {
561 wci = *(WarmCallInfo::always_cold());
562 }
563 }
600
601 return freq;
602 }
603
604 //------------------------------build_inline_tree_for_callee-------------------
605 InlineTree *InlineTree::build_inline_tree_for_callee( ciMethod* callee_method, JVMState* caller_jvms, int caller_bci) {
606 float recur_frequency = _site_invoke_ratio * compute_callee_frequency(caller_bci);
607 // Attempt inlining.
608 InlineTree* old_ilt = callee_at(caller_bci, callee_method);
609 if (old_ilt != NULL) {
610 return old_ilt;
611 }
612 int max_inline_level_adjust = 0;
613 if (caller_jvms->method() != NULL) {
614 if (caller_jvms->method()->is_compiled_lambda_form())
615 max_inline_level_adjust += 1; // don't count actions in MH or indy adapter frames
616 else if (callee_method->is_method_handle_intrinsic() ||
617 callee_method->is_compiled_lambda_form()) {
618 max_inline_level_adjust += 1; // don't count method handle calls from java.lang.invoke implem
619 }
620 if (max_inline_level_adjust != 0 && C->print_inlining() && (Verbose || WizardMode)) {
621 CompileTask::print_inline_indent(inline_level());
622 tty->print_cr(" \\-> discounting inline depth");
623 }
624 if (max_inline_level_adjust != 0 && C->log()) {
625 int id1 = C->log()->identify(caller_jvms->method());
626 int id2 = C->log()->identify(callee_method);
627 C->log()->elem("inline_level_discount caller='%d' callee='%d'", id1, id2);
628 }
629 }
630 InlineTree* ilt = new InlineTree(C, this, callee_method, caller_jvms, caller_bci, recur_frequency, _max_inline_level + max_inline_level_adjust);
631 _subtrees.append(ilt);
632
633 NOT_PRODUCT( _count_inlines += 1; )
634
635 return ilt;
636 }
637
638
639 //---------------------------------------callee_at-----------------------------
640 InlineTree *InlineTree::callee_at(int bci, ciMethod* callee) const {
|