Mercurial > hg > graal-jvmci-8
comparison src/share/vm/oops/method.cpp @ 24094:9b69cec6d01b
Merge with jdk8u121-b13
author | Gilles Duboscq <gilles.m.duboscq@oracle.com> |
---|---|
date | Mon, 06 Feb 2017 17:18:57 +0100 |
parents | f13e777eb255 d18eb5b5a3d6 |
children |
comparison
equal
deleted
inserted
replaced
23997:9a740aa0d87b | 24094:9b69cec6d01b |
---|---|
109 } | 109 } |
110 | 110 |
111 // Release Method*. The nmethod will be gone when we get here because | 111 // Release Method*. The nmethod will be gone when we get here because |
112 // we've walked the code cache. | 112 // we've walked the code cache. |
113 void Method::deallocate_contents(ClassLoaderData* loader_data) { | 113 void Method::deallocate_contents(ClassLoaderData* loader_data) { |
114 clear_jmethod_id(loader_data); | |
114 MetadataFactory::free_metadata(loader_data, constMethod()); | 115 MetadataFactory::free_metadata(loader_data, constMethod()); |
115 set_constMethod(NULL); | 116 set_constMethod(NULL); |
116 MetadataFactory::free_metadata(loader_data, method_data()); | 117 MetadataFactory::free_metadata(loader_data, method_data()); |
117 set_method_data(NULL); | 118 set_method_data(NULL); |
118 MetadataFactory::free_metadata(loader_data, method_counters()); | 119 MetadataFactory::free_metadata(loader_data, method_counters()); |
1798 #ifdef ASSERT | 1799 #ifdef ASSERT |
1799 assert(contains(m), "should be a methodID"); | 1800 assert(contains(m), "should be a methodID"); |
1800 #endif // ASSERT | 1801 #endif // ASSERT |
1801 *m = _free_method; | 1802 *m = _free_method; |
1802 } | 1803 } |
1804 void clear_method(Method* m) { | |
1805 for (JNIMethodBlock* b = this; b != NULL; b = b->_next) { | |
1806 for (int i = 0; i < number_of_methods; i++) { | |
1807 if (b->_methods[i] == m) { | |
1808 b->_methods[i] = NULL; | |
1809 return; | |
1810 } | |
1811 } | |
1812 } | |
1813 // not found | |
1814 } | |
1803 | 1815 |
1804 // During class unloading the methods are cleared, which is different | 1816 // During class unloading the methods are cleared, which is different |
1805 // than freed. | 1817 // than freed. |
1806 void clear_all_methods() { | 1818 void clear_all_methods() { |
1807 for (JNIMethodBlock* b = this; b != NULL; b = b->_next) { | 1819 for (JNIMethodBlock* b = this; b != NULL; b = b->_next) { |
1808 for (int i = 0; i< number_of_methods; i++) { | 1820 for (int i = 0; i< number_of_methods; i++) { |
1809 _methods[i] = NULL; | 1821 b->_methods[i] = NULL; |
1810 } | 1822 } |
1811 } | 1823 } |
1812 } | 1824 } |
1813 #ifndef PRODUCT | 1825 #ifndef PRODUCT |
1814 int count_methods() { | 1826 int count_methods() { |
1815 // count all allocated methods | 1827 // count all allocated methods |
1816 int count = 0; | 1828 int count = 0; |
1817 for (JNIMethodBlock* b = this; b != NULL; b = b->_next) { | 1829 for (JNIMethodBlock* b = this; b != NULL; b = b->_next) { |
1818 for (int i = 0; i< number_of_methods; i++) { | 1830 for (int i = 0; i< number_of_methods; i++) { |
1819 if (_methods[i] != _free_method) count++; | 1831 if (b->_methods[i] != _free_method) count++; |
1820 } | 1832 } |
1821 } | 1833 } |
1822 return count; | 1834 return count; |
1823 } | 1835 } |
1824 #endif // PRODUCT | 1836 #endif // PRODUCT |
1870 *((Method**)jmid) = new_method; | 1882 *((Method**)jmid) = new_method; |
1871 } | 1883 } |
1872 | 1884 |
1873 bool Method::is_method_id(jmethodID mid) { | 1885 bool Method::is_method_id(jmethodID mid) { |
1874 Method* m = resolve_jmethod_id(mid); | 1886 Method* m = resolve_jmethod_id(mid); |
1875 assert(m != NULL, "should be called with non-null method"); | 1887 if (m == NULL) { |
1888 return false; | |
1889 } | |
1876 InstanceKlass* ik = m->method_holder(); | 1890 InstanceKlass* ik = m->method_holder(); |
1891 if (ik == NULL) { | |
1892 return false; | |
1893 } | |
1877 ClassLoaderData* cld = ik->class_loader_data(); | 1894 ClassLoaderData* cld = ik->class_loader_data(); |
1878 if (cld->jmethod_ids() == NULL) return false; | 1895 if (cld->jmethod_ids() == NULL) return false; |
1879 return (cld->jmethod_ids()->contains((Method**)mid)); | 1896 return (cld->jmethod_ids()->contains((Method**)mid)); |
1880 } | 1897 } |
1881 | 1898 |
1882 Method* Method::checked_resolve_jmethod_id(jmethodID mid) { | 1899 Method* Method::checked_resolve_jmethod_id(jmethodID mid) { |
1883 if (mid == NULL) return NULL; | 1900 if (mid == NULL) return NULL; |
1901 if (!Method::is_method_id(mid)) { | |
1902 return NULL; | |
1903 } | |
1884 Method* o = resolve_jmethod_id(mid); | 1904 Method* o = resolve_jmethod_id(mid); |
1885 if (o == NULL || o == JNIMethodBlock::_free_method || !((Metadata*)o)->is_method()) { | 1905 if (o == NULL || o == JNIMethodBlock::_free_method || !((Metadata*)o)->is_method()) { |
1886 return NULL; | 1906 return NULL; |
1887 } | 1907 } |
1888 return o; | 1908 return o; |
1895 | 1915 |
1896 bool succeeded = _access_flags.set_on_stack(value); | 1916 bool succeeded = _access_flags.set_on_stack(value); |
1897 if (value && succeeded) { | 1917 if (value && succeeded) { |
1898 MetadataOnStackMark::record(this, Thread::current()); | 1918 MetadataOnStackMark::record(this, Thread::current()); |
1899 } | 1919 } |
1920 } | |
1921 | |
1922 void Method::clear_jmethod_id(ClassLoaderData* loader_data) { | |
1923 loader_data->jmethod_ids()->clear_method(this); | |
1900 } | 1924 } |
1901 | 1925 |
1902 // Called when the class loader is unloaded to make all methods weak. | 1926 // Called when the class loader is unloaded to make all methods weak. |
1903 void Method::clear_jmethod_ids(ClassLoaderData* loader_data) { | 1927 void Method::clear_jmethod_ids(ClassLoaderData* loader_data) { |
1904 loader_data->jmethod_ids()->clear_all_methods(); | 1928 loader_data->jmethod_ids()->clear_all_methods(); |