< prev index next >

src/share/vm/opto/bytecodeInfo.cpp

Print this page




  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "ci/ciReplay.hpp"
  27 #include "classfile/systemDictionary.hpp"
  28 #include "classfile/vmSymbols.hpp"
  29 #include "compiler/compileBroker.hpp"
  30 #include "compiler/compileLog.hpp"
  31 #include "interpreter/linkResolver.hpp"

  32 #include "jfr/jfrEvents.hpp"

  33 #include "oops/objArrayKlass.hpp"
  34 #include "opto/callGenerator.hpp"
  35 #include "opto/parse.hpp"
  36 #include "runtime/handles.inline.hpp"
  37 
  38 //=============================================================================
  39 //------------------------------InlineTree-------------------------------------
  40 InlineTree::InlineTree(Compile* c,
  41                        const InlineTree *caller_tree, ciMethod* callee,
  42                        JVMState* caller_jvms, int caller_bci,
  43                        float site_invoke_ratio, int max_inline_level) :
  44   C(c),
  45   _caller_jvms(caller_jvms),
  46   _caller_tree((InlineTree*) caller_tree),
  47   _method(callee),
  48   _site_invoke_ratio(site_invoke_ratio),
  49   _max_inline_level(max_inline_level),
  50   _count_inline_bcs(method()->code_size_for_inlining()),
  51   _subtrees(c->comp_arena(), 2, 0, NULL),
  52   _msg(NULL)


 463   }
 464   // We will attempt to see if a class/field/etc got properly loaded.  If it
 465   // did not, it may attempt to throw an exception during our probing.  Catch
 466   // and ignore such exceptions and do not attempt to compile the method.
 467   if( callee_method->should_exclude() )  return false;
 468 
 469   return true;
 470 }
 471 
 472 //------------------------------check_can_parse--------------------------------
 473 const char* InlineTree::check_can_parse(ciMethod* callee) {
 474   // Certain methods cannot be parsed at all:
 475   if ( callee->is_native())                     return "native method";
 476   if ( callee->is_abstract())                   return "abstract method";
 477   if (!callee->can_be_compiled())               return "not compilable (disabled)";
 478   if (!callee->has_balanced_monitors())         return "not compilable (unbalanced monitors)";
 479   if ( callee->get_flow_analysis()->failing())  return "not compilable (flow analysis failed)";
 480   return NULL;
 481 }
 482 

 483 static void post_inlining_event(int compile_id,const char* msg, bool success, int bci, ciMethod* caller, ciMethod* callee) {
 484   assert(caller != NULL, "invariant");
 485   assert(callee != NULL, "invariant");
 486   EventCompilerInlining event;
 487   if (event.should_commit()) {
 488     JfrStructCalleeMethod callee_struct;
 489     callee_struct.set_type(callee->holder()->name()->as_utf8());
 490     callee_struct.set_name(callee->name()->as_utf8());
 491     callee_struct.set_descriptor(callee->signature()->as_symbol()->as_utf8());
 492     event.set_compileId(compile_id);
 493     event.set_message(msg);
 494     event.set_succeeded(success);
 495     event.set_bci(bci);
 496     event.set_caller(caller->get_Method());
 497     event.set_callee(callee_struct);
 498     event.commit();
 499   }
 500 }

 501 
 502 //------------------------------print_inlining---------------------------------
 503 void InlineTree::print_inlining(ciMethod* callee_method, int caller_bci,
 504                                 ciMethod* caller_method, bool success) const {
 505   const char* inline_msg = msg();
 506   assert(inline_msg != NULL, "just checking");
 507   if (C->log() != NULL) {
 508     if (success) {
 509       C->log()->inline_success(inline_msg);
 510     } else {
 511       C->log()->inline_fail(inline_msg);
 512     }
 513   }
 514   if (C->print_inlining()) {
 515     C->print_inlining(callee_method, inline_level(), caller_bci, inline_msg);
 516     if (callee_method == NULL) tty->print(" callee not monotonic or profiled");
 517     if (Verbose && callee_method) {
 518       const InlineTree *top = this;
 519       while( top->caller_tree() != NULL ) { top = top->caller_tree(); }
 520       //tty->print("  bcs: %d+%d  invoked: %d", top->count_inline_bcs(), callee_method->code_size(), callee_method->interpreter_invocation_count());
 521     }
 522   }

 523   post_inlining_event(C->compile_id(), inline_msg, success, caller_bci, caller_method, callee_method);

 524 }
 525 
 526 //------------------------------ok_to_inline-----------------------------------
 527 WarmCallInfo* InlineTree::ok_to_inline(ciMethod* callee_method, JVMState* jvms, ciCallProfile& profile, WarmCallInfo* initial_wci, bool& should_delay) {
 528   assert(callee_method != NULL, "caller checks for optimized virtual!");
 529   assert(!should_delay, "should be initialized to false");
 530 #ifdef ASSERT
 531   // Make sure the incoming jvms has the same information content as me.
 532   // This means that we can eventually make this whole class AllStatic.
 533   if (jvms->caller() == NULL) {
 534     assert(_caller_jvms == NULL, "redundant instance state");
 535   } else {
 536     assert(_caller_jvms->same_calls_as(jvms->caller()), "redundant instance state");
 537   }
 538   assert(_method == jvms->method(), "redundant instance state");
 539 #endif
 540   int         caller_bci    = jvms->bci();
 541   ciMethod*   caller_method = jvms->method();
 542 
 543   // Do some initial checks.




  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "ci/ciReplay.hpp"
  27 #include "classfile/systemDictionary.hpp"
  28 #include "classfile/vmSymbols.hpp"
  29 #include "compiler/compileBroker.hpp"
  30 #include "compiler/compileLog.hpp"
  31 #include "interpreter/linkResolver.hpp"
  32 #if INCLUDE_JFR
  33 #include "jfr/jfrEvents.hpp"
  34 #endif
  35 #include "oops/objArrayKlass.hpp"
  36 #include "opto/callGenerator.hpp"
  37 #include "opto/parse.hpp"
  38 #include "runtime/handles.inline.hpp"
  39 
  40 //=============================================================================
  41 //------------------------------InlineTree-------------------------------------
  42 InlineTree::InlineTree(Compile* c,
  43                        const InlineTree *caller_tree, ciMethod* callee,
  44                        JVMState* caller_jvms, int caller_bci,
  45                        float site_invoke_ratio, int max_inline_level) :
  46   C(c),
  47   _caller_jvms(caller_jvms),
  48   _caller_tree((InlineTree*) caller_tree),
  49   _method(callee),
  50   _site_invoke_ratio(site_invoke_ratio),
  51   _max_inline_level(max_inline_level),
  52   _count_inline_bcs(method()->code_size_for_inlining()),
  53   _subtrees(c->comp_arena(), 2, 0, NULL),
  54   _msg(NULL)


 465   }
 466   // We will attempt to see if a class/field/etc got properly loaded.  If it
 467   // did not, it may attempt to throw an exception during our probing.  Catch
 468   // and ignore such exceptions and do not attempt to compile the method.
 469   if( callee_method->should_exclude() )  return false;
 470 
 471   return true;
 472 }
 473 
 474 //------------------------------check_can_parse--------------------------------
 475 const char* InlineTree::check_can_parse(ciMethod* callee) {
 476   // Certain methods cannot be parsed at all:
 477   if ( callee->is_native())                     return "native method";
 478   if ( callee->is_abstract())                   return "abstract method";
 479   if (!callee->can_be_compiled())               return "not compilable (disabled)";
 480   if (!callee->has_balanced_monitors())         return "not compilable (unbalanced monitors)";
 481   if ( callee->get_flow_analysis()->failing())  return "not compilable (flow analysis failed)";
 482   return NULL;
 483 }
 484 
 485 #if INCLUDE_JFR
 486 static void post_inlining_event(int compile_id,const char* msg, bool success, int bci, ciMethod* caller, ciMethod* callee) {
 487   assert(caller != NULL, "invariant");
 488   assert(callee != NULL, "invariant");
 489   EventCompilerInlining event;
 490   if (event.should_commit()) {
 491     JfrStructCalleeMethod callee_struct;
 492     callee_struct.set_type(callee->holder()->name()->as_utf8());
 493     callee_struct.set_name(callee->name()->as_utf8());
 494     callee_struct.set_descriptor(callee->signature()->as_symbol()->as_utf8());
 495     event.set_compileId(compile_id);
 496     event.set_message(msg);
 497     event.set_succeeded(success);
 498     event.set_bci(bci);
 499     event.set_caller(caller->get_Method());
 500     event.set_callee(callee_struct);
 501     event.commit();
 502   }
 503 }
 504 #endif
 505 
 506 //------------------------------print_inlining---------------------------------
 507 void InlineTree::print_inlining(ciMethod* callee_method, int caller_bci,
 508                                 ciMethod* caller_method, bool success) const {
 509   const char* inline_msg = msg();
 510   assert(inline_msg != NULL, "just checking");
 511   if (C->log() != NULL) {
 512     if (success) {
 513       C->log()->inline_success(inline_msg);
 514     } else {
 515       C->log()->inline_fail(inline_msg);
 516     }
 517   }
 518   if (C->print_inlining()) {
 519     C->print_inlining(callee_method, inline_level(), caller_bci, inline_msg);
 520     if (callee_method == NULL) tty->print(" callee not monotonic or profiled");
 521     if (Verbose && callee_method) {
 522       const InlineTree *top = this;
 523       while( top->caller_tree() != NULL ) { top = top->caller_tree(); }
 524       //tty->print("  bcs: %d+%d  invoked: %d", top->count_inline_bcs(), callee_method->code_size(), callee_method->interpreter_invocation_count());
 525     }
 526   }
 527 #if INCLUDE_JFR
 528   post_inlining_event(C->compile_id(), inline_msg, success, caller_bci, caller_method, callee_method);
 529 #endif
 530 }
 531 
 532 //------------------------------ok_to_inline-----------------------------------
 533 WarmCallInfo* InlineTree::ok_to_inline(ciMethod* callee_method, JVMState* jvms, ciCallProfile& profile, WarmCallInfo* initial_wci, bool& should_delay) {
 534   assert(callee_method != NULL, "caller checks for optimized virtual!");
 535   assert(!should_delay, "should be initialized to false");
 536 #ifdef ASSERT
 537   // Make sure the incoming jvms has the same information content as me.
 538   // This means that we can eventually make this whole class AllStatic.
 539   if (jvms->caller() == NULL) {
 540     assert(_caller_jvms == NULL, "redundant instance state");
 541   } else {
 542     assert(_caller_jvms->same_calls_as(jvms->caller()), "redundant instance state");
 543   }
 544   assert(_method == jvms->method(), "redundant instance state");
 545 #endif
 546   int         caller_bci    = jvms->bci();
 547   ciMethod*   caller_method = jvms->method();
 548 
 549   // Do some initial checks.


< prev index next >