comparison src/share/vm/oops/method.cpp @ 17935:7384f6a12fc1

8038212: Method::is_valid_method() check has performance regression impact for stackwalking Summary: Only prune metaspace virtual spaces at safepoint so walking them is safe outside a safepoint. Reviewed-by: mgerdin, mgronlun, hseigel, stefank
author coleenp
date Thu, 15 May 2014 18:23:26 -0400
parents 9428a0b94204
children 78bbf4d43a14
comparison
equal deleted inserted replaced
17934:366c198c896d 17935:7384f6a12fc1
1871 // Called when the class loader is unloaded to make all methods weak. 1871 // Called when the class loader is unloaded to make all methods weak.
1872 void Method::clear_jmethod_ids(ClassLoaderData* loader_data) { 1872 void Method::clear_jmethod_ids(ClassLoaderData* loader_data) {
1873 loader_data->jmethod_ids()->clear_all_methods(); 1873 loader_data->jmethod_ids()->clear_all_methods();
1874 } 1874 }
1875 1875
1876 bool Method::has_method_vptr(const void* ptr) {
1877 Method m;
1878 // This assumes that the vtbl pointer is the first word of a C++ object.
1879 // This assumption is also in universe.cpp patch_klass_vtble
1880 void* vtbl2 = dereference_vptr((const void*)&m);
1881 void* this_vtbl = dereference_vptr(ptr);
1882 return vtbl2 == this_vtbl;
1883 }
1876 1884
1877 // Check that this pointer is valid by checking that the vtbl pointer matches 1885 // Check that this pointer is valid by checking that the vtbl pointer matches
1878 bool Method::is_valid_method() const { 1886 bool Method::is_valid_method() const {
1879 if (this == NULL) { 1887 if (this == NULL) {
1880 return false; 1888 return false;
1881 } else if (!is_metaspace_object()) { 1889 } else if (!is_metaspace_object()) {
1882 return false; 1890 return false;
1883 } else { 1891 } else {
1884 Method m; 1892 return has_method_vptr((const void*)this);
1885 // This assumes that the vtbl pointer is the first word of a C++ object.
1886 // This assumption is also in universe.cpp patch_klass_vtble
1887 void* vtbl2 = dereference_vptr((void*)&m);
1888 void* this_vtbl = dereference_vptr((void*)this);
1889 return vtbl2 == this_vtbl;
1890 } 1893 }
1891 } 1894 }
1892 1895
1893 #ifndef PRODUCT 1896 #ifndef PRODUCT
1894 void Method::print_jmethod_ids(ClassLoaderData* loader_data, outputStream* out) { 1897 void Method::print_jmethod_ids(ClassLoaderData* loader_data, outputStream* out) {