hotspot/src/share/vm/ci/ciMethod.cpp
changeset 13391 30245956af37
parent 13282 9872915dd78d
child 13522 5ad4627e792a
equal deleted inserted replaced
13309:50c604cb0d5f 13391:30245956af37
   767 
   767 
   768 // ------------------------------------------------------------------
   768 // ------------------------------------------------------------------
   769 // invokedynamic support
   769 // invokedynamic support
   770 
   770 
   771 // ------------------------------------------------------------------
   771 // ------------------------------------------------------------------
   772 // ciMethod::is_method_handle_invoke
   772 // ciMethod::is_method_handle_intrinsic
   773 //
   773 //
   774 // Return true if the method is an instance of one of the two
   774 // Return true if the method is an instance of the JVM-generated
   775 // signature-polymorphic MethodHandle methods, invokeExact or invokeGeneric.
   775 // signature-polymorphic MethodHandle methods, _invokeBasic, _linkToVirtual, etc.
   776 bool ciMethod::is_method_handle_invoke() const {
   776 bool ciMethod::is_method_handle_intrinsic() const {
   777   if (!is_loaded()) {
   777   vmIntrinsics::ID iid = _intrinsic_id;  // do not check if loaded
   778     bool flag = (holder()->name() == ciSymbol::java_lang_invoke_MethodHandle() &&
   778   return (MethodHandles::is_signature_polymorphic(iid) &&
   779                  methodOopDesc::is_method_handle_invoke_name(name()->sid()));
   779           MethodHandles::is_signature_polymorphic_intrinsic(iid));
   780     return flag;
   780 }
   781   }
   781 
   782   VM_ENTRY_MARK;
   782 // ------------------------------------------------------------------
   783   return get_methodOop()->is_method_handle_invoke();
   783 // ciMethod::is_compiled_lambda_form
   784 }
       
   785 
       
   786 // ------------------------------------------------------------------
       
   787 // ciMethod::is_method_handle_adapter
       
   788 //
   784 //
   789 // Return true if the method is a generated MethodHandle adapter.
   785 // Return true if the method is a generated MethodHandle adapter.
   790 // These are built by MethodHandleCompiler.
   786 // These are built by Java code.
   791 bool ciMethod::is_method_handle_adapter() const {
   787 bool ciMethod::is_compiled_lambda_form() const {
   792   if (!is_loaded())  return false;
   788   vmIntrinsics::ID iid = _intrinsic_id;  // do not check if loaded
   793   VM_ENTRY_MARK;
   789   return iid == vmIntrinsics::_compiledLambdaForm;
   794   return get_methodOop()->is_method_handle_adapter();
   790 }
   795 }
   791 
   796 
   792 // ------------------------------------------------------------------
   797 ciInstance* ciMethod::method_handle_type() {
   793 // ciMethod::has_member_arg
   798   check_is_loaded();
   794 //
   799   VM_ENTRY_MARK;
   795 // Return true if the method is a linker intrinsic like _linkToVirtual.
   800   oop mtype = get_methodOop()->method_handle_type();
   796 // These are built by the JVM.
   801   return CURRENT_THREAD_ENV->get_object(mtype)->as_instance();
   797 bool ciMethod::has_member_arg() const {
   802 }
   798   vmIntrinsics::ID iid = _intrinsic_id;  // do not check if loaded
   803 
   799   return (MethodHandles::is_signature_polymorphic(iid) &&
       
   800           MethodHandles::has_member_arg(iid));
       
   801 }
   804 
   802 
   805 // ------------------------------------------------------------------
   803 // ------------------------------------------------------------------
   806 // ciMethod::ensure_method_data
   804 // ciMethod::ensure_method_data
   807 //
   805 //
   808 // Generate new methodDataOop objects at compile time.
   806 // Generate new methodDataOop objects at compile time.
  1022 }
  1020 }
  1023 
  1021 
  1024 // ------------------------------------------------------------------
  1022 // ------------------------------------------------------------------
  1025 // ciMethod::code_size_for_inlining
  1023 // ciMethod::code_size_for_inlining
  1026 //
  1024 //
  1027 // Code size for inlining decisions.
  1025 // Code size for inlining decisions.  This method returns a code
  1028 //
  1026 // size of 1 for methods which has the ForceInline annotation.
  1029 // Don't fully count method handle adapters against inlining budgets:
       
  1030 // the metric we use here is the number of call sites in the adapter
       
  1031 // as they are probably the instructions which generate some code.
       
  1032 int ciMethod::code_size_for_inlining() {
  1027 int ciMethod::code_size_for_inlining() {
  1033   check_is_loaded();
  1028   check_is_loaded();
  1034 
  1029   if (get_methodOop()->force_inline()) {
  1035   // Method handle adapters
  1030     return 1;
  1036   if (is_method_handle_adapter()) {
  1031   }
  1037     // Count call sites
       
  1038     int call_site_count = 0;
       
  1039     ciBytecodeStream iter(this);
       
  1040     while (iter.next() != ciBytecodeStream::EOBC()) {
       
  1041       if (Bytecodes::is_invoke(iter.cur_bc())) {
       
  1042         call_site_count++;
       
  1043       }
       
  1044     }
       
  1045     return call_site_count;
       
  1046   }
       
  1047 
       
  1048   // Normal method
       
  1049   return code_size();
  1032   return code_size();
  1050 }
  1033 }
  1051 
  1034 
  1052 // ------------------------------------------------------------------
  1035 // ------------------------------------------------------------------
  1053 // ciMethod::instructions_size
  1036 // ciMethod::instructions_size
  1125     EXCEPTION_MARK;
  1108     EXCEPTION_MARK;
  1126     HandleMark hm(THREAD);
  1109     HandleMark hm(THREAD);
  1127     constantPoolHandle pool (THREAD, get_methodOop()->constants());
  1110     constantPoolHandle pool (THREAD, get_methodOop()->constants());
  1128     methodHandle spec_method;
  1111     methodHandle spec_method;
  1129     KlassHandle  spec_klass;
  1112     KlassHandle  spec_klass;
  1130     LinkResolver::resolve_method(spec_method, spec_klass, pool, refinfo_index, THREAD);
  1113     Bytecodes::Code code = (is_static ? Bytecodes::_invokestatic : Bytecodes::_invokevirtual);
       
  1114     LinkResolver::resolve_method_statically(spec_method, spec_klass, code, pool, refinfo_index, THREAD);
  1131     if (HAS_PENDING_EXCEPTION) {
  1115     if (HAS_PENDING_EXCEPTION) {
  1132       CLEAR_PENDING_EXCEPTION;
  1116       CLEAR_PENDING_EXCEPTION;
  1133       return false;
  1117       return false;
  1134     } else {
  1118     } else {
  1135       return (spec_method->is_static() == is_static);
  1119       return (spec_method->is_static() == is_static);
  1205 // ------------------------------------------------------------------
  1189 // ------------------------------------------------------------------
  1206 // ciMethod::print_short_name
  1190 // ciMethod::print_short_name
  1207 //
  1191 //
  1208 // Print the name of this method, without signature.
  1192 // Print the name of this method, without signature.
  1209 void ciMethod::print_short_name(outputStream* st) {
  1193 void ciMethod::print_short_name(outputStream* st) {
  1210   check_is_loaded();
  1194   if (is_loaded()) {
  1211   GUARDED_VM_ENTRY(get_methodOop()->print_short_name(st);)
  1195     GUARDED_VM_ENTRY(get_methodOop()->print_short_name(st););
       
  1196   } else {
       
  1197     // Fall back if method is not loaded.
       
  1198     holder()->print_name_on(st);
       
  1199     st->print("::");
       
  1200     name()->print_symbol_on(st);
       
  1201     if (WizardMode)
       
  1202       signature()->as_symbol()->print_symbol_on(st);
       
  1203   }
  1212 }
  1204 }
  1213 
  1205 
  1214 // ------------------------------------------------------------------
  1206 // ------------------------------------------------------------------
  1215 // ciMethod::print_impl
  1207 // ciMethod::print_impl
  1216 //
  1208 //
  1221   name()->print_symbol_on(st);
  1213   name()->print_symbol_on(st);
  1222   st->print(" holder=");
  1214   st->print(" holder=");
  1223   holder()->print_name_on(st);
  1215   holder()->print_name_on(st);
  1224   st->print(" signature=");
  1216   st->print(" signature=");
  1225   signature()->as_symbol()->print_symbol_on(st);
  1217   signature()->as_symbol()->print_symbol_on(st);
       
  1218   st->print(" arg_size=%d", arg_size());
  1226   if (is_loaded()) {
  1219   if (is_loaded()) {
  1227     st->print(" loaded=true flags=");
  1220     st->print(" loaded=true flags=");
  1228     flags().print_member_flags(st);
  1221     flags().print_member_flags(st);
  1229   } else {
  1222   } else {
  1230     st->print(" loaded=false");
  1223     st->print(" loaded=false");