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);
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_or_interface = (bytecode == Bytecodes::_invokevirtual) ||
101 (bytecode == Bytecodes::_invokeinterface) ||
102 (orig_callee->intrinsic_id() == vmIntrinsics::_linkToVirtual) ||
103 (orig_callee->intrinsic_id() == vmIntrinsics::_linkToInterface);
104
105 const bool check_access = !orig_callee->is_method_handle_intrinsic(); // method handle intrinsics don't perform access checks
106
107 // Dtrace currently doesn't work unless all calls are vanilla
108 if (env()->dtrace_method_probes()) {
109 allow_inline = false;
110 }
111
112 // Note: When we get profiling during stage-1 compiles, we want to pull
113 // from more specific profile data which pertains to this inlining.
114 // Right now, ignore the information in jvms->caller(), and do method[bci].
115 ciCallProfile profile = caller->call_profile_at_bci(bci);
116
117 // See how many times this site has been invoked.
118 int site_count = profile.count();
119 int receiver_count = -1;
120 if (call_does_dispatch && UseTypeProfile && profile.has_receiver(0)) {
121 // Receivers in the profile structure are ordered by call counts
122 // so that the most called (major) receiver is profile.receiver(0).
123 receiver_count = profile.receiver_count(0);
124 }
125
126 CompileLog* log = this->log();
473 }
474
475 bool Compile::should_delay_vector_reboxing_inlining(ciMethod* call_method, JVMState* jvms) {
476 return EnableVectorSupport && (call_method->intrinsic_id() == vmIntrinsics::_VectorRebox);
477 }
478
479 // uncommon-trap call-sites where callee is unloaded, uninitialized or will not link
480 bool Parse::can_not_compile_call_site(ciMethod *dest_method, ciInstanceKlass* klass) {
481 // Additional inputs to consider...
482 // bc = bc()
483 // caller = method()
484 // iter().get_method_holder_index()
485 assert( dest_method->is_loaded(), "ciTypeFlow should not let us get here" );
486 // Interface classes can be loaded & linked and never get around to
487 // being initialized. Uncommon-trap for not-initialized static or
488 // v-calls. Let interface calls happen.
489 ciInstanceKlass* holder_klass = dest_method->holder();
490 if (!holder_klass->is_being_initialized() &&
491 !holder_klass->is_initialized() &&
492 !holder_klass->is_interface()) {
493 uncommon_trap(Deoptimization::Reason_uninitialized,
494 Deoptimization::Action_reinterpret,
495 holder_klass);
496 return true;
497 }
498
499 assert(dest_method->is_loaded(), "dest_method: typeflow responsibility");
500 return false;
501 }
502
503 #ifdef ASSERT
504 static bool check_call_consistency(JVMState* jvms, CallGenerator* cg) {
505 ciMethod* symbolic_info = jvms->method()->get_method_at_bci(jvms->bci());
506 ciMethod* resolved_method = cg->method();
507 if (!ciMethod::is_consistent_info(symbolic_info, resolved_method)) {
508 tty->print_cr("JVMS:");
509 jvms->dump();
510 tty->print_cr("Bytecode info:");
511 jvms->method()->get_method_at_bci(jvms->bci())->print(); tty->cr();
512 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);
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_or_interface = (bytecode == Bytecodes::_invokevirtual) ||
102 (bytecode == Bytecodes::_invokeinterface) ||
103 (orig_callee->intrinsic_id() == vmIntrinsics::_linkToVirtual) ||
104 (orig_callee->intrinsic_id() == vmIntrinsics::_linkToInterface);
105
106 const bool check_access = !orig_callee->is_method_handle_intrinsic(); // method handle intrinsics don't perform access checks
107
108 callee->ensure_method_data(true);
109
110 // Dtrace currently doesn't work unless all calls are vanilla
111 if (env()->dtrace_method_probes()) {
112 allow_inline = false;
113 }
114
115 // Note: When we get profiling during stage-1 compiles, we want to pull
116 // from more specific profile data which pertains to this inlining.
117 // Right now, ignore the information in jvms->caller(), and do method[bci].
118 ciCallProfile profile = caller->call_profile_at_bci(bci);
119
120 // See how many times this site has been invoked.
121 int site_count = profile.count();
122 int receiver_count = -1;
123 if (call_does_dispatch && UseTypeProfile && profile.has_receiver(0)) {
124 // Receivers in the profile structure are ordered by call counts
125 // so that the most called (major) receiver is profile.receiver(0).
126 receiver_count = profile.receiver_count(0);
127 }
128
129 CompileLog* log = this->log();
476 }
477
478 bool Compile::should_delay_vector_reboxing_inlining(ciMethod* call_method, JVMState* jvms) {
479 return EnableVectorSupport && (call_method->intrinsic_id() == vmIntrinsics::_VectorRebox);
480 }
481
482 // uncommon-trap call-sites where callee is unloaded, uninitialized or will not link
483 bool Parse::can_not_compile_call_site(ciMethod *dest_method, ciInstanceKlass* klass) {
484 // Additional inputs to consider...
485 // bc = bc()
486 // caller = method()
487 // iter().get_method_holder_index()
488 assert( dest_method->is_loaded(), "ciTypeFlow should not let us get here" );
489 // Interface classes can be loaded & linked and never get around to
490 // being initialized. Uncommon-trap for not-initialized static or
491 // v-calls. Let interface calls happen.
492 ciInstanceKlass* holder_klass = dest_method->holder();
493 if (!holder_klass->is_being_initialized() &&
494 !holder_klass->is_initialized() &&
495 !holder_klass->is_interface()) {
496 if (C->env()->task()->is_precompile()) {
497 ResourceMark rm;
498 log_debug(precompile)("Emitting uncommon trap (cannot compile call site) in AOT code for %s", holder_klass->name()->as_klass_external_name());
499 }
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:");
|