307 address bcp = code_base() + bci; 308 assert(is_native() && bcp == code_base() || contains(bcp), "bcp doesn't belong to this method"); 309 return bcp; 310 } 311 312 address Method::bcp_from(address bcp) const { 313 if (is_native() && bcp == NULL) { 314 return code_base(); 315 } else { 316 return bcp; 317 } 318 } 319 320 int Method::size(bool is_native) { 321 // If native, then include pointers for native_function and signature_handler 322 int extra_bytes = (is_native) ? 2*sizeof(address*) : 0; 323 int extra_words = align_up(extra_bytes, BytesPerWord) / BytesPerWord; 324 return align_metadata_size(header_size() + extra_words); 325 } 326 327 328 Symbol* Method::klass_name() const { 329 return method_holder()->name(); 330 } 331 332 333 void Method::metaspace_pointers_do(MetaspaceClosure* it) { 334 log_trace(cds)("Iter(Method): %p", this); 335 336 it->push(&_constMethod); 337 it->push(&_method_data); 338 it->push(&_method_counters); 339 } 340 341 // Attempt to return method oop to original state. Clear any pointers 342 // (to objects outside the shared spaces). We won't be able to predict 343 // where they should point in a new JVM. Further initialize some 344 // entries now in order allow them to be write protected later. 345 346 void Method::remove_unshareable_info() { 347 unlink_method(); 348 } 349 350 void Method::set_vtable_index(int index) { 351 if (is_shared() && !MetaspaceShared::remapped_readwrite()) { 352 // At runtime initialize_vtable is rerun as part of link_class_impl() 353 // for a shared class loaded by the non-boot loader to obtain the loader 354 // constraints based on the runtime classloaders' context. 355 return; // don't write into the shared class 356 } else { 357 _vtable_index = index; 358 } 1648 ResourceMark rm; 1649 #ifdef PRODUCT 1650 st->print(" %s::", method_holder()->external_name()); 1651 #else 1652 st->print(" %s::", method_holder()->internal_name()); 1653 #endif 1654 name()->print_symbol_on(st); 1655 if (WizardMode) signature()->print_symbol_on(st); 1656 else if (MethodHandles::is_signature_polymorphic(intrinsic_id())) 1657 MethodHandles::print_as_basic_type_signature_on(st, signature(), true); 1658 } 1659 1660 // Comparer for sorting an object array containing 1661 // Method*s. 1662 static int method_comparator(Method* a, Method* b) { 1663 return a->name()->fast_compare(b->name()); 1664 } 1665 1666 // This is only done during class loading, so it is OK to assume method_idnum matches the methods() array 1667 // default_methods also uses this without the ordering for fast find_method 1668 void Method::sort_methods(Array<Method*>* methods, bool set_idnums) { 1669 int length = methods->length(); 1670 if (length > 1) { 1671 { 1672 NoSafepointVerifier nsv; 1673 QuickSort::sort(methods->data(), length, method_comparator, /*idempotent=*/false); 1674 } 1675 // Reset method ordering 1676 if (set_idnums) { 1677 for (int i = 0; i < length; i++) { 1678 Method* m = methods->at(i); 1679 m->set_method_idnum(i); 1680 m->set_orig_method_idnum(i); 1681 } 1682 } 1683 } 1684 } 1685 1686 //----------------------------------------------------------------------------------- 1687 // Non-product code unless JVM/TI needs it 1688 1689 #if !defined(PRODUCT) || INCLUDE_JVMTI 1690 class SignatureTypePrinter : public SignatureTypeNames { 1691 private: 1692 outputStream* _st; 1693 bool _use_separator; | 307 address bcp = code_base() + bci; 308 assert(is_native() && bcp == code_base() || contains(bcp), "bcp doesn't belong to this method"); 309 return bcp; 310 } 311 312 address Method::bcp_from(address bcp) const { 313 if (is_native() && bcp == NULL) { 314 return code_base(); 315 } else { 316 return bcp; 317 } 318 } 319 320 int Method::size(bool is_native) { 321 // If native, then include pointers for native_function and signature_handler 322 int extra_bytes = (is_native) ? 2*sizeof(address*) : 0; 323 int extra_words = align_up(extra_bytes, BytesPerWord) / BytesPerWord; 324 return align_metadata_size(header_size() + extra_words); 325 } 326 327 Symbol* Method::klass_name() const { 328 return method_holder()->name(); 329 } 330 331 void Method::metaspace_pointers_do(MetaspaceClosure* it) { 332 log_trace(cds)("Iter(Method): %p", this); 333 334 it->push(&_constMethod); 335 it->push(&_method_data); 336 it->push(&_method_counters); 337 338 Method* this_ptr = this; 339 it->push_method_entry(&this_ptr, (intptr_t*)&_i2i_entry); 340 it->push_method_entry(&this_ptr, (intptr_t*)&_from_compiled_entry); 341 it->push_method_entry(&this_ptr, (intptr_t*)&_from_interpreted_entry); 342 } 343 344 // Attempt to return method oop to original state. Clear any pointers 345 // (to objects outside the shared spaces). We won't be able to predict 346 // where they should point in a new JVM. Further initialize some 347 // entries now in order allow them to be write protected later. 348 349 void Method::remove_unshareable_info() { 350 unlink_method(); 351 } 352 353 void Method::set_vtable_index(int index) { 354 if (is_shared() && !MetaspaceShared::remapped_readwrite()) { 355 // At runtime initialize_vtable is rerun as part of link_class_impl() 356 // for a shared class loaded by the non-boot loader to obtain the loader 357 // constraints based on the runtime classloaders' context. 358 return; // don't write into the shared class 359 } else { 360 _vtable_index = index; 361 } 1651 ResourceMark rm; 1652 #ifdef PRODUCT 1653 st->print(" %s::", method_holder()->external_name()); 1654 #else 1655 st->print(" %s::", method_holder()->internal_name()); 1656 #endif 1657 name()->print_symbol_on(st); 1658 if (WizardMode) signature()->print_symbol_on(st); 1659 else if (MethodHandles::is_signature_polymorphic(intrinsic_id())) 1660 MethodHandles::print_as_basic_type_signature_on(st, signature(), true); 1661 } 1662 1663 // Comparer for sorting an object array containing 1664 // Method*s. 1665 static int method_comparator(Method* a, Method* b) { 1666 return a->name()->fast_compare(b->name()); 1667 } 1668 1669 // This is only done during class loading, so it is OK to assume method_idnum matches the methods() array 1670 // default_methods also uses this without the ordering for fast find_method 1671 void Method::sort_methods(Array<Method*>* methods, bool set_idnums, method_comparator_func func) { 1672 int length = methods->length(); 1673 if (length > 1) { 1674 if (func == NULL) { 1675 func = method_comparator; 1676 } 1677 { 1678 NoSafepointVerifier nsv; 1679 QuickSort::sort(methods->data(), length, func, /*idempotent=*/false); 1680 } 1681 // Reset method ordering 1682 if (set_idnums) { 1683 for (int i = 0; i < length; i++) { 1684 Method* m = methods->at(i); 1685 m->set_method_idnum(i); 1686 m->set_orig_method_idnum(i); 1687 } 1688 } 1689 } 1690 } 1691 1692 //----------------------------------------------------------------------------------- 1693 // Non-product code unless JVM/TI needs it 1694 1695 #if !defined(PRODUCT) || INCLUDE_JVMTI 1696 class SignatureTypePrinter : public SignatureTypeNames { 1697 private: 1698 outputStream* _st; 1699 bool _use_separator; |