hotspot/src/share/vm/opto/bytecodeInfo.cpp
changeset 29582 9a0bb63adf5a
parent 27148 a4b542d56e01
child 30305 b92a97e1e9cb
equal deleted inserted replaced
29477:82f545c6572b 29582:9a0bb63adf5a
    31 #include "interpreter/linkResolver.hpp"
    31 #include "interpreter/linkResolver.hpp"
    32 #include "oops/objArrayKlass.hpp"
    32 #include "oops/objArrayKlass.hpp"
    33 #include "opto/callGenerator.hpp"
    33 #include "opto/callGenerator.hpp"
    34 #include "opto/parse.hpp"
    34 #include "opto/parse.hpp"
    35 #include "runtime/handles.inline.hpp"
    35 #include "runtime/handles.inline.hpp"
       
    36 #include "utilities/events.hpp"
    36 
    37 
    37 //=============================================================================
    38 //=============================================================================
    38 //------------------------------InlineTree-------------------------------------
    39 //------------------------------InlineTree-------------------------------------
    39 InlineTree::InlineTree(Compile* c,
    40 InlineTree::InlineTree(Compile* c,
    40                        const InlineTree *caller_tree, ciMethod* callee,
    41                        const InlineTree *caller_tree, ciMethod* callee,
   488   return NULL;
   489   return NULL;
   489 }
   490 }
   490 
   491 
   491 //------------------------------print_inlining---------------------------------
   492 //------------------------------print_inlining---------------------------------
   492 void InlineTree::print_inlining(ciMethod* callee_method, int caller_bci,
   493 void InlineTree::print_inlining(ciMethod* callee_method, int caller_bci,
   493                                 bool success) const {
   494                                 ciMethod* caller_method, bool success) const {
   494   const char* inline_msg = msg();
   495   const char* inline_msg = msg();
   495   assert(inline_msg != NULL, "just checking");
   496   assert(inline_msg != NULL, "just checking");
   496   if (C->log() != NULL) {
   497   if (C->log() != NULL) {
   497     if (success) {
   498     if (success) {
   498       C->log()->inline_success(inline_msg);
   499       C->log()->inline_success(inline_msg);
   507       const InlineTree *top = this;
   508       const InlineTree *top = this;
   508       while( top->caller_tree() != NULL ) { top = top->caller_tree(); }
   509       while( top->caller_tree() != NULL ) { top = top->caller_tree(); }
   509       //tty->print("  bcs: %d+%d  invoked: %d", top->count_inline_bcs(), callee_method->code_size(), callee_method->interpreter_invocation_count());
   510       //tty->print("  bcs: %d+%d  invoked: %d", top->count_inline_bcs(), callee_method->code_size(), callee_method->interpreter_invocation_count());
   510     }
   511     }
   511   }
   512   }
       
   513 #if INCLUDE_TRACE
       
   514   EventCompilerInlining event;
       
   515   if (event.should_commit()) {
       
   516     event.set_compileID(C->compile_id());
       
   517     event.set_message(inline_msg);
       
   518     event.set_succeeded(success);
       
   519     event.set_bci(caller_bci);
       
   520     event.set_caller(caller_method->get_Method());
       
   521     event.set_callee(callee_method->to_trace_struct());
       
   522     event.commit();
       
   523   }
       
   524 #endif // INCLUDE_TRACE
   512 }
   525 }
   513 
   526 
   514 //------------------------------ok_to_inline-----------------------------------
   527 //------------------------------ok_to_inline-----------------------------------
   515 WarmCallInfo* InlineTree::ok_to_inline(ciMethod* callee_method, JVMState* jvms, ciCallProfile& profile, WarmCallInfo* initial_wci, bool& should_delay) {
   528 WarmCallInfo* InlineTree::ok_to_inline(ciMethod* callee_method, JVMState* jvms, ciCallProfile& profile, WarmCallInfo* initial_wci, bool& should_delay) {
   516   assert(callee_method != NULL, "caller checks for optimized virtual!");
   529   assert(callee_method != NULL, "caller checks for optimized virtual!");
   529   ciMethod*   caller_method = jvms->method();
   542   ciMethod*   caller_method = jvms->method();
   530 
   543 
   531   // Do some initial checks.
   544   // Do some initial checks.
   532   if (!pass_initial_checks(caller_method, caller_bci, callee_method)) {
   545   if (!pass_initial_checks(caller_method, caller_bci, callee_method)) {
   533     set_msg("failed initial checks");
   546     set_msg("failed initial checks");
   534     print_inlining(callee_method, caller_bci, false /* !success */);
   547     print_inlining(callee_method, caller_bci, caller_method, false /* !success */);
   535     return NULL;
   548     return NULL;
   536   }
   549   }
   537 
   550 
   538   // Do some parse checks.
   551   // Do some parse checks.
   539   set_msg(check_can_parse(callee_method));
   552   set_msg(check_can_parse(callee_method));
   540   if (msg() != NULL) {
   553   if (msg() != NULL) {
   541     print_inlining(callee_method, caller_bci, false /* !success */);
   554     print_inlining(callee_method, caller_bci, caller_method, false /* !success */);
   542     return NULL;
   555     return NULL;
   543   }
   556   }
   544 
   557 
   545   // Check if inlining policy says no.
   558   // Check if inlining policy says no.
   546   WarmCallInfo wci = *(initial_wci);
   559   WarmCallInfo wci = *(initial_wci);
   578   if (!wci.is_cold()) {
   591   if (!wci.is_cold()) {
   579     // Inline!
   592     // Inline!
   580     if (msg() == NULL) {
   593     if (msg() == NULL) {
   581       set_msg("inline (hot)");
   594       set_msg("inline (hot)");
   582     }
   595     }
   583     print_inlining(callee_method, caller_bci, true /* success */);
   596     print_inlining(callee_method, caller_bci, caller_method, true /* success */);
   584     build_inline_tree_for_callee(callee_method, jvms, caller_bci);
   597     build_inline_tree_for_callee(callee_method, jvms, caller_bci);
   585     if (InlineWarmCalls && !wci.is_hot())
   598     if (InlineWarmCalls && !wci.is_hot()) {
   586       return new (C) WarmCallInfo(wci);  // copy to heap
   599       return new (C) WarmCallInfo(wci);  // copy to heap
       
   600     }
   587     return WarmCallInfo::always_hot();
   601     return WarmCallInfo::always_hot();
   588   }
   602   }
   589 
   603 
   590   // Do not inline
   604   // Do not inline
   591   if (msg() == NULL) {
   605   if (msg() == NULL) {
   592     set_msg("too cold to inline");
   606     set_msg("too cold to inline");
   593   }
   607   }
   594   print_inlining(callee_method, caller_bci, false /* !success */ );
   608   print_inlining(callee_method, caller_bci, caller_method, false /* !success */ );
   595   return NULL;
   609   return NULL;
   596 }
   610 }
   597 
   611 
   598 //------------------------------compute_callee_frequency-----------------------
   612 //------------------------------compute_callee_frequency-----------------------
   599 float InlineTree::compute_callee_frequency( int caller_bci ) const {
   613 float InlineTree::compute_callee_frequency( int caller_bci ) const {