src/hotspot/share/classfile/classLoaderData.cpp
Index
Unified diffs
Context diffs
Sdiffs
Wdiffs
Patch
New
Old
Previous File
Next File
webrev Cdiff src/hotspot/share/classfile/classLoaderData.cpp
src/hotspot/share/classfile/classLoaderData.cpp
Print this page
*** 602,645 ****
return modules;
}
const int _boot_loader_dictionary_size = 1009;
const int _default_loader_dictionary_size = 107;
- const int _prime_array_size = 8; // array of primes for system dictionary size
- const int _average_depth_goal = 3; // goal for lookup length
- const int _primelist[_prime_array_size] = {107, 1009, 2017, 4049, 5051, 10103, 20201, 40423};
-
- // Calculate a "good" dictionary size based
- // on predicted or current loaded classes count.
- static int calculate_dictionary_size(int classcount) {
- int newsize = _primelist[0];
- if (classcount > 0 && !DumpSharedSpaces) {
- int index = 0;
- int desiredsize = classcount/_average_depth_goal;
- for (newsize = _primelist[index]; index < _prime_array_size -1;
- newsize = _primelist[++index]) {
- if (desiredsize <= newsize) {
- break;
- }
- }
- }
- return newsize;
- }
Dictionary* ClassLoaderData::create_dictionary() {
assert(!is_anonymous(), "anonymous class loader data do not have a dictionary");
int size;
if (_the_null_class_loader_data == NULL) {
size = _boot_loader_dictionary_size;
} else if (class_loader()->is_a(SystemDictionary::reflect_DelegatingClassLoader_klass())) {
size = 1; // there's only one class in relection class loader and no initiated classes
} else if (is_system_class_loader_data()) {
! size = calculate_dictionary_size(PredictedLoadedClassCount);
} else {
size = _default_loader_dictionary_size;
}
! return new Dictionary(this, size);
}
// Unloading support
oop ClassLoaderData::keep_alive_object() const {
assert_locked_or_safepoint(_metaspace_lock);
--- 602,632 ----
return modules;
}
const int _boot_loader_dictionary_size = 1009;
const int _default_loader_dictionary_size = 107;
Dictionary* ClassLoaderData::create_dictionary() {
assert(!is_anonymous(), "anonymous class loader data do not have a dictionary");
int size;
+ bool resizable = false;
if (_the_null_class_loader_data == NULL) {
size = _boot_loader_dictionary_size;
+ resizable = true;
} else if (class_loader()->is_a(SystemDictionary::reflect_DelegatingClassLoader_klass())) {
size = 1; // there's only one class in relection class loader and no initiated classes
} else if (is_system_class_loader_data()) {
! size = _boot_loader_dictionary_size;
! resizable = true;
} else {
size = _default_loader_dictionary_size;
+ resizable = true;
+ }
+ if (!DynamicallyResizeSystemDictionaries || DumpSharedSpaces || UseSharedSpaces) {
+ resizable = false;
}
! return new Dictionary(this, size, resizable);
}
// Unloading support
oop ClassLoaderData::keep_alive_object() const {
assert_locked_or_safepoint(_metaspace_lock);
*** 1323,1332 ****
--- 1310,1332 ----
Metaspace::purge();
set_metaspace_oom(false);
}
}
+ int ClassLoaderDataGraph::resize_if_needed() {
+ assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!");
+ int resized = 0;
+ if (Dictionary::does_any_dictionary_needs_resizing()) {
+ FOR_ALL_DICTIONARY(cld) {
+ if (cld->dictionary()->resize_if_needed()) {
+ resized++;
+ }
+ }
+ }
+ return resized;
+ }
+
void ClassLoaderDataGraph::post_class_unload_events() {
#if INCLUDE_TRACE
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!");
if (Tracing::enabled()) {
if (Tracing::is_event_enabled(TraceClassUnloadEvent)) {
src/hotspot/share/classfile/classLoaderData.cpp
Index
Unified diffs
Context diffs
Sdiffs
Wdiffs
Patch
New
Old
Previous File
Next File