8340826: Should not send unload notification for scratch classes

Reviewed-by: sspitsyn, coleenp
This commit is contained in:
Leonid Mesnik 2024-09-27 15:02:01 +00:00
parent 25e892911d
commit 12de4fbce7
4 changed files with 17 additions and 2 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -227,6 +227,10 @@ void DependencyContext::remove_and_mark_for_deoptimization_all_dependents(Deopti
} }
#ifndef PRODUCT #ifndef PRODUCT
bool DependencyContext::is_empty() {
return dependencies() == nullptr;
}
void DependencyContext::print_dependent_nmethods(bool verbose) { void DependencyContext::print_dependent_nmethods(bool verbose) {
int idx = 0; int idx = 0;
for (nmethodBucket* b = dependencies_not_unloading(); b != nullptr; b = b->next_not_unloading()) { for (nmethodBucket* b = dependencies_not_unloading(); b != nullptr; b = b->next_not_unloading()) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -124,6 +124,7 @@ class DependencyContext : public StackObj {
#ifndef PRODUCT #ifndef PRODUCT
void print_dependent_nmethods(bool verbose); void print_dependent_nmethods(bool verbose);
bool is_empty();
#endif //PRODUCT #endif //PRODUCT
bool is_dependent_nmethod(nmethod* nm); bool is_dependent_nmethod(nmethod* nm);
}; };

View File

@ -484,6 +484,9 @@ static void do_primitives() {
static void do_unloading_klass(Klass* klass) { static void do_unloading_klass(Klass* klass) {
assert(klass != nullptr, "invariant"); assert(klass != nullptr, "invariant");
assert(_subsystem_callback != nullptr, "invariant"); assert(_subsystem_callback != nullptr, "invariant");
if (klass->is_instance_klass() && InstanceKlass::cast(klass)->is_scratch_class()) {
return;
}
if (JfrKlassUnloading::on_unload(klass)) { if (JfrKlassUnloading::on_unload(klass)) {
_subsystem_callback->do_artifact(klass); _subsystem_callback->do_artifact(klass);
} }

View File

@ -2721,6 +2721,13 @@ static void clear_all_breakpoints(Method* m) {
#endif #endif
void InstanceKlass::unload_class(InstanceKlass* ik) { void InstanceKlass::unload_class(InstanceKlass* ik) {
if (ik->is_scratch_class()) {
assert(ik->dependencies().is_empty(), "dependencies should be empty for scratch classes");
return;
}
assert(ik->is_loaded(), "class should be loaded " PTR_FORMAT, p2i(ik));
// Release dependencies. // Release dependencies.
ik->dependencies().remove_all_dependents(); ik->dependencies().remove_all_dependents();