53 #include "runtime/handles.inline.hpp" |
53 #include "runtime/handles.inline.hpp" |
54 #include "runtime/orderAccess.inline.hpp" |
54 #include "runtime/orderAccess.inline.hpp" |
55 #include "runtime/relocator.hpp" |
55 #include "runtime/relocator.hpp" |
56 #include "runtime/sharedRuntime.hpp" |
56 #include "runtime/sharedRuntime.hpp" |
57 #include "runtime/signature.hpp" |
57 #include "runtime/signature.hpp" |
|
58 #include "runtime/stubRoutines.hpp" |
58 #include "utilities/quickSort.hpp" |
59 #include "utilities/quickSort.hpp" |
59 #include "utilities/xmlstream.hpp" |
60 #include "utilities/xmlstream.hpp" |
60 |
61 |
61 // Implementation of Method |
62 // Implementation of Method |
62 |
63 |
2096 void Method::clear_jmethod_ids(ClassLoaderData* loader_data) { |
2097 void Method::clear_jmethod_ids(ClassLoaderData* loader_data) { |
2097 loader_data->jmethod_ids()->clear_all_methods(); |
2098 loader_data->jmethod_ids()->clear_all_methods(); |
2098 } |
2099 } |
2099 |
2100 |
2100 bool Method::has_method_vptr(const void* ptr) { |
2101 bool Method::has_method_vptr(const void* ptr) { |
|
2102 // Use SafeFetch to check if this is a valid pointer first |
|
2103 // This assumes that the vtbl pointer is the first word of a C++ object. |
|
2104 // This assumption is also in universe.cpp patch_klass_vtable |
|
2105 intptr_t this_vptr = SafeFetchN((intptr_t*)ptr, intptr_t(1)); |
|
2106 if (this_vptr == 1) { |
|
2107 return false; |
|
2108 } |
2101 Method m; |
2109 Method m; |
2102 // This assumes that the vtbl pointer is the first word of a C++ object. |
2110 return (intptr_t)dereference_vptr(&m) == this_vptr; |
2103 // This assumption is also in universe.cpp patch_klass_vtble |
|
2104 void* vtbl2 = dereference_vptr((const void*)&m); |
|
2105 void* this_vtbl = dereference_vptr(ptr); |
|
2106 return vtbl2 == this_vtbl; |
|
2107 } |
2111 } |
2108 |
2112 |
2109 // Check that this pointer is valid by checking that the vtbl pointer matches |
2113 // Check that this pointer is valid by checking that the vtbl pointer matches |
2110 bool Method::is_valid_method() const { |
2114 bool Method::is_valid_method() const { |
2111 if (this == NULL) { |
2115 if (this == NULL) { |
2112 return false; |
2116 return false; |
2113 } else if (!is_metaspace_object()) { |
2117 } |
|
2118 |
|
2119 // Quick sanity check on pointer. |
|
2120 if ((intptr_t(this) & (wordSize-1)) != 0) { |
2114 return false; |
2121 return false; |
2115 } else { |
2122 } |
2116 return has_method_vptr((const void*)this); |
2123 |
2117 } |
2124 return has_method_vptr(this); |
2118 } |
2125 } |
2119 |
2126 |
2120 #ifndef PRODUCT |
2127 #ifndef PRODUCT |
2121 void Method::print_jmethod_ids(ClassLoaderData* loader_data, outputStream* out) { |
2128 void Method::print_jmethod_ids(ClassLoaderData* loader_data, outputStream* out) { |
2122 out->print_cr("jni_method_id count = %d", loader_data->jmethod_ids()->count_methods()); |
2129 out->print_cr("jni_method_id count = %d", loader_data->jmethod_ids()->count_methods()); |