< prev index next >

src/hotspot/share/code/nmethod.cpp

Print this page
rev 54589 : 8219586: CodeHeap State Analytics processes dead nmethods
Reviewed-by:

*** 843,852 **** --- 843,870 ---- } #undef LOG_OFFSET + // Iterating over all nmethods, e.g. with the help of CodeCache::nmethods_do(fun) was found + // to not be inherently safe. There is a chance that fields are seen which are not properly + // initialized. This happens despite the fact that nmethods_do() asserts the CodeCache_lock + // to be held. + // To bundle knowledge about necessary checks in one place, this function was introduced. + // It is not claimed that these checks are sufficient, but they were found to be necessary. + bool nmethod::access_is_safe(nmethod* nm) { + Method* method = (nm == NULL) ? NULL : nm->method(); // nm->method() may be uninitialized, i.e. != NULL, but invalid + return (nm != NULL) && (method != NULL) && + nm->is_alive() && !nm->is_not_installed() && + os::is_readable_pointer(method) && + os::is_readable_pointer(method->constMethod()) && + os::is_readable_pointer(method->constants()) && + (method->signature() != NULL) && + os::is_readable_pointer(method->signature()); + } + + // Print out more verbose output usually for a newly created nmethod. void nmethod::print_on(outputStream* st, const char* msg) const { if (st != NULL) { ttyLocker ttyl; if (WizardMode) {
< prev index next >