2135 2136 Method* Method::checked_resolve_jmethod_id(jmethodID mid) { 2137 if (mid == NULL) return NULL; 2138 Method* o = resolve_jmethod_id(mid); 2139 if (o == NULL || o == JNIMethodBlock::_free_method || !((Metadata*)o)->is_method()) { 2140 return NULL; 2141 } 2142 return o; 2143 }; 2144 2145 void Method::set_on_stack(const bool value) { 2146 // Set both the method itself and its constant pool. The constant pool 2147 // on stack means some method referring to it is also on the stack. 2148 constants()->set_on_stack(value); 2149 2150 bool already_set = on_stack(); 2151 _access_flags.set_on_stack(value); 2152 if (value && !already_set) { 2153 MetadataOnStackMark::record(this); 2154 } 2155 } 2156 2157 // Called when the class loader is unloaded to make all methods weak. 2158 void Method::clear_jmethod_ids(ClassLoaderData* loader_data) { 2159 loader_data->jmethod_ids()->clear_all_methods(); 2160 } 2161 2162 bool Method::has_method_vptr(const void* ptr) { 2163 Method m; 2164 // This assumes that the vtbl pointer is the first word of a C++ object. 2165 return dereference_vptr(&m) == dereference_vptr(ptr); 2166 } 2167 2168 // Check that this pointer is valid by checking that the vtbl pointer matches 2169 bool Method::is_valid_method(const Method* m) { 2170 if (m == NULL) { 2171 return false; 2172 } else if ((intptr_t(m) & (wordSize-1)) != 0) { 2173 // Quick sanity check on pointer. 2174 return false; | 2135 2136 Method* Method::checked_resolve_jmethod_id(jmethodID mid) { 2137 if (mid == NULL) return NULL; 2138 Method* o = resolve_jmethod_id(mid); 2139 if (o == NULL || o == JNIMethodBlock::_free_method || !((Metadata*)o)->is_method()) { 2140 return NULL; 2141 } 2142 return o; 2143 }; 2144 2145 void Method::set_on_stack(const bool value) { 2146 // Set both the method itself and its constant pool. The constant pool 2147 // on stack means some method referring to it is also on the stack. 2148 constants()->set_on_stack(value); 2149 2150 bool already_set = on_stack(); 2151 _access_flags.set_on_stack(value); 2152 if (value && !already_set) { 2153 MetadataOnStackMark::record(this); 2154 } 2155 assert(!value || !is_old() || is_obsolete() || is_running_emcp(), 2156 "emcp methods cannot run after emcp bit is cleared"); 2157 } 2158 2159 // Called when the class loader is unloaded to make all methods weak. 2160 void Method::clear_jmethod_ids(ClassLoaderData* loader_data) { 2161 loader_data->jmethod_ids()->clear_all_methods(); 2162 } 2163 2164 bool Method::has_method_vptr(const void* ptr) { 2165 Method m; 2166 // This assumes that the vtbl pointer is the first word of a C++ object. 2167 return dereference_vptr(&m) == dereference_vptr(ptr); 2168 } 2169 2170 // Check that this pointer is valid by checking that the vtbl pointer matches 2171 bool Method::is_valid_method(const Method* m) { 2172 if (m == NULL) { 2173 return false; 2174 } else if ((intptr_t(m) & (wordSize-1)) != 0) { 2175 // Quick sanity check on pointer. 2176 return false; |