8232112: MDO extra_data_lock leaks during class unloading

Call the MDO destructor during class unloading.

Reviewed-by: dholmes, eosterlund
This commit is contained in:
Coleen Phillimore 2019-10-17 07:35:22 -04:00
parent d8c6516c92
commit 86fdbc0f85
4 changed files with 21 additions and 6 deletions

View file

@ -2497,10 +2497,18 @@ void InstanceKlass::unload_class(InstanceKlass* ik) {
#endif
}
static void method_release_C_heap_structures(Method* m) {
m->release_C_heap_structures();
}
void InstanceKlass::release_C_heap_structures(InstanceKlass* ik) {
// Clean up C heap
ik->release_C_heap_structures();
ik->constants()->release_C_heap_structures();
// Deallocate and call destructors for MDO mutexes
ik->methods_do(method_release_C_heap_structures);
}
void InstanceKlass::release_C_heap_structures() {

View file

@ -118,11 +118,6 @@ Method::Method(ConstMethod* xconst, AccessFlags access_flags) {
void Method::deallocate_contents(ClassLoaderData* loader_data) {
MetadataFactory::free_metadata(loader_data, constMethod());
set_constMethod(NULL);
#if INCLUDE_JVMCI
if (method_data()) {
FailedSpeculation::free_failed_speculations(method_data()->get_failed_speculations_address());
}
#endif
MetadataFactory::free_metadata(loader_data, method_data());
set_method_data(NULL);
MetadataFactory::free_metadata(loader_data, method_counters());
@ -131,6 +126,16 @@ void Method::deallocate_contents(ClassLoaderData* loader_data) {
if (code() != NULL) _code = NULL;
}
void Method::release_C_heap_structures() {
if (method_data()) {
#if INCLUDE_JVMCI
FailedSpeculation::free_failed_speculations(method_data()->get_failed_speculations_address());
#endif
// Destroy MethodData
method_data()->~MethodData();
}
}
address Method::get_i2c_entry() {
assert(adapter() != NULL, "must have");
return adapter()->get_i2c_entry();

View file

@ -1006,6 +1006,8 @@ public:
// Deallocation function for redefine classes or if an error occurs
void deallocate_contents(ClassLoaderData* loader_data);
void release_C_heap_structures();
Method* get_new_method() const {
InstanceKlass* holder = method_holder();
Method* new_method = holder->method_with_idnum(orig_method_idnum());

View file

@ -2445,7 +2445,7 @@ public:
virtual void metaspace_pointers_do(MetaspaceClosure* iter);
virtual MetaspaceObj::Type type() const { return MethodDataType; }
// Deallocation support - no pointer fields to deallocate
// Deallocation support - no metaspace pointer fields to deallocate
void deallocate_contents(ClassLoaderData* loader_data) {}
// GC support