hotspot/src/share/vm/opto/doCall.cpp
changeset 10265 4c869854aebd
parent 10007 43d4a6542551
child 10510 ab626d1bdf53
equal deleted inserted replaced
10264:6879f93d268d 10265:4c869854aebd
   112   if (allow_inline) {
   112   if (allow_inline) {
   113     cg = find_intrinsic(call_method, call_is_virtual);
   113     cg = find_intrinsic(call_method, call_is_virtual);
   114     if (cg != NULL)  return cg;
   114     if (cg != NULL)  return cg;
   115   }
   115   }
   116 
   116 
   117   // Do MethodHandle calls.
   117   // Do method handle calls.
   118   // NOTE: This must happen before normal inlining logic below since
   118   // NOTE: This must happen before normal inlining logic below since
   119   // MethodHandle.invoke* are native methods which obviously don't
   119   // MethodHandle.invoke* are native methods which obviously don't
   120   // have bytecodes and so normal inlining fails.
   120   // have bytecodes and so normal inlining fails.
   121   if (call_method->is_method_handle_invoke()) {
   121   if (call_method->is_method_handle_invoke()) {
   122     if (bytecode != Bytecodes::_invokedynamic) {
   122     if (bytecode != Bytecodes::_invokedynamic) {
   125 
   125 
   126       CallGenerator* cg = CallGenerator::for_method_handle_inline(n, jvms, caller, call_method, profile);
   126       CallGenerator* cg = CallGenerator::for_method_handle_inline(n, jvms, caller, call_method, profile);
   127       if (cg != NULL) {
   127       if (cg != NULL) {
   128         return cg;
   128         return cg;
   129       }
   129       }
   130 
       
   131       return CallGenerator::for_direct_call(call_method);
   130       return CallGenerator::for_direct_call(call_method);
   132     }
   131     }
   133     else {
   132     else {
   134       // Get the MethodHandle from the CallSite.
   133       // Get the CallSite object.
   135       ciMethod* caller_method = jvms->method();
   134       ciMethod* caller_method = jvms->method();
   136       ciBytecodeStream str(caller_method);
   135       ciBytecodeStream str(caller_method);
   137       str.force_bci(jvms->bci());  // Set the stream to the invokedynamic bci.
   136       str.force_bci(jvms->bci());  // Set the stream to the invokedynamic bci.
   138       ciCallSite*     call_site     = str.get_call_site();
   137       ciCallSite* call_site = str.get_call_site();
   139       ciMethodHandle* method_handle = call_site->get_target();
   138 
   140 
   139       // Inline constant and mutable call sites.  We don't inline
   141       // Set the callee to have access to the class and signature in
   140       // volatile call sites optimistically since they are specified
   142       // the MethodHandleCompiler.
   141       // to change their value often and that would result in a lot of
   143       method_handle->set_callee(call_method);
   142       // deoptimizations and recompiles.
   144       method_handle->set_caller(caller);
   143       if (call_site->is_constant_call_site() || call_site->is_mutable_call_site()) {
   145       method_handle->set_call_profile(profile);
   144         CallGenerator* cg = CallGenerator::for_invokedynamic_inline(call_site, jvms, caller, call_method, profile);
   146 
   145         if (cg != NULL) {
   147       // Get an adapter for the MethodHandle.
   146           return cg;
   148       ciMethod* target_method = method_handle->get_invokedynamic_adapter();
       
   149       if (target_method != NULL) {
       
   150         CallGenerator* hit_cg = this->call_generator(target_method, vtable_index, false, jvms, true, prof_factor);
       
   151         if (hit_cg != NULL && hit_cg->is_inline()) {
       
   152           CallGenerator* miss_cg = CallGenerator::for_dynamic_call(call_method);
       
   153           return CallGenerator::for_predicted_dynamic_call(method_handle, miss_cg, hit_cg, prof_factor);
       
   154         }
   147         }
   155       }
   148       }
   156 
       
   157       // If something failed, generate a normal dynamic call.
   149       // If something failed, generate a normal dynamic call.
   158       return CallGenerator::for_dynamic_call(call_method);
   150       return CallGenerator::for_dynamic_call(call_method);
   159     }
   151     }
   160   }
   152   }
   161 
   153