< prev index next >

src/hotspot/share/opto/doCall.cpp

Print this page

  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 "ci/ciCallSite.hpp"
  26 #include "ci/ciMethodHandle.hpp"
  27 #include "ci/ciSymbols.hpp"
  28 #include "classfile/vmSymbols.hpp"
  29 #include "compiler/compileBroker.hpp"
  30 #include "compiler/compileLog.hpp"
  31 #include "interpreter/linkResolver.hpp"
  32 #include "logging/log.hpp"
  33 #include "logging/logLevel.hpp"
  34 #include "logging/logMessage.hpp"
  35 #include "logging/logStream.hpp"

  36 #include "opto/addnode.hpp"
  37 #include "opto/callGenerator.hpp"
  38 #include "opto/castnode.hpp"
  39 #include "opto/cfgnode.hpp"
  40 #include "opto/mulnode.hpp"
  41 #include "opto/parse.hpp"
  42 #include "opto/rootnode.hpp"
  43 #include "opto/runtime.hpp"
  44 #include "opto/subnode.hpp"
  45 #include "prims/methodHandles.hpp"
  46 #include "runtime/sharedRuntime.hpp"
  47 #include "utilities/macros.hpp"
  48 #if INCLUDE_JFR
  49 #include "jfr/jfr.hpp"
  50 #endif
  51 
  52 static void print_trace_type_profile(outputStream* out, int depth, ciKlass* prof_klass, int site_count, int receiver_count,
  53                                      bool with_deco) {
  54   if (with_deco) {
  55     CompileTask::print_inline_indent(depth, out);

  86   }
  87 }
  88 
  89 CallGenerator* Compile::call_generator(ciMethod* callee, int vtable_index, bool call_does_dispatch,
  90                                        JVMState* jvms, bool allow_inline,
  91                                        float prof_factor, ciKlass* speculative_receiver_type,
  92                                        bool allow_intrinsics) {
  93   assert(callee != nullptr, "failed method resolution");
  94 
  95   ciMethod*       caller      = jvms->method();
  96   int             bci         = jvms->bci();
  97   Bytecodes::Code bytecode    = caller->java_code_at_bci(bci);
  98   ciMethod*       orig_callee = caller->get_method_at_bci(bci);
  99 
 100   const bool is_virtual = (bytecode == Bytecodes::_invokevirtual) || (orig_callee->intrinsic_id() == vmIntrinsics::_linkToVirtual);
 101   const bool is_interface = (bytecode == Bytecodes::_invokeinterface) || (orig_callee->intrinsic_id() == vmIntrinsics::_linkToInterface);
 102   const bool is_virtual_or_interface = is_virtual || is_interface;
 103 
 104   const bool check_access = !orig_callee->is_method_handle_intrinsic(); // method handle intrinsics don't perform access checks
 105 


 106   // Dtrace currently doesn't work unless all calls are vanilla
 107   if (env()->dtrace_method_probes()) {
 108     allow_inline = false;
 109   }
 110 
 111   // Note: When we get profiling during stage-1 compiles, we want to pull
 112   // from more specific profile data which pertains to this inlining.
 113   // Right now, ignore the information in jvms->caller(), and do method[bci].
 114   ciCallProfile profile = caller->call_profile_at_bci(bci);
 115 
 116   // See how many times this site has been invoked.
 117   int site_count = profile.count();
 118   int receiver_count = -1;
 119   if (call_does_dispatch && UseTypeProfile && profile.has_receiver(0)) {
 120     // Receivers in the profile structure are ordered by call counts
 121     // so that the most called (major) receiver is profile.receiver(0).
 122     receiver_count = profile.receiver_count(0);
 123   }
 124 
 125   CompileLog* log = this->log();

 480 }
 481 
 482 bool Compile::should_delay_vector_reboxing_inlining(ciMethod* call_method, JVMState* jvms) {
 483   return EnableVectorSupport && (call_method->intrinsic_id() == vmIntrinsics::_VectorRebox);
 484 }
 485 
 486 // uncommon-trap call-sites where callee is unloaded, uninitialized or will not link
 487 bool Parse::can_not_compile_call_site(ciMethod *dest_method, ciInstanceKlass* klass) {
 488   // Additional inputs to consider...
 489   // bc      = bc()
 490   // caller  = method()
 491   // iter().get_method_holder_index()
 492   assert( dest_method->is_loaded(), "ciTypeFlow should not let us get here" );
 493   // Interface classes can be loaded & linked and never get around to
 494   // being initialized.  Uncommon-trap for not-initialized static or
 495   // v-calls.  Let interface calls happen.
 496   ciInstanceKlass* holder_klass = dest_method->holder();
 497   if (!holder_klass->is_being_initialized() &&
 498       !holder_klass->is_initialized() &&
 499       !holder_klass->is_interface()) {




 500     uncommon_trap(Deoptimization::Reason_uninitialized,
 501                   Deoptimization::Action_reinterpret,
 502                   holder_klass);
 503     return true;
 504   }
 505 
 506   assert(dest_method->is_loaded(), "dest_method: typeflow responsibility");
 507   return false;
 508 }
 509 
 510 #ifdef ASSERT
 511 static bool check_call_consistency(JVMState* jvms, CallGenerator* cg) {
 512   ciMethod* symbolic_info = jvms->method()->get_method_at_bci(jvms->bci());
 513   ciMethod* resolved_method = cg->method();
 514   if (!ciMethod::is_consistent_info(symbolic_info, resolved_method)) {
 515     tty->print_cr("JVMS:");
 516     jvms->dump();
 517     tty->print_cr("Bytecode info:");
 518     jvms->method()->get_method_at_bci(jvms->bci())->print(); tty->cr();
 519     tty->print_cr("Resolved method:");

  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 "ci/ciCallSite.hpp"
  26 #include "ci/ciMethodHandle.hpp"
  27 #include "ci/ciSymbols.hpp"
  28 #include "classfile/vmSymbols.hpp"
  29 #include "compiler/compileBroker.hpp"
  30 #include "compiler/compileLog.hpp"
  31 #include "interpreter/linkResolver.hpp"
  32 #include "logging/log.hpp"
  33 #include "logging/logLevel.hpp"
  34 #include "logging/logMessage.hpp"
  35 #include "logging/logStream.hpp"
  36 #include "oops/trainingData.hpp"
  37 #include "opto/addnode.hpp"
  38 #include "opto/callGenerator.hpp"
  39 #include "opto/castnode.hpp"
  40 #include "opto/cfgnode.hpp"
  41 #include "opto/mulnode.hpp"
  42 #include "opto/parse.hpp"
  43 #include "opto/rootnode.hpp"
  44 #include "opto/runtime.hpp"
  45 #include "opto/subnode.hpp"
  46 #include "prims/methodHandles.hpp"
  47 #include "runtime/sharedRuntime.hpp"
  48 #include "utilities/macros.hpp"
  49 #if INCLUDE_JFR
  50 #include "jfr/jfr.hpp"
  51 #endif
  52 
  53 static void print_trace_type_profile(outputStream* out, int depth, ciKlass* prof_klass, int site_count, int receiver_count,
  54                                      bool with_deco) {
  55   if (with_deco) {
  56     CompileTask::print_inline_indent(depth, out);

  87   }
  88 }
  89 
  90 CallGenerator* Compile::call_generator(ciMethod* callee, int vtable_index, bool call_does_dispatch,
  91                                        JVMState* jvms, bool allow_inline,
  92                                        float prof_factor, ciKlass* speculative_receiver_type,
  93                                        bool allow_intrinsics) {
  94   assert(callee != nullptr, "failed method resolution");
  95 
  96   ciMethod*       caller      = jvms->method();
  97   int             bci         = jvms->bci();
  98   Bytecodes::Code bytecode    = caller->java_code_at_bci(bci);
  99   ciMethod*       orig_callee = caller->get_method_at_bci(bci);
 100 
 101   const bool is_virtual = (bytecode == Bytecodes::_invokevirtual) || (orig_callee->intrinsic_id() == vmIntrinsics::_linkToVirtual);
 102   const bool is_interface = (bytecode == Bytecodes::_invokeinterface) || (orig_callee->intrinsic_id() == vmIntrinsics::_linkToInterface);
 103   const bool is_virtual_or_interface = is_virtual || is_interface;
 104 
 105   const bool check_access = !orig_callee->is_method_handle_intrinsic(); // method handle intrinsics don't perform access checks
 106 
 107   callee->ensure_method_data(true);
 108 
 109   // Dtrace currently doesn't work unless all calls are vanilla
 110   if (env()->dtrace_method_probes()) {
 111     allow_inline = false;
 112   }
 113 
 114   // Note: When we get profiling during stage-1 compiles, we want to pull
 115   // from more specific profile data which pertains to this inlining.
 116   // Right now, ignore the information in jvms->caller(), and do method[bci].
 117   ciCallProfile profile = caller->call_profile_at_bci(bci);
 118 
 119   // See how many times this site has been invoked.
 120   int site_count = profile.count();
 121   int receiver_count = -1;
 122   if (call_does_dispatch && UseTypeProfile && profile.has_receiver(0)) {
 123     // Receivers in the profile structure are ordered by call counts
 124     // so that the most called (major) receiver is profile.receiver(0).
 125     receiver_count = profile.receiver_count(0);
 126   }
 127 
 128   CompileLog* log = this->log();

 483 }
 484 
 485 bool Compile::should_delay_vector_reboxing_inlining(ciMethod* call_method, JVMState* jvms) {
 486   return EnableVectorSupport && (call_method->intrinsic_id() == vmIntrinsics::_VectorRebox);
 487 }
 488 
 489 // uncommon-trap call-sites where callee is unloaded, uninitialized or will not link
 490 bool Parse::can_not_compile_call_site(ciMethod *dest_method, ciInstanceKlass* klass) {
 491   // Additional inputs to consider...
 492   // bc      = bc()
 493   // caller  = method()
 494   // iter().get_method_holder_index()
 495   assert( dest_method->is_loaded(), "ciTypeFlow should not let us get here" );
 496   // Interface classes can be loaded & linked and never get around to
 497   // being initialized.  Uncommon-trap for not-initialized static or
 498   // v-calls.  Let interface calls happen.
 499   ciInstanceKlass* holder_klass = dest_method->holder();
 500   if (!holder_klass->is_being_initialized() &&
 501       !holder_klass->is_initialized() &&
 502       !holder_klass->is_interface()) {
 503     if (C->env()->task()->is_precompile()) {
 504       ResourceMark rm;
 505       log_debug(precompile)("Emitting uncommon trap (cannot compile call site) in AOT code for %s", holder_klass->name()->as_klass_external_name());
 506     }
 507     uncommon_trap(Deoptimization::Reason_uninitialized,
 508                   Deoptimization::Action_reinterpret,
 509                   holder_klass);
 510     return true;
 511   }
 512 
 513   assert(dest_method->is_loaded(), "dest_method: typeflow responsibility");
 514   return false;
 515 }
 516 
 517 #ifdef ASSERT
 518 static bool check_call_consistency(JVMState* jvms, CallGenerator* cg) {
 519   ciMethod* symbolic_info = jvms->method()->get_method_at_bci(jvms->bci());
 520   ciMethod* resolved_method = cg->method();
 521   if (!ciMethod::is_consistent_info(symbolic_info, resolved_method)) {
 522     tty->print_cr("JVMS:");
 523     jvms->dump();
 524     tty->print_cr("Bytecode info:");
 525     jvms->method()->get_method_at_bci(jvms->bci())->print(); tty->cr();
 526     tty->print_cr("Resolved method:");
< prev index next >