mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8207778: Add locking to ModuleEntry and PackageEntry tables
Restructure ClassLoaderDataGraph code to simplify using locks in SystemDictionary::do_unloading() Reviewed-by: lfoltan, coleenp
This commit is contained in:
parent
092e9e4f81
commit
83b2fb5b0d
7 changed files with 37 additions and 28 deletions
|
@ -1418,7 +1418,18 @@ bool ClassLoaderDataGraph::do_unloading(bool do_cleaning) {
|
|||
}
|
||||
|
||||
if (seen_dead_loader) {
|
||||
data = _head;
|
||||
JFR_ONLY(post_class_unload_events();)
|
||||
}
|
||||
|
||||
log_debug(class, loader, data)("do_unloading: loaders processed %u, loaders removed %u", loaders_processed, loaders_removed);
|
||||
|
||||
return seen_dead_loader;
|
||||
}
|
||||
|
||||
// There's at least one dead class loader. Purge refererences of healthy module
|
||||
// reads lists and package export lists to modules belonging to dead loaders.
|
||||
void ClassLoaderDataGraph::clean_module_and_package_info() {
|
||||
ClassLoaderData* data = _head;
|
||||
while (data != NULL) {
|
||||
// Remove entries in the dictionary of live class loader that have
|
||||
// initiated loading classes in a dead class loader.
|
||||
|
@ -1439,12 +1450,6 @@ bool ClassLoaderDataGraph::do_unloading(bool do_cleaning) {
|
|||
}
|
||||
data = data->next();
|
||||
}
|
||||
JFR_ONLY(post_class_unload_events();)
|
||||
}
|
||||
|
||||
log_debug(class, loader, data)("do_unloading: loaders processed %u, loaders removed %u", loaders_processed, loaders_removed);
|
||||
|
||||
return seen_dead_loader;
|
||||
}
|
||||
|
||||
void ClassLoaderDataGraph::purge() {
|
||||
|
|
|
@ -97,6 +97,7 @@ class ClassLoaderDataGraph : public AllStatic {
|
|||
|
||||
public:
|
||||
static ClassLoaderData* find_or_create(Handle class_loader);
|
||||
static void clean_module_and_package_info();
|
||||
static void purge();
|
||||
static void clear_claimed_marks();
|
||||
// oops do
|
||||
|
|
|
@ -65,7 +65,7 @@ void LoaderConstraintTable::free_entry(LoaderConstraintEntry *entry) {
|
|||
|
||||
LoaderConstraintEntry** LoaderConstraintTable::find_loader_constraint(
|
||||
Symbol* name, Handle loader) {
|
||||
|
||||
assert_lock_strong(SystemDictionary_lock);
|
||||
unsigned int hash = compute_hash(name);
|
||||
int index = hash_to_index(hash);
|
||||
LoaderConstraintEntry** pp = bucket_addr(index);
|
||||
|
@ -89,7 +89,7 @@ LoaderConstraintEntry** LoaderConstraintTable::find_loader_constraint(
|
|||
|
||||
|
||||
void LoaderConstraintTable::purge_loader_constraints() {
|
||||
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
|
||||
assert_locked_or_safepoint(SystemDictionary_lock);
|
||||
LogTarget(Info, class, loader, constraints) lt;
|
||||
// Remove unloaded entries from constraint table
|
||||
for (int index = 0; index < table_size(); index++) {
|
||||
|
|
|
@ -436,7 +436,7 @@ ModuleEntry* ModuleEntryTable::lookup_only(Symbol* name) {
|
|||
// Remove dead modules from all other alive modules' reads list.
|
||||
// This should only occur at class unloading.
|
||||
void ModuleEntryTable::purge_all_module_reads() {
|
||||
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
|
||||
assert_locked_or_safepoint(Module_lock);
|
||||
for (int i = 0; i < table_size(); i++) {
|
||||
for (ModuleEntry* entry = bucket(i);
|
||||
entry != NULL;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -302,7 +302,7 @@ bool PackageEntry::exported_pending_delete() const {
|
|||
|
||||
// Remove dead entries from all packages' exported list
|
||||
void PackageEntryTable::purge_all_package_exports() {
|
||||
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
|
||||
assert_locked_or_safepoint(Module_lock);
|
||||
for (int i = 0; i < table_size(); i++) {
|
||||
for (PackageEntry* entry = bucket(i);
|
||||
entry != NULL;
|
||||
|
|
|
@ -100,7 +100,7 @@ ResolutionErrorTable::ResolutionErrorTable(int table_size)
|
|||
// RedefineClasses support - remove matching entry of a
|
||||
// constant pool that is going away
|
||||
void ResolutionErrorTable::delete_entry(ConstantPool* c) {
|
||||
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
|
||||
assert_locked_or_safepoint(SystemDictionary_lock);
|
||||
for (int i = 0; i < table_size(); i++) {
|
||||
for (ResolutionErrorEntry** p = bucket_addr(i); *p != NULL; ) {
|
||||
ResolutionErrorEntry* entry = *p;
|
||||
|
@ -118,7 +118,7 @@ void ResolutionErrorTable::delete_entry(ConstantPool* c) {
|
|||
|
||||
// Remove unloaded entries from the table
|
||||
void ResolutionErrorTable::purge_resolution_errors() {
|
||||
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
|
||||
assert_locked_or_safepoint(SystemDictionary_lock);
|
||||
for (int i = 0; i < table_size(); i++) {
|
||||
for (ResolutionErrorEntry** p = bucket_addr(i); *p != NULL; ) {
|
||||
ResolutionErrorEntry* entry = *p;
|
||||
|
|
|
@ -1853,6 +1853,9 @@ bool SystemDictionary::do_unloading(GCTimer* gc_timer,
|
|||
|
||||
// First, mark for unload all ClassLoaderData referencing a dead class loader.
|
||||
unloading_occurred = ClassLoaderDataGraph::do_unloading(do_cleaning);
|
||||
if (unloading_occurred) {
|
||||
ClassLoaderDataGraph::clean_module_and_package_info();
|
||||
}
|
||||
}
|
||||
|
||||
if (unloading_occurred) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue