src/share/vm/opto/bytecodeInfo.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8011138 Sdiff src/share/vm/opto

src/share/vm/opto/bytecodeInfo.cpp

Print this page




 180         callee_method->instructions_size() > inline_small_code_size) {
 181       set_msg("already compiled into a medium method");
 182       return false;
 183     }
 184   }
 185   if (size > max_inline_size) {
 186     if (max_inline_size > default_max_inline_size) {
 187       set_msg("hot method too big");
 188     } else {
 189       set_msg("too big");
 190     }
 191     return false;
 192   }
 193   return true;
 194 }
 195 
 196 
 197 // negative filter: should callee NOT be inlined?
 198 bool InlineTree::should_not_inline(ciMethod *callee_method,
 199                                    ciMethod* caller_method,

 200                                    WarmCallInfo* wci_result) {
 201 
 202   const char* fail_msg = NULL;
 203 
 204   // First check all inlining restrictions which are required for correctness
 205   if ( callee_method->is_abstract()) {
 206     fail_msg = "abstract method"; // // note: we allow ik->is_abstract()
 207   } else if (!callee_method->holder()->is_initialized()) {
 208     fail_msg = "method holder not initialized";
 209   } else if ( callee_method->is_native()) {
 210     fail_msg = "native method";
 211   } else if ( callee_method->dont_inline()) {
 212     fail_msg = "don't inline by annotation";
 213   }
 214 
 215   if (!UseOldInlining) {
 216     if (fail_msg != NULL) {
 217       *wci_result = *(WarmCallInfo::always_cold());
 218       set_msg(fail_msg);
 219       return true;
 220     }
 221 
 222     if (callee_method->has_unloaded_classes_in_signature()) {
 223       wci_result->set_profit(wci_result->profit() * 0.1);
 224     }
 225 
 226     // don't inline exception code unless the top method belongs to an
 227     // exception class
 228     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       if (!top_method->holder()->is_subclass_of(C->env()->Throwable_klass())) {
 231         wci_result->set_profit(wci_result->profit() * 0.1);
 232       }
 233     }
 234 
 235     if (callee_method->has_compiled_code() &&
 236         callee_method->instructions_size() > InlineSmallCode) {
 237       wci_result->set_profit(wci_result->profit() * 0.1);
 238       // %%% adjust wci_result->size()?
 239     }
 240 
 241     return false;
 242   }
 243 
 244   // one more inlining restriction
 245   if (fail_msg == NULL && callee_method->has_unloaded_classes_in_signature()) {
 246     fail_msg = "unloaded signature classes";
 247   }
 248 
 249   if (fail_msg != NULL) {


 311       return true;
 312     }
 313 
 314     if (is_init_with_ea(callee_method, caller_method, C)) {
 315       // Escape Analysis: inline all executed constructors
 316       return false;
 317     } else if (!callee_method->was_executed_more_than(MIN2(MinInliningThreshold,
 318                                                            CompileThreshold >> 1))) {
 319       set_msg("executed < MinInliningThreshold times");
 320       return true;
 321     }
 322   }
 323 
 324   return false;
 325 }
 326 
 327 //-----------------------------try_to_inline-----------------------------------
 328 // return true if ok
 329 // Relocated from "InliningClosure::try_to_inline"
 330 bool InlineTree::try_to_inline(ciMethod* callee_method, ciMethod* caller_method,
 331                                int caller_bci, ciCallProfile& profile,
 332                                WarmCallInfo* wci_result, bool& should_delay) {
 333 
 334    // Old algorithm had funny accumulating BC-size counters
 335   if (UseOldInlining && ClipInlining
 336       && (int)count_inline_bcs() >= DesiredMethodLimit) {
 337     if (!callee_method->force_inline() || !IncrementalInline) {
 338       set_msg("size > DesiredMethodLimit");
 339       return false;
 340     } else if (!C->inlining_incrementally()) {
 341       should_delay = true;
 342     }
 343   }
 344 
 345   if (!should_inline(callee_method, caller_method, caller_bci, profile,
 346                      wci_result)) {
 347     return false;
 348   }
 349   if (should_not_inline(callee_method, caller_method, wci_result)) {
 350     return false;
 351   }
 352 
 353   if (InlineAccessors && callee_method->is_accessor()) {
 354     // accessor methods are not subject to any of the following limits.
 355     set_msg("accessor");
 356     return true;
 357   }
 358 
 359   // suppress a few checks for accessors and trivial methods
 360   if (callee_method->code_size() > MaxTrivialSize) {
 361 
 362     // don't inline into giant methods
 363     if (C->over_inlining_cutoff()) {
 364       if ((!callee_method->force_inline() && !caller_method->is_compiled_lambda_form())
 365           || !IncrementalInline) {
 366         set_msg("NodeCountInliningCutoff");
 367         return false;
 368       } else {
 369         should_delay = true;


 380       // don't inline unreached call sites
 381        set_msg("call site not reached");
 382        return false;
 383     }
 384   }
 385 
 386   if (!C->do_inlining() && InlineAccessors) {
 387     set_msg("not an accessor");
 388     return false;
 389   }
 390   if (inline_level() > _max_inline_level) {
 391     if (!callee_method->force_inline() || !IncrementalInline) {
 392       set_msg("inlining too deep");
 393       return false;
 394     } else if (!C->inlining_incrementally()) {
 395       should_delay = true;
 396     }
 397   }
 398 
 399   // detect direct and indirect recursive inlining
 400   if (!callee_method->is_compiled_lambda_form()) {
 401     // count the current method and the callee
 402     int inline_level = (method() == callee_method) ? 1 : 0;
 403     if (inline_level > MaxRecursiveInlineLevel) {
 404       set_msg("recursively inlining too deep");
 405       return false;

 406     }
 407     // count callers of current method and callee
 408     JVMState* jvms = caller_jvms();
 409     while (jvms != NULL && jvms->has_method()) {
 410       if (jvms->method() == callee_method) {









 411         inline_level++;
 412         if (inline_level > MaxRecursiveInlineLevel) {
 413           set_msg("recursively inlining too deep");
 414           return false;
 415         }
 416       }
 417       jvms = jvms->caller();



 418     }
 419   }
 420 
 421   int size = callee_method->code_size_for_inlining();
 422 
 423   if (UseOldInlining && ClipInlining
 424       && (int)count_inline_bcs() + size >= DesiredMethodLimit) {
 425     if (!callee_method->force_inline() || !IncrementalInline) {
 426       set_msg("size > DesiredMethodLimit");
 427       return false;
 428     } else if (!C->inlining_incrementally()) {
 429       should_delay = true;
 430     }
 431   }
 432 
 433   // ok, inline this method
 434   return true;
 435 }
 436 
 437 //------------------------------pass_initial_checks----------------------------


 519   int         caller_bci    = jvms->bci();
 520   ciMethod*   caller_method = jvms->method();
 521 
 522   // Do some initial checks.
 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());




 180         callee_method->instructions_size() > inline_small_code_size) {
 181       set_msg("already compiled into a medium method");
 182       return false;
 183     }
 184   }
 185   if (size > max_inline_size) {
 186     if (max_inline_size > default_max_inline_size) {
 187       set_msg("hot method too big");
 188     } else {
 189       set_msg("too big");
 190     }
 191     return false;
 192   }
 193   return true;
 194 }
 195 
 196 
 197 // negative filter: should callee NOT be inlined?
 198 bool InlineTree::should_not_inline(ciMethod *callee_method,
 199                                    ciMethod* caller_method,
 200                                    JVMState* jvms,
 201                                    WarmCallInfo* wci_result) {
 202 
 203   const char* fail_msg = NULL;
 204 
 205   // First check all inlining restrictions which are required for correctness
 206   if ( callee_method->is_abstract()) {
 207     fail_msg = "abstract method"; // // note: we allow ik->is_abstract()
 208   } else if (!callee_method->holder()->is_initialized()) {
 209     fail_msg = "method holder not initialized";
 210   } else if ( callee_method->is_native()) {
 211     fail_msg = "native method";
 212   } else if ( callee_method->dont_inline()) {
 213     fail_msg = "don't inline by annotation";
 214   }
 215 
 216   if (!UseOldInlining) {
 217     if (fail_msg != NULL) {
 218       *wci_result = *(WarmCallInfo::always_cold());
 219       set_msg(fail_msg);
 220       return true;
 221     }
 222 
 223     if (callee_method->has_unloaded_classes_in_signature()) {
 224       wci_result->set_profit(wci_result->profit() * 0.1);
 225     }
 226 
 227     // don't inline exception code unless the top method belongs to an
 228     // exception class
 229     if (callee_method->holder()->is_subclass_of(C->env()->Throwable_klass())) {
 230       ciMethod* top_method = jvms->caller() != NULL ? jvms->caller()->of_depth(1)->method() : method();
 231       if (!top_method->holder()->is_subclass_of(C->env()->Throwable_klass())) {
 232         wci_result->set_profit(wci_result->profit() * 0.1);
 233       }
 234     }
 235 
 236     if (callee_method->has_compiled_code() &&
 237         callee_method->instructions_size() > InlineSmallCode) {
 238       wci_result->set_profit(wci_result->profit() * 0.1);
 239       // %%% adjust wci_result->size()?
 240     }
 241 
 242     return false;
 243   }
 244 
 245   // one more inlining restriction
 246   if (fail_msg == NULL && callee_method->has_unloaded_classes_in_signature()) {
 247     fail_msg = "unloaded signature classes";
 248   }
 249 
 250   if (fail_msg != NULL) {


 312       return true;
 313     }
 314 
 315     if (is_init_with_ea(callee_method, caller_method, C)) {
 316       // Escape Analysis: inline all executed constructors
 317       return false;
 318     } else if (!callee_method->was_executed_more_than(MIN2(MinInliningThreshold,
 319                                                            CompileThreshold >> 1))) {
 320       set_msg("executed < MinInliningThreshold times");
 321       return true;
 322     }
 323   }
 324 
 325   return false;
 326 }
 327 
 328 //-----------------------------try_to_inline-----------------------------------
 329 // return true if ok
 330 // Relocated from "InliningClosure::try_to_inline"
 331 bool InlineTree::try_to_inline(ciMethod* callee_method, ciMethod* caller_method,
 332                                int caller_bci, JVMState* jvms, ciCallProfile& profile,
 333                                WarmCallInfo* wci_result, bool& should_delay) {
 334 
 335    // Old algorithm had funny accumulating BC-size counters
 336   if (UseOldInlining && ClipInlining
 337       && (int)count_inline_bcs() >= DesiredMethodLimit) {
 338     if (!callee_method->force_inline() || !IncrementalInline) {
 339       set_msg("size > DesiredMethodLimit");
 340       return false;
 341     } else if (!C->inlining_incrementally()) {
 342       should_delay = true;
 343     }
 344   }
 345 
 346   if (!should_inline(callee_method, caller_method, caller_bci, profile,
 347                      wci_result)) {
 348     return false;
 349   }
 350   if (should_not_inline(callee_method, caller_method, jvms, wci_result)) {
 351     return false;
 352   }
 353 
 354   if (InlineAccessors && callee_method->is_accessor()) {
 355     // accessor methods are not subject to any of the following limits.
 356     set_msg("accessor");
 357     return true;
 358   }
 359 
 360   // suppress a few checks for accessors and trivial methods
 361   if (callee_method->code_size() > MaxTrivialSize) {
 362 
 363     // don't inline into giant methods
 364     if (C->over_inlining_cutoff()) {
 365       if ((!callee_method->force_inline() && !caller_method->is_compiled_lambda_form())
 366           || !IncrementalInline) {
 367         set_msg("NodeCountInliningCutoff");
 368         return false;
 369       } else {
 370         should_delay = true;


 381       // don't inline unreached call sites
 382        set_msg("call site not reached");
 383        return false;
 384     }
 385   }
 386 
 387   if (!C->do_inlining() && InlineAccessors) {
 388     set_msg("not an accessor");
 389     return false;
 390   }
 391   if (inline_level() > _max_inline_level) {
 392     if (!callee_method->force_inline() || !IncrementalInline) {
 393       set_msg("inlining too deep");
 394       return false;
 395     } else if (!C->inlining_incrementally()) {
 396       should_delay = true;
 397     }
 398   }
 399 
 400   // detect direct and indirect recursive inlining
 401   {
 402     // count the current method and the callee
 403     int inline_level = 0;
 404     if (!callee_method->is_compiled_lambda_form()) {
 405       if (method() == callee_method) {
 406         inline_level++;
 407       }
 408     }
 409     // count callers of current method and callee
 410     for (JVMState* j = jvms->caller(); j != NULL && j->has_method(); j = j->caller()) {
 411       if (j->method() == callee_method) {
 412         if (callee_method->is_compiled_lambda_form()) {
 413           // Since compiled lambda forms are heavily reused we allow recursive inlining.  If it is truly
 414           // a recursion (using the same "receiver") we limit inlining otherwise we can easily blow the
 415           // compiler stack.
 416           Node* callee_argument0 = jvms->map()->argument(jvms, 0)->uncast();
 417           Node* caller_argument0 = j->map()->argument(j, 0)->uncast();
 418           if (caller_argument0 == callee_argument0) {
 419             inline_level++;
 420           }
 421         } else {
 422           inline_level++;



 423         }
 424       }
 425     }
 426     if (inline_level > MaxRecursiveInlineLevel) {
 427       set_msg("recursive inlining is too deep");
 428       return false;
 429     }
 430   }
 431 
 432   int size = callee_method->code_size_for_inlining();
 433 
 434   if (UseOldInlining && ClipInlining
 435       && (int)count_inline_bcs() + size >= DesiredMethodLimit) {
 436     if (!callee_method->force_inline() || !IncrementalInline) {
 437       set_msg("size > DesiredMethodLimit");
 438       return false;
 439     } else if (!C->inlining_incrementally()) {
 440       should_delay = true;
 441     }
 442   }
 443 
 444   // ok, inline this method
 445   return true;
 446 }
 447 
 448 //------------------------------pass_initial_checks----------------------------


 530   int         caller_bci    = jvms->bci();
 531   ciMethod*   caller_method = jvms->method();
 532 
 533   // Do some initial checks.
 534   if (!pass_initial_checks(caller_method, caller_bci, callee_method)) {
 535     set_msg("failed initial checks");
 536     print_inlining(callee_method, caller_bci, false /* !success */);
 537     return NULL;
 538   }
 539 
 540   // Do some parse checks.
 541   set_msg(check_can_parse(callee_method));
 542   if (msg() != NULL) {
 543     print_inlining(callee_method, caller_bci, false /* !success */);
 544     return NULL;
 545   }
 546 
 547   // Check if inlining policy says no.
 548   WarmCallInfo wci = *(initial_wci);
 549   bool success = try_to_inline(callee_method, caller_method, caller_bci,
 550                                jvms, profile, &wci, should_delay);
 551 
 552 #ifndef PRODUCT
 553   if (UseOldInlining && InlineWarmCalls
 554       && (PrintOpto || C->print_inlining())) {
 555     bool cold = wci.is_cold();
 556     bool hot  = !cold && wci.is_hot();
 557     bool old_cold = !success;
 558     if (old_cold != cold || (Verbose || WizardMode)) {
 559       if (msg() == NULL) {
 560         set_msg("OK");
 561       }
 562       tty->print("   OldInlining= %4s : %s\n           WCI=",
 563                  old_cold ? "cold" : "hot", msg());
 564       wci.print();
 565     }
 566   }
 567 #endif
 568   if (UseOldInlining) {
 569     if (success) {
 570       wci = *(WarmCallInfo::always_hot());


src/share/vm/opto/bytecodeInfo.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File