src/share/vm/opto/bytecodeInfo.cpp

changeset 2898
e2a92dd0d3d2
parent 2877
bad7ecd0b6ed
child 2981
aabf25fa3f05
     1.1 --- a/src/share/vm/opto/bytecodeInfo.cpp	Mon May 09 19:45:52 2011 -0700
     1.2 +++ b/src/share/vm/opto/bytecodeInfo.cpp	Tue May 10 00:45:03 2011 -0700
     1.3 @@ -89,7 +89,7 @@
     1.4  }
     1.5  
     1.6  // positive filter: should send be inlined?  returns NULL, if yes, or rejection msg
     1.7 -const char* InlineTree::shouldInline(ciMethod* callee_method, ciMethod* caller_method, int caller_bci, ciCallProfile& profile, WarmCallInfo* wci_result) const {
     1.8 +const char* InlineTree::should_inline(ciMethod* callee_method, ciMethod* caller_method, int caller_bci, ciCallProfile& profile, WarmCallInfo* wci_result) const {
     1.9    // Allows targeted inlining
    1.10    if(callee_method->should_inline()) {
    1.11      *wci_result = *(WarmCallInfo::always_hot());
    1.12 @@ -102,8 +102,7 @@
    1.13  
    1.14    // positive filter: should send be inlined?  returns NULL (--> yes)
    1.15    // or rejection msg
    1.16 -  int max_size = C->max_inline_size();
    1.17 -  int size     = callee_method->code_size();
    1.18 +  int size = callee_method->code_size();
    1.19  
    1.20    // Check for too many throws (and not too huge)
    1.21    if(callee_method->interpreter_throwout_count() > InlineThrowCount &&
    1.22 @@ -120,18 +119,36 @@
    1.23      return NULL;  // size and frequency are represented in a new way
    1.24    }
    1.25  
    1.26 +  int default_max_inline_size = C->max_inline_size();
    1.27 +  int inline_small_code_size  = InlineSmallCode / 4;
    1.28 +  int max_inline_size         = default_max_inline_size;
    1.29 +
    1.30    int call_site_count  = method()->scale_count(profile.count());
    1.31    int invoke_count     = method()->interpreter_invocation_count();
    1.32 -  assert( invoke_count != 0, "Require invokation count greater than zero");
    1.33 -  int freq = call_site_count/invoke_count;
    1.34 +
    1.35 +  // Bytecoded method handle adapters do not have interpreter
    1.36 +  // profiling data but only made up MDO data.  Get the counter from
    1.37 +  // there.
    1.38 +  if (caller_method->is_method_handle_adapter()) {
    1.39 +    assert(method()->method_data_or_null(), "must have an MDO");
    1.40 +    ciMethodData* mdo = method()->method_data();
    1.41 +    ciProfileData* mha_profile = mdo->bci_to_data(caller_bci);
    1.42 +    assert(mha_profile, "must exist");
    1.43 +    CounterData* cd = mha_profile->as_CounterData();
    1.44 +    invoke_count = cd->count();
    1.45 +    call_site_count = invoke_count;  // use the same value
    1.46 +  }
    1.47 +
    1.48 +  assert(invoke_count != 0, "require invocation count greater than zero");
    1.49 +  int freq = call_site_count / invoke_count;
    1.50  
    1.51    // bump the max size if the call is frequent
    1.52    if ((freq >= InlineFrequencyRatio) ||
    1.53        (call_site_count >= InlineFrequencyCount) ||
    1.54        is_init_with_ea(callee_method, caller_method, C)) {
    1.55  
    1.56 -    max_size = C->freq_inline_size();
    1.57 -    if (size <= max_size && TraceFrequencyInlining) {
    1.58 +    max_inline_size = C->freq_inline_size();
    1.59 +    if (size <= max_inline_size && TraceFrequencyInlining) {
    1.60        CompileTask::print_inline_indent(inline_depth());
    1.61        tty->print_cr("Inlined frequent method (freq=%d count=%d):", freq, call_site_count);
    1.62        CompileTask::print_inline_indent(inline_depth());
    1.63 @@ -141,11 +158,11 @@
    1.64    } else {
    1.65      // Not hot.  Check for medium-sized pre-existing nmethod at cold sites.
    1.66      if (callee_method->has_compiled_code() &&
    1.67 -        callee_method->instructions_size(CompLevel_full_optimization) > InlineSmallCode/4)
    1.68 +        callee_method->instructions_size(CompLevel_full_optimization) > inline_small_code_size)
    1.69        return "already compiled into a medium method";
    1.70    }
    1.71 -  if (size > max_size) {
    1.72 -    if (max_size > C->max_inline_size())
    1.73 +  if (size > max_inline_size) {
    1.74 +    if (max_inline_size > default_max_inline_size)
    1.75        return "hot method too big";
    1.76      return "too big";
    1.77    }
    1.78 @@ -154,7 +171,7 @@
    1.79  
    1.80  
    1.81  // negative filter: should send NOT be inlined?  returns NULL, ok to inline, or rejection msg
    1.82 -const char* InlineTree::shouldNotInline(ciMethod *callee_method, ciMethod* caller_method, WarmCallInfo* wci_result) const {
    1.83 +const char* InlineTree::should_not_inline(ciMethod *callee_method, ciMethod* caller_method, WarmCallInfo* wci_result) const {
    1.84    // negative filter: should send NOT be inlined?  returns NULL (--> inline) or rejection msg
    1.85    if (!UseOldInlining) {
    1.86      const char* fail = NULL;
    1.87 @@ -269,14 +286,13 @@
    1.88    }
    1.89  
    1.90    const char *msg = NULL;
    1.91 -  if ((msg = shouldInline(callee_method, caller_method, caller_bci,
    1.92 -                          profile, wci_result)) != NULL) {
    1.93 +  msg = should_inline(callee_method, caller_method, caller_bci, profile, wci_result);
    1.94 +  if (msg != NULL)
    1.95      return msg;
    1.96 -  }
    1.97 -  if ((msg = shouldNotInline(callee_method, caller_method,
    1.98 -                             wci_result)) != NULL) {
    1.99 +
   1.100 +  msg = should_not_inline(callee_method, caller_method, wci_result);
   1.101 +  if (msg != NULL)
   1.102      return msg;
   1.103 -  }
   1.104  
   1.105    if (InlineAccessors && callee_method->is_accessor()) {
   1.106      // accessor methods are not subject to any of the following limits.
   1.107 @@ -492,9 +508,8 @@
   1.108        new_depth_adjust -= 1;  // don't count method handle calls from java.lang.invoke implem
   1.109      }
   1.110      if (new_depth_adjust != 0 && PrintInlining) {
   1.111 -      stringStream nm1; caller_jvms->method()->print_name(&nm1);
   1.112 -      stringStream nm2; callee_method->print_name(&nm2);
   1.113 -      tty->print_cr("discounting inlining depth from %s to %s", nm1.base(), nm2.base());
   1.114 +      CompileTask::print_inline_indent(inline_depth());
   1.115 +      tty->print_cr(" \\-> discounting inline depth");
   1.116      }
   1.117      if (new_depth_adjust != 0 && C->log()) {
   1.118        int id1 = C->log()->identify(caller_jvms->method());

mercurial