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