From 7dbc9d0e1d97975522e265d8cd9e2dc7c4d4ce65 Mon Sep 17 00:00:00 2001 From: Vladimir Dvorak Date: Fri, 26 Jul 2024 23:29:08 +0200 Subject: [PATCH] JBR-7447 use new method for unregister nmethods in G1 caused by JBR-7219 ("Rebasing JBR21 on top of OpenJDK 21.0.4") and changes in G1 nmethods unregister --- .../share/prims/jvmtiEnhancedRedefineClasses.cpp | 11 ++++++----- .../share/prims/jvmtiEnhancedRedefineClasses.hpp | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp index 2fb8c9399b5d..482e7dce2140 100644 --- a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp +++ b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.cpp @@ -242,10 +242,10 @@ void VM_EnhancedRedefineClasses::mark_as_scavengable(nmethod* nm) { ScavengableNMethods::register_nmethod(nm); } -void VM_EnhancedRedefineClasses::unregister_nmethod_g1(nmethod* nm) { - // It should work not only for G1 but also for another GCs, but this way is safer now - Universe::heap()->unregister_nmethod(nm); -} +//void VM_EnhancedRedefineClasses::unregister_nmethod_g1(nmethod* nm) { +// // It should work not only for G1 but also for another GCs, but this way is safer now +// Universe::heap()->unregister_nmethod(nm); +//} void VM_EnhancedRedefineClasses::register_nmethod_g1(nmethod* nm) { // It should work not only for G1 but also for another GCs, but this way is safer now @@ -612,7 +612,8 @@ void VM_EnhancedRedefineClasses::doit() { if (UseG1GC) { // G1 holds references to nmethods in regions based on oops values. Since oops in nmethod can be changed in ChangePointers* closures // we unregister nmethods from G1 heap, then closures are processed (oops are changed) and finally we register nmethod to G1 again - CodeCache::nmethods_do(unregister_nmethod_g1); + // CodeCache::nmethods_do(unregister_nmethod_g1); + G1CollectedHeap::heap()->bulk_unregister_nmethods(); } else { #endif CodeCache::nmethods_do(mark_as_scavengable); diff --git a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.hpp b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.hpp index a457b457d261..b51a63af4ce5 100644 --- a/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.hpp +++ b/src/hotspot/share/prims/jvmtiEnhancedRedefineClasses.hpp @@ -126,7 +126,7 @@ class VM_EnhancedRedefineClasses: public VM_GC_Operation { void rollback(); static void mark_as_scavengable(nmethod* nm); - static void unregister_nmethod_g1(nmethod* nm); + //static void unregister_nmethod_g1(nmethod* nm); static void register_nmethod_g1(nmethod* nm); static void unpatch_bytecode(Method* method);