hotspot/src/share/vm/ci/ciMethod.cpp
changeset 43947 a52ee13998f3
parent 40664 1ec65b303bb7
child 43951 c23519aaccc1
equal deleted inserted replaced
43946:b683a1f9f2e5 43947:a52ee13998f3
  1407   } else {
  1407   } else {
  1408     st->print(" loaded=false");
  1408     st->print(" loaded=false");
  1409   }
  1409   }
  1410 }
  1410 }
  1411 
  1411 
       
  1412 // ------------------------------------------------------------------
       
  1413 
       
  1414 static BasicType erase_to_word_type(BasicType bt) {
       
  1415   if (is_subword_type(bt)) return T_INT;
       
  1416   if (bt == T_ARRAY)       return T_OBJECT;
       
  1417   return bt;
       
  1418 }
       
  1419 
       
  1420 static bool basic_types_match(ciType* t1, ciType* t2) {
       
  1421   if (t1 == t2)  return true;
       
  1422   return erase_to_word_type(t1->basic_type()) == erase_to_word_type(t2->basic_type());
       
  1423 }
       
  1424 
       
  1425 bool ciMethod::is_consistent_info(ciMethod* declared_method, ciMethod* resolved_method) {
       
  1426   bool invoke_through_mh_intrinsic = declared_method->is_method_handle_intrinsic() &&
       
  1427                                   !resolved_method->is_method_handle_intrinsic();
       
  1428 
       
  1429   if (!invoke_through_mh_intrinsic) {
       
  1430     // Method name & descriptor should stay the same.
       
  1431     return (declared_method->name()->equals(resolved_method->name())) &&
       
  1432            (declared_method->signature()->equals(resolved_method->signature()));
       
  1433   }
       
  1434 
       
  1435   ciMethod* linker = declared_method;
       
  1436   ciMethod* target = resolved_method;
       
  1437   // Linkers have appendix argument which is not passed to callee.
       
  1438   int has_appendix = MethodHandles::has_member_arg(linker->intrinsic_id()) ? 1 : 0;
       
  1439   if (linker->arg_size() != (target->arg_size() + has_appendix)) {
       
  1440     return false; // argument slot count mismatch
       
  1441   }
       
  1442 
       
  1443   ciSignature* linker_sig = linker->signature();
       
  1444   ciSignature* target_sig = target->signature();
       
  1445 
       
  1446   if (linker_sig->count() + (linker->is_static() ? 0 : 1) !=
       
  1447       target_sig->count() + (target->is_static() ? 0 : 1) + has_appendix) {
       
  1448     return false; // argument count mismatch
       
  1449   }
       
  1450 
       
  1451   int sbase = 0, rbase = 0;
       
  1452   switch (linker->intrinsic_id()) {
       
  1453     case vmIntrinsics::_linkToVirtual:
       
  1454     case vmIntrinsics::_linkToInterface:
       
  1455     case vmIntrinsics::_linkToSpecial: {
       
  1456       if (target->is_static()) {
       
  1457         return false;
       
  1458       }
       
  1459       if (linker_sig->type_at(0)->is_primitive_type()) {
       
  1460         return false;  // receiver should be an oop
       
  1461       }
       
  1462       sbase = 1; // skip receiver
       
  1463       break;
       
  1464     }
       
  1465     case vmIntrinsics::_linkToStatic: {
       
  1466       if (!target->is_static()) {
       
  1467         return false;
       
  1468       }
       
  1469       break;
       
  1470     }
       
  1471     case vmIntrinsics::_invokeBasic: {
       
  1472       if (target->is_static()) {
       
  1473         if (target_sig->type_at(0)->is_primitive_type()) {
       
  1474           return false; // receiver should be an oop
       
  1475         }
       
  1476         rbase = 1; // skip receiver
       
  1477       }
       
  1478       break;
       
  1479     }
       
  1480   }
       
  1481   assert(target_sig->count() - rbase == linker_sig->count() - sbase - has_appendix, "argument count mismatch");
       
  1482   int arg_count = target_sig->count() - rbase;
       
  1483   for (int i = 0; i < arg_count; i++) {
       
  1484     if (!basic_types_match(linker_sig->type_at(sbase + i), target_sig->type_at(rbase + i))) {
       
  1485       return false;
       
  1486     }
       
  1487   }
       
  1488   // Only check the return type if the symbolic info has non-void return type.
       
  1489   // I.e. the return value of the resolved method can be dropped.
       
  1490   if (!linker->return_type()->is_void() &&
       
  1491       !basic_types_match(linker->return_type(), target->return_type())) {
       
  1492     return false;
       
  1493   }
       
  1494   return true; // no mismatch found
       
  1495 }
       
  1496 
       
  1497 // ------------------------------------------------------------------
       
  1498 
  1412 #if INCLUDE_TRACE
  1499 #if INCLUDE_TRACE
  1413 TraceStructCalleeMethod ciMethod::to_trace_struct() const {
  1500 TraceStructCalleeMethod ciMethod::to_trace_struct() const {
  1414   TraceStructCalleeMethod result;
  1501   TraceStructCalleeMethod result;
  1415   result.set_type(holder()->name()->as_utf8());
  1502   result.set_type(holder()->name()->as_utf8());
  1416   result.set_name(name()->as_utf8());
  1503   result.set_name(name()->as_utf8());