Created
April 16, 2025 23:02
-
-
Save JohnTortugo/95e95ca4855854c658ea7374c63dd456 to your computer and use it in GitHub Desktop.
Patched nmethod::purge to print JVMCI method names
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void nmethod::purge(bool free_code_cache_data, bool unregister_nmethod) { | |
assert(!free_code_cache_data, "must only call not freeing code cache data"); | |
MutexLocker ml(CodeCache_lock, Mutex::_no_safepoint_check_flag); | |
// completely deallocate this method | |
const char* name = method()->name()->as_C_string(); | |
const char* is_jvmci = ""; | |
const char* is_osr = is_osr_method() ? "osr" : ""; | |
const size_t code_cache_free_space = CodeCache::unallocated_capacity(CodeCache::get_code_blob_type(this))/1024; | |
if (is_compiled_by_jvmci()) { | |
name = jvmci_name(); | |
is_jvmci = "JVMCI compiled "; | |
} | |
Events::log_nmethod_flush(Thread::current(), "flushing %s nmethod " INTPTR_FORMAT, is_osr, p2i(this)); | |
log_debug(codecache)("Flushing nmethod %3d/" INTPTR_FORMAT ", is_osr=%d, is_cold=%d, gc_epoch=%llu, gc_cold_count=%llu. " | |
"CodeCache total blobs:" UINT32_FORMAT ", free space:" SIZE_FORMAT "Kb. " | |
"%s Method %s", | |
_compile_id, p2i(this), is_osr_method(), is_cold(), _gc_epoch, CodeCache::cold_gc_count(), | |
CodeCache::blob_count(), code_cache_free_space, | |
is_jvmci, name); | |
// We need to deallocate any ExceptionCache data. | |
// Note that we do not need to grab the nmethod lock for this, it | |
// better be thread safe if we're disposing of it! | |
ExceptionCache* ec = exception_cache(); | |
while(ec != nullptr) { | |
ExceptionCache* next = ec->next(); | |
delete ec; | |
ec = next; | |
} | |
if (unregister_nmethod) { | |
Universe::heap()->unregister_nmethod(this); | |
} | |
CodeCache::unregister_old_nmethod(this); | |
CodeBlob::purge(free_code_cache_data, unregister_nmethod); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The code above may need some adjustment depending on which JDK version you're trying to apply it.