1.1 --- a/src/share/vm/opto/bytecodeInfo.cpp Sun Mar 27 13:17:37 2011 -0700 1.2 +++ b/src/share/vm/opto/bytecodeInfo.cpp Mon Mar 28 03:58:07 2011 -0700 1.3 @@ -25,6 +25,7 @@ 1.4 #include "precompiled.hpp" 1.5 #include "classfile/systemDictionary.hpp" 1.6 #include "classfile/vmSymbols.hpp" 1.7 +#include "compiler/compileBroker.hpp" 1.8 #include "compiler/compileLog.hpp" 1.9 #include "interpreter/linkResolver.hpp" 1.10 #include "oops/objArrayKlass.hpp" 1.11 @@ -75,13 +76,6 @@ 1.12 assert(!UseOldInlining, "do not use for old stuff"); 1.13 } 1.14 1.15 - 1.16 - 1.17 -static void print_indent(int depth) { 1.18 - tty->print(" "); 1.19 - for (int i = depth; i != 0; --i) tty->print(" "); 1.20 -} 1.21 - 1.22 static bool is_init_with_ea(ciMethod* callee_method, 1.23 ciMethod* caller_method, Compile* C) { 1.24 // True when EA is ON and a java constructor is called or 1.25 @@ -100,7 +94,7 @@ 1.26 if(callee_method->should_inline()) { 1.27 *wci_result = *(WarmCallInfo::always_hot()); 1.28 if (PrintInlining && Verbose) { 1.29 - print_indent(inline_depth()); 1.30 + CompileTask::print_inline_indent(inline_depth()); 1.31 tty->print_cr("Inlined method is hot: "); 1.32 } 1.33 return NULL; 1.34 @@ -116,7 +110,7 @@ 1.35 size < InlineThrowMaxSize ) { 1.36 wci_result->set_profit(wci_result->profit() * 100); 1.37 if (PrintInlining && Verbose) { 1.38 - print_indent(inline_depth()); 1.39 + CompileTask::print_inline_indent(inline_depth()); 1.40 tty->print_cr("Inlined method with many throws (throws=%d):", callee_method->interpreter_throwout_count()); 1.41 } 1.42 return NULL; 1.43 @@ -138,9 +132,9 @@ 1.44 1.45 max_size = C->freq_inline_size(); 1.46 if (size <= max_size && TraceFrequencyInlining) { 1.47 - print_indent(inline_depth()); 1.48 + CompileTask::print_inline_indent(inline_depth()); 1.49 tty->print_cr("Inlined frequent method (freq=%d count=%d):", freq, call_site_count); 1.50 - print_indent(inline_depth()); 1.51 + CompileTask::print_inline_indent(inline_depth()); 1.52 callee_method->print(); 1.53 tty->cr(); 1.54 } 1.55 @@ -315,8 +309,25 @@ 1.56 if( inline_depth() > MaxInlineLevel ) { 1.57 return "inlining too deep"; 1.58 } 1.59 - if( method() == callee_method && 1.60 - inline_depth() > MaxRecursiveInlineLevel ) { 1.61 + 1.62 + // We need to detect recursive inlining of method handle targets: if 1.63 + // the current method is a method handle adapter and one of the 1.64 + // callers is the same method as the callee, we bail out if 1.65 + // MaxRecursiveInlineLevel is hit. 1.66 + if (method()->is_method_handle_adapter()) { 1.67 + JVMState* jvms = caller_jvms(); 1.68 + int inline_level = 0; 1.69 + while (jvms != NULL && jvms->has_method()) { 1.70 + if (jvms->method() == callee_method) { 1.71 + inline_level++; 1.72 + if (inline_level > MaxRecursiveInlineLevel) 1.73 + return "recursively inlining too deep"; 1.74 + } 1.75 + jvms = jvms->caller(); 1.76 + } 1.77 + } 1.78 + 1.79 + if (method() == callee_method && inline_depth() > MaxRecursiveInlineLevel) { 1.80 return "recursively inlining too deep"; 1.81 } 1.82 1.83 @@ -368,18 +379,14 @@ 1.84 #ifndef PRODUCT 1.85 //------------------------------print_inlining--------------------------------- 1.86 // Really, the failure_msg can be a success message also. 1.87 -void InlineTree::print_inlining(ciMethod *callee_method, int caller_bci, const char *failure_msg) const { 1.88 - print_indent(inline_depth()); 1.89 - tty->print("@ %d ", caller_bci); 1.90 - if( callee_method ) callee_method->print_short_name(); 1.91 - else tty->print(" callee not monotonic or profiled"); 1.92 - tty->print(" %s", (failure_msg ? failure_msg : "inline")); 1.93 - if( Verbose && callee_method ) { 1.94 +void InlineTree::print_inlining(ciMethod* callee_method, int caller_bci, const char* failure_msg) const { 1.95 + CompileTask::print_inlining(callee_method, inline_depth(), caller_bci, failure_msg ? failure_msg : "inline"); 1.96 + if (callee_method == NULL) tty->print(" callee not monotonic or profiled"); 1.97 + if (Verbose && callee_method) { 1.98 const InlineTree *top = this; 1.99 while( top->caller_tree() != NULL ) { top = top->caller_tree(); } 1.100 tty->print(" bcs: %d+%d invoked: %d", top->count_inline_bcs(), callee_method->code_size(), callee_method->interpreter_invocation_count()); 1.101 } 1.102 - tty->cr(); 1.103 } 1.104 #endif 1.105