src/share/vm/opto/bytecodeInfo.cpp

Print this page
rev 13113 : 8182651: Add TRACE_ONLY conditional macro to support more fine-grained INCLUDE_TRACE programming
Reviewed-by:
   1 /*
   2  * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  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 "oops/objArrayKlass.hpp"
  33 #include "opto/callGenerator.hpp"
  34 #include "opto/parse.hpp"
  35 #include "runtime/handles.inline.hpp"
  36 #include "utilities/events.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)
  53 {
  54 #ifndef PRODUCT
  55   _count_inlines = 0;
  56   _forced_inline = false;


 467       // Try to do constant pool resolution if running Xcomp
 468       if( !caller_method->check_call(index, call_bc == Bytecodes::_invokestatic) ) {
 469         return false;
 470       }
 471     }
 472   }
 473   return true;
 474 }
 475 
 476 //------------------------------check_can_parse--------------------------------
 477 const char* InlineTree::check_can_parse(ciMethod* callee) {
 478   // Certain methods cannot be parsed at all:
 479   if ( callee->is_native())                     return "native method";
 480   if ( callee->is_abstract())                   return "abstract method";
 481   if (!callee->can_be_compiled())               return "not compilable (disabled)";
 482   if (!callee->has_balanced_monitors())         return "not compilable (unbalanced monitors)";
 483   if ( callee->get_flow_analysis()->failing())  return "not compilable (flow analysis failed)";
 484   return NULL;
 485 }
 486 



























 487 //------------------------------print_inlining---------------------------------
 488 void InlineTree::print_inlining(ciMethod* callee_method, int caller_bci,
 489                                 ciMethod* caller_method, bool success) const {
 490   const char* inline_msg = msg();
 491   assert(inline_msg != NULL, "just checking");
 492   if (C->log() != NULL) {
 493     if (success) {
 494       C->log()->inline_success(inline_msg);
 495     } else {
 496       C->log()->inline_fail(inline_msg);
 497     }
 498   }
 499   CompileTask::print_inlining_ul(callee_method, inline_level(),
 500                                                caller_bci, inline_msg);
 501   if (C->print_inlining()) {
 502     C->print_inlining(callee_method, inline_level(), caller_bci, inline_msg);
 503     if (callee_method == NULL) tty->print(" callee not monotonic or profiled");
 504     if (Verbose && callee_method) {
 505       const InlineTree *top = this;
 506       while( top->caller_tree() != NULL ) { top = top->caller_tree(); }
 507       //tty->print("  bcs: %d+%d  invoked: %d", top->count_inline_bcs(), callee_method->code_size(), callee_method->interpreter_invocation_count());
 508     }
 509   }
 510 #if INCLUDE_TRACE
 511   EventCompilerInlining event;
 512   if (event.should_commit()) {
 513     event.set_compileId(C->compile_id());
 514     event.set_message(inline_msg);
 515     event.set_succeeded(success);
 516     event.set_bci(caller_bci);
 517     event.set_caller(caller_method->get_Method());
 518     event.set_callee(callee_method->to_trace_struct());
 519     event.commit();
 520   }
 521 #endif // INCLUDE_TRACE
 522 }
 523 
 524 //------------------------------ok_to_inline-----------------------------------
 525 WarmCallInfo* InlineTree::ok_to_inline(ciMethod* callee_method, JVMState* jvms, ciCallProfile& profile, WarmCallInfo* initial_wci, bool& should_delay) {
 526   assert(callee_method != NULL, "caller checks for optimized virtual!");
 527   assert(!should_delay, "should be initialized to false");
 528 #ifdef ASSERT
 529   // Make sure the incoming jvms has the same information content as me.
 530   // This means that we can eventually make this whole class AllStatic.
 531   if (jvms->caller() == NULL) {
 532     assert(_caller_jvms == NULL, "redundant instance state");
 533   } else {
 534     assert(_caller_jvms->same_calls_as(jvms->caller()), "redundant instance state");
 535   }
 536   assert(_method == jvms->method(), "redundant instance state");
 537 #endif
 538   int         caller_bci    = jvms->bci();
 539   ciMethod*   caller_method = jvms->method();
 540 
 541   // Do some initial checks.


   1 /*
   2  * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  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 "oops/objArrayKlass.hpp"
  33 #include "opto/callGenerator.hpp"
  34 #include "opto/parse.hpp"
  35 #include "runtime/handles.inline.hpp"
  36 #include "utilities/events.hpp"
  37 #include "utilities/macros.hpp"
  38 #if INCLUDE_TRACE
  39 #include "trace/tracing.hpp"
  40 #include "tracefiles/traceEventClasses.hpp"
  41 #endif
  42 
  43 //=============================================================================
  44 //------------------------------InlineTree-------------------------------------
  45 InlineTree::InlineTree(Compile* c,
  46                        const InlineTree *caller_tree, ciMethod* callee,
  47                        JVMState* caller_jvms, int caller_bci,
  48                        float site_invoke_ratio, int max_inline_level) :
  49   C(c),
  50   _caller_jvms(caller_jvms),
  51   _caller_tree((InlineTree*) caller_tree),
  52   _method(callee),
  53   _site_invoke_ratio(site_invoke_ratio),
  54   _max_inline_level(max_inline_level),
  55   _count_inline_bcs(method()->code_size_for_inlining()),
  56   _subtrees(c->comp_arena(), 2, 0, NULL),
  57   _msg(NULL)
  58 {
  59 #ifndef PRODUCT
  60   _count_inlines = 0;
  61   _forced_inline = false;


 472       // Try to do constant pool resolution if running Xcomp
 473       if( !caller_method->check_call(index, call_bc == Bytecodes::_invokestatic) ) {
 474         return false;
 475       }
 476     }
 477   }
 478   return true;
 479 }
 480 
 481 //------------------------------check_can_parse--------------------------------
 482 const char* InlineTree::check_can_parse(ciMethod* callee) {
 483   // Certain methods cannot be parsed at all:
 484   if ( callee->is_native())                     return "native method";
 485   if ( callee->is_abstract())                   return "abstract method";
 486   if (!callee->can_be_compiled())               return "not compilable (disabled)";
 487   if (!callee->has_balanced_monitors())         return "not compilable (unbalanced monitors)";
 488   if ( callee->get_flow_analysis()->failing())  return "not compilable (flow analysis failed)";
 489   return NULL;
 490 }
 491 
 492 #if INCLUDE_TRACE
 493 static void post_inlining_event(int compile_id,
 494                                 const char* msg,
 495                                 bool success,
 496                                 int bci,
 497                                 ciMethod* caller,
 498                                 ciMethod* callee) {
 499   assert(caller != NULL, "invariant");
 500   assert(callee != NULL, "invariant");
 501 
 502   EventCompilerInlining event;
 503   if (event.should_commit()) {
 504     TraceStructCalleeMethod callee_struct;
 505     callee_struct.set_type(callee->holder()->name()->as_utf8());
 506     callee_struct.set_name(callee->name()->as_utf8());
 507     callee_struct.set_descriptor(callee->signature()->as_symbol()->as_utf8());
 508     event.set_compileId(compile_id);
 509     event.set_message(msg);
 510     event.set_succeeded(success);
 511     event.set_bci(bci);
 512     event.set_caller(caller->get_Method());
 513     event.set_callee(callee_struct);
 514     event.commit();
 515   }
 516 }
 517 #endif // INCLUDE_TRACE
 518 
 519 //------------------------------print_inlining---------------------------------
 520 void InlineTree::print_inlining(ciMethod* callee_method, int caller_bci,
 521                                 ciMethod* caller_method, bool success) const {
 522   const char* inline_msg = msg();
 523   assert(inline_msg != NULL, "just checking");
 524   if (C->log() != NULL) {
 525     if (success) {
 526       C->log()->inline_success(inline_msg);
 527     } else {
 528       C->log()->inline_fail(inline_msg);
 529     }
 530   }
 531   CompileTask::print_inlining_ul(callee_method, inline_level(),
 532                                                caller_bci, inline_msg);
 533   if (C->print_inlining()) {
 534     C->print_inlining(callee_method, inline_level(), caller_bci, inline_msg);
 535     if (callee_method == NULL) tty->print(" callee not monotonic or profiled");
 536     if (Verbose && callee_method) {
 537       const InlineTree *top = this;
 538       while( top->caller_tree() != NULL ) { top = top->caller_tree(); }
 539       //tty->print("  bcs: %d+%d  invoked: %d", top->count_inline_bcs(), callee_method->code_size(), callee_method->interpreter_invocation_count());
 540     }
 541   }
 542   TRACE_ONLY(post_inlining_event(C->compile_id(),
 543                                  inline_msg,
 544                                  success,
 545                                  caller_bci,
 546                                  caller_method,
 547                                  callee_method);)






 548 }
 549 
 550 //------------------------------ok_to_inline-----------------------------------
 551 WarmCallInfo* InlineTree::ok_to_inline(ciMethod* callee_method, JVMState* jvms, ciCallProfile& profile, WarmCallInfo* initial_wci, bool& should_delay) {
 552   assert(callee_method != NULL, "caller checks for optimized virtual!");
 553   assert(!should_delay, "should be initialized to false");
 554 #ifdef ASSERT
 555   // Make sure the incoming jvms has the same information content as me.
 556   // This means that we can eventually make this whole class AllStatic.
 557   if (jvms->caller() == NULL) {
 558     assert(_caller_jvms == NULL, "redundant instance state");
 559   } else {
 560     assert(_caller_jvms->same_calls_as(jvms->caller()), "redundant instance state");
 561   }
 562   assert(_method == jvms->method(), "redundant instance state");
 563 #endif
 564   int         caller_bci    = jvms->bci();
 565   ciMethod*   caller_method = jvms->method();
 566 
 567   // Do some initial checks.