93 int rid = (receiver_count >= 0)? log->identify(profile.receiver(0)): -1; 94 int r2id = (rid != -1 && profile.has_receiver(1))? log->identify(profile.receiver(1)):-1; 95 log->begin_elem("call method='%d' count='%d' prof_factor='%g'", 96 log->identify(callee), site_count, prof_factor); 97 if (call_does_dispatch) log->print(" virtual='1'"); 98 if (allow_inline) log->print(" inline='1'"); 99 if (receiver_count >= 0) { 100 log->print(" receiver='%d' receiver_count='%d'", rid, receiver_count); 101 if (profile.has_receiver(1)) { 102 log->print(" receiver2='%d' receiver2_count='%d'", r2id, profile.receiver_count(1)); 103 } 104 } 105 log->end_elem(); 106 } 107 108 // Special case the handling of certain common, profitable library 109 // methods. If these methods are replaced with specialized code, 110 // then we return it as the inlined version of the call. 111 // We do this before the strict f.p. check below because the 112 // intrinsics handle strict f.p. correctly. 113 if (allow_inline && allow_intrinsics) { 114 CallGenerator* cg = find_intrinsic(callee, call_does_dispatch); 115 if (cg != NULL) { 116 if (cg->is_predicted()) { 117 // Code without intrinsic but, hopefully, inlined. 118 CallGenerator* inline_cg = this->call_generator(callee, 119 vtable_index, call_does_dispatch, jvms, allow_inline, prof_factor, false); 120 if (inline_cg != NULL) { 121 cg = CallGenerator::for_predicted_intrinsic(cg, inline_cg); 122 } 123 } 124 return cg; 125 } 126 } 127 128 // Do method handle calls. 129 // NOTE: This must happen before normal inlining logic below since 130 // MethodHandle.invoke* are native methods which obviously don't 131 // have bytecodes and so normal inlining fails. 132 if (callee->is_method_handle_intrinsic()) { 133 CallGenerator* cg = CallGenerator::for_method_handle_call(jvms, caller, callee, delayed_forbidden); 134 assert(cg == NULL || !delayed_forbidden || !cg->is_late_inline() || cg->is_mh_late_inline(), "unexpected CallGenerator"); 135 return cg; 136 } 137 138 // Do not inline strict fp into non-strict code, or the reverse 139 if (caller->is_strict() ^ callee->is_strict()) { 140 allow_inline = false; 141 } 142 143 // Attempt to inline... 144 if (allow_inline) { 145 // The profile data is only partly attributable to this caller, 146 // scale back the call site information. 247 // Generate virtual call for class check failure path 248 // in case of polymorphic virtual call site. 249 miss_cg = CallGenerator::for_virtual_call(callee, vtable_index); 250 } 251 if (miss_cg != NULL) { 252 if (next_hit_cg != NULL) { 253 trace_type_profile(C, jvms->method(), jvms->depth() - 1, jvms->bci(), next_receiver_method, profile.receiver(1), site_count, profile.receiver_count(1)); 254 // We don't need to record dependency on a receiver here and below. 255 // Whenever we inline, the dependency is added by Parse::Parse(). 256 miss_cg = CallGenerator::for_predicted_call(profile.receiver(1), miss_cg, next_hit_cg, PROB_MAX); 257 } 258 if (miss_cg != NULL) { 259 trace_type_profile(C, jvms->method(), jvms->depth() - 1, jvms->bci(), receiver_method, profile.receiver(0), site_count, receiver_count); 260 CallGenerator* cg = CallGenerator::for_predicted_call(profile.receiver(0), miss_cg, hit_cg, profile.receiver_prob(0)); 261 if (cg != NULL) return cg; 262 } 263 } 264 } 265 } 266 } 267 } 268 269 // There was no special inlining tactic, or it bailed out. 270 // Use a more generic tactic, like a simple call. 271 if (call_does_dispatch) { 272 return CallGenerator::for_virtual_call(callee, vtable_index); 273 } else { 274 // Class Hierarchy Analysis or Type Profile reveals a unique target, 275 // or it is a static or special call. 276 return CallGenerator::for_direct_call(callee, should_delay_inlining(callee, jvms)); 277 } 278 } 279 280 // Return true for methods that shouldn't be inlined early so that 281 // they are easier to analyze and optimize as intrinsics. 282 bool Compile::should_delay_string_inlining(ciMethod* call_method, JVMState* jvms) { 283 if (has_stringbuilder()) { 284 285 if ((call_method->holder() == C->env()->StringBuilder_klass() || 286 call_method->holder() == C->env()->StringBuffer_klass()) && | 93 int rid = (receiver_count >= 0)? log->identify(profile.receiver(0)): -1; 94 int r2id = (rid != -1 && profile.has_receiver(1))? log->identify(profile.receiver(1)):-1; 95 log->begin_elem("call method='%d' count='%d' prof_factor='%g'", 96 log->identify(callee), site_count, prof_factor); 97 if (call_does_dispatch) log->print(" virtual='1'"); 98 if (allow_inline) log->print(" inline='1'"); 99 if (receiver_count >= 0) { 100 log->print(" receiver='%d' receiver_count='%d'", rid, receiver_count); 101 if (profile.has_receiver(1)) { 102 log->print(" receiver2='%d' receiver2_count='%d'", r2id, profile.receiver_count(1)); 103 } 104 } 105 log->end_elem(); 106 } 107 108 // Special case the handling of certain common, profitable library 109 // methods. If these methods are replaced with specialized code, 110 // then we return it as the inlined version of the call. 111 // We do this before the strict f.p. check below because the 112 // intrinsics handle strict f.p. correctly. 113 CallGenerator* cg_intrinsic = NULL; 114 if (allow_inline && allow_intrinsics) { 115 CallGenerator* cg = find_intrinsic(callee, call_does_dispatch); 116 if (cg != NULL) { 117 if (cg->is_predicted()) { 118 // Code without intrinsic but, hopefully, inlined. 119 CallGenerator* inline_cg = this->call_generator(callee, 120 vtable_index, call_does_dispatch, jvms, allow_inline, prof_factor, false); 121 if (inline_cg != NULL) { 122 cg = CallGenerator::for_predicted_intrinsic(cg, inline_cg); 123 } 124 } 125 126 // If intrinsic does the virtual dispatch, we try to use the type profile 127 // first, and hopefully inline it as the regular virtual call below. 128 // We will retry the intrinsic if nothing had claimed it afterwards. 129 if (cg->does_virtual_dispatch()) { 130 cg_intrinsic = cg; 131 cg = NULL; 132 } else { 133 return cg; 134 } 135 } 136 } 137 138 // Do method handle calls. 139 // NOTE: This must happen before normal inlining logic below since 140 // MethodHandle.invoke* are native methods which obviously don't 141 // have bytecodes and so normal inlining fails. 142 if (callee->is_method_handle_intrinsic()) { 143 CallGenerator* cg = CallGenerator::for_method_handle_call(jvms, caller, callee, delayed_forbidden); 144 assert(cg == NULL || !delayed_forbidden || !cg->is_late_inline() || cg->is_mh_late_inline(), "unexpected CallGenerator"); 145 return cg; 146 } 147 148 // Do not inline strict fp into non-strict code, or the reverse 149 if (caller->is_strict() ^ callee->is_strict()) { 150 allow_inline = false; 151 } 152 153 // Attempt to inline... 154 if (allow_inline) { 155 // The profile data is only partly attributable to this caller, 156 // scale back the call site information. 257 // Generate virtual call for class check failure path 258 // in case of polymorphic virtual call site. 259 miss_cg = CallGenerator::for_virtual_call(callee, vtable_index); 260 } 261 if (miss_cg != NULL) { 262 if (next_hit_cg != NULL) { 263 trace_type_profile(C, jvms->method(), jvms->depth() - 1, jvms->bci(), next_receiver_method, profile.receiver(1), site_count, profile.receiver_count(1)); 264 // We don't need to record dependency on a receiver here and below. 265 // Whenever we inline, the dependency is added by Parse::Parse(). 266 miss_cg = CallGenerator::for_predicted_call(profile.receiver(1), miss_cg, next_hit_cg, PROB_MAX); 267 } 268 if (miss_cg != NULL) { 269 trace_type_profile(C, jvms->method(), jvms->depth() - 1, jvms->bci(), receiver_method, profile.receiver(0), site_count, receiver_count); 270 CallGenerator* cg = CallGenerator::for_predicted_call(profile.receiver(0), miss_cg, hit_cg, profile.receiver_prob(0)); 271 if (cg != NULL) return cg; 272 } 273 } 274 } 275 } 276 } 277 } 278 279 // Nothing claimed the intrinsic, we go with straight-forward inlining 280 // for already discovered intrinsic. 281 if (allow_inline && allow_intrinsics && cg_intrinsic != NULL) { 282 assert(cg_intrinsic->does_virtual_dispatch(), "sanity"); 283 return cg_intrinsic; 284 } 285 286 // There was no special inlining tactic, or it bailed out. 287 // Use a more generic tactic, like a simple call. 288 if (call_does_dispatch) { 289 return CallGenerator::for_virtual_call(callee, vtable_index); 290 } else { 291 // Class Hierarchy Analysis or Type Profile reveals a unique target, 292 // or it is a static or special call. 293 return CallGenerator::for_direct_call(callee, should_delay_inlining(callee, jvms)); 294 } 295 } 296 297 // Return true for methods that shouldn't be inlined early so that 298 // they are easier to analyze and optimize as intrinsics. 299 bool Compile::should_delay_string_inlining(ciMethod* call_method, JVMState* jvms) { 300 if (has_stringbuilder()) { 301 302 if ((call_method->holder() == C->env()->StringBuilder_klass() || 303 call_method->holder() == C->env()->StringBuffer_klass()) && |