src/share/vm/opto/doCall.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 6829187 Sdiff src/share/vm/opto

src/share/vm/opto/doCall.cpp

Print this page
rev 1081 : imported patch indy-cleanup-6893081.patch
rev 1082 : [mq]: indy.compiler.patch


 211               NOT_PRODUCT(trace_type_profile(jvms->method(), jvms->depth(), jvms->bci(), next_receiver_method, profile.receiver(1), site_count, profile.receiver_count(1)));
 212               // We don't need to record dependency on a receiver here and below.
 213               // Whenever we inline, the dependency is added by Parse::Parse().
 214               miss_cg = CallGenerator::for_predicted_call(profile.receiver(1), miss_cg, next_hit_cg, PROB_MAX);
 215             }
 216             if (miss_cg != NULL) {
 217               NOT_PRODUCT(trace_type_profile(jvms->method(), jvms->depth(), jvms->bci(), receiver_method, profile.receiver(0), site_count, receiver_count));
 218               cg = CallGenerator::for_predicted_call(profile.receiver(0), miss_cg, hit_cg, profile.receiver_prob(0));
 219               if (cg != NULL)  return cg;
 220             }
 221           }
 222         }
 223       }
 224     }
 225   }
 226 
 227   // There was no special inlining tactic, or it bailed out.
 228   // Use a more generic tactic, like a simple call.
 229   if (call_is_virtual) {
 230     return CallGenerator::for_virtual_call(call_method, vtable_index);






 231   } else {
 232     // Class Hierarchy Analysis or Type Profile reveals a unique target,
 233     // or it is a static or special call.
 234     return CallGenerator::for_direct_call(call_method, should_delay_inlining(call_method, jvms));
 235   }
 236 }
 237 
 238 // Return true for methods that shouldn't be inlined early so that
 239 // they are easier to analyze and optimize as intrinsics.
 240 bool Compile::should_delay_inlining(ciMethod* call_method, JVMState* jvms) {
 241   if (has_stringbuilder()) {
 242 
 243     if ((call_method->holder() == C->env()->StringBuilder_klass() ||
 244          call_method->holder() == C->env()->StringBuffer_klass()) &&
 245         (jvms->method()->holder() == C->env()->StringBuilder_klass() ||
 246          jvms->method()->holder() == C->env()->StringBuffer_klass())) {
 247       // Delay SB calls only when called from non-SB code
 248       return false;
 249     }
 250 


 290 
 291 
 292 // uncommon-trap call-sites where callee is unloaded, uninitialized or will not link
 293 bool Parse::can_not_compile_call_site(ciMethod *dest_method, ciInstanceKlass* klass) {
 294   // Additional inputs to consider...
 295   // bc      = bc()
 296   // caller  = method()
 297   // iter().get_method_holder_index()
 298   assert( dest_method->is_loaded(), "ciTypeFlow should not let us get here" );
 299   // Interface classes can be loaded & linked and never get around to
 300   // being initialized.  Uncommon-trap for not-initialized static or
 301   // v-calls.  Let interface calls happen.
 302   ciInstanceKlass* holder_klass  = dest_method->holder();
 303   if (!holder_klass->is_initialized() &&
 304       !holder_klass->is_interface()) {
 305     uncommon_trap(Deoptimization::Reason_uninitialized,
 306                   Deoptimization::Action_reinterpret,
 307                   holder_klass);
 308     return true;
 309   }
 310   if (dest_method->is_method_handle_invoke()
 311       && holder_klass->name() == ciSymbol::java_dyn_InvokeDynamic()) {
 312     // FIXME: NYI
 313     uncommon_trap(Deoptimization::Reason_unhandled,
 314                   Deoptimization::Action_none,
 315                   holder_klass);
 316     return true;
 317   }
 318 
 319   assert(dest_method->will_link(method()->holder(), klass, bc()), "dest_method: typeflow responsibility");
 320   return false;
 321 }
 322 
 323 
 324 //------------------------------do_call----------------------------------------
 325 // Handle your basic call.  Inline if we can & want to, else just setup call.
 326 void Parse::do_call() {
 327   // It's likely we are going to add debug info soon.
 328   // Also, if we inline a guy who eventually needs debug info for this JVMS,
 329   // our contribution to it is cleaned up right here.
 330   kill_dead_locals();
 331 
 332   // Set frequently used booleans
 333   bool is_virtual = bc() == Bytecodes::_invokevirtual;
 334   bool is_virtual_or_interface = is_virtual || bc() == Bytecodes::_invokeinterface;
 335   bool has_receiver = is_virtual_or_interface || bc() == Bytecodes::_invokespecial;

 336 
 337   // Find target being called
 338   bool             will_link;
 339   ciMethod*        dest_method   = iter().get_method(will_link);
 340   ciInstanceKlass* holder_klass  = dest_method->holder();
 341   ciKlass* holder = iter().get_declared_method_holder();
 342   ciInstanceKlass* klass = ciEnv::get_instance_klass_for_declared_method_holder(holder);
 343 
 344   int   nargs    = dest_method->arg_size();

 345 
 346   // uncommon-trap when callee is unloaded, uninitialized or will not link
 347   // bailout when too many arguments for register representation
 348   if (!will_link || can_not_compile_call_site(dest_method, klass)) {
 349 #ifndef PRODUCT
 350     if (PrintOpto && (Verbose || WizardMode)) {
 351       method()->print_name(); tty->print_cr(" can not compile call at bci %d to:", bci());
 352       dest_method->print_name(); tty->cr();
 353     }
 354 #endif
 355     return;
 356   }
 357   assert(holder_klass->is_loaded(), "");
 358   assert(dest_method->is_static() == !has_receiver, "must match bc");
 359   // Note: this takes into account invokeinterface of methods declared in java/lang/Object,
 360   // which should be invokevirtuals but according to the VM spec may be invokeinterfaces
 361   assert(holder_klass->is_interface() || holder_klass->super() == NULL || (bc() != Bytecodes::_invokeinterface), "must match bc");
 362   // Note:  In the absence of miranda methods, an abstract class K can perform
 363   // an invokevirtual directly on an interface method I.m if K implements I.
 364 
 365   // ---------------------
 366   // Does Class Hierarchy Analysis reveal only a single target of a v-call?
 367   // Then we may inline or make a static call, but become dependent on there being only 1 target.
 368   // Does the call-site type profile reveal only one receiver?
 369   // Then we may introduce a run-time check and inline on the path where it succeeds.
 370   // The other path may uncommon_trap, check for another receiver, or do a v-call.
 371 
 372   // Choose call strategy.
 373   bool call_is_virtual = is_virtual_or_interface;
 374   int vtable_index = methodOopDesc::invalid_vtable_index;
 375   ciMethod* call_method = dest_method;
 376 
 377   // Try to get the most accurate receiver type
 378   if (is_virtual_or_interface) {




 211               NOT_PRODUCT(trace_type_profile(jvms->method(), jvms->depth(), jvms->bci(), next_receiver_method, profile.receiver(1), site_count, profile.receiver_count(1)));
 212               // We don't need to record dependency on a receiver here and below.
 213               // Whenever we inline, the dependency is added by Parse::Parse().
 214               miss_cg = CallGenerator::for_predicted_call(profile.receiver(1), miss_cg, next_hit_cg, PROB_MAX);
 215             }
 216             if (miss_cg != NULL) {
 217               NOT_PRODUCT(trace_type_profile(jvms->method(), jvms->depth(), jvms->bci(), receiver_method, profile.receiver(0), site_count, receiver_count));
 218               cg = CallGenerator::for_predicted_call(profile.receiver(0), miss_cg, hit_cg, profile.receiver_prob(0));
 219               if (cg != NULL)  return cg;
 220             }
 221           }
 222         }
 223       }
 224     }
 225   }
 226 
 227   // There was no special inlining tactic, or it bailed out.
 228   // Use a more generic tactic, like a simple call.
 229   if (call_is_virtual) {
 230     return CallGenerator::for_virtual_call(call_method, vtable_index);
 231   } else if (call_method->is_method_handle_invoke()) {
 232     if (jvms->method()->java_code_at_bci(jvms->bci()) == Bytecodes::_invokedynamic)
 233       return CallGenerator::for_dynamic_call(call_method);
 234     else
 235       // %%% if the target MH is a compile-time constant, we should try to inline it
 236       return CallGenerator::for_direct_call(call_method);
 237   } else {
 238     // Class Hierarchy Analysis or Type Profile reveals a unique target,
 239     // or it is a static or special call.
 240     return CallGenerator::for_direct_call(call_method, should_delay_inlining(call_method, jvms));
 241   }
 242 }
 243 
 244 // Return true for methods that shouldn't be inlined early so that
 245 // they are easier to analyze and optimize as intrinsics.
 246 bool Compile::should_delay_inlining(ciMethod* call_method, JVMState* jvms) {
 247   if (has_stringbuilder()) {
 248 
 249     if ((call_method->holder() == C->env()->StringBuilder_klass() ||
 250          call_method->holder() == C->env()->StringBuffer_klass()) &&
 251         (jvms->method()->holder() == C->env()->StringBuilder_klass() ||
 252          jvms->method()->holder() == C->env()->StringBuffer_klass())) {
 253       // Delay SB calls only when called from non-SB code
 254       return false;
 255     }
 256 


 296 
 297 
 298 // uncommon-trap call-sites where callee is unloaded, uninitialized or will not link
 299 bool Parse::can_not_compile_call_site(ciMethod *dest_method, ciInstanceKlass* klass) {
 300   // Additional inputs to consider...
 301   // bc      = bc()
 302   // caller  = method()
 303   // iter().get_method_holder_index()
 304   assert( dest_method->is_loaded(), "ciTypeFlow should not let us get here" );
 305   // Interface classes can be loaded & linked and never get around to
 306   // being initialized.  Uncommon-trap for not-initialized static or
 307   // v-calls.  Let interface calls happen.
 308   ciInstanceKlass* holder_klass = dest_method->holder();
 309   if (!holder_klass->is_initialized() &&
 310       !holder_klass->is_interface()) {
 311     uncommon_trap(Deoptimization::Reason_uninitialized,
 312                   Deoptimization::Action_reinterpret,
 313                   holder_klass);
 314     return true;
 315   }








 316 
 317   assert(dest_method->will_link(method()->holder(), klass, bc()), "dest_method: typeflow responsibility");
 318   return false;
 319 }
 320 
 321 
 322 //------------------------------do_call----------------------------------------
 323 // Handle your basic call.  Inline if we can & want to, else just setup call.
 324 void Parse::do_call() {
 325   // It's likely we are going to add debug info soon.
 326   // Also, if we inline a guy who eventually needs debug info for this JVMS,
 327   // our contribution to it is cleaned up right here.
 328   kill_dead_locals();
 329 
 330   // Set frequently used booleans
 331   bool is_virtual = bc() == Bytecodes::_invokevirtual;
 332   bool is_virtual_or_interface = is_virtual || bc() == Bytecodes::_invokeinterface;
 333   bool has_receiver = is_virtual_or_interface || bc() == Bytecodes::_invokespecial;
 334   bool is_invokedynamic = bc() == Bytecodes::_invokedynamic;
 335 
 336   // Find target being called
 337   bool             will_link;
 338   ciMethod*        dest_method   = iter().get_method(will_link);
 339   ciInstanceKlass* holder_klass  = dest_method->holder();
 340   ciKlass* holder = iter().get_declared_method_holder();
 341   ciInstanceKlass* klass = ciEnv::get_instance_klass_for_declared_method_holder(holder);
 342 
 343   int nargs = dest_method->arg_size();
 344   if (is_invokedynamic)  nargs -= 1;
 345 
 346   // uncommon-trap when callee is unloaded, uninitialized or will not link
 347   // bailout when too many arguments for register representation
 348   if (!will_link || can_not_compile_call_site(dest_method, klass)) {
 349 #ifndef PRODUCT
 350     if (PrintOpto && (Verbose || WizardMode)) {
 351       method()->print_name(); tty->print_cr(" can not compile call at bci %d to:", bci());
 352       dest_method->print_name(); tty->cr();
 353     }
 354 #endif
 355     return;
 356   }
 357   assert(holder_klass->is_loaded(), "");
 358   assert((dest_method->is_static() || is_invokedynamic) == !has_receiver , "must match bc");
 359   // Note: this takes into account invokeinterface of methods declared in java/lang/Object,
 360   // which should be invokevirtuals but according to the VM spec may be invokeinterfaces
 361   assert(holder_klass->is_interface() || holder_klass->super() == NULL || (bc() != Bytecodes::_invokeinterface), "must match bc");
 362   // Note:  In the absence of miranda methods, an abstract class K can perform
 363   // an invokevirtual directly on an interface method I.m if K implements I.
 364 
 365   // ---------------------
 366   // Does Class Hierarchy Analysis reveal only a single target of a v-call?
 367   // Then we may inline or make a static call, but become dependent on there being only 1 target.
 368   // Does the call-site type profile reveal only one receiver?
 369   // Then we may introduce a run-time check and inline on the path where it succeeds.
 370   // The other path may uncommon_trap, check for another receiver, or do a v-call.
 371 
 372   // Choose call strategy.
 373   bool call_is_virtual = is_virtual_or_interface;
 374   int vtable_index = methodOopDesc::invalid_vtable_index;
 375   ciMethod* call_method = dest_method;
 376 
 377   // Try to get the most accurate receiver type
 378   if (is_virtual_or_interface) {


src/share/vm/opto/doCall.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File