< prev index next >

src/hotspot/share/ci/ciMethod.cpp

Print this page

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

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

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






































































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

 957 //
 958 // Return true if the method is an instance of the JVM-generated
 959 // signature-polymorphic MethodHandle methods, _invokeBasic, _linkToVirtual, etc.
 960 bool ciMethod::is_method_handle_intrinsic() const {
 961   vmIntrinsics::ID iid = _intrinsic_id;  // do not check if loaded
 962   return (MethodHandles::is_signature_polymorphic(iid) &&
 963           MethodHandles::is_signature_polymorphic_intrinsic(iid));
 964 }
 965 
 966 // ------------------------------------------------------------------
 967 // ciMethod::is_compiled_lambda_form
 968 //
 969 // Return true if the method is a generated MethodHandle adapter.
 970 // These are built by Java code.
 971 bool ciMethod::is_compiled_lambda_form() const {
 972   vmIntrinsics::ID iid = _intrinsic_id;  // do not check if loaded
 973   return iid == vmIntrinsics::_compiledLambdaForm;
 974 }
 975 
 976 // ------------------------------------------------------------------
 977 // ciMethod::is_object_initializer
 978 //
 979 bool ciMethod::is_object_initializer() const {
 980    return name() == ciSymbols::object_initializer_name();



 981 }
 982 
 983 // ------------------------------------------------------------------
 984 // ciMethod::is_scoped
 985 //
 986 // Return true for methods annotated with @Scoped
 987 bool ciMethod::is_scoped() const {
 988    return get_Method()->is_scoped();
 989 }
 990 
 991 // ------------------------------------------------------------------
 992 // ciMethod::has_member_arg
 993 //
 994 // Return true if the method is a linker intrinsic like _linkToVirtual.
 995 // These are built by the JVM.
 996 bool ciMethod::has_member_arg() const {
 997   vmIntrinsics::ID iid = _intrinsic_id;  // do not check if loaded
 998   return (MethodHandles::is_signature_polymorphic(iid) &&
 999           MethodHandles::has_member_arg(iid));
1000 }

1512     default:
1513       break;
1514   }
1515   assert(target_sig->count() - rbase == linker_sig->count() - sbase - has_appendix, "argument count mismatch");
1516   int arg_count = target_sig->count() - rbase;
1517   for (int i = 0; i < arg_count; i++) {
1518     if (!basic_types_match(linker_sig->type_at(sbase + i), target_sig->type_at(rbase + i))) {
1519       return false;
1520     }
1521   }
1522   // Only check the return type if the symbolic info has non-void return type.
1523   // I.e. the return value of the resolved method can be dropped.
1524   if (!linker->return_type()->is_void() &&
1525       !basic_types_match(linker->return_type(), target->return_type())) {
1526     return false;
1527   }
1528   return true; // no mismatch found
1529 }
1530 
1531 // ------------------------------------------------------------------



















1532 // ciMethod::is_old
1533 //
1534 // Return true for redefined methods
1535 bool ciMethod::is_old() const {
1536   ASSERT_IN_VM;
1537   return get_Method()->is_old();
1538 }

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

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

1028 //
1029 // Return true if the method is an instance of the JVM-generated
1030 // signature-polymorphic MethodHandle methods, _invokeBasic, _linkToVirtual, etc.
1031 bool ciMethod::is_method_handle_intrinsic() const {
1032   vmIntrinsics::ID iid = _intrinsic_id;  // do not check if loaded
1033   return (MethodHandles::is_signature_polymorphic(iid) &&
1034           MethodHandles::is_signature_polymorphic_intrinsic(iid));
1035 }
1036 
1037 // ------------------------------------------------------------------
1038 // ciMethod::is_compiled_lambda_form
1039 //
1040 // Return true if the method is a generated MethodHandle adapter.
1041 // These are built by Java code.
1042 bool ciMethod::is_compiled_lambda_form() const {
1043   vmIntrinsics::ID iid = _intrinsic_id;  // do not check if loaded
1044   return iid == vmIntrinsics::_compiledLambdaForm;
1045 }
1046 
1047 // ------------------------------------------------------------------
1048 // ciMethod::is_object_constructor
1049 //
1050 bool ciMethod::is_object_constructor() const {
1051    return (name() == ciSymbols::object_initializer_name()
1052            && signature()->return_type()->is_void());
1053    // Note:  We can't test is_static, because that would
1054    // require the method to be loaded.  Sometimes it isn't.
1055 }
1056 
1057 // ------------------------------------------------------------------
1058 // ciMethod::is_scoped
1059 //
1060 // Return true for methods annotated with @Scoped
1061 bool ciMethod::is_scoped() const {
1062    return get_Method()->is_scoped();
1063 }
1064 
1065 // ------------------------------------------------------------------
1066 // ciMethod::has_member_arg
1067 //
1068 // Return true if the method is a linker intrinsic like _linkToVirtual.
1069 // These are built by the JVM.
1070 bool ciMethod::has_member_arg() const {
1071   vmIntrinsics::ID iid = _intrinsic_id;  // do not check if loaded
1072   return (MethodHandles::is_signature_polymorphic(iid) &&
1073           MethodHandles::has_member_arg(iid));
1074 }

1586     default:
1587       break;
1588   }
1589   assert(target_sig->count() - rbase == linker_sig->count() - sbase - has_appendix, "argument count mismatch");
1590   int arg_count = target_sig->count() - rbase;
1591   for (int i = 0; i < arg_count; i++) {
1592     if (!basic_types_match(linker_sig->type_at(sbase + i), target_sig->type_at(rbase + i))) {
1593       return false;
1594     }
1595   }
1596   // Only check the return type if the symbolic info has non-void return type.
1597   // I.e. the return value of the resolved method can be dropped.
1598   if (!linker->return_type()->is_void() &&
1599       !basic_types_match(linker->return_type(), target->return_type())) {
1600     return false;
1601   }
1602   return true; // no mismatch found
1603 }
1604 
1605 // ------------------------------------------------------------------
1606 
1607 bool ciMethod::is_scalarized_arg(int idx) const {
1608   VM_ENTRY_MARK;
1609   return get_Method()->is_scalarized_arg(idx);
1610 }
1611 
1612 bool ciMethod::has_scalarized_args() const {
1613   VM_ENTRY_MARK;
1614   return get_Method()->has_scalarized_args();
1615 }
1616 
1617 const GrowableArray<SigEntry>* ciMethod::get_sig_cc() const {
1618   VM_ENTRY_MARK;
1619   if (get_Method()->adapter() == nullptr) {
1620     return nullptr;
1621   }
1622   return get_Method()->adapter()->get_sig_cc();
1623 }
1624 
1625 // ciMethod::is_old
1626 //
1627 // Return true for redefined methods
1628 bool ciMethod::is_old() const {
1629   ASSERT_IN_VM;
1630   return get_Method()->is_old();
1631 }
< prev index next >