< prev index next >

src/hotspot/share/ci/ciMethod.cpp

Print this page




  30 #include "ci/ciMethodBlocks.hpp"
  31 #include "ci/ciMethodData.hpp"
  32 #include "ci/ciStreams.hpp"
  33 #include "ci/ciSymbol.hpp"
  34 #include "ci/ciReplay.hpp"
  35 #include "ci/ciUtilities.inline.hpp"
  36 #include "classfile/systemDictionary.hpp"
  37 #include "compiler/abstractCompiler.hpp"
  38 #include "compiler/methodLiveness.hpp"
  39 #include "interpreter/interpreter.hpp"
  40 #include "interpreter/linkResolver.hpp"
  41 #include "interpreter/oopMapCache.hpp"
  42 #include "memory/allocation.inline.hpp"
  43 #include "memory/resourceArea.hpp"
  44 #include "oops/generateOopMap.hpp"
  45 #include "oops/method.inline.hpp"
  46 #include "oops/oop.inline.hpp"
  47 #include "prims/nativeLookup.hpp"
  48 #include "runtime/deoptimization.hpp"
  49 #include "runtime/handles.inline.hpp"

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


 970 //
 971 // Return true if the method is an instance of the JVM-generated
 972 // signature-polymorphic MethodHandle methods, _invokeBasic, _linkToVirtual, etc.
 973 bool ciMethod::is_method_handle_intrinsic() const {
 974   vmIntrinsics::ID iid = _intrinsic_id;  // do not check if loaded
 975   return (MethodHandles::is_signature_polymorphic(iid) &&
 976           MethodHandles::is_signature_polymorphic_intrinsic(iid));
 977 }
 978 
 979 // ------------------------------------------------------------------
 980 // ciMethod::is_compiled_lambda_form
 981 //
 982 // Return true if the method is a generated MethodHandle adapter.
 983 // These are built by Java code.
 984 bool ciMethod::is_compiled_lambda_form() const {
 985   vmIntrinsics::ID iid = _intrinsic_id;  // do not check if loaded
 986   return iid == vmIntrinsics::_compiledLambdaForm;
 987 }
 988 
 989 // ------------------------------------------------------------------
 990 // ciMethod::is_object_initializer
 991 //
 992 bool ciMethod::is_object_initializer() const {
 993    return name() == ciSymbol::object_initializer_name();













 994 }
 995 
 996 // ------------------------------------------------------------------
 997 // ciMethod::has_member_arg
 998 //
 999 // Return true if the method is a linker intrinsic like _linkToVirtual.
1000 // These are built by the JVM.
1001 bool ciMethod::has_member_arg() const {
1002   vmIntrinsics::ID iid = _intrinsic_id;  // do not check if loaded
1003   return (MethodHandles::is_signature_polymorphic(iid) &&
1004           MethodHandles::has_member_arg(iid));
1005 }
1006 
1007 // ------------------------------------------------------------------
1008 // ciMethod::ensure_method_data
1009 //
1010 // Generate new MethodData* objects at compile time.
1011 // Return true if allocation was successful or no MDO is required.
1012 bool ciMethod::ensure_method_data(const methodHandle& h_m) {
1013   EXCEPTION_CONTEXT;


1293 // Print the bytecodes for this method.
1294 void ciMethod::print_codes_on(outputStream* st) {
1295   check_is_loaded();
1296   GUARDED_VM_ENTRY(get_Method()->print_codes_on(st);)
1297 }
1298 
1299 
1300 #define FETCH_FLAG_FROM_VM(flag_accessor) { \
1301   check_is_loaded(); \
1302   VM_ENTRY_MARK; \
1303   return get_Method()->flag_accessor(); \
1304 }
1305 
1306 bool ciMethod::is_empty_method() const {         FETCH_FLAG_FROM_VM(is_empty_method); }
1307 bool ciMethod::is_vanilla_constructor() const {  FETCH_FLAG_FROM_VM(is_vanilla_constructor); }
1308 bool ciMethod::has_loops      () const {         FETCH_FLAG_FROM_VM(has_loops); }
1309 bool ciMethod::has_jsrs       () const {         FETCH_FLAG_FROM_VM(has_jsrs);  }
1310 bool ciMethod::is_getter      () const {         FETCH_FLAG_FROM_VM(is_getter); }
1311 bool ciMethod::is_setter      () const {         FETCH_FLAG_FROM_VM(is_setter); }
1312 bool ciMethod::is_accessor    () const {         FETCH_FLAG_FROM_VM(is_accessor); }
1313 bool ciMethod::is_initializer () const {         FETCH_FLAG_FROM_VM(is_initializer); }
1314 
1315 bool ciMethod::is_boxing_method() const {
1316   if (holder()->is_box_klass()) {
1317     switch (intrinsic_id()) {
1318       case vmIntrinsics::_Boolean_valueOf:
1319       case vmIntrinsics::_Byte_valueOf:
1320       case vmIntrinsics::_Character_valueOf:
1321       case vmIntrinsics::_Short_valueOf:
1322       case vmIntrinsics::_Integer_valueOf:
1323       case vmIntrinsics::_Long_valueOf:
1324       case vmIntrinsics::_Float_valueOf:
1325       case vmIntrinsics::_Double_valueOf:
1326         return true;
1327       default:
1328         return false;
1329     }
1330   }
1331   return false;
1332 }
1333 


1439   name()->print_symbol_on(st);
1440   st->print(" holder=");
1441   holder()->print_name_on(st);
1442   st->print(" signature=");
1443   signature()->as_symbol()->print_symbol_on(st);
1444   if (is_loaded()) {
1445     st->print(" loaded=true");
1446     st->print(" arg_size=%d", arg_size());
1447     st->print(" flags=");
1448     flags().print_member_flags(st);
1449   } else {
1450     st->print(" loaded=false");
1451   }
1452 }
1453 
1454 // ------------------------------------------------------------------
1455 
1456 static BasicType erase_to_word_type(BasicType bt) {
1457   if (is_subword_type(bt)) return T_INT;
1458   if (bt == T_ARRAY)       return T_OBJECT;

1459   return bt;
1460 }
1461 
1462 static bool basic_types_match(ciType* t1, ciType* t2) {
1463   if (t1 == t2)  return true;
1464   return erase_to_word_type(t1->basic_type()) == erase_to_word_type(t2->basic_type());
1465 }
1466 
1467 bool ciMethod::is_consistent_info(ciMethod* declared_method, ciMethod* resolved_method) {
1468   bool invoke_through_mh_intrinsic = declared_method->is_method_handle_intrinsic() &&
1469                                   !resolved_method->is_method_handle_intrinsic();
1470 
1471   if (!invoke_through_mh_intrinsic) {
1472     // Method name & descriptor should stay the same.
1473     // Signatures may reference unloaded types and thus they may be not strictly equal.
1474     ciSymbol* declared_signature = declared_method->signature()->as_symbol();
1475     ciSymbol* resolved_signature = resolved_method->signature()->as_symbol();
1476 
1477     return (declared_method->name()->equals(resolved_method->name())) &&
1478            (declared_signature->equals(resolved_signature));


1526     default:
1527       break;
1528   }
1529   assert(target_sig->count() - rbase == linker_sig->count() - sbase - has_appendix, "argument count mismatch");
1530   int arg_count = target_sig->count() - rbase;
1531   for (int i = 0; i < arg_count; i++) {
1532     if (!basic_types_match(linker_sig->type_at(sbase + i), target_sig->type_at(rbase + i))) {
1533       return false;
1534     }
1535   }
1536   // Only check the return type if the symbolic info has non-void return type.
1537   // I.e. the return value of the resolved method can be dropped.
1538   if (!linker->return_type()->is_void() &&
1539       !basic_types_match(linker->return_type(), target->return_type())) {
1540     return false;
1541   }
1542   return true; // no mismatch found
1543 }
1544 
1545 // ------------------------------------------------------------------















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


 971 //
 972 // Return true if the method is an instance of the JVM-generated
 973 // signature-polymorphic MethodHandle methods, _invokeBasic, _linkToVirtual, etc.
 974 bool ciMethod::is_method_handle_intrinsic() const {
 975   vmIntrinsics::ID iid = _intrinsic_id;  // do not check if loaded
 976   return (MethodHandles::is_signature_polymorphic(iid) &&
 977           MethodHandles::is_signature_polymorphic_intrinsic(iid));
 978 }
 979 
 980 // ------------------------------------------------------------------
 981 // ciMethod::is_compiled_lambda_form
 982 //
 983 // Return true if the method is a generated MethodHandle adapter.
 984 // These are built by Java code.
 985 bool ciMethod::is_compiled_lambda_form() const {
 986   vmIntrinsics::ID iid = _intrinsic_id;  // do not check if loaded
 987   return iid == vmIntrinsics::_compiledLambdaForm;
 988 }
 989 
 990 // ------------------------------------------------------------------
 991 // ciMethod::is_object_constructor
 992 //
 993 bool ciMethod::is_object_constructor() const {
 994    return (name() == ciSymbol::object_initializer_name()
 995            && signature()->return_type()->is_void());
 996    // Note:  We can't test is_static, because that would
 997    // require the method to be loaded.  Sometimes it isn't.
 998 }
 999 
1000 // ------------------------------------------------------------------
1001 // ciMethod::is_static_init_factory
1002 //
1003 bool ciMethod::is_static_init_factory() const {
1004    return (name() == ciSymbol::object_initializer_name()
1005            && !signature()->return_type()->is_void());
1006    // Note:  We can't test is_static, because that would
1007    // require the method to be loaded.  Sometimes it isn't.
1008 }
1009 
1010 // ------------------------------------------------------------------
1011 // ciMethod::has_member_arg
1012 //
1013 // Return true if the method is a linker intrinsic like _linkToVirtual.
1014 // These are built by the JVM.
1015 bool ciMethod::has_member_arg() const {
1016   vmIntrinsics::ID iid = _intrinsic_id;  // do not check if loaded
1017   return (MethodHandles::is_signature_polymorphic(iid) &&
1018           MethodHandles::has_member_arg(iid));
1019 }
1020 
1021 // ------------------------------------------------------------------
1022 // ciMethod::ensure_method_data
1023 //
1024 // Generate new MethodData* objects at compile time.
1025 // Return true if allocation was successful or no MDO is required.
1026 bool ciMethod::ensure_method_data(const methodHandle& h_m) {
1027   EXCEPTION_CONTEXT;


1307 // Print the bytecodes for this method.
1308 void ciMethod::print_codes_on(outputStream* st) {
1309   check_is_loaded();
1310   GUARDED_VM_ENTRY(get_Method()->print_codes_on(st);)
1311 }
1312 
1313 
1314 #define FETCH_FLAG_FROM_VM(flag_accessor) { \
1315   check_is_loaded(); \
1316   VM_ENTRY_MARK; \
1317   return get_Method()->flag_accessor(); \
1318 }
1319 
1320 bool ciMethod::is_empty_method() const {         FETCH_FLAG_FROM_VM(is_empty_method); }
1321 bool ciMethod::is_vanilla_constructor() const {  FETCH_FLAG_FROM_VM(is_vanilla_constructor); }
1322 bool ciMethod::has_loops      () const {         FETCH_FLAG_FROM_VM(has_loops); }
1323 bool ciMethod::has_jsrs       () const {         FETCH_FLAG_FROM_VM(has_jsrs);  }
1324 bool ciMethod::is_getter      () const {         FETCH_FLAG_FROM_VM(is_getter); }
1325 bool ciMethod::is_setter      () const {         FETCH_FLAG_FROM_VM(is_setter); }
1326 bool ciMethod::is_accessor    () const {         FETCH_FLAG_FROM_VM(is_accessor); }
1327 bool ciMethod::is_object_constructor_or_class_initializer() const { FETCH_FLAG_FROM_VM(is_object_constructor_or_class_initializer); }
1328 
1329 bool ciMethod::is_boxing_method() const {
1330   if (holder()->is_box_klass()) {
1331     switch (intrinsic_id()) {
1332       case vmIntrinsics::_Boolean_valueOf:
1333       case vmIntrinsics::_Byte_valueOf:
1334       case vmIntrinsics::_Character_valueOf:
1335       case vmIntrinsics::_Short_valueOf:
1336       case vmIntrinsics::_Integer_valueOf:
1337       case vmIntrinsics::_Long_valueOf:
1338       case vmIntrinsics::_Float_valueOf:
1339       case vmIntrinsics::_Double_valueOf:
1340         return true;
1341       default:
1342         return false;
1343     }
1344   }
1345   return false;
1346 }
1347 


1453   name()->print_symbol_on(st);
1454   st->print(" holder=");
1455   holder()->print_name_on(st);
1456   st->print(" signature=");
1457   signature()->as_symbol()->print_symbol_on(st);
1458   if (is_loaded()) {
1459     st->print(" loaded=true");
1460     st->print(" arg_size=%d", arg_size());
1461     st->print(" flags=");
1462     flags().print_member_flags(st);
1463   } else {
1464     st->print(" loaded=false");
1465   }
1466 }
1467 
1468 // ------------------------------------------------------------------
1469 
1470 static BasicType erase_to_word_type(BasicType bt) {
1471   if (is_subword_type(bt)) return T_INT;
1472   if (bt == T_ARRAY)       return T_OBJECT;
1473   if (bt == T_VALUETYPE)   return T_OBJECT;
1474   return bt;
1475 }
1476 
1477 static bool basic_types_match(ciType* t1, ciType* t2) {
1478   if (t1 == t2)  return true;
1479   return erase_to_word_type(t1->basic_type()) == erase_to_word_type(t2->basic_type());
1480 }
1481 
1482 bool ciMethod::is_consistent_info(ciMethod* declared_method, ciMethod* resolved_method) {
1483   bool invoke_through_mh_intrinsic = declared_method->is_method_handle_intrinsic() &&
1484                                   !resolved_method->is_method_handle_intrinsic();
1485 
1486   if (!invoke_through_mh_intrinsic) {
1487     // Method name & descriptor should stay the same.
1488     // Signatures may reference unloaded types and thus they may be not strictly equal.
1489     ciSymbol* declared_signature = declared_method->signature()->as_symbol();
1490     ciSymbol* resolved_signature = resolved_method->signature()->as_symbol();
1491 
1492     return (declared_method->name()->equals(resolved_method->name())) &&
1493            (declared_signature->equals(resolved_signature));


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