418 if ( callee->get_flow_analysis()->failing()) return "not compilable (flow analysis failed)"; |
418 if ( callee->get_flow_analysis()->failing()) return "not compilable (flow analysis failed)"; |
419 return NULL; |
419 return NULL; |
420 } |
420 } |
421 |
421 |
422 //------------------------------print_inlining--------------------------------- |
422 //------------------------------print_inlining--------------------------------- |
423 // Really, the failure_msg can be a success message also. |
423 void InlineTree::print_inlining(ciMethod* callee_method, int caller_bci, |
424 void InlineTree::print_inlining(ciMethod* callee_method, int caller_bci, const char* failure_msg) const { |
424 const char* msg, bool success) const { |
425 C->print_inlining(callee_method, inline_level(), caller_bci, failure_msg ? failure_msg : "inline"); |
425 assert(msg != NULL, "just checking"); |
426 if (callee_method == NULL) tty->print(" callee not monotonic or profiled"); |
426 if (C->log() != NULL) { |
427 if (Verbose && callee_method) { |
427 if (success) { |
428 const InlineTree *top = this; |
428 C->log()->inline_success(msg); |
429 while( top->caller_tree() != NULL ) { top = top->caller_tree(); } |
429 } else { |
430 //tty->print(" bcs: %d+%d invoked: %d", top->count_inline_bcs(), callee_method->code_size(), callee_method->interpreter_invocation_count()); |
430 C->log()->inline_fail(msg); |
|
431 } |
|
432 } |
|
433 if (PrintInlining) { |
|
434 C->print_inlining(callee_method, inline_level(), caller_bci, msg); |
|
435 if (callee_method == NULL) tty->print(" callee not monotonic or profiled"); |
|
436 if (Verbose && callee_method) { |
|
437 const InlineTree *top = this; |
|
438 while( top->caller_tree() != NULL ) { top = top->caller_tree(); } |
|
439 //tty->print(" bcs: %d+%d invoked: %d", top->count_inline_bcs(), callee_method->code_size(), callee_method->interpreter_invocation_count()); |
|
440 } |
431 } |
441 } |
432 } |
442 } |
433 |
443 |
434 //------------------------------ok_to_inline----------------------------------- |
444 //------------------------------ok_to_inline----------------------------------- |
435 WarmCallInfo* InlineTree::ok_to_inline(ciMethod* callee_method, JVMState* jvms, ciCallProfile& profile, WarmCallInfo* initial_wci, bool& should_delay) { |
445 WarmCallInfo* InlineTree::ok_to_inline(ciMethod* callee_method, JVMState* jvms, ciCallProfile& profile, WarmCallInfo* initial_wci, bool& should_delay) { |
449 int caller_bci = jvms->bci(); |
459 int caller_bci = jvms->bci(); |
450 ciMethod *caller_method = jvms->method(); |
460 ciMethod *caller_method = jvms->method(); |
451 |
461 |
452 // Do some initial checks. |
462 // Do some initial checks. |
453 if (!pass_initial_checks(caller_method, caller_bci, callee_method)) { |
463 if (!pass_initial_checks(caller_method, caller_bci, callee_method)) { |
454 if (PrintInlining) print_inlining(callee_method, caller_bci, "failed initial checks"); |
464 print_inlining(callee_method, caller_bci, "failed initial checks", |
|
465 false /* !success */); |
455 return NULL; |
466 return NULL; |
456 } |
467 } |
457 |
468 |
458 // Do some parse checks. |
469 // Do some parse checks. |
459 failure_msg = check_can_parse(callee_method); |
470 failure_msg = check_can_parse(callee_method); |
460 if (failure_msg != NULL) { |
471 if (failure_msg != NULL) { |
461 if (PrintInlining) print_inlining(callee_method, caller_bci, failure_msg); |
472 print_inlining(callee_method, caller_bci, failure_msg, |
|
473 false /* !success */); |
462 return NULL; |
474 return NULL; |
463 } |
475 } |
464 |
476 |
465 // Check if inlining policy says no. |
477 // Check if inlining policy says no. |
466 WarmCallInfo wci = *(initial_wci); |
478 WarmCallInfo wci = *(initial_wci); |
467 failure_msg = try_to_inline(callee_method, caller_method, caller_bci, profile, &wci, should_delay); |
479 failure_msg = try_to_inline(callee_method, caller_method, caller_bci, profile, |
468 if (failure_msg != NULL && C->log() != NULL) { |
480 &wci, should_delay); |
469 C->log()->inline_fail(failure_msg); |
|
470 } |
|
471 |
481 |
472 #ifndef PRODUCT |
482 #ifndef PRODUCT |
473 if (UseOldInlining && InlineWarmCalls |
483 if (UseOldInlining && InlineWarmCalls |
474 && (PrintOpto || PrintOptoInlining || PrintInlining)) { |
484 && (PrintOpto || PrintOptoInlining || PrintInlining)) { |
475 bool cold = wci.is_cold(); |
485 bool cold = wci.is_cold(); |
485 if (UseOldInlining) { |
495 if (UseOldInlining) { |
486 if (failure_msg == NULL) |
496 if (failure_msg == NULL) |
487 wci = *(WarmCallInfo::always_hot()); |
497 wci = *(WarmCallInfo::always_hot()); |
488 else |
498 else |
489 wci = *(WarmCallInfo::always_cold()); |
499 wci = *(WarmCallInfo::always_cold()); |
490 } |
500 } |
491 if (!InlineWarmCalls) { |
501 if (!InlineWarmCalls) { |
492 if (!wci.is_cold() && !wci.is_hot()) { |
502 if (!wci.is_cold() && !wci.is_hot()) { |
493 // Do not inline the warm calls. |
503 // Do not inline the warm calls. |
494 wci = *(WarmCallInfo::always_cold()); |
504 wci = *(WarmCallInfo::always_cold()); |
495 } |
505 } |
496 } |
506 } |
497 |
507 |
498 if (!wci.is_cold()) { |
508 if (!wci.is_cold()) { |
499 // In -UseOldInlining, the failure_msg may also be a success message. |
|
500 if (failure_msg == NULL) failure_msg = "inline (hot)"; |
|
501 |
|
502 // Inline! |
509 // Inline! |
503 if (PrintInlining) print_inlining(callee_method, caller_bci, failure_msg); |
510 print_inlining(callee_method, caller_bci, |
|
511 failure_msg ? failure_msg : "inline (hot)", |
|
512 true /* success */); |
504 if (UseOldInlining) |
513 if (UseOldInlining) |
505 build_inline_tree_for_callee(callee_method, jvms, caller_bci); |
514 build_inline_tree_for_callee(callee_method, jvms, caller_bci); |
506 if (InlineWarmCalls && !wci.is_hot()) |
515 if (InlineWarmCalls && !wci.is_hot()) |
507 return new (C) WarmCallInfo(wci); // copy to heap |
516 return new (C) WarmCallInfo(wci); // copy to heap |
508 return WarmCallInfo::always_hot(); |
517 return WarmCallInfo::always_hot(); |
509 } |
518 } |
510 |
519 |
511 // Do not inline |
520 // Do not inline |
512 if (failure_msg == NULL) failure_msg = "too cold to inline"; |
521 print_inlining(callee_method, caller_bci, |
513 if (PrintInlining) print_inlining(callee_method, caller_bci, failure_msg); |
522 failure_msg ? failure_msg : "too cold to inline", |
|
523 false /* !success */ ); |
514 return NULL; |
524 return NULL; |
515 } |
525 } |
516 |
526 |
517 //------------------------------compute_callee_frequency----------------------- |
527 //------------------------------compute_callee_frequency----------------------- |
518 float InlineTree::compute_callee_frequency( int caller_bci ) const { |
528 float InlineTree::compute_callee_frequency( int caller_bci ) const { |