1.1 --- a/src/share/vm/opto/bytecodeInfo.cpp Fri Jan 08 13:47:01 2010 -0800 1.2 +++ b/src/share/vm/opto/bytecodeInfo.cpp Fri Jan 08 13:58:49 2010 -0800 1.3 @@ -27,11 +27,16 @@ 1.4 1.5 //============================================================================= 1.6 //------------------------------InlineTree------------------------------------- 1.7 -InlineTree::InlineTree( Compile* c, const InlineTree *caller_tree, ciMethod* callee, JVMState* caller_jvms, int caller_bci, float site_invoke_ratio ) 1.8 +InlineTree::InlineTree( Compile* c, 1.9 + const InlineTree *caller_tree, ciMethod* callee, 1.10 + JVMState* caller_jvms, int caller_bci, 1.11 + float site_invoke_ratio, int site_depth_adjust) 1.12 : C(c), _caller_jvms(caller_jvms), 1.13 _caller_tree((InlineTree*)caller_tree), 1.14 _method(callee), _site_invoke_ratio(site_invoke_ratio), 1.15 - _count_inline_bcs(method()->code_size()) { 1.16 + _site_depth_adjust(site_depth_adjust), 1.17 + _count_inline_bcs(method()->code_size()) 1.18 +{ 1.19 NOT_PRODUCT(_count_inlines = 0;) 1.20 if (_caller_jvms != NULL) { 1.21 // Keep a private copy of the caller_jvms: 1.22 @@ -40,7 +45,7 @@ 1.23 assert(!caller_jvms->should_reexecute(), "there should be no reexecute bytecode with inlining"); 1.24 } 1.25 assert(_caller_jvms->same_calls_as(caller_jvms), "consistent JVMS"); 1.26 - assert((caller_tree == NULL ? 0 : caller_tree->inline_depth() + 1) == inline_depth(), "correct (redundant) depth parameter"); 1.27 + assert((caller_tree == NULL ? 0 : caller_tree->stack_depth() + 1) == stack_depth(), "correct (redundant) depth parameter"); 1.28 assert(caller_bci == this->caller_bci(), "correct (redundant) bci parameter"); 1.29 if (UseOldInlining) { 1.30 // Update hierarchical counts, count_inline_bcs() and count_inlines() 1.31 @@ -52,10 +57,13 @@ 1.32 } 1.33 } 1.34 1.35 -InlineTree::InlineTree(Compile* c, ciMethod* callee_method, JVMState* caller_jvms, float site_invoke_ratio) 1.36 +InlineTree::InlineTree(Compile* c, ciMethod* callee_method, JVMState* caller_jvms, 1.37 + float site_invoke_ratio, int site_depth_adjust) 1.38 : C(c), _caller_jvms(caller_jvms), _caller_tree(NULL), 1.39 _method(callee_method), _site_invoke_ratio(site_invoke_ratio), 1.40 - _count_inline_bcs(method()->code_size()) { 1.41 + _site_depth_adjust(site_depth_adjust), 1.42 + _count_inline_bcs(method()->code_size()) 1.43 +{ 1.44 NOT_PRODUCT(_count_inlines = 0;) 1.45 assert(!UseOldInlining, "do not use for old stuff"); 1.46 } 1.47 @@ -269,10 +277,13 @@ 1.48 return msg; 1.49 } 1.50 1.51 - bool is_accessor = InlineAccessors && callee_method->is_accessor(); 1.52 + if (InlineAccessors && callee_method->is_accessor()) { 1.53 + // accessor methods are not subject to any of the following limits. 1.54 + return NULL; 1.55 + } 1.56 1.57 // suppress a few checks for accessors and trivial methods 1.58 - if (!is_accessor && callee_method->code_size() > MaxTrivialSize) { 1.59 + if (callee_method->code_size() > MaxTrivialSize) { 1.60 1.61 // don't inline into giant methods 1.62 if (C->unique() > (uint)NodeCountInliningCutoff) { 1.63 @@ -291,7 +302,7 @@ 1.64 } 1.65 } 1.66 1.67 - if (!C->do_inlining() && InlineAccessors && !is_accessor) { 1.68 + if (!C->do_inlining() && InlineAccessors) { 1.69 return "not an accessor"; 1.70 } 1.71 if( inline_depth() > MaxInlineLevel ) { 1.72 @@ -464,7 +475,30 @@ 1.73 if (old_ilt != NULL) { 1.74 return old_ilt; 1.75 } 1.76 - InlineTree *ilt = new InlineTree( C, this, callee_method, caller_jvms, caller_bci, recur_frequency ); 1.77 + int new_depth_adjust = 0; 1.78 + if (caller_jvms->method() != NULL) { 1.79 + if ((caller_jvms->method()->name() == ciSymbol::invoke_name() && 1.80 + caller_jvms->method()->holder()->name() == ciSymbol::java_dyn_MethodHandle()) 1.81 + || caller_jvms->method()->holder()->name() == ciSymbol::java_dyn_InvokeDynamic()) 1.82 + /* @@@ FIXME: 1.83 + if (caller_jvms->method()->is_method_handle_adapter()) 1.84 + */ 1.85 + new_depth_adjust -= 1; // don't count actions in MH or indy adapter frames 1.86 + else if (callee_method->is_method_handle_invoke()) { 1.87 + new_depth_adjust -= 1; // don't count method handle calls from java.dyn implem 1.88 + } 1.89 + if (new_depth_adjust != 0 && PrintInlining) { 1.90 + stringStream nm1; caller_jvms->method()->print_name(&nm1); 1.91 + stringStream nm2; callee_method->print_name(&nm2); 1.92 + tty->print_cr("discounting inlining depth from %s to %s", nm1.base(), nm2.base()); 1.93 + } 1.94 + if (new_depth_adjust != 0 && C->log()) { 1.95 + int id1 = C->log()->identify(caller_jvms->method()); 1.96 + int id2 = C->log()->identify(callee_method); 1.97 + C->log()->elem("inline_depth_discount caller='%d' callee='%d'", id1, id2); 1.98 + } 1.99 + } 1.100 + InlineTree *ilt = new InlineTree(C, this, callee_method, caller_jvms, caller_bci, recur_frequency, _site_depth_adjust + new_depth_adjust); 1.101 _subtrees.append( ilt ); 1.102 1.103 NOT_PRODUCT( _count_inlines += 1; ) 1.104 @@ -490,7 +524,7 @@ 1.105 Compile* C = Compile::current(); 1.106 1.107 // Root of inline tree 1.108 - InlineTree *ilt = new InlineTree(C, NULL, C->method(), NULL, -1, 1.0F); 1.109 + InlineTree *ilt = new InlineTree(C, NULL, C->method(), NULL, -1, 1.0F, 0); 1.110 1.111 return ilt; 1.112 }