35 #include "jvmtifiles/jvmti.h" |
35 #include "jvmtifiles/jvmti.h" |
36 #include "memory/genOopClosures.inline.hpp" |
36 #include "memory/genOopClosures.inline.hpp" |
37 #include "memory/oopFactory.hpp" |
37 #include "memory/oopFactory.hpp" |
38 #include "memory/permGen.hpp" |
38 #include "memory/permGen.hpp" |
39 #include "oops/instanceKlass.hpp" |
39 #include "oops/instanceKlass.hpp" |
|
40 #include "oops/instanceMirrorKlass.hpp" |
40 #include "oops/instanceOop.hpp" |
41 #include "oops/instanceOop.hpp" |
41 #include "oops/methodOop.hpp" |
42 #include "oops/methodOop.hpp" |
42 #include "oops/objArrayKlassKlass.hpp" |
43 #include "oops/objArrayKlassKlass.hpp" |
43 #include "oops/oop.inline.hpp" |
44 #include "oops/oop.inline.hpp" |
44 #include "oops/symbol.hpp" |
45 #include "oops/symbol.hpp" |
647 JavaCalls::call(&result, mh, &args, CHECK_NULL); |
648 JavaCalls::call(&result, mh, &args, CHECK_NULL); |
648 return h_i(); |
649 return h_i(); |
649 } |
650 } |
650 |
651 |
651 instanceOop instanceKlass::allocate_instance(TRAPS) { |
652 instanceOop instanceKlass::allocate_instance(TRAPS) { |
|
653 assert(!oop_is_instanceMirror(), "wrong allocation path"); |
652 bool has_finalizer_flag = has_finalizer(); // Query before possible GC |
654 bool has_finalizer_flag = has_finalizer(); // Query before possible GC |
653 int size = size_helper(); // Query before forming handle. |
655 int size = size_helper(); // Query before forming handle. |
654 |
656 |
655 KlassHandle h_k(THREAD, as_klassOop()); |
657 KlassHandle h_k(THREAD, as_klassOop()); |
656 |
658 |
667 // Finalizer registration occurs in the Object.<init> constructor |
669 // Finalizer registration occurs in the Object.<init> constructor |
668 // and constructors normally aren't run when allocating perm |
670 // and constructors normally aren't run when allocating perm |
669 // instances so simply disallow finalizable perm objects. This can |
671 // instances so simply disallow finalizable perm objects. This can |
670 // be relaxed if a need for it is found. |
672 // be relaxed if a need for it is found. |
671 assert(!has_finalizer(), "perm objects not allowed to have finalizers"); |
673 assert(!has_finalizer(), "perm objects not allowed to have finalizers"); |
|
674 assert(!oop_is_instanceMirror(), "wrong allocation path"); |
672 int size = size_helper(); // Query before forming handle. |
675 int size = size_helper(); // Query before forming handle. |
673 KlassHandle h_k(THREAD, as_klassOop()); |
676 KlassHandle h_k(THREAD, as_klassOop()); |
674 instanceOop i = (instanceOop) |
677 instanceOop i = (instanceOop) |
675 CollectedHeap::permanent_obj_allocate(h_k, size, CHECK_NULL); |
678 CollectedHeap::permanent_obj_allocate(h_k, size, CHECK_NULL); |
676 return i; |
679 return i; |
895 methodOop m = methodOop(methods()->obj_at(index)); |
898 methodOop m = methodOop(methods()->obj_at(index)); |
896 assert(m->is_method(), "must be method"); |
899 assert(m->is_method(), "must be method"); |
897 f(m); |
900 f(m); |
898 } |
901 } |
899 } |
902 } |
|
903 |
900 |
904 |
901 void instanceKlass::do_local_static_fields(FieldClosure* cl) { |
905 void instanceKlass::do_local_static_fields(FieldClosure* cl) { |
902 fieldDescriptor fd; |
906 fieldDescriptor fd; |
903 int length = fields()->length(); |
907 int length = fields()->length(); |
904 for (int i = 0; i < length; i += next_offset) { |
908 for (int i = 0; i < length; i += next_offset) { |
1607 |
1611 |
1608 |
1612 |
1609 // The following macros call specialized macros, passing either oop or |
1613 // The following macros call specialized macros, passing either oop or |
1610 // narrowOop as the specialization type. These test the UseCompressedOops |
1614 // narrowOop as the specialization type. These test the UseCompressedOops |
1611 // flag. |
1615 // flag. |
1612 #define InstanceKlass_OOP_ITERATE(start_p, count, \ |
|
1613 do_oop, assert_fn) \ |
|
1614 { \ |
|
1615 if (UseCompressedOops) { \ |
|
1616 InstanceKlass_SPECIALIZED_OOP_ITERATE(narrowOop, \ |
|
1617 start_p, count, \ |
|
1618 do_oop, assert_fn) \ |
|
1619 } else { \ |
|
1620 InstanceKlass_SPECIALIZED_OOP_ITERATE(oop, \ |
|
1621 start_p, count, \ |
|
1622 do_oop, assert_fn) \ |
|
1623 } \ |
|
1624 } |
|
1625 |
|
1626 #define InstanceKlass_BOUNDED_OOP_ITERATE(start_p, count, low, high, \ |
|
1627 do_oop, assert_fn) \ |
|
1628 { \ |
|
1629 if (UseCompressedOops) { \ |
|
1630 InstanceKlass_SPECIALIZED_BOUNDED_OOP_ITERATE(narrowOop, \ |
|
1631 start_p, count, \ |
|
1632 low, high, \ |
|
1633 do_oop, assert_fn) \ |
|
1634 } else { \ |
|
1635 InstanceKlass_SPECIALIZED_BOUNDED_OOP_ITERATE(oop, \ |
|
1636 start_p, count, \ |
|
1637 low, high, \ |
|
1638 do_oop, assert_fn) \ |
|
1639 } \ |
|
1640 } |
|
1641 |
|
1642 #define InstanceKlass_OOP_MAP_ITERATE(obj, do_oop, assert_fn) \ |
1616 #define InstanceKlass_OOP_MAP_ITERATE(obj, do_oop, assert_fn) \ |
1643 { \ |
1617 { \ |
1644 /* Compute oopmap block range. The common case \ |
1618 /* Compute oopmap block range. The common case \ |
1645 is nonstatic_oop_map_size == 1. */ \ |
1619 is nonstatic_oop_map_size == 1. */ \ |
1646 OopMapBlock* map = start_of_nonstatic_oop_maps(); \ |
1620 OopMapBlock* map = start_of_nonstatic_oop_maps(); \ |
1709 ++map; \ |
1683 ++map; \ |
1710 } \ |
1684 } \ |
1711 } \ |
1685 } \ |
1712 } |
1686 } |
1713 |
1687 |
1714 void instanceKlass::follow_static_fields() { |
|
1715 InstanceKlass_OOP_ITERATE( \ |
|
1716 start_of_static_fields(), static_oop_field_size(), \ |
|
1717 MarkSweep::mark_and_push(p), \ |
|
1718 assert_is_in_closed_subset) |
|
1719 } |
|
1720 |
|
1721 #ifndef SERIALGC |
|
1722 void instanceKlass::follow_static_fields(ParCompactionManager* cm) { |
|
1723 InstanceKlass_OOP_ITERATE( \ |
|
1724 start_of_static_fields(), static_oop_field_size(), \ |
|
1725 PSParallelCompact::mark_and_push(cm, p), \ |
|
1726 assert_is_in) |
|
1727 } |
|
1728 #endif // SERIALGC |
|
1729 |
|
1730 void instanceKlass::adjust_static_fields() { |
|
1731 InstanceKlass_OOP_ITERATE( \ |
|
1732 start_of_static_fields(), static_oop_field_size(), \ |
|
1733 MarkSweep::adjust_pointer(p), \ |
|
1734 assert_nothing) |
|
1735 } |
|
1736 |
|
1737 #ifndef SERIALGC |
|
1738 void instanceKlass::update_static_fields() { |
|
1739 InstanceKlass_OOP_ITERATE( \ |
|
1740 start_of_static_fields(), static_oop_field_size(), \ |
|
1741 PSParallelCompact::adjust_pointer(p), \ |
|
1742 assert_nothing) |
|
1743 } |
|
1744 #endif // SERIALGC |
|
1745 |
|
1746 void instanceKlass::oop_follow_contents(oop obj) { |
1688 void instanceKlass::oop_follow_contents(oop obj) { |
1747 assert(obj != NULL, "can't follow the content of NULL object"); |
1689 assert(obj != NULL, "can't follow the content of NULL object"); |
1748 obj->follow_header(); |
1690 obj->follow_header(); |
1749 InstanceKlass_OOP_MAP_ITERATE( \ |
1691 InstanceKlass_OOP_MAP_ITERATE( \ |
1750 obj, \ |
1692 obj, \ |
1827 #ifndef SERIALGC |
1769 #ifndef SERIALGC |
1828 ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN) |
1770 ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN) |
1829 ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN) |
1771 ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN) |
1830 #endif // !SERIALGC |
1772 #endif // !SERIALGC |
1831 |
1773 |
1832 void instanceKlass::iterate_static_fields(OopClosure* closure) { |
|
1833 InstanceKlass_OOP_ITERATE( \ |
|
1834 start_of_static_fields(), static_oop_field_size(), \ |
|
1835 closure->do_oop(p), \ |
|
1836 assert_is_in_reserved) |
|
1837 } |
|
1838 |
|
1839 void instanceKlass::iterate_static_fields(OopClosure* closure, |
|
1840 MemRegion mr) { |
|
1841 InstanceKlass_BOUNDED_OOP_ITERATE( \ |
|
1842 start_of_static_fields(), static_oop_field_size(), \ |
|
1843 mr.start(), mr.end(), \ |
|
1844 (closure)->do_oop_v(p), \ |
|
1845 assert_is_in_closed_subset) |
|
1846 } |
|
1847 |
|
1848 int instanceKlass::oop_adjust_pointers(oop obj) { |
1774 int instanceKlass::oop_adjust_pointers(oop obj) { |
1849 int size = size_helper(); |
1775 int size = size_helper(); |
1850 InstanceKlass_OOP_MAP_ITERATE( \ |
1776 InstanceKlass_OOP_MAP_ITERATE( \ |
1851 obj, \ |
1777 obj, \ |
1852 MarkSweep::adjust_pointer(p), \ |
1778 MarkSweep::adjust_pointer(p), \ |
1871 PSParallelCompact::adjust_pointer(p), \ |
1797 PSParallelCompact::adjust_pointer(p), \ |
1872 assert_nothing) |
1798 assert_nothing) |
1873 return size_helper(); |
1799 return size_helper(); |
1874 } |
1800 } |
1875 |
1801 |
1876 void instanceKlass::push_static_fields(PSPromotionManager* pm) { |
|
1877 InstanceKlass_OOP_ITERATE( \ |
|
1878 start_of_static_fields(), static_oop_field_size(), \ |
|
1879 if (PSScavenge::should_scavenge(p)) { \ |
|
1880 pm->claim_or_forward_depth(p); \ |
|
1881 }, \ |
|
1882 assert_nothing ) |
|
1883 } |
|
1884 |
|
1885 void instanceKlass::copy_static_fields(ParCompactionManager* cm) { |
|
1886 InstanceKlass_OOP_ITERATE( \ |
|
1887 start_of_static_fields(), static_oop_field_size(), \ |
|
1888 PSParallelCompact::adjust_pointer(p), \ |
|
1889 assert_is_in) |
|
1890 } |
|
1891 #endif // SERIALGC |
1802 #endif // SERIALGC |
1892 |
1803 |
1893 // This klass is alive but the implementor link is not followed/updated. |
1804 // This klass is alive but the implementor link is not followed/updated. |
1894 // Subklass and sibling links are handled by Klass::follow_weak_klass_links |
1805 // Subklass and sibling links are handled by Klass::follow_weak_klass_links |
1895 |
1806 |
1999 |
1910 |
2000 void instanceKlass::set_source_debug_extension(Symbol* n) { |
1911 void instanceKlass::set_source_debug_extension(Symbol* n) { |
2001 _source_debug_extension = n; |
1912 _source_debug_extension = n; |
2002 if (_source_debug_extension != NULL) _source_debug_extension->increment_refcount(); |
1913 if (_source_debug_extension != NULL) _source_debug_extension->increment_refcount(); |
2003 } |
1914 } |
|
1915 |
|
1916 address instanceKlass::static_field_addr(int offset) { |
|
1917 return (address)(offset + instanceMirrorKlass::offset_of_static_fields() + (intptr_t)java_mirror()); |
|
1918 } |
|
1919 |
2004 |
1920 |
2005 const char* instanceKlass::signature_name() const { |
1921 const char* instanceKlass::signature_name() const { |
2006 const char* src = (const char*) (name()->as_C_string()); |
1922 const char* src = (const char*) (name()->as_C_string()); |
2007 const int src_length = (int)strlen(src); |
1923 const int src_length = (int)strlen(src); |
2008 char* dest = NEW_RESOURCE_ARRAY(char, src_length + 3); |
1924 char* dest = NEW_RESOURCE_ARRAY(char, src_length + 3); |
2397 if (!WizardMode) return; // that is enough |
2313 if (!WizardMode) return; // that is enough |
2398 } |
2314 } |
2399 } |
2315 } |
2400 |
2316 |
2401 st->print_cr(BULLET"---- fields (total size %d words):", oop_size(obj)); |
2317 st->print_cr(BULLET"---- fields (total size %d words):", oop_size(obj)); |
2402 FieldPrinter print_nonstatic_field(st, obj); |
2318 FieldPrinter print_field(st, obj); |
2403 do_nonstatic_fields(&print_nonstatic_field); |
2319 do_nonstatic_fields(&print_field); |
2404 |
2320 |
2405 if (as_klassOop() == SystemDictionary::Class_klass()) { |
2321 if (as_klassOop() == SystemDictionary::Class_klass()) { |
2406 st->print(BULLET"signature: "); |
2322 st->print(BULLET"signature: "); |
2407 java_lang_Class::print_signature(obj, st); |
2323 java_lang_Class::print_signature(obj, st); |
2408 st->cr(); |
2324 st->cr(); |
2416 klassOop array_klass = java_lang_Class::array_klass(obj); |
2332 klassOop array_klass = java_lang_Class::array_klass(obj); |
2417 st->cr(); |
2333 st->cr(); |
2418 st->print(BULLET"fake entry for array: "); |
2334 st->print(BULLET"fake entry for array: "); |
2419 array_klass->print_value_on(st); |
2335 array_klass->print_value_on(st); |
2420 st->cr(); |
2336 st->cr(); |
|
2337 st->print_cr(BULLET"fake entry for oop_size: %d", java_lang_Class::oop_size(obj)); |
|
2338 st->print_cr(BULLET"fake entry for static_oop_field_count: %d", java_lang_Class::static_oop_field_count(obj)); |
|
2339 klassOop real_klass = java_lang_Class::as_klassOop(obj); |
|
2340 if (real_klass && real_klass->klass_part()->oop_is_instance()) { |
|
2341 instanceKlass::cast(real_klass)->do_local_static_fields(&print_field); |
|
2342 } |
2421 } else if (as_klassOop() == SystemDictionary::MethodType_klass()) { |
2343 } else if (as_klassOop() == SystemDictionary::MethodType_klass()) { |
2422 st->print(BULLET"signature: "); |
2344 st->print(BULLET"signature: "); |
2423 java_lang_invoke_MethodType::print_signature(obj, st); |
2345 java_lang_invoke_MethodType::print_signature(obj, st); |
2424 st->cr(); |
2346 st->cr(); |
2425 } |
2347 } |
2558 } |
2480 } |
2559 } |
2481 } |
2560 |
2482 |
2561 |
2483 |
2562 void JNIid::verify(klassOop holder) { |
2484 void JNIid::verify(klassOop holder) { |
2563 int first_field_offset = instanceKlass::cast(holder)->offset_of_static_fields(); |
2485 int first_field_offset = instanceMirrorKlass::offset_of_static_fields(); |
2564 int end_field_offset; |
2486 int end_field_offset; |
2565 end_field_offset = first_field_offset + (instanceKlass::cast(holder)->static_field_size() * wordSize); |
2487 end_field_offset = first_field_offset + (instanceKlass::cast(holder)->static_field_size() * wordSize); |
2566 |
2488 |
2567 JNIid* current = this; |
2489 JNIid* current = this; |
2568 while (current != NULL) { |
2490 while (current != NULL) { |