comparison src/share/vm/opto/bytecodeInfo.cpp @ 14422:2b8e28fdf503

Merge
author kvn
date Tue, 05 Nov 2013 17:38:04 -0800
parents 0c4c40f5c399
children e74074c34312
comparison
equal deleted inserted replaced
14421:3068270ba476 14422:2b8e28fdf503
121 int caller_bci, ciCallProfile& profile, 121 int caller_bci, ciCallProfile& profile,
122 WarmCallInfo* wci_result) { 122 WarmCallInfo* wci_result) {
123 // Allows targeted inlining 123 // Allows targeted inlining
124 if(callee_method->should_inline()) { 124 if(callee_method->should_inline()) {
125 *wci_result = *(WarmCallInfo::always_hot()); 125 *wci_result = *(WarmCallInfo::always_hot());
126 if (PrintInlining && Verbose) { 126 if (C->print_inlining() && Verbose) {
127 CompileTask::print_inline_indent(inline_level()); 127 CompileTask::print_inline_indent(inline_level());
128 tty->print_cr("Inlined method is hot: "); 128 tty->print_cr("Inlined method is hot: ");
129 } 129 }
130 set_msg("force inline by CompilerOracle"); 130 set_msg("force inline by CompilerOracle");
131 return true; 131 return true;
135 135
136 // Check for too many throws (and not too huge) 136 // Check for too many throws (and not too huge)
137 if(callee_method->interpreter_throwout_count() > InlineThrowCount && 137 if(callee_method->interpreter_throwout_count() > InlineThrowCount &&
138 size < InlineThrowMaxSize ) { 138 size < InlineThrowMaxSize ) {
139 wci_result->set_profit(wci_result->profit() * 100); 139 wci_result->set_profit(wci_result->profit() * 100);
140 if (PrintInlining && Verbose) { 140 if (C->print_inlining() && Verbose) {
141 CompileTask::print_inline_indent(inline_level()); 141 CompileTask::print_inline_indent(inline_level());
142 tty->print_cr("Inlined method with many throws (throws=%d):", callee_method->interpreter_throwout_count()); 142 tty->print_cr("Inlined method with many throws (throws=%d):", callee_method->interpreter_throwout_count());
143 } 143 }
144 set_msg("many throws"); 144 set_msg("many throws");
145 return true; 145 return true;
195 195
196 196
197 // negative filter: should callee NOT be inlined? 197 // negative filter: should callee NOT be inlined?
198 bool InlineTree::should_not_inline(ciMethod *callee_method, 198 bool InlineTree::should_not_inline(ciMethod *callee_method,
199 ciMethod* caller_method, 199 ciMethod* caller_method,
200 JVMState* jvms,
200 WarmCallInfo* wci_result) { 201 WarmCallInfo* wci_result) {
201 202
202 const char* fail_msg = NULL; 203 const char* fail_msg = NULL;
203 204
204 // First check all inlining restrictions which are required for correctness 205 // First check all inlining restrictions which are required for correctness
224 } 225 }
225 226
226 // don't inline exception code unless the top method belongs to an 227 // don't inline exception code unless the top method belongs to an
227 // exception class 228 // exception class
228 if (callee_method->holder()->is_subclass_of(C->env()->Throwable_klass())) { 229 if (callee_method->holder()->is_subclass_of(C->env()->Throwable_klass())) {
229 ciMethod* top_method = caller_jvms() ? caller_jvms()->of_depth(1)->method() : method(); 230 ciMethod* top_method = jvms->caller() != NULL ? jvms->caller()->of_depth(1)->method() : method();
230 if (!top_method->holder()->is_subclass_of(C->env()->Throwable_klass())) { 231 if (!top_method->holder()->is_subclass_of(C->env()->Throwable_klass())) {
231 wci_result->set_profit(wci_result->profit() * 0.1); 232 wci_result->set_profit(wci_result->profit() * 0.1);
232 } 233 }
233 } 234 }
234 235
326 327
327 //-----------------------------try_to_inline----------------------------------- 328 //-----------------------------try_to_inline-----------------------------------
328 // return true if ok 329 // return true if ok
329 // Relocated from "InliningClosure::try_to_inline" 330 // Relocated from "InliningClosure::try_to_inline"
330 bool InlineTree::try_to_inline(ciMethod* callee_method, ciMethod* caller_method, 331 bool InlineTree::try_to_inline(ciMethod* callee_method, ciMethod* caller_method,
331 int caller_bci, ciCallProfile& profile, 332 int caller_bci, JVMState* jvms, ciCallProfile& profile,
332 WarmCallInfo* wci_result, bool& should_delay) { 333 WarmCallInfo* wci_result, bool& should_delay) {
333 334
334 // Old algorithm had funny accumulating BC-size counters 335 // Old algorithm had funny accumulating BC-size counters
335 if (UseOldInlining && ClipInlining 336 if (UseOldInlining && ClipInlining
336 && (int)count_inline_bcs() >= DesiredMethodLimit) { 337 && (int)count_inline_bcs() >= DesiredMethodLimit) {
344 345
345 if (!should_inline(callee_method, caller_method, caller_bci, profile, 346 if (!should_inline(callee_method, caller_method, caller_bci, profile,
346 wci_result)) { 347 wci_result)) {
347 return false; 348 return false;
348 } 349 }
349 if (should_not_inline(callee_method, caller_method, wci_result)) { 350 if (should_not_inline(callee_method, caller_method, jvms, wci_result)) {
350 return false; 351 return false;
351 } 352 }
352 353
353 if (InlineAccessors && callee_method->is_accessor()) { 354 if (InlineAccessors && callee_method->is_accessor()) {
354 // accessor methods are not subject to any of the following limits. 355 // accessor methods are not subject to any of the following limits.
395 should_delay = true; 396 should_delay = true;
396 } 397 }
397 } 398 }
398 399
399 // detect direct and indirect recursive inlining 400 // detect direct and indirect recursive inlining
400 if (!callee_method->is_compiled_lambda_form()) { 401 {
401 // count the current method and the callee 402 // count the current method and the callee
402 int inline_level = (method() == callee_method) ? 1 : 0; 403 const bool is_compiled_lambda_form = callee_method->is_compiled_lambda_form();
403 if (inline_level > MaxRecursiveInlineLevel) { 404 int inline_level = 0;
404 set_msg("recursively inlining too deep"); 405 if (!is_compiled_lambda_form) {
405 return false; 406 if (method() == callee_method) {
407 inline_level++;
408 }
406 } 409 }
407 // count callers of current method and callee 410 // count callers of current method and callee
408 JVMState* jvms = caller_jvms(); 411 Node* callee_argument0 = is_compiled_lambda_form ? jvms->map()->argument(jvms, 0)->uncast() : NULL;
409 while (jvms != NULL && jvms->has_method()) { 412 for (JVMState* j = jvms->caller(); j != NULL && j->has_method(); j = j->caller()) {
410 if (jvms->method() == callee_method) { 413 if (j->method() == callee_method) {
411 inline_level++; 414 if (is_compiled_lambda_form) {
412 if (inline_level > MaxRecursiveInlineLevel) { 415 // Since compiled lambda forms are heavily reused we allow recursive inlining. If it is truly
413 set_msg("recursively inlining too deep"); 416 // a recursion (using the same "receiver") we limit inlining otherwise we can easily blow the
414 return false; 417 // compiler stack.
418 Node* caller_argument0 = j->map()->argument(j, 0)->uncast();
419 if (caller_argument0 == callee_argument0) {
420 inline_level++;
421 }
422 } else {
423 inline_level++;
415 } 424 }
416 } 425 }
417 jvms = jvms->caller(); 426 }
427 if (inline_level > MaxRecursiveInlineLevel) {
428 set_msg("recursive inlining is too deep");
429 return false;
418 } 430 }
419 } 431 }
420 432
421 int size = callee_method->code_size_for_inlining(); 433 int size = callee_method->code_size_for_inlining();
422 434
489 C->log()->inline_success(inline_msg); 501 C->log()->inline_success(inline_msg);
490 } else { 502 } else {
491 C->log()->inline_fail(inline_msg); 503 C->log()->inline_fail(inline_msg);
492 } 504 }
493 } 505 }
494 if (PrintInlining) { 506 if (C->print_inlining()) {
495 C->print_inlining(callee_method, inline_level(), caller_bci, inline_msg); 507 C->print_inlining(callee_method, inline_level(), caller_bci, inline_msg);
496 if (callee_method == NULL) tty->print(" callee not monotonic or profiled"); 508 if (callee_method == NULL) tty->print(" callee not monotonic or profiled");
497 if (Verbose && callee_method) { 509 if (Verbose && callee_method) {
498 const InlineTree *top = this; 510 const InlineTree *top = this;
499 while( top->caller_tree() != NULL ) { top = top->caller_tree(); } 511 while( top->caller_tree() != NULL ) { top = top->caller_tree(); }
534 } 546 }
535 547
536 // Check if inlining policy says no. 548 // Check if inlining policy says no.
537 WarmCallInfo wci = *(initial_wci); 549 WarmCallInfo wci = *(initial_wci);
538 bool success = try_to_inline(callee_method, caller_method, caller_bci, 550 bool success = try_to_inline(callee_method, caller_method, caller_bci,
539 profile, &wci, should_delay); 551 jvms, profile, &wci, should_delay);
540 552
541 #ifndef PRODUCT 553 #ifndef PRODUCT
542 if (UseOldInlining && InlineWarmCalls 554 if (UseOldInlining && InlineWarmCalls
543 && (PrintOpto || PrintOptoInlining || PrintInlining)) { 555 && (PrintOpto || C->print_inlining())) {
544 bool cold = wci.is_cold(); 556 bool cold = wci.is_cold();
545 bool hot = !cold && wci.is_hot(); 557 bool hot = !cold && wci.is_hot();
546 bool old_cold = !success; 558 bool old_cold = !success;
547 if (old_cold != cold || (Verbose || WizardMode)) { 559 if (old_cold != cold || (Verbose || WizardMode)) {
548 if (msg() == NULL) { 560 if (msg() == NULL) {
615 max_inline_level_adjust += 1; // don't count actions in MH or indy adapter frames 627 max_inline_level_adjust += 1; // don't count actions in MH or indy adapter frames
616 else if (callee_method->is_method_handle_intrinsic() || 628 else if (callee_method->is_method_handle_intrinsic() ||
617 callee_method->is_compiled_lambda_form()) { 629 callee_method->is_compiled_lambda_form()) {
618 max_inline_level_adjust += 1; // don't count method handle calls from java.lang.invoke implem 630 max_inline_level_adjust += 1; // don't count method handle calls from java.lang.invoke implem
619 } 631 }
620 if (max_inline_level_adjust != 0 && PrintInlining && (Verbose || WizardMode)) { 632 if (max_inline_level_adjust != 0 && C->print_inlining() && (Verbose || WizardMode)) {
621 CompileTask::print_inline_indent(inline_level()); 633 CompileTask::print_inline_indent(inline_level());
622 tty->print_cr(" \\-> discounting inline depth"); 634 tty->print_cr(" \\-> discounting inline depth");
623 } 635 }
624 if (max_inline_level_adjust != 0 && C->log()) { 636 if (max_inline_level_adjust != 0 && C->log()) {
625 int id1 = C->log()->identify(caller_jvms->method()); 637 int id1 = C->log()->identify(caller_jvms->method());