Print this page


Split Close
Expand all
Collapse all
          --- old/src/share/vm/opto/bytecodeInfo.cpp
          +++ new/src/share/vm/opto/bytecodeInfo.cpp
↓ open down ↓ 17 lines elided ↑ open up ↑
  18   18   *
  19   19   * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20   20   * or visit www.oracle.com if you need additional information or have any
  21   21   * questions.
  22   22   *
  23   23   */
  24   24  
  25   25  #include "precompiled.hpp"
  26   26  #include "classfile/systemDictionary.hpp"
  27   27  #include "classfile/vmSymbols.hpp"
       28 +#include "compiler/compileBroker.hpp"
  28   29  #include "compiler/compileLog.hpp"
  29   30  #include "interpreter/linkResolver.hpp"
  30   31  #include "oops/objArrayKlass.hpp"
  31   32  #include "opto/callGenerator.hpp"
  32   33  #include "opto/parse.hpp"
  33   34  #include "runtime/handles.inline.hpp"
  34   35  
  35   36  //=============================================================================
  36   37  //------------------------------InlineTree-------------------------------------
  37   38  InlineTree::InlineTree( Compile* c,
↓ open down ↓ 30 lines elided ↑ open up ↑
  68   69                         float site_invoke_ratio, int site_depth_adjust)
  69   70  : C(c), _caller_jvms(caller_jvms), _caller_tree(NULL),
  70   71    _method(callee_method), _site_invoke_ratio(site_invoke_ratio),
  71   72    _site_depth_adjust(site_depth_adjust),
  72   73    _count_inline_bcs(method()->code_size())
  73   74  {
  74   75    NOT_PRODUCT(_count_inlines = 0;)
  75   76    assert(!UseOldInlining, "do not use for old stuff");
  76   77  }
  77   78  
  78      -
  79      -
  80      -static void print_indent(int depth) {
  81      -  tty->print("      ");
  82      -  for (int i = depth; i != 0; --i) tty->print("  ");
  83      -}
  84      -
  85   79  static bool is_init_with_ea(ciMethod* callee_method,
  86   80                              ciMethod* caller_method, Compile* C) {
  87   81    // True when EA is ON and a java constructor is called or
  88   82    // a super constructor is called from an inlined java constructor.
  89   83    return C->do_escape_analysis() && EliminateAllocations &&
  90   84           ( callee_method->is_initializer() ||
  91   85             (caller_method->is_initializer() &&
  92   86              caller_method != C->method() &&
  93   87              caller_method->holder()->is_subclass_of(callee_method->holder()))
  94   88           );
  95   89  }
  96   90  
  97   91  // positive filter: should send be inlined?  returns NULL, if yes, or rejection msg
  98   92  const char* InlineTree::shouldInline(ciMethod* callee_method, ciMethod* caller_method, int caller_bci, ciCallProfile& profile, WarmCallInfo* wci_result) const {
  99   93    // Allows targeted inlining
 100   94    if(callee_method->should_inline()) {
 101   95      *wci_result = *(WarmCallInfo::always_hot());
 102   96      if (PrintInlining && Verbose) {
 103      -      print_indent(inline_depth());
       97 +      CompileTask::print_inline_indent(inline_depth());
 104   98        tty->print_cr("Inlined method is hot: ");
 105   99      }
 106  100      return NULL;
 107  101    }
 108  102  
 109  103    // positive filter: should send be inlined?  returns NULL (--> yes)
 110  104    // or rejection msg
 111  105    int max_size = C->max_inline_size();
 112  106    int size     = callee_method->code_size();
 113  107  
 114  108    // Check for too many throws (and not too huge)
 115  109    if(callee_method->interpreter_throwout_count() > InlineThrowCount &&
 116  110       size < InlineThrowMaxSize ) {
 117  111      wci_result->set_profit(wci_result->profit() * 100);
 118  112      if (PrintInlining && Verbose) {
 119      -      print_indent(inline_depth());
      113 +      CompileTask::print_inline_indent(inline_depth());
 120  114        tty->print_cr("Inlined method with many throws (throws=%d):", callee_method->interpreter_throwout_count());
 121  115      }
 122  116      return NULL;
 123  117    }
 124  118  
 125  119    if (!UseOldInlining) {
 126  120      return NULL;  // size and frequency are represented in a new way
 127  121    }
 128  122  
 129  123    int call_site_count  = method()->scale_count(profile.count());
↓ open down ↓ 1 lines elided ↑ open up ↑
 131  125    assert( invoke_count != 0, "Require invokation count greater than zero");
 132  126    int freq = call_site_count/invoke_count;
 133  127  
 134  128    // bump the max size if the call is frequent
 135  129    if ((freq >= InlineFrequencyRatio) ||
 136  130        (call_site_count >= InlineFrequencyCount) ||
 137  131        is_init_with_ea(callee_method, caller_method, C)) {
 138  132  
 139  133      max_size = C->freq_inline_size();
 140  134      if (size <= max_size && TraceFrequencyInlining) {
 141      -      print_indent(inline_depth());
      135 +      CompileTask::print_inline_indent(inline_depth());
 142  136        tty->print_cr("Inlined frequent method (freq=%d count=%d):", freq, call_site_count);
 143      -      print_indent(inline_depth());
      137 +      CompileTask::print_inline_indent(inline_depth());
 144  138        callee_method->print();
 145  139        tty->cr();
 146  140      }
 147  141    } else {
 148  142      // Not hot.  Check for medium-sized pre-existing nmethod at cold sites.
 149  143      if (callee_method->has_compiled_code() &&
 150  144          callee_method->instructions_size(CompLevel_full_optimization) > InlineSmallCode/4)
 151  145        return "already compiled into a medium method";
 152  146    }
 153  147    if (size > max_size) {
↓ open down ↓ 154 lines elided ↑ open up ↑
 308  302        return "call site not reached";
 309  303      }
 310  304    }
 311  305  
 312  306    if (!C->do_inlining() && InlineAccessors) {
 313  307      return "not an accessor";
 314  308    }
 315  309    if( inline_depth() > MaxInlineLevel ) {
 316  310      return "inlining too deep";
 317  311    }
 318      -  if( method() == callee_method &&
 319      -      inline_depth() > MaxRecursiveInlineLevel ) {
      312 +
      313 +  // We need to detect recursive inlining of method handle targets: if
      314 +  // the current method is a method handle adapter and one of the
      315 +  // callers is the same method as the callee, we bail out if
      316 +  // MaxRecursiveInlineLevel is hit.
      317 +  if (method()->is_method_handle_adapter()) {
      318 +    JVMState* jvms = caller_jvms();
      319 +    int inline_level = 0;
      320 +    while (jvms != NULL && jvms->has_method()) {
      321 +      if (jvms->method() == callee_method) {
      322 +        inline_level++;
      323 +        if (inline_level > MaxRecursiveInlineLevel)
      324 +          return "recursively inlining too deep";
      325 +      }
      326 +      jvms = jvms->caller();
      327 +    }
      328 +  }
      329 +
      330 +  if (method() == callee_method && inline_depth() > MaxRecursiveInlineLevel) {
 320  331      return "recursively inlining too deep";
 321  332    }
 322  333  
 323  334    int size = callee_method->code_size();
 324  335  
 325  336    if (UseOldInlining && ClipInlining
 326  337        && (int)count_inline_bcs() + size >= DesiredMethodLimit) {
 327  338      return "size > DesiredMethodLimit";
 328  339    }
 329  340  
↓ open down ↓ 31 lines elided ↑ open up ↑
 361  372    // did not, it may attempt to throw an exception during our probing.  Catch
 362  373    // and ignore such exceptions and do not attempt to compile the method.
 363  374    if( callee_method->should_exclude() )  return false;
 364  375  
 365  376    return true;
 366  377  }
 367  378  
 368  379  #ifndef PRODUCT
 369  380  //------------------------------print_inlining---------------------------------
 370  381  // Really, the failure_msg can be a success message also.
 371      -void InlineTree::print_inlining(ciMethod *callee_method, int caller_bci, const char *failure_msg) const {
 372      -  print_indent(inline_depth());
 373      -  tty->print("@ %d  ", caller_bci);
 374      -  if( callee_method ) callee_method->print_short_name();
 375      -  else                tty->print(" callee not monotonic or profiled");
 376      -  tty->print("  %s", (failure_msg ? failure_msg : "inline"));
 377      -  if( Verbose && callee_method ) {
      382 +void InlineTree::print_inlining(ciMethod* callee_method, int caller_bci, const char* failure_msg) const {
      383 +  CompileTask::print_inlining(callee_method, inline_depth(), caller_bci, failure_msg ? failure_msg : "inline");
      384 +  if (callee_method == NULL)  tty->print(" callee not monotonic or profiled");
      385 +  if (Verbose && callee_method) {
 378  386      const InlineTree *top = this;
 379  387      while( top->caller_tree() != NULL ) { top = top->caller_tree(); }
 380  388      tty->print("  bcs: %d+%d  invoked: %d", top->count_inline_bcs(), callee_method->code_size(), callee_method->interpreter_invocation_count());
 381  389    }
 382      -  tty->cr();
 383  390  }
 384  391  #endif
 385  392  
 386  393  //------------------------------ok_to_inline-----------------------------------
 387  394  WarmCallInfo* InlineTree::ok_to_inline(ciMethod* callee_method, JVMState* jvms, ciCallProfile& profile, WarmCallInfo* initial_wci) {
 388  395    assert(callee_method != NULL, "caller checks for optimized virtual!");
 389  396  #ifdef ASSERT
 390  397    // Make sure the incoming jvms has the same information content as me.
 391  398    // This means that we can eventually make this whole class AllStatic.
 392  399    if (jvms->caller() == NULL) {
↓ open down ↓ 166 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX