< prev index next >

src/hotspot/share/ci/ciMethod.cpp

Print this page

  33 #include "ci/ciSymbol.hpp"
  34 #include "ci/ciSymbols.hpp"
  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/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()),

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

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



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

1480     default:
1481       break;
1482   }
1483   assert(target_sig->count() - rbase == linker_sig->count() - sbase - has_appendix, "argument count mismatch");
1484   int arg_count = target_sig->count() - rbase;
1485   for (int i = 0; i < arg_count; i++) {
1486     if (!basic_types_match(linker_sig->type_at(sbase + i), target_sig->type_at(rbase + i))) {
1487       return false;
1488     }
1489   }
1490   // Only check the return type if the symbolic info has non-void return type.
1491   // I.e. the return value of the resolved method can be dropped.
1492   if (!linker->return_type()->is_void() &&
1493       !basic_types_match(linker->return_type(), target->return_type())) {
1494     return false;
1495   }
1496   return true; // no mismatch found
1497 }
1498 
1499 // ------------------------------------------------------------------



















1500 // ciMethod::is_old
1501 //
1502 // Return true for redefined methods
1503 bool ciMethod::is_old() const {
1504   ASSERT_IN_VM;
1505   return get_Method()->is_old();
1506 }

  33 #include "ci/ciSymbol.hpp"
  34 #include "ci/ciSymbols.hpp"
  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/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()),

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

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

1538     default:
1539       break;
1540   }
1541   assert(target_sig->count() - rbase == linker_sig->count() - sbase - has_appendix, "argument count mismatch");
1542   int arg_count = target_sig->count() - rbase;
1543   for (int i = 0; i < arg_count; i++) {
1544     if (!basic_types_match(linker_sig->type_at(sbase + i), target_sig->type_at(rbase + i))) {
1545       return false;
1546     }
1547   }
1548   // Only check the return type if the symbolic info has non-void return type.
1549   // I.e. the return value of the resolved method can be dropped.
1550   if (!linker->return_type()->is_void() &&
1551       !basic_types_match(linker->return_type(), target->return_type())) {
1552     return false;
1553   }
1554   return true; // no mismatch found
1555 }
1556 
1557 // ------------------------------------------------------------------
1558 
1559 bool ciMethod::is_scalarized_arg(int idx) const {
1560   VM_ENTRY_MARK;
1561   return get_Method()->is_scalarized_arg(idx);
1562 }
1563 
1564 bool ciMethod::has_scalarized_args() const {
1565   VM_ENTRY_MARK;
1566   return get_Method()->has_scalarized_args();
1567 }
1568 
1569 const GrowableArray<SigEntry>* ciMethod::get_sig_cc() const {
1570   VM_ENTRY_MARK;
1571   if (get_Method()->adapter() == nullptr) {
1572     return nullptr;
1573   }
1574   return get_Method()->adapter()->get_sig_cc();
1575 }
1576 
1577 // ciMethod::is_old
1578 //
1579 // Return true for redefined methods
1580 bool ciMethod::is_old() const {
1581   ASSERT_IN_VM;
1582   return get_Method()->is_old();
1583 }
< prev index next >