8214523: Fix nmethod asserts for concurrent nmethod unloading

Reviewed-by: coleenp, kvn
This commit is contained in:
Erik Österlund 2018-12-03 14:16:39 +01:00
parent fff6e05c96
commit 86a41aa926

View File

@ -1053,7 +1053,8 @@ void nmethod::make_unloaded() {
// 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 @@ void nmethod::make_unloaded() {
}
// 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::clear_speculation_log() {
}
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);