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