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

src/share/vm/opto/doCall.cpp

Print this page




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












































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




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


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