< prev index next >

src/hotspot/share/oops/method.cpp

Print this page
   1 /*
   2  * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


2163 }
2164 
2165 // Called when the class loader is unloaded to make all methods weak.
2166 void Method::clear_jmethod_ids(ClassLoaderData* loader_data) {
2167   loader_data->jmethod_ids()->clear_all_methods();
2168 }
2169 
2170 bool Method::has_method_vptr(const void* ptr) {
2171   Method m;
2172   // This assumes that the vtbl pointer is the first word of a C++ object.
2173   return dereference_vptr(&m) == dereference_vptr(ptr);
2174 }
2175 
2176 // Check that this pointer is valid by checking that the vtbl pointer matches
2177 bool Method::is_valid_method() const {
2178   if (this == NULL) {
2179     return false;
2180   } else if ((intptr_t(this) & (wordSize-1)) != 0) {
2181     // Quick sanity check on pointer.
2182     return false;
2183   } else if (MetaspaceShared::is_in_shared_space(this)) {
2184     return MetaspaceShared::is_valid_shared_method(this);
2185   } else if (Metaspace::contains_non_shared(this)) {
2186     return has_method_vptr((const void*)this);
2187   } else {
2188     return false;
2189   }
2190 }
2191 
2192 #ifndef PRODUCT
2193 void Method::print_jmethod_ids(ClassLoaderData* loader_data, outputStream* out) {
2194   out->print_cr("jni_method_id count = %d", loader_data->jmethod_ids()->count_methods());
2195 }
2196 #endif // PRODUCT
2197 
2198 
2199 // Printing
2200 
2201 #ifndef PRODUCT
2202 
2203 void Method::print_on(outputStream* st) const {


   1 /*
   2  * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


2163 }
2164 
2165 // Called when the class loader is unloaded to make all methods weak.
2166 void Method::clear_jmethod_ids(ClassLoaderData* loader_data) {
2167   loader_data->jmethod_ids()->clear_all_methods();
2168 }
2169 
2170 bool Method::has_method_vptr(const void* ptr) {
2171   Method m;
2172   // This assumes that the vtbl pointer is the first word of a C++ object.
2173   return dereference_vptr(&m) == dereference_vptr(ptr);
2174 }
2175 
2176 // Check that this pointer is valid by checking that the vtbl pointer matches
2177 bool Method::is_valid_method() const {
2178   if (this == NULL) {
2179     return false;
2180   } else if ((intptr_t(this) & (wordSize-1)) != 0) {
2181     // Quick sanity check on pointer.
2182     return false;
2183   } else if (this->is_shared()) {
2184     return MetaspaceShared::is_valid_shared_method(this);
2185   } else if (Metaspace::contains_non_shared(this)) {
2186     return has_method_vptr((const void*)this);
2187   } else {
2188     return false;
2189   }
2190 }
2191 
2192 #ifndef PRODUCT
2193 void Method::print_jmethod_ids(ClassLoaderData* loader_data, outputStream* out) {
2194   out->print_cr("jni_method_id count = %d", loader_data->jmethod_ids()->count_methods());
2195 }
2196 #endif // PRODUCT
2197 
2198 
2199 // Printing
2200 
2201 #ifndef PRODUCT
2202 
2203 void Method::print_on(outputStream* st) const {


< prev index next >