hotspot/src/share/vm/opto/callGenerator.cpp
changeset 35086 bbf32241d851
parent 33589 7cbd1b2c139b
child 35846 f5a8b47778ef
equal deleted inserted replaced
35085:839c8ba29724 35086:bbf32241d851
    44 // Utility function.
    44 // Utility function.
    45 const TypeFunc* CallGenerator::tf() const {
    45 const TypeFunc* CallGenerator::tf() const {
    46   return TypeFunc::make(method());
    46   return TypeFunc::make(method());
    47 }
    47 }
    48 
    48 
       
    49 bool CallGenerator::is_inlined_mh_linker(JVMState* jvms, ciMethod* callee) {
       
    50   ciMethod* symbolic_info = jvms->method()->get_method_at_bci(jvms->bci());
       
    51   return symbolic_info->is_method_handle_intrinsic() && !callee->is_method_handle_intrinsic();
       
    52 }
       
    53 
    49 //-----------------------------ParseGenerator---------------------------------
    54 //-----------------------------ParseGenerator---------------------------------
    50 // Internal class which handles all direct bytecode traversal.
    55 // Internal class which handles all direct bytecode traversal.
    51 class ParseGenerator : public InlineCallGenerator {
    56 class ParseGenerator : public InlineCallGenerator {
    52 private:
    57 private:
    53   bool  _is_osr;
    58   bool  _is_osr;
   135   if (kit.C->log() != NULL) {
   140   if (kit.C->log() != NULL) {
   136     kit.C->log()->elem("direct_call bci='%d'", jvms->bci());
   141     kit.C->log()->elem("direct_call bci='%d'", jvms->bci());
   137   }
   142   }
   138 
   143 
   139   CallStaticJavaNode *call = new CallStaticJavaNode(kit.C, tf(), target, method(), kit.bci());
   144   CallStaticJavaNode *call = new CallStaticJavaNode(kit.C, tf(), target, method(), kit.bci());
       
   145   if (is_inlined_mh_linker(jvms, method())) {
       
   146     // To be able to issue a direct call and skip a call to MH.linkTo*/invokeBasic adapter,
       
   147     // additional information about the method being invoked should be attached
       
   148     // to the call site to make resolution logic work
       
   149     // (see SharedRuntime::resolve_static_call_C).
       
   150     call->set_override_symbolic_info(true);
       
   151   }
   140   _call_node = call;  // Save the call node in case we need it later
   152   _call_node = call;  // Save the call node in case we need it later
   141   if (!is_static) {
   153   if (!is_static) {
   142     // Make an explicit receiver null_check as part of this call.
   154     // Make an explicit receiver null_check as part of this call.
   143     // Since we share a map with the caller, his JVMS gets adjusted.
   155     // Since we share a map with the caller, his JVMS gets adjusted.
   144     kit.null_check_receiver_before_call(method());
   156     kit.null_check_receiver_before_call(method());
   190   // by attempting to call through it.  The compile will proceed
   202   // by attempting to call through it.  The compile will proceed
   191   // correctly, but may bail out in final_graph_reshaping, because
   203   // correctly, but may bail out in final_graph_reshaping, because
   192   // the call instruction will have a seemingly deficient out-count.
   204   // the call instruction will have a seemingly deficient out-count.
   193   // (The bailout says something misleading about an "infinite loop".)
   205   // (The bailout says something misleading about an "infinite loop".)
   194   if (kit.gvn().type(receiver)->higher_equal(TypePtr::NULL_PTR)) {
   206   if (kit.gvn().type(receiver)->higher_equal(TypePtr::NULL_PTR)) {
   195     kit.inc_sp(method()->arg_size());  // restore arguments
   207     assert(Bytecodes::is_invoke(kit.java_bc()), "%d: %s", kit.java_bc(), Bytecodes::name(kit.java_bc()));
       
   208     ciMethod* declared_method = kit.method()->get_method_at_bci(kit.bci());
       
   209     int arg_size = declared_method->signature()->arg_size_for_bc(kit.java_bc());
       
   210     kit.inc_sp(arg_size);  // restore arguments
   196     kit.uncommon_trap(Deoptimization::Reason_null_check,
   211     kit.uncommon_trap(Deoptimization::Reason_null_check,
   197                       Deoptimization::Action_none,
   212                       Deoptimization::Action_none,
   198                       NULL, "null receiver");
   213                       NULL, "null receiver");
   199     return kit.transfer_exceptions_into_jvms();
   214     return kit.transfer_exceptions_into_jvms();
   200   }
   215   }
   224   assert(_vtable_index == Method::invalid_vtable_index || !UseInlineCaches,
   239   assert(_vtable_index == Method::invalid_vtable_index || !UseInlineCaches,
   225          "no vtable calls if +UseInlineCaches ");
   240          "no vtable calls if +UseInlineCaches ");
   226   address target = SharedRuntime::get_resolve_virtual_call_stub();
   241   address target = SharedRuntime::get_resolve_virtual_call_stub();
   227   // Normal inline cache used for call
   242   // Normal inline cache used for call
   228   CallDynamicJavaNode *call = new CallDynamicJavaNode(tf(), target, method(), _vtable_index, kit.bci());
   243   CallDynamicJavaNode *call = new CallDynamicJavaNode(tf(), target, method(), _vtable_index, kit.bci());
       
   244   if (is_inlined_mh_linker(jvms, method())) {
       
   245     // To be able to issue a direct call (optimized virtual or virtual)
       
   246     // and skip a call to MH.linkTo*/invokeBasic adapter, additional information
       
   247     // about the method being invoked should be attached to the call site to
       
   248     // make resolution logic work (see SharedRuntime::resolve_{virtual,opt_virtual}_call_C).
       
   249     call->set_override_symbolic_info(true);
       
   250   }
   229   kit.set_arguments_for_java_call(call);
   251   kit.set_arguments_for_java_call(call);
   230   kit.set_edges_for_java_call(call);
   252   kit.set_edges_for_java_call(call);
   231   Node* ret = kit.set_results_for_java_call(call);
   253   Node* ret = kit.set_results_for_java_call(call);
   232   kit.push_node(method()->return_type()->basic_type(), ret);
   254   kit.push_node(method()->return_type()->basic_type(), ret);
   233 
   255 
   461 
   483 
   462   if (!_input_not_const) {
   484   if (!_input_not_const) {
   463     _attempt++;
   485     _attempt++;
   464   }
   486   }
   465 
   487 
   466   if (cg != NULL) {
   488   if (cg != NULL && cg->is_inline()) {
   467     assert(!cg->is_late_inline() && cg->is_inline(), "we're doing late inlining");
   489     assert(!cg->is_late_inline(), "we're doing late inlining");
   468     _inline_cg = cg;
   490     _inline_cg = cg;
   469     Compile::current()->dec_number_of_mh_late_inlines();
   491     Compile::current()->dec_number_of_mh_late_inlines();
   470     return true;
   492     return true;
   471   }
   493   }
   472 
   494 
   805         ciMethod* target = oop_ptr->const_oop()->as_method_handle()->get_vmtarget();
   827         ciMethod* target = oop_ptr->const_oop()->as_method_handle()->get_vmtarget();
   806         guarantee(!target->is_method_handle_intrinsic(), "should not happen");  // XXX remove
   828         guarantee(!target->is_method_handle_intrinsic(), "should not happen");  // XXX remove
   807         const int vtable_index = Method::invalid_vtable_index;
   829         const int vtable_index = Method::invalid_vtable_index;
   808         CallGenerator* cg = C->call_generator(target, vtable_index, false, jvms, true, PROB_ALWAYS, NULL, true, true);
   830         CallGenerator* cg = C->call_generator(target, vtable_index, false, jvms, true, PROB_ALWAYS, NULL, true, true);
   809         assert(cg == NULL || !cg->is_late_inline() || cg->is_mh_late_inline(), "no late inline here");
   831         assert(cg == NULL || !cg->is_late_inline() || cg->is_mh_late_inline(), "no late inline here");
   810         if (cg != NULL && cg->is_inline())
   832         return cg;
   811           return cg;
       
   812       } else {
   833       } else {
   813         const char* msg = "receiver not constant";
   834         const char* msg = "receiver not constant";
   814         if (PrintInlining)  C->print_inlining(callee, jvms->depth() - 1, jvms->bci(), msg);
   835         if (PrintInlining)  C->print_inlining(callee, jvms->depth() - 1, jvms->bci(), msg);
   815         C->log_inline_failure(msg);
   836         C->log_inline_failure(msg);
   816       }
   837       }
   827       if (member_name->Opcode() == Op_ConP) {
   848       if (member_name->Opcode() == Op_ConP) {
   828         input_not_const = false;
   849         input_not_const = false;
   829         const TypeOopPtr* oop_ptr = member_name->bottom_type()->is_oopptr();
   850         const TypeOopPtr* oop_ptr = member_name->bottom_type()->is_oopptr();
   830         ciMethod* target = oop_ptr->const_oop()->as_member_name()->get_vmtarget();
   851         ciMethod* target = oop_ptr->const_oop()->as_member_name()->get_vmtarget();
   831 
   852 
   832         // In lamda forms we erase signature types to avoid resolving issues
   853         // In lambda forms we erase signature types to avoid resolving issues
   833         // involving class loaders.  When we optimize a method handle invoke
   854         // involving class loaders.  When we optimize a method handle invoke
   834         // to a direct call we must cast the receiver and arguments to its
   855         // to a direct call we must cast the receiver and arguments to its
   835         // actual types.
   856         // actual types.
   836         ciSignature* signature = target->signature();
   857         ciSignature* signature = target->signature();
   837         const int receiver_skip = target->is_static() ? 0 : 1;
   858         const int receiver_skip = target->is_static() ? 0 : 1;
   880                                             /*check_access=*/false);
   901                                             /*check_access=*/false);
   881           // We lack profiling at this call but type speculation may
   902           // We lack profiling at this call but type speculation may
   882           // provide us with a type
   903           // provide us with a type
   883           speculative_receiver_type = (receiver_type != NULL) ? receiver_type->speculative_type() : NULL;
   904           speculative_receiver_type = (receiver_type != NULL) ? receiver_type->speculative_type() : NULL;
   884         }
   905         }
   885         CallGenerator* cg = C->call_generator(target, vtable_index, call_does_dispatch, jvms, true, PROB_ALWAYS, speculative_receiver_type, true, true);
   906         CallGenerator* cg = C->call_generator(target, vtable_index, call_does_dispatch, jvms, /*allow_inline=*/true, PROB_ALWAYS, speculative_receiver_type, true, true);
   886         assert(cg == NULL || !cg->is_late_inline() || cg->is_mh_late_inline(), "no late inline here");
   907         assert(cg == NULL || !cg->is_late_inline() || cg->is_mh_late_inline(), "no late inline here");
   887         if (cg != NULL && cg->is_inline())
   908         return cg;
   888           return cg;
       
   889       } else {
   909       } else {
   890         const char* msg = "member_name not constant";
   910         const char* msg = "member_name not constant";
   891         if (PrintInlining)  C->print_inlining(callee, jvms->depth() - 1, jvms->bci(), msg);
   911         if (PrintInlining)  C->print_inlining(callee, jvms->depth() - 1, jvms->bci(), msg);
   892         C->log_inline_failure(msg);
   912         C->log_inline_failure(msg);
   893       }
   913       }