< prev index next >

src/hotspot/share/ci/ciMethod.cpp

Print this page

  33 #include "ci/ciSymbol.hpp"
  34 #include "ci/ciReplay.hpp"
  35 #include "ci/ciSymbols.hpp"
  36 #include "ci/ciUtilities.inline.hpp"
  37 #include "compiler/abstractCompiler.hpp"
  38 #include "compiler/compilerDefinitions.inline.hpp"
  39 #include "compiler/methodLiveness.hpp"
  40 #include "interpreter/interpreter.hpp"
  41 #include "interpreter/linkResolver.hpp"
  42 #include "interpreter/oopMapCache.hpp"
  43 #include "logging/log.hpp"
  44 #include "logging/logStream.hpp"
  45 #include "memory/allocation.inline.hpp"
  46 #include "memory/resourceArea.hpp"
  47 #include "oops/generateOopMap.hpp"
  48 #include "oops/method.inline.hpp"
  49 #include "oops/oop.inline.hpp"
  50 #include "prims/methodHandles.hpp"
  51 #include "runtime/deoptimization.hpp"
  52 #include "runtime/handles.inline.hpp"

  53 #include "utilities/bitMap.inline.hpp"
  54 #include "utilities/xmlstream.hpp"
  55 #ifdef COMPILER2
  56 #include "ci/bcEscapeAnalyzer.hpp"
  57 #include "ci/ciTypeFlow.hpp"
  58 #include "oops/method.hpp"
  59 #endif
  60 
  61 // ciMethod
  62 //
  63 // This class represents a Method* in the HotSpot virtual
  64 // machine.
  65 
  66 
  67 // ------------------------------------------------------------------
  68 // ciMethod::ciMethod
  69 //
  70 // Loaded method.
  71 ciMethod::ciMethod(const methodHandle& h_m, ciInstanceKlass* holder) :
  72   ciMetadata(h_m()),

 642  * Check whether profiling provides a type for the parameter i
 643  *
 644  * @param [in]i           parameter number
 645  * @param [out]type       profiled type of parameter, null if none
 646  * @param [out]ptr_kind   whether always null, never null or maybe null
 647  * @return                true if profiling exists
 648  *
 649  */
 650 bool ciMethod::parameter_profiled_type(int i, ciKlass*& type, ProfilePtrKind& ptr_kind) {
 651   if (MethodData::profile_parameters() && method_data() != nullptr && method_data()->is_mature()) {
 652     ciParametersTypeData* parameters = method_data()->parameters_type_data();
 653     if (parameters != nullptr && i < parameters->number_of_parameters()) {
 654       type = parameters->valid_parameter_type(i);
 655       ptr_kind = parameters->parameter_ptr_kind(i);
 656       return true;
 657     }
 658   }
 659   return false;
 660 }
 661 






















































 662 
 663 // ------------------------------------------------------------------
 664 // ciMethod::find_monomorphic_target
 665 //
 666 // Given a certain calling environment, find the monomorphic target
 667 // for the call.  Return null if the call is not monomorphic in
 668 // its calling environment, or if there are only abstract methods.
 669 // The returned method is never abstract.
 670 // Note: If caller uses a non-null result, it must inform dependencies
 671 // via assert_unique_concrete_method or assert_leaf_type.
 672 ciMethod* ciMethod::find_monomorphic_target(ciInstanceKlass* caller,
 673                                             ciInstanceKlass* callee_holder,
 674                                             ciInstanceKlass* actual_recv,
 675                                             bool check_access) {
 676   check_is_loaded();
 677 
 678   if (actual_recv->is_interface()) {
 679     // %%% We cannot trust interface types, yet.  See bug 6312651.
 680     return nullptr;
 681   }

 942 //
 943 // Return true if the method is an instance of the JVM-generated
 944 // signature-polymorphic MethodHandle methods, _invokeBasic, _linkToVirtual, etc.
 945 bool ciMethod::is_method_handle_intrinsic() const {
 946   vmIntrinsics::ID iid = _intrinsic_id;  // do not check if loaded
 947   return (MethodHandles::is_signature_polymorphic(iid) &&
 948           MethodHandles::is_signature_polymorphic_intrinsic(iid));
 949 }
 950 
 951 // ------------------------------------------------------------------
 952 // ciMethod::is_compiled_lambda_form
 953 //
 954 // Return true if the method is a generated MethodHandle adapter.
 955 // These are built by Java code.
 956 bool ciMethod::is_compiled_lambda_form() const {
 957   vmIntrinsics::ID iid = _intrinsic_id;  // do not check if loaded
 958   return iid == vmIntrinsics::_compiledLambdaForm;
 959 }
 960 
 961 // ------------------------------------------------------------------
 962 // ciMethod::is_object_initializer
 963 //
 964 bool ciMethod::is_object_initializer() const {
 965    return name() == ciSymbols::object_initializer_name();



 966 }
 967 
 968 // ------------------------------------------------------------------
 969 // ciMethod::has_member_arg
 970 //
 971 // Return true if the method is a linker intrinsic like _linkToVirtual.
 972 // These are built by the JVM.
 973 bool ciMethod::has_member_arg() const {
 974   vmIntrinsics::ID iid = _intrinsic_id;  // do not check if loaded
 975   return (MethodHandles::is_signature_polymorphic(iid) &&
 976           MethodHandles::has_member_arg(iid));
 977 }
 978 
 979 // ------------------------------------------------------------------
 980 // ciMethod::ensure_method_data
 981 //
 982 // Generate new MethodData* objects at compile time.
 983 // Return true if allocation was successful or no MDO is required.
 984 bool ciMethod::ensure_method_data(const methodHandle& h_m) {
 985   EXCEPTION_CONTEXT;

1213 // ciMethod::print_codes
1214 //
1215 // Print the bytecodes for this method.
1216 void ciMethod::print_codes_on(outputStream* st) {
1217   check_is_loaded();
1218   GUARDED_VM_ENTRY(get_Method()->print_codes_on(st);)
1219 }
1220 
1221 
1222 #define FETCH_FLAG_FROM_VM(flag_accessor) { \
1223   check_is_loaded(); \
1224   VM_ENTRY_MARK; \
1225   return get_Method()->flag_accessor(); \
1226 }
1227 
1228 bool ciMethod::has_loops      () const {         FETCH_FLAG_FROM_VM(has_loops); }
1229 bool ciMethod::has_jsrs       () const {         FETCH_FLAG_FROM_VM(has_jsrs);  }
1230 bool ciMethod::is_getter      () const {         FETCH_FLAG_FROM_VM(is_getter); }
1231 bool ciMethod::is_setter      () const {         FETCH_FLAG_FROM_VM(is_setter); }
1232 bool ciMethod::is_accessor    () const {         FETCH_FLAG_FROM_VM(is_accessor); }
1233 bool ciMethod::is_initializer () const {         FETCH_FLAG_FROM_VM(is_initializer); }
1234 bool ciMethod::is_empty       () const {         FETCH_FLAG_FROM_VM(is_empty_method); }
1235 
1236 bool ciMethod::is_boxing_method() const {
1237   if (intrinsic_id() != vmIntrinsics::_none && holder()->is_box_klass()) {
1238     switch (intrinsic_id()) {
1239       case vmIntrinsics::_Boolean_valueOf:
1240       case vmIntrinsics::_Byte_valueOf:
1241       case vmIntrinsics::_Character_valueOf:
1242       case vmIntrinsics::_Short_valueOf:
1243       case vmIntrinsics::_Integer_valueOf:
1244       case vmIntrinsics::_Long_valueOf:
1245       case vmIntrinsics::_Float_valueOf:
1246       case vmIntrinsics::_Double_valueOf:
1247         return true;
1248       default:
1249         return false;
1250     }
1251   }
1252   return false;
1253 }

1460     default:
1461       break;
1462   }
1463   assert(target_sig->count() - rbase == linker_sig->count() - sbase - has_appendix, "argument count mismatch");
1464   int arg_count = target_sig->count() - rbase;
1465   for (int i = 0; i < arg_count; i++) {
1466     if (!basic_types_match(linker_sig->type_at(sbase + i), target_sig->type_at(rbase + i))) {
1467       return false;
1468     }
1469   }
1470   // Only check the return type if the symbolic info has non-void return type.
1471   // I.e. the return value of the resolved method can be dropped.
1472   if (!linker->return_type()->is_void() &&
1473       !basic_types_match(linker->return_type(), target->return_type())) {
1474     return false;
1475   }
1476   return true; // no mismatch found
1477 }
1478 
1479 // ------------------------------------------------------------------



















  33 #include "ci/ciSymbol.hpp"
  34 #include "ci/ciReplay.hpp"
  35 #include "ci/ciSymbols.hpp"
  36 #include "ci/ciUtilities.inline.hpp"
  37 #include "compiler/abstractCompiler.hpp"
  38 #include "compiler/compilerDefinitions.inline.hpp"
  39 #include "compiler/methodLiveness.hpp"
  40 #include "interpreter/interpreter.hpp"
  41 #include "interpreter/linkResolver.hpp"
  42 #include "interpreter/oopMapCache.hpp"
  43 #include "logging/log.hpp"
  44 #include "logging/logStream.hpp"
  45 #include "memory/allocation.inline.hpp"
  46 #include "memory/resourceArea.hpp"
  47 #include "oops/generateOopMap.hpp"
  48 #include "oops/method.inline.hpp"
  49 #include "oops/oop.inline.hpp"
  50 #include "prims/methodHandles.hpp"
  51 #include "runtime/deoptimization.hpp"
  52 #include "runtime/handles.inline.hpp"
  53 #include "runtime/sharedRuntime.hpp"
  54 #include "utilities/bitMap.inline.hpp"
  55 #include "utilities/xmlstream.hpp"
  56 #ifdef COMPILER2
  57 #include "ci/bcEscapeAnalyzer.hpp"
  58 #include "ci/ciTypeFlow.hpp"
  59 #include "oops/method.hpp"
  60 #endif
  61 
  62 // ciMethod
  63 //
  64 // This class represents a Method* in the HotSpot virtual
  65 // machine.
  66 
  67 
  68 // ------------------------------------------------------------------
  69 // ciMethod::ciMethod
  70 //
  71 // Loaded method.
  72 ciMethod::ciMethod(const methodHandle& h_m, ciInstanceKlass* holder) :
  73   ciMetadata(h_m()),

 643  * Check whether profiling provides a type for the parameter i
 644  *
 645  * @param [in]i           parameter number
 646  * @param [out]type       profiled type of parameter, null if none
 647  * @param [out]ptr_kind   whether always null, never null or maybe null
 648  * @return                true if profiling exists
 649  *
 650  */
 651 bool ciMethod::parameter_profiled_type(int i, ciKlass*& type, ProfilePtrKind& ptr_kind) {
 652   if (MethodData::profile_parameters() && method_data() != nullptr && method_data()->is_mature()) {
 653     ciParametersTypeData* parameters = method_data()->parameters_type_data();
 654     if (parameters != nullptr && i < parameters->number_of_parameters()) {
 655       type = parameters->valid_parameter_type(i);
 656       ptr_kind = parameters->parameter_ptr_kind(i);
 657       return true;
 658     }
 659   }
 660   return false;
 661 }
 662 
 663 bool ciMethod::array_access_profiled_type(int bci, ciKlass*& array_type, ciKlass*& element_type, ProfilePtrKind& element_ptr, bool &flat_array, bool &null_free_array) {
 664   if (method_data() != nullptr && method_data()->is_mature()) {
 665     ciProfileData* data = method_data()->bci_to_data(bci);
 666     if (data != nullptr) {
 667       if (data->is_ArrayLoadData()) {
 668         ciArrayLoadData* array_access = (ciArrayLoadData*) data->as_ArrayLoadData();
 669         array_type = array_access->array()->valid_type();
 670         element_type = array_access->element()->valid_type();
 671         element_ptr = array_access->element()->ptr_kind();
 672         flat_array = array_access->flat_array();
 673         null_free_array = array_access->null_free_array();
 674         return true;
 675       } else if (data->is_ArrayStoreData()) {
 676         ciArrayStoreData* array_access = (ciArrayStoreData*) data->as_ArrayStoreData();
 677         array_type = array_access->array()->valid_type();
 678         flat_array = array_access->flat_array();
 679         null_free_array = array_access->null_free_array();
 680         ciCallProfile call_profile = call_profile_at_bci(bci);
 681         if (call_profile.morphism() == 1) {
 682           element_type = call_profile.receiver(0);
 683         } else {
 684           element_type = nullptr;
 685         }
 686         if (!array_access->null_seen()) {
 687           element_ptr = ProfileNeverNull;
 688         } else if (call_profile.count() == 0) {
 689           element_ptr = ProfileAlwaysNull;
 690         } else {
 691           element_ptr = ProfileMaybeNull;
 692         }
 693         return true;
 694       }
 695     }
 696   }
 697   return false;
 698 }
 699 
 700 bool ciMethod::acmp_profiled_type(int bci, ciKlass*& left_type, ciKlass*& right_type, ProfilePtrKind& left_ptr, ProfilePtrKind& right_ptr, bool &left_inline_type, bool &right_inline_type) {
 701   if (method_data() != nullptr && method_data()->is_mature()) {
 702     ciProfileData* data = method_data()->bci_to_data(bci);
 703     if (data != nullptr && data->is_ACmpData()) {
 704       ciACmpData* acmp = (ciACmpData*)data->as_ACmpData();
 705       left_type = acmp->left()->valid_type();
 706       right_type = acmp->right()->valid_type();
 707       left_ptr = acmp->left()->ptr_kind();
 708       right_ptr = acmp->right()->ptr_kind();
 709       left_inline_type = acmp->left_inline_type();
 710       right_inline_type = acmp->right_inline_type();
 711       return true;
 712     }
 713   }
 714   return false;
 715 }
 716 
 717 
 718 // ------------------------------------------------------------------
 719 // ciMethod::find_monomorphic_target
 720 //
 721 // Given a certain calling environment, find the monomorphic target
 722 // for the call.  Return null if the call is not monomorphic in
 723 // its calling environment, or if there are only abstract methods.
 724 // The returned method is never abstract.
 725 // Note: If caller uses a non-null result, it must inform dependencies
 726 // via assert_unique_concrete_method or assert_leaf_type.
 727 ciMethod* ciMethod::find_monomorphic_target(ciInstanceKlass* caller,
 728                                             ciInstanceKlass* callee_holder,
 729                                             ciInstanceKlass* actual_recv,
 730                                             bool check_access) {
 731   check_is_loaded();
 732 
 733   if (actual_recv->is_interface()) {
 734     // %%% We cannot trust interface types, yet.  See bug 6312651.
 735     return nullptr;
 736   }

 997 //
 998 // Return true if the method is an instance of the JVM-generated
 999 // signature-polymorphic MethodHandle methods, _invokeBasic, _linkToVirtual, etc.
1000 bool ciMethod::is_method_handle_intrinsic() const {
1001   vmIntrinsics::ID iid = _intrinsic_id;  // do not check if loaded
1002   return (MethodHandles::is_signature_polymorphic(iid) &&
1003           MethodHandles::is_signature_polymorphic_intrinsic(iid));
1004 }
1005 
1006 // ------------------------------------------------------------------
1007 // ciMethod::is_compiled_lambda_form
1008 //
1009 // Return true if the method is a generated MethodHandle adapter.
1010 // These are built by Java code.
1011 bool ciMethod::is_compiled_lambda_form() const {
1012   vmIntrinsics::ID iid = _intrinsic_id;  // do not check if loaded
1013   return iid == vmIntrinsics::_compiledLambdaForm;
1014 }
1015 
1016 // ------------------------------------------------------------------
1017 // ciMethod::is_object_constructor
1018 //
1019 bool ciMethod::is_object_constructor() const {
1020    return (name() == ciSymbols::object_initializer_name()
1021            && signature()->return_type()->is_void());
1022    // Note:  We can't test is_static, because that would
1023    // require the method to be loaded.  Sometimes it isn't.
1024 }
1025 
1026 // ------------------------------------------------------------------
1027 // ciMethod::has_member_arg
1028 //
1029 // Return true if the method is a linker intrinsic like _linkToVirtual.
1030 // These are built by the JVM.
1031 bool ciMethod::has_member_arg() const {
1032   vmIntrinsics::ID iid = _intrinsic_id;  // do not check if loaded
1033   return (MethodHandles::is_signature_polymorphic(iid) &&
1034           MethodHandles::has_member_arg(iid));
1035 }
1036 
1037 // ------------------------------------------------------------------
1038 // ciMethod::ensure_method_data
1039 //
1040 // Generate new MethodData* objects at compile time.
1041 // Return true if allocation was successful or no MDO is required.
1042 bool ciMethod::ensure_method_data(const methodHandle& h_m) {
1043   EXCEPTION_CONTEXT;

1271 // ciMethod::print_codes
1272 //
1273 // Print the bytecodes for this method.
1274 void ciMethod::print_codes_on(outputStream* st) {
1275   check_is_loaded();
1276   GUARDED_VM_ENTRY(get_Method()->print_codes_on(st);)
1277 }
1278 
1279 
1280 #define FETCH_FLAG_FROM_VM(flag_accessor) { \
1281   check_is_loaded(); \
1282   VM_ENTRY_MARK; \
1283   return get_Method()->flag_accessor(); \
1284 }
1285 
1286 bool ciMethod::has_loops      () const {         FETCH_FLAG_FROM_VM(has_loops); }
1287 bool ciMethod::has_jsrs       () const {         FETCH_FLAG_FROM_VM(has_jsrs);  }
1288 bool ciMethod::is_getter      () const {         FETCH_FLAG_FROM_VM(is_getter); }
1289 bool ciMethod::is_setter      () const {         FETCH_FLAG_FROM_VM(is_setter); }
1290 bool ciMethod::is_accessor    () const {         FETCH_FLAG_FROM_VM(is_accessor); }
1291 bool ciMethod::is_object_constructor_or_class_initializer() const { FETCH_FLAG_FROM_VM(is_object_constructor_or_class_initializer); }
1292 bool ciMethod::is_empty       () const {         FETCH_FLAG_FROM_VM(is_empty_method); }
1293 
1294 bool ciMethod::is_boxing_method() const {
1295   if (intrinsic_id() != vmIntrinsics::_none && holder()->is_box_klass()) {
1296     switch (intrinsic_id()) {
1297       case vmIntrinsics::_Boolean_valueOf:
1298       case vmIntrinsics::_Byte_valueOf:
1299       case vmIntrinsics::_Character_valueOf:
1300       case vmIntrinsics::_Short_valueOf:
1301       case vmIntrinsics::_Integer_valueOf:
1302       case vmIntrinsics::_Long_valueOf:
1303       case vmIntrinsics::_Float_valueOf:
1304       case vmIntrinsics::_Double_valueOf:
1305         return true;
1306       default:
1307         return false;
1308     }
1309   }
1310   return false;
1311 }

1518     default:
1519       break;
1520   }
1521   assert(target_sig->count() - rbase == linker_sig->count() - sbase - has_appendix, "argument count mismatch");
1522   int arg_count = target_sig->count() - rbase;
1523   for (int i = 0; i < arg_count; i++) {
1524     if (!basic_types_match(linker_sig->type_at(sbase + i), target_sig->type_at(rbase + i))) {
1525       return false;
1526     }
1527   }
1528   // Only check the return type if the symbolic info has non-void return type.
1529   // I.e. the return value of the resolved method can be dropped.
1530   if (!linker->return_type()->is_void() &&
1531       !basic_types_match(linker->return_type(), target->return_type())) {
1532     return false;
1533   }
1534   return true; // no mismatch found
1535 }
1536 
1537 // ------------------------------------------------------------------
1538 
1539 bool ciMethod::is_scalarized_arg(int idx) const {
1540   VM_ENTRY_MARK;
1541   return get_Method()->is_scalarized_arg(idx);
1542 }
1543 
1544 bool ciMethod::has_scalarized_args() const {
1545   VM_ENTRY_MARK;
1546   return get_Method()->has_scalarized_args();
1547 }
1548 
1549 const GrowableArray<SigEntry>* ciMethod::get_sig_cc() const {
1550   VM_ENTRY_MARK;
1551   if (get_Method()->adapter() == nullptr) {
1552     return nullptr;
1553   }
1554   return get_Method()->adapter()->get_sig_cc();
1555 }
< prev index next >