< 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         return true;
 678       } else if (data->is_ArrayStoreData()) {
 679         ciArrayStoreData* array_access = (ciArrayStoreData*) data->as_ArrayStoreData();
 680         array_type = array_access->array()->valid_type();
 681         flat_array = array_access->flat_array();
 682         null_free_array = array_access->null_free_array();
 683         ciCallProfile call_profile = call_profile_at_bci(bci);
 684         if (call_profile.morphism() == 1) {
 685           element_type = call_profile.receiver(0);
 686         } else {
 687           element_type = nullptr;
 688         }
 689         if (!array_access->null_seen()) {
 690           element_ptr = ProfileNeverNull;
 691         } else if (call_profile.count() == 0) {
 692           element_ptr = ProfileAlwaysNull;
 693         } else {
 694           element_ptr = ProfileMaybeNull;
 695         }
 696         return true;
 697       }
 698     }
 699   }
 700   return false;
 701 }
 702 
 703 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) {
 704   if (method_data() != nullptr && method_data()->is_mature()) {
 705     ciProfileData* data = method_data()->bci_to_data(bci);
 706     if (data != nullptr && data->is_ACmpData()) {
 707       ciACmpData* acmp = (ciACmpData*)data->as_ACmpData();
 708       left_type = acmp->left()->valid_type();
 709       right_type = acmp->right()->valid_type();
 710       left_ptr = acmp->left()->ptr_kind();
 711       right_ptr = acmp->right()->ptr_kind();
 712       left_inline_type = acmp->left_inline_type();
 713       right_inline_type = acmp->right_inline_type();
 714       return true;
 715     }
 716   }
 717   return false;
 718 }
 719 
 720 
 721 // ------------------------------------------------------------------
 722 // ciMethod::find_monomorphic_target
 723 //
 724 // Given a certain calling environment, find the monomorphic target
 725 // for the call.  Return null if the call is not monomorphic in
 726 // its calling environment, or if there are only abstract methods.
 727 // The returned method is never abstract.
 728 // Note: If caller uses a non-null result, it must inform dependencies
 729 // via assert_unique_concrete_method or assert_leaf_type.
 730 ciMethod* ciMethod::find_monomorphic_target(ciInstanceKlass* caller,
 731                                             ciInstanceKlass* callee_holder,
 732                                             ciInstanceKlass* actual_recv,
 733                                             bool check_access) {
 734   check_is_loaded();
 735 
 736   if (actual_recv->is_interface()) {
 737     // %%% We cannot trust interface types, yet.  See bug 6312651.
 738     return nullptr;
 739   }

1012 //
1013 // Return true if the method is an instance of the JVM-generated
1014 // signature-polymorphic MethodHandle methods, _invokeBasic, _linkToVirtual, etc.
1015 bool ciMethod::is_method_handle_intrinsic() const {
1016   vmIntrinsics::ID iid = _intrinsic_id;  // do not check if loaded
1017   return (MethodHandles::is_signature_polymorphic(iid) &&
1018           MethodHandles::is_signature_polymorphic_intrinsic(iid));
1019 }
1020 
1021 // ------------------------------------------------------------------
1022 // ciMethod::is_compiled_lambda_form
1023 //
1024 // Return true if the method is a generated MethodHandle adapter.
1025 // These are built by Java code.
1026 bool ciMethod::is_compiled_lambda_form() const {
1027   vmIntrinsics::ID iid = _intrinsic_id;  // do not check if loaded
1028   return iid == vmIntrinsics::_compiledLambdaForm;
1029 }
1030 
1031 // ------------------------------------------------------------------
1032 // ciMethod::is_object_constructor
1033 //
1034 bool ciMethod::is_object_constructor() const {
1035    return (name() == ciSymbols::object_initializer_name()
1036            && signature()->return_type()->is_void());
1037    // Note:  We can't test is_static, because that would
1038    // require the method to be loaded.  Sometimes it isn't.
1039 }
1040 
1041 // ------------------------------------------------------------------
1042 // ciMethod::is_scoped
1043 //
1044 // Return true for methods annotated with @Scoped
1045 bool ciMethod::is_scoped() const {
1046    return get_Method()->is_scoped();
1047 }
1048 
1049 // ------------------------------------------------------------------
1050 // ciMethod::has_member_arg
1051 //
1052 // Return true if the method is a linker intrinsic like _linkToVirtual.
1053 // These are built by the JVM.
1054 bool ciMethod::has_member_arg() const {
1055   vmIntrinsics::ID iid = _intrinsic_id;  // do not check if loaded
1056   return (MethodHandles::is_signature_polymorphic(iid) &&
1057           MethodHandles::has_member_arg(iid));
1058 }

1570     default:
1571       break;
1572   }
1573   assert(target_sig->count() - rbase == linker_sig->count() - sbase - has_appendix, "argument count mismatch");
1574   int arg_count = target_sig->count() - rbase;
1575   for (int i = 0; i < arg_count; i++) {
1576     if (!basic_types_match(linker_sig->type_at(sbase + i), target_sig->type_at(rbase + i))) {
1577       return false;
1578     }
1579   }
1580   // Only check the return type if the symbolic info has non-void return type.
1581   // I.e. the return value of the resolved method can be dropped.
1582   if (!linker->return_type()->is_void() &&
1583       !basic_types_match(linker->return_type(), target->return_type())) {
1584     return false;
1585   }
1586   return true; // no mismatch found
1587 }
1588 
1589 // ------------------------------------------------------------------
1590 
1591 bool ciMethod::is_scalarized_arg(int idx) const {
1592   VM_ENTRY_MARK;
1593   return get_Method()->is_scalarized_arg(idx);
1594 }
1595 
1596 bool ciMethod::has_scalarized_args() const {
1597   VM_ENTRY_MARK;
1598   return get_Method()->has_scalarized_args();
1599 }
1600 
1601 const GrowableArray<SigEntry>* ciMethod::get_sig_cc() const {
1602   VM_ENTRY_MARK;
1603   if (get_Method()->adapter() == nullptr) {
1604     return nullptr;
1605   }
1606   return get_Method()->adapter()->get_sig_cc();
1607 }
1608 
1609 // ciMethod::is_old
1610 //
1611 // Return true for redefined methods
1612 bool ciMethod::is_old() const {
1613   ASSERT_IN_VM;
1614   return get_Method()->is_old();
1615 }
< prev index next >