< prev index next >

src/hotspot/share/opto/doCall.cpp

Print this page




 275           }
 276           if (miss_cg != NULL) {
 277             if (next_hit_cg != NULL) {
 278               assert(speculative_receiver_type == NULL, "shouldn't end up here if we used speculation");
 279               trace_type_profile(C, jvms->method(), jvms->depth() - 1, jvms->bci(), next_receiver_method, profile.receiver(1), site_count, profile.receiver_count(1));
 280               // We don't need to record dependency on a receiver here and below.
 281               // Whenever we inline, the dependency is added by Parse::Parse().
 282               miss_cg = CallGenerator::for_predicted_call(profile.receiver(1), miss_cg, next_hit_cg, PROB_MAX);
 283             }
 284             if (miss_cg != NULL) {
 285               ciKlass* k = speculative_receiver_type != NULL ? speculative_receiver_type : profile.receiver(0);
 286               trace_type_profile(C, jvms->method(), jvms->depth() - 1, jvms->bci(), receiver_method, k, site_count, receiver_count);
 287               float hit_prob = speculative_receiver_type != NULL ? 1.0 : profile.receiver_prob(0);
 288               CallGenerator* cg = CallGenerator::for_predicted_call(k, miss_cg, hit_cg, hit_prob);
 289               if (cg != NULL)  return cg;
 290             }
 291           }
 292         }
 293       }
 294     }













































 295   }
 296 
 297   // Nothing claimed the intrinsic, we go with straight-forward inlining
 298   // for already discovered intrinsic.
 299   if (allow_inline && allow_intrinsics && cg_intrinsic != NULL) {
 300     assert(cg_intrinsic->does_virtual_dispatch(), "sanity");
 301     return cg_intrinsic;
 302   }
 303 
 304   // There was no special inlining tactic, or it bailed out.
 305   // Use a more generic tactic, like a simple call.
 306   if (call_does_dispatch) {
 307     const char* msg = "virtual call";
 308     if (PrintInlining) print_inlining(callee, jvms->depth() - 1, jvms->bci(), msg);
 309     C->log_inline_failure(msg);
 310     return CallGenerator::for_virtual_call(callee, vtable_index);
 311   } else {
 312     // Class Hierarchy Analysis or Type Profile reveals a unique target,
 313     // or it is a static or special call.
 314     return CallGenerator::for_direct_call(callee, should_delay_inlining(callee, jvms));




 275           }
 276           if (miss_cg != NULL) {
 277             if (next_hit_cg != NULL) {
 278               assert(speculative_receiver_type == NULL, "shouldn't end up here if we used speculation");
 279               trace_type_profile(C, jvms->method(), jvms->depth() - 1, jvms->bci(), next_receiver_method, profile.receiver(1), site_count, profile.receiver_count(1));
 280               // We don't need to record dependency on a receiver here and below.
 281               // Whenever we inline, the dependency is added by Parse::Parse().
 282               miss_cg = CallGenerator::for_predicted_call(profile.receiver(1), miss_cg, next_hit_cg, PROB_MAX);
 283             }
 284             if (miss_cg != NULL) {
 285               ciKlass* k = speculative_receiver_type != NULL ? speculative_receiver_type : profile.receiver(0);
 286               trace_type_profile(C, jvms->method(), jvms->depth() - 1, jvms->bci(), receiver_method, k, site_count, receiver_count);
 287               float hit_prob = speculative_receiver_type != NULL ? 1.0 : profile.receiver_prob(0);
 288               CallGenerator* cg = CallGenerator::for_predicted_call(k, miss_cg, hit_cg, hit_prob);
 289               if (cg != NULL)  return cg;
 290             }
 291           }
 292         }
 293       }
 294     }
 295 
 296     // If there is only one implementor of this interface then we
 297     // may be able to bind this invoke directly to the implementing
 298     // klass but we need both a dependence on the single interface
 299     // and on the method we bind to. Additionally since all we know
 300     // about the receiver type is that it's supposed to implement the
 301     // interface we have to insert a check that it's the class we
 302     // expect.  Interface types are not checked by the verifier so
 303     // they are roughly equivalent to Object.
 304     // The number of implementors for declared_interface is less or
 305     // equal to the number of implementors for target->holder() so
 306     // if number of implementors of target->holder() == 1 then
 307     // number of implementors for decl_interface is 0 or 1. If
 308     // it's 0 then no class implements decl_interface and there's
 309     // no point in inlining.
 310     if (call_does_dispatch && bytecode == Bytecodes::_invokeinterface) {
 311       ciInstanceKlass* declared_interface =
 312           caller->get_declared_method_holder_at_bci(bci)->as_instance_klass();
 313 
 314       if (declared_interface->nof_implementors() == 1 &&
 315           (!callee->is_default_method() || callee->is_overpass()) /* CHA doesn't support default methods yet */) {
 316         ciInstanceKlass* singleton = declared_interface->implementor();
 317         ciMethod* cha_monomorphic_target =
 318             callee->find_monomorphic_target(caller->holder(), declared_interface, singleton);
 319 
 320         if (cha_monomorphic_target != NULL &&
 321             cha_monomorphic_target->holder() != env()->Object_klass()) { // subtype check against Object is useless
 322           ciKlass* holder = cha_monomorphic_target->holder();
 323 
 324           // Try to inline the method found by CHA. Inlined method is guarded by the type check.
 325           CallGenerator* hit_cg = call_generator(cha_monomorphic_target,
 326               vtable_index, !call_does_dispatch, jvms, allow_inline, prof_factor);
 327 
 328           // Deoptimize on type check fail. The interpreter will throw ICCE for us.
 329           CallGenerator* miss_cg = CallGenerator::for_uncommon_trap(callee,
 330               Deoptimization::Reason_class_check, Deoptimization::Action_none);
 331 
 332           CallGenerator* cg = CallGenerator::for_guarded_call(holder, miss_cg, hit_cg);
 333           if (hit_cg != NULL && cg != NULL) {
 334             dependencies()->assert_unique_concrete_method(declared_interface, cha_monomorphic_target);
 335             return cg;
 336           }
 337         }
 338       }
 339     }
 340   }
 341 
 342   // Nothing claimed the intrinsic, we go with straight-forward inlining
 343   // for already discovered intrinsic.
 344   if (allow_inline && allow_intrinsics && cg_intrinsic != NULL) {
 345     assert(cg_intrinsic->does_virtual_dispatch(), "sanity");
 346     return cg_intrinsic;
 347   }
 348 
 349   // There was no special inlining tactic, or it bailed out.
 350   // Use a more generic tactic, like a simple call.
 351   if (call_does_dispatch) {
 352     const char* msg = "virtual call";
 353     if (PrintInlining) print_inlining(callee, jvms->depth() - 1, jvms->bci(), msg);
 354     C->log_inline_failure(msg);
 355     return CallGenerator::for_virtual_call(callee, vtable_index);
 356   } else {
 357     // Class Hierarchy Analysis or Type Profile reveals a unique target,
 358     // or it is a static or special call.
 359     return CallGenerator::for_direct_call(callee, should_delay_inlining(callee, jvms));


< prev index next >