86 if (call_does_dispatch && UseTypeProfile && profile.has_receiver(0)) {
87 // Receivers in the profile structure are ordered by call counts
88 // so that the most called (major) receiver is profile.receiver(0).
89 receiver_count = profile.receiver_count(0);
90 }
91
92 CompileLog* log = this->log();
93 if (log != NULL) {
94 int rid = (receiver_count >= 0)? log->identify(profile.receiver(0)): -1;
95 int r2id = (rid != -1 && profile.has_receiver(1))? log->identify(profile.receiver(1)):-1;
96 log->begin_elem("call method='%d' count='%d' prof_factor='%g'",
97 log->identify(callee), site_count, prof_factor);
98 if (call_does_dispatch) log->print(" virtual='1'");
99 if (allow_inline) log->print(" inline='1'");
100 if (receiver_count >= 0) {
101 log->print(" receiver='%d' receiver_count='%d'", rid, receiver_count);
102 if (profile.has_receiver(1)) {
103 log->print(" receiver2='%d' receiver2_count='%d'", r2id, profile.receiver_count(1));
104 }
105 }
106 log->end_elem();
107 }
108
109 // Special case the handling of certain common, profitable library
110 // methods. If these methods are replaced with specialized code,
111 // then we return it as the inlined version of the call.
112 // We do this before the strict f.p. check below because the
113 // intrinsics handle strict f.p. correctly.
114 CallGenerator* cg_intrinsic = NULL;
115 if (allow_inline && allow_intrinsics) {
116 CallGenerator* cg = find_intrinsic(callee, call_does_dispatch);
117 if (cg != NULL) {
118 if (cg->is_predicted()) {
119 // Code without intrinsic but, hopefully, inlined.
120 CallGenerator* inline_cg = this->call_generator(callee,
121 vtable_index, call_does_dispatch, jvms, allow_inline, prof_factor, speculative_receiver_type, false);
122 if (inline_cg != NULL) {
123 cg = CallGenerator::for_predicted_intrinsic(cg, inline_cg);
124 }
125 }
279 if (cg != NULL) return cg;
280 }
281 }
282 }
283 }
284 }
285 }
286
287 // Nothing claimed the intrinsic, we go with straight-forward inlining
288 // for already discovered intrinsic.
289 if (allow_inline && allow_intrinsics && cg_intrinsic != NULL) {
290 assert(cg_intrinsic->does_virtual_dispatch(), "sanity");
291 return cg_intrinsic;
292 }
293
294 // There was no special inlining tactic, or it bailed out.
295 // Use a more generic tactic, like a simple call.
296 if (call_does_dispatch) {
297 const char* msg = "virtual call";
298 if (PrintInlining) print_inlining(callee, jvms->depth() - 1, jvms->bci(), msg);
299 return CallGenerator::for_virtual_call(callee, vtable_index);
300 } else {
301 // Class Hierarchy Analysis or Type Profile reveals a unique target,
302 // or it is a static or special call.
303 return CallGenerator::for_direct_call(callee, should_delay_inlining(callee, jvms));
304 }
305 }
306
307 // Return true for methods that shouldn't be inlined early so that
308 // they are easier to analyze and optimize as intrinsics.
309 bool Compile::should_delay_string_inlining(ciMethod* call_method, JVMState* jvms) {
310 if (has_stringbuilder()) {
311
312 if ((call_method->holder() == C->env()->StringBuilder_klass() ||
313 call_method->holder() == C->env()->StringBuffer_klass()) &&
314 (jvms->method()->holder() == C->env()->StringBuilder_klass() ||
315 jvms->method()->holder() == C->env()->StringBuffer_klass())) {
316 // Delay SB calls only when called from non-SB code
317 return false;
318 }
|
86 if (call_does_dispatch && UseTypeProfile && profile.has_receiver(0)) {
87 // Receivers in the profile structure are ordered by call counts
88 // so that the most called (major) receiver is profile.receiver(0).
89 receiver_count = profile.receiver_count(0);
90 }
91
92 CompileLog* log = this->log();
93 if (log != NULL) {
94 int rid = (receiver_count >= 0)? log->identify(profile.receiver(0)): -1;
95 int r2id = (rid != -1 && profile.has_receiver(1))? log->identify(profile.receiver(1)):-1;
96 log->begin_elem("call method='%d' count='%d' prof_factor='%g'",
97 log->identify(callee), site_count, prof_factor);
98 if (call_does_dispatch) log->print(" virtual='1'");
99 if (allow_inline) log->print(" inline='1'");
100 if (receiver_count >= 0) {
101 log->print(" receiver='%d' receiver_count='%d'", rid, receiver_count);
102 if (profile.has_receiver(1)) {
103 log->print(" receiver2='%d' receiver2_count='%d'", r2id, profile.receiver_count(1));
104 }
105 }
106 if (callee->is_method_handle_intrinsic()) {
107 log->print(" method_handle_intrinsic='1'");
108 }
109 log->end_elem();
110 }
111
112 // Special case the handling of certain common, profitable library
113 // methods. If these methods are replaced with specialized code,
114 // then we return it as the inlined version of the call.
115 // We do this before the strict f.p. check below because the
116 // intrinsics handle strict f.p. correctly.
117 CallGenerator* cg_intrinsic = NULL;
118 if (allow_inline && allow_intrinsics) {
119 CallGenerator* cg = find_intrinsic(callee, call_does_dispatch);
120 if (cg != NULL) {
121 if (cg->is_predicted()) {
122 // Code without intrinsic but, hopefully, inlined.
123 CallGenerator* inline_cg = this->call_generator(callee,
124 vtable_index, call_does_dispatch, jvms, allow_inline, prof_factor, speculative_receiver_type, false);
125 if (inline_cg != NULL) {
126 cg = CallGenerator::for_predicted_intrinsic(cg, inline_cg);
127 }
128 }
282 if (cg != NULL) return cg;
283 }
284 }
285 }
286 }
287 }
288 }
289
290 // Nothing claimed the intrinsic, we go with straight-forward inlining
291 // for already discovered intrinsic.
292 if (allow_inline && allow_intrinsics && cg_intrinsic != NULL) {
293 assert(cg_intrinsic->does_virtual_dispatch(), "sanity");
294 return cg_intrinsic;
295 }
296
297 // There was no special inlining tactic, or it bailed out.
298 // Use a more generic tactic, like a simple call.
299 if (call_does_dispatch) {
300 const char* msg = "virtual call";
301 if (PrintInlining) print_inlining(callee, jvms->depth() - 1, jvms->bci(), msg);
302 C->log_inline_failure(msg);
303 return CallGenerator::for_virtual_call(callee, vtable_index);
304 } else {
305 // Class Hierarchy Analysis or Type Profile reveals a unique target,
306 // or it is a static or special call.
307 return CallGenerator::for_direct_call(callee, should_delay_inlining(callee, jvms));
308 }
309 }
310
311 // Return true for methods that shouldn't be inlined early so that
312 // they are easier to analyze and optimize as intrinsics.
313 bool Compile::should_delay_string_inlining(ciMethod* call_method, JVMState* jvms) {
314 if (has_stringbuilder()) {
315
316 if ((call_method->holder() == C->env()->StringBuilder_klass() ||
317 call_method->holder() == C->env()->StringBuffer_klass()) &&
318 (jvms->method()->holder() == C->env()->StringBuilder_klass() ||
319 jvms->method()->holder() == C->env()->StringBuffer_klass())) {
320 // Delay SB calls only when called from non-SB code
321 return false;
322 }
|