Skip to content

Commit b47438c

Browse files
committed
8292068: Convert ModuleEntryTable into ResourceHashtable
Reviewed-by: iklam, lfoltan
1 parent 543163a commit b47438c

File tree

8 files changed

+185
-259
lines changed

8 files changed

+185
-259
lines changed

src/hotspot/share/classfile/classLoaderData.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -400,13 +400,7 @@ void ClassLoaderData::modules_do(void f(ModuleEntry*)) {
400400
f(_unnamed_module);
401401
}
402402
if (_modules != NULL) {
403-
for (int i = 0; i < _modules->table_size(); i++) {
404-
for (ModuleEntry* entry = _modules->bucket(i);
405-
entry != NULL;
406-
entry = entry->next()) {
407-
f(entry);
408-
}
409-
}
403+
_modules->modules_do(f);
410404
}
411405
}
412406

@@ -592,7 +586,7 @@ ModuleEntryTable* ClassLoaderData::modules() {
592586
MutexLocker m1(Module_lock);
593587
// Check if _modules got allocated while we were waiting for this lock.
594588
if ((modules = _modules) == NULL) {
595-
modules = new ModuleEntryTable(ModuleEntryTable::_moduletable_entry_size);
589+
modules = new ModuleEntryTable();
596590

597591
{
598592
MutexLocker m1(metaspace_lock(), Mutex::_no_safepoint_check_flag);
@@ -715,7 +709,7 @@ ClassLoaderData::~ClassLoaderData() {
715709
}
716710

717711
if (_unnamed_module != NULL) {
718-
_unnamed_module->delete_unnamed_module();
712+
delete _unnamed_module;
719713
_unnamed_module = NULL;
720714
}
721715

@@ -1040,6 +1034,10 @@ void ClassLoaderData::verify() {
10401034
k->verify();
10411035
assert(k != k->next_link(), "no loops!");
10421036
}
1037+
1038+
if (_modules != NULL) {
1039+
_modules->verify();
1040+
}
10431041
}
10441042

10451043
bool ClassLoaderData::contains_klass(Klass* klass) {

src/hotspot/share/classfile/classLoaderExt.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -81,17 +81,22 @@ void ClassLoaderExt::setup_app_search_path(JavaThread* current) {
8181

8282
void ClassLoaderExt::process_module_table(JavaThread* current, ModuleEntryTable* met) {
8383
ResourceMark rm(current);
84-
for (int i = 0; i < met->table_size(); i++) {
85-
for (ModuleEntry* m = met->bucket(i); m != NULL;) {
84+
class Process : public ModuleClosure {
85+
JavaThread* _current;
86+
public:
87+
Process(JavaThread* current) : _current(current) {}
88+
void do_module(ModuleEntry* m) {
8689
char* path = m->location()->as_C_string();
8790
if (strncmp(path, "file:", 5) == 0) {
8891
path = ClassLoader::skip_uri_protocol(path);
89-
ClassLoader::setup_module_search_path(current, path);
92+
ClassLoader::setup_module_search_path(_current, path);
9093
}
91-
m = m->next();
9294
}
93-
}
95+
};
96+
Process process(current);
97+
met->modules_do(&process);
9498
}
99+
95100
void ClassLoaderExt::setup_module_paths(JavaThread* current) {
96101
Arguments::assert_is_dumping_archive();
97102
_app_module_paths_start_index = ClassLoader::num_boot_classpath_entries() +

0 commit comments

Comments
 (0)