< prev index next >

src/hotspot/share/ci/ciMethod.cpp

Print this page

  33 #include "ci/ciReplay.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   }

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



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

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



















1494 // ciMethod::is_old
1495 //
1496 // Return true for redefined methods
1497 bool ciMethod::is_old() const {
1498   ASSERT_IN_VM;
1499   return get_Method()->is_old();
1500 }

  33 #include "ci/ciReplay.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   }

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

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