comparison src/share/vm/opto/bytecodeInfo.cpp @ 13086:096c224171c4

Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/
author Doug Simon <doug.simon@oracle.com>
date Wed, 20 Nov 2013 00:10:38 +0100
parents 359f7e70ae7f e74074c34312
children d8041d695d19
comparison
equal deleted inserted replaced
12782:92b7ec34ddfa 13086:096c224171c4
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.
386 if (!C->do_inlining() && InlineAccessors) { 387 if (!C->do_inlining() && InlineAccessors) {
387 set_msg("not an accessor"); 388 set_msg("not an accessor");
388 return false; 389 return false;
389 } 390 }
390 if (inline_level() > _max_inline_level) { 391 if (inline_level() > _max_inline_level) {
392 if (callee_method->force_inline() && inline_level() > MaxForceInlineLevel) {
393 set_msg("MaxForceInlineLevel");
394 return false;
395 }
391 if (!callee_method->force_inline() || !IncrementalInline) { 396 if (!callee_method->force_inline() || !IncrementalInline) {
392 set_msg("inlining too deep"); 397 set_msg("inlining too deep");
393 return false; 398 return false;
394 } else if (!C->inlining_incrementally()) { 399 } else if (!C->inlining_incrementally()) {
395 should_delay = true; 400 should_delay = true;
396 } 401 }
397 } 402 }
398 403
399 // detect direct and indirect recursive inlining 404 // detect direct and indirect recursive inlining
400 if (!callee_method->is_compiled_lambda_form()) { 405 {
401 // count the current method and the callee 406 // count the current method and the callee
402 int inline_level = (method() == callee_method) ? 1 : 0; 407 const bool is_compiled_lambda_form = callee_method->is_compiled_lambda_form();
403 if (inline_level > MaxRecursiveInlineLevel) { 408 int inline_level = 0;
404 set_msg("recursively inlining too deep"); 409 if (!is_compiled_lambda_form) {
405 return false; 410 if (method() == callee_method) {
411 inline_level++;
412 }
406 } 413 }
407 // count callers of current method and callee 414 // count callers of current method and callee
408 JVMState* jvms = caller_jvms(); 415 Node* callee_argument0 = is_compiled_lambda_form ? jvms->map()->argument(jvms, 0)->uncast() : NULL;
409 while (jvms != NULL && jvms->has_method()) { 416 for (JVMState* j = jvms->caller(); j != NULL && j->has_method(); j = j->caller()) {
410 if (jvms->method() == callee_method) { 417 if (j->method() == callee_method) {
411 inline_level++; 418 if (is_compiled_lambda_form) {
412 if (inline_level > MaxRecursiveInlineLevel) { 419 // Since compiled lambda forms are heavily reused we allow recursive inlining. If it is truly
413 set_msg("recursively inlining too deep"); 420 // a recursion (using the same "receiver") we limit inlining otherwise we can easily blow the
414 return false; 421 // compiler stack.
422 Node* caller_argument0 = j->map()->argument(j, 0)->uncast();
423 if (caller_argument0 == callee_argument0) {
424 inline_level++;
425 }
426 } else {
427 inline_level++;
415 } 428 }
416 } 429 }
417 jvms = jvms->caller(); 430 }
431 if (inline_level > MaxRecursiveInlineLevel) {
432 set_msg("recursive inlining is too deep");
433 return false;
418 } 434 }
419 } 435 }
420 436
421 int size = callee_method->code_size_for_inlining(); 437 int size = callee_method->code_size_for_inlining();
422 438
534 } 550 }
535 551
536 // Check if inlining policy says no. 552 // Check if inlining policy says no.
537 WarmCallInfo wci = *(initial_wci); 553 WarmCallInfo wci = *(initial_wci);
538 bool success = try_to_inline(callee_method, caller_method, caller_bci, 554 bool success = try_to_inline(callee_method, caller_method, caller_bci,
539 profile, &wci, should_delay); 555 jvms, profile, &wci, should_delay);
540 556
541 #ifndef PRODUCT 557 #ifndef PRODUCT
542 if (UseOldInlining && InlineWarmCalls 558 if (UseOldInlining && InlineWarmCalls
543 && (PrintOpto || C->print_inlining())) { 559 && (PrintOpto || C->print_inlining())) {
544 bool cold = wci.is_cold(); 560 bool cold = wci.is_cold();