8214523: Fix nmethod asserts for concurrent nmethod unloading
Reviewed-by: coleenp, kvn
--- a/src/hotspot/share/code/nmethod.cpp Mon Dec 03 14:52:49 2018 +0100
+++ b/src/hotspot/share/code/nmethod.cpp Mon Dec 03 14:16:39 2018 +0100
@@ -1053,7 +1053,8 @@
// recorded in instanceKlasses get flushed.
// Since this work is being done during a GC, defer deleting dependencies from the
// InstanceKlass.
- assert(Universe::heap()->is_gc_active(), "should only be called during gc");
+ assert(Universe::heap()->is_gc_active() || Thread::current()->is_ConcurrentGC_thread(),
+ "should only be called during gc");
flush_dependencies(/*delete_immediately*/false);
// Break cycle between nmethod & method
@@ -1095,7 +1096,8 @@
}
// Make the class unloaded - i.e., change state and notify sweeper
- assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
+ assert(SafepointSynchronize::is_at_safepoint() || Thread::current()->is_ConcurrentGC_thread(),
+ "must be at safepoint");
// Unregister must be done before the state change
Universe::heap()->unregister_nmethod(this);
@@ -2923,6 +2925,10 @@
}
void nmethod::maybe_invalidate_installed_code() {
+ if (!is_compiled_by_jvmci()) {
+ return;
+ }
+
assert(Patching_lock->is_locked() ||
SafepointSynchronize::is_at_safepoint(), "should be performed under a lock for consistency");
oop installed_code = JNIHandles::resolve(_jvmci_installed_code);