< prev index next >

src/hotspot/share/oops/method.cpp

Print this page




1091     set_interpreter_entry(entry);
1092   }
1093 
1094   // Don't overwrite already registered native entries.
1095   if (is_native() && !has_native_function()) {
1096     set_native_function(
1097       SharedRuntime::native_method_throw_unsatisfied_link_error_entry(),
1098       !native_bind_event_is_interesting);
1099   }
1100 
1101   // Setup compiler entrypoint.  This is made eagerly, so we do not need
1102   // special handling of vtables.  An alternative is to make adapters more
1103   // lazily by calling make_adapter() from from_compiled_entry() for the
1104   // normal calls.  For vtable calls life gets more complicated.  When a
1105   // call-site goes mega-morphic we need adapters in all methods which can be
1106   // called from the vtable.  We need adapters on such methods that get loaded
1107   // later.  Ditto for mega-morphic itable calls.  If this proves to be a
1108   // problem we'll make these lazily later.
1109   (void) make_adapters(h_method, CHECK);
1110 


1111   // ONLY USE the h_method now as make_adapter may have blocked
1112 
1113 }
1114 
1115 address Method::make_adapters(const methodHandle& mh, TRAPS) {
1116   // Adapters for compiled code are made eagerly here.  They are fairly
1117   // small (generally < 100 bytes) and quick to make (and cached and shared)
1118   // so making them eagerly shouldn't be too expensive.
1119   AdapterHandlerEntry* adapter = AdapterHandlerLibrary::get_adapter(mh);
1120   if (adapter == NULL ) {
1121     if (!is_init_completed()) {
1122       // Don't throw exceptions during VM initialization because java.lang.* classes
1123       // might not have been initialized, causing problems when constructing the
1124       // Java exception object.
1125       vm_exit_during_initialization("Out of space in CodeCache for adapters");
1126     } else {
1127       THROW_MSG_NULL(vmSymbols::java_lang_VirtualMachineError(), "Out of space in CodeCache for adapters");
1128     }
1129   }
1130 


1609   return sig_is_loaded;
1610 }
1611 
1612 bool Method::has_unloaded_classes_in_signature(const methodHandle& m, TRAPS) {
1613   Handle class_loader(THREAD, m->method_holder()->class_loader());
1614   Handle protection_domain(THREAD, m->method_holder()->protection_domain());
1615   ResourceMark rm(THREAD);
1616   Symbol*  signature = m->signature();
1617   for(SignatureStream ss(signature); !ss.is_done(); ss.next()) {
1618     if (ss.type() == T_OBJECT) {
1619       Symbol* name = ss.as_symbol_or_null();
1620       if (name == NULL) return true;
1621       Klass* klass = SystemDictionary::find(name, class_loader, protection_domain, THREAD);
1622       if (klass == NULL) return true;
1623     }
1624   }
1625   return false;
1626 }
1627 
1628 // Exposed so field engineers can debug VM
1629 void Method::print_short_name(outputStream* st) {
1630   ResourceMark rm;
1631 #ifdef PRODUCT
1632   st->print(" %s::", method_holder()->external_name());
1633 #else
1634   st->print(" %s::", method_holder()->internal_name());
1635 #endif
1636   name()->print_symbol_on(st);
1637   if (WizardMode) signature()->print_symbol_on(st);
1638   else if (MethodHandles::is_signature_polymorphic(intrinsic_id()))
1639     MethodHandles::print_as_basic_type_signature_on(st, signature(), true);
1640 }
1641 
1642 // Comparer for sorting an object array containing
1643 // Method*s.
1644 static int method_comparator(Method* a, Method* b) {
1645   return a->name()->fast_compare(b->name());
1646 }
1647 
1648 // This is only done during class loading, so it is OK to assume method_idnum matches the methods() array
1649 // default_methods also uses this without the ordering for fast find_method
1650 void Method::sort_methods(Array<Method*>* methods, bool set_idnums) {
1651   int length = methods->length();
1652   if (length > 1) {
1653     {
1654       NoSafepointVerifier nsv;
1655       QuickSort::sort(methods->data(), length, method_comparator, /*idempotent=*/false);
1656     }
1657     // Reset method ordering
1658     if (set_idnums) {
1659       for (int i = 0; i < length; i++) {
1660         Method* m = methods->at(i);
1661         m->set_method_idnum(i);
1662         m->set_orig_method_idnum(i);
1663       }
1664     }
1665   }
1666 }
1667 



















1668 //-----------------------------------------------------------------------------------
1669 // Non-product code unless JVM/TI needs it
1670 
1671 #if !defined(PRODUCT) || INCLUDE_JVMTI
1672 class SignatureTypePrinter : public SignatureTypeNames {
1673  private:
1674   outputStream* _st;
1675   bool _use_separator;
1676 
1677   void type_name(const char* name) {
1678     if (_use_separator) _st->print(", ");
1679     _st->print("%s", name);
1680     _use_separator = true;
1681   }
1682 
1683  public:
1684   SignatureTypePrinter(Symbol* signature, outputStream* st) : SignatureTypeNames(signature) {
1685     _st = st;
1686     _use_separator = false;
1687   }
1688 
1689   void print_parameters()              { _use_separator = false; iterate_parameters(); }
1690   void print_returntype()              { _use_separator = false; iterate_returntype(); }
1691 };
1692 
1693 
1694 void Method::print_name(outputStream* st) {
1695   Thread *thread = Thread::current();
1696   ResourceMark rm(thread);
1697   st->print("%s ", is_static() ? "static" : "virtual");
1698   if (WizardMode) {
1699     st->print("%s.", method_holder()->internal_name());
1700     name()->print_symbol_on(st);
1701     signature()->print_symbol_on(st);
1702   } else {
1703     SignatureTypePrinter sig(signature(), st);
1704     sig.print_returntype();
1705     st->print(" %s.", method_holder()->internal_name());
1706     name()->print_symbol_on(st);
1707     st->print("(");
1708     sig.print_parameters();
1709     st->print(")");
1710   }
1711 }
1712 #endif // !PRODUCT || INCLUDE_JVMTI
1713 
1714 




1091     set_interpreter_entry(entry);
1092   }
1093 
1094   // Don't overwrite already registered native entries.
1095   if (is_native() && !has_native_function()) {
1096     set_native_function(
1097       SharedRuntime::native_method_throw_unsatisfied_link_error_entry(),
1098       !native_bind_event_is_interesting);
1099   }
1100 
1101   // Setup compiler entrypoint.  This is made eagerly, so we do not need
1102   // special handling of vtables.  An alternative is to make adapters more
1103   // lazily by calling make_adapter() from from_compiled_entry() for the
1104   // normal calls.  For vtable calls life gets more complicated.  When a
1105   // call-site goes mega-morphic we need adapters in all methods which can be
1106   // called from the vtable.  We need adapters on such methods that get loaded
1107   // later.  Ditto for mega-morphic itable calls.  If this proves to be a
1108   // problem we'll make these lazily later.
1109   (void) make_adapters(h_method, CHECK);
1110 
1111   set_num_stack_arg_slots();
1112 
1113   // ONLY USE the h_method now as make_adapter may have blocked
1114 
1115 }
1116 
1117 address Method::make_adapters(const methodHandle& mh, TRAPS) {
1118   // Adapters for compiled code are made eagerly here.  They are fairly
1119   // small (generally < 100 bytes) and quick to make (and cached and shared)
1120   // so making them eagerly shouldn't be too expensive.
1121   AdapterHandlerEntry* adapter = AdapterHandlerLibrary::get_adapter(mh);
1122   if (adapter == NULL ) {
1123     if (!is_init_completed()) {
1124       // Don't throw exceptions during VM initialization because java.lang.* classes
1125       // might not have been initialized, causing problems when constructing the
1126       // Java exception object.
1127       vm_exit_during_initialization("Out of space in CodeCache for adapters");
1128     } else {
1129       THROW_MSG_NULL(vmSymbols::java_lang_VirtualMachineError(), "Out of space in CodeCache for adapters");
1130     }
1131   }
1132 


1611   return sig_is_loaded;
1612 }
1613 
1614 bool Method::has_unloaded_classes_in_signature(const methodHandle& m, TRAPS) {
1615   Handle class_loader(THREAD, m->method_holder()->class_loader());
1616   Handle protection_domain(THREAD, m->method_holder()->protection_domain());
1617   ResourceMark rm(THREAD);
1618   Symbol*  signature = m->signature();
1619   for(SignatureStream ss(signature); !ss.is_done(); ss.next()) {
1620     if (ss.type() == T_OBJECT) {
1621       Symbol* name = ss.as_symbol_or_null();
1622       if (name == NULL) return true;
1623       Klass* klass = SystemDictionary::find(name, class_loader, protection_domain, THREAD);
1624       if (klass == NULL) return true;
1625     }
1626   }
1627   return false;
1628 }
1629 
1630 // Exposed so field engineers can debug VM
1631 void Method::print_short_name(outputStream* st) const {
1632   ResourceMark rm;
1633 #ifdef PRODUCT
1634   st->print(" %s::", method_holder()->external_name());
1635 #else
1636   st->print(" %s::", method_holder()->internal_name());
1637 #endif
1638   name()->print_symbol_on(st);
1639   if (WizardMode) signature()->print_symbol_on(st);
1640   else if (MethodHandles::is_signature_polymorphic(intrinsic_id()))
1641     MethodHandles::print_as_basic_type_signature_on(st, signature(), true);
1642 }
1643 
1644 // Comparer for sorting an object array containing
1645 // Method*s.
1646 static int method_comparator(Method* a, Method* b) {
1647   return a->name()->fast_compare(b->name());
1648 }
1649 
1650 // This is only done during class loading, so it is OK to assume method_idnum matches the methods() array
1651 // default_methods also uses this without the ordering for fast find_method
1652 void Method::sort_methods(Array<Method*>* methods, bool set_idnums) {
1653   int length = methods->length();
1654   if (length > 1) {
1655     {
1656       NoSafepointVerifier nsv;
1657       QuickSort::sort(methods->data(), length, method_comparator, /*idempotent=*/false);
1658     }
1659     // Reset method ordering
1660     if (set_idnums) {
1661       for (int i = 0; i < length; i++) {
1662         Method* m = methods->at(i);
1663         m->set_method_idnum(i);
1664         m->set_orig_method_idnum(i);
1665       }
1666     }
1667   }
1668 }
1669 
1670 void Method::set_num_stack_arg_slots() {
1671   ResourceMark rm;
1672   int sizeargs = size_of_parameters();
1673   BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType, sizeargs);
1674   VMRegPair* regs   = NEW_RESOURCE_ARRAY(VMRegPair, sizeargs);
1675 
1676   int sig_index = 0;
1677   if (!is_static()) sig_bt[sig_index++] = T_OBJECT; // 'this'
1678   for (SignatureStream ss(signature()); !ss.at_return_type(); ss.next()) {
1679     BasicType t = ss.type();
1680     assert(type2size[t] == 1 || type2size[t] == 2, "size is 1 or 2");
1681     sig_bt[sig_index++] = t;
1682     if (type2size[t] == 2) sig_bt[sig_index++] = T_VOID;
1683   }
1684   assert(sig_index == sizeargs, "");
1685 
1686   _num_stack_arg_slots = SharedRuntime::java_calling_convention(sig_bt, regs, sizeargs, false);
1687 }
1688 
1689 //-----------------------------------------------------------------------------------
1690 // Non-product code unless JVM/TI needs it
1691 
1692 #if !defined(PRODUCT) || INCLUDE_JVMTI
1693 class SignatureTypePrinter : public SignatureTypeNames {
1694  private:
1695   outputStream* _st;
1696   bool _use_separator;
1697 
1698   void type_name(const char* name) {
1699     if (_use_separator) _st->print(", ");
1700     _st->print("%s", name);
1701     _use_separator = true;
1702   }
1703 
1704  public:
1705   SignatureTypePrinter(Symbol* signature, outputStream* st) : SignatureTypeNames(signature) {
1706     _st = st;
1707     _use_separator = false;
1708   }
1709 
1710   void print_parameters()              { _use_separator = false; iterate_parameters(); }
1711   void print_returntype()              { _use_separator = false; iterate_returntype(); }
1712 };
1713 
1714 
1715 void Method::print_name(outputStream* st) const {
1716   Thread *thread = Thread::current();
1717   ResourceMark rm(thread);
1718   st->print("%s ", is_static() ? "static" : "virtual");
1719   if (WizardMode) {
1720     st->print("%s.", method_holder()->internal_name());
1721     name()->print_symbol_on(st);
1722     signature()->print_symbol_on(st);
1723   } else {
1724     SignatureTypePrinter sig(signature(), st);
1725     sig.print_returntype();
1726     st->print(" %s.", method_holder()->internal_name());
1727     name()->print_symbol_on(st);
1728     st->print("(");
1729     sig.print_parameters();
1730     st->print(")");
1731   }
1732 }
1733 #endif // !PRODUCT || INCLUDE_JVMTI
1734 
1735 


< prev index next >