8026985: Rewrite SystemDictionary::classes_do and Dictionary::classes_do to use KlassClosure

Actually remove unused functions like classes_do and methods_do.

Reviewed-by: iveresov, sspitsyn, dholmes
This commit is contained in:
Coleen Phillimore 2017-04-12 08:02:29 -04:00
parent 221d948b51
commit c52443f75b
17 changed files with 19 additions and 200 deletions

View file

@ -247,7 +247,7 @@ void ClassLoaderData::classes_do(void f(Klass * const)) {
void ClassLoaderData::methods_do(void f(Method*)) { void ClassLoaderData::methods_do(void f(Method*)) {
// Lock-free access requires load_ptr_acquire // Lock-free access requires load_ptr_acquire
for (Klass* k = load_ptr_acquire(&_klasses); k != NULL; k = k->next_link()) { for (Klass* k = load_ptr_acquire(&_klasses); k != NULL; k = k->next_link()) {
if (k->is_instance_klass()) { if (k->is_instance_klass() && InstanceKlass::cast(k)->is_loaded()) {
InstanceKlass::cast(k)->methods_do(f); InstanceKlass::cast(k)->methods_do(f);
} }
} }

View file

@ -94,6 +94,10 @@ class ClassLoaderDataGraph : public AllStatic {
static void keep_alive_cld_do(CLDClosure* cl); static void keep_alive_cld_do(CLDClosure* cl);
static void always_strong_cld_do(CLDClosure* cl); static void always_strong_cld_do(CLDClosure* cl);
// klass do // klass do
// Walking classes through the ClassLoaderDataGraph include array classes. It also includes
// classes that are allocated but not loaded, classes that have errors, and scratch classes
// for redefinition. These classes are removed during the next class unloading.
// Walking the ClassLoaderDataGraph also includes anonymous classes.
static void classes_do(KlassClosure* klass_closure); static void classes_do(KlassClosure* klass_closure);
static void classes_do(void f(Klass* const)); static void classes_do(void f(Klass* const));
static void methods_do(void f(Method*)); static void methods_do(void f(Method*));

View file

@ -266,23 +266,6 @@ void Dictionary::always_strong_oops_do(OopClosure* blk) {
_pd_cache_table->always_strong_oops_do(blk); _pd_cache_table->always_strong_oops_do(blk);
} }
void Dictionary::always_strong_classes_do(KlassClosure* closure) {
// Follow all system classes and temporary placeholders in dictionary
for (int index = 0; index < table_size(); index++) {
for (DictionaryEntry* probe = bucket(index);
probe != NULL;
probe = probe->next()) {
Klass* e = probe->klass();
ClassLoaderData* loader_data = probe->loader_data();
if (is_strongly_reachable(loader_data, e)) {
closure->do_klass(e);
}
}
}
}
// Just the classes from defining class loaders // Just the classes from defining class loaders
void Dictionary::classes_do(void f(Klass*)) { void Dictionary::classes_do(void f(Klass*)) {
for (int index = 0; index < table_size(); index++) { for (int index = 0; index < table_size(); index++) {
@ -331,20 +314,6 @@ void Dictionary::oops_do(OopClosure* f) {
_pd_cache_table->oops_do(f); _pd_cache_table->oops_do(f);
} }
void Dictionary::methods_do(void f(Method*)) {
for (int index = 0; index < table_size(); index++) {
for (DictionaryEntry* probe = bucket(index);
probe != NULL;
probe = probe->next()) {
Klass* k = probe->klass();
if (probe->loader_data() == k->class_loader_data()) {
// only take klass is we have the entry with the defining class loader
InstanceKlass::cast(k)->methods_do(f);
}
}
}
}
void Dictionary::unlink(BoolObjectClosure* is_alive) { void Dictionary::unlink(BoolObjectClosure* is_alive) {
// Only the protection domain cache table may contain references to the heap // Only the protection domain cache table may contain references to the heap
// that need to be unlinked. // that need to be unlinked.
@ -651,25 +620,6 @@ ProtectionDomainCacheEntry* ProtectionDomainCacheTable::add_entry(int index, uns
return p; return p;
} }
void ProtectionDomainCacheTable::free(ProtectionDomainCacheEntry* to_delete) {
unsigned int hash = compute_hash(Handle(Thread::current(), to_delete->protection_domain()));
int index = hash_to_index(hash);
ProtectionDomainCacheEntry** p = bucket_addr(index);
ProtectionDomainCacheEntry* entry = bucket(index);
while (true) {
assert(entry != NULL, "sanity");
if (entry == to_delete) {
*p = entry->next();
Hashtable<oop, mtClass>::free_entry(entry);
break;
} else {
p = entry->next_addr();
entry = *p;
}
}
}
SymbolPropertyTable::SymbolPropertyTable(int table_size) SymbolPropertyTable::SymbolPropertyTable(int table_size)
: Hashtable<Symbol*, mtSymbol>(table_size, sizeof(SymbolPropertyEntry)) : Hashtable<Symbol*, mtSymbol>(table_size, sizeof(SymbolPropertyEntry))

View file

@ -75,8 +75,6 @@ public:
DictionaryEntry* new_entry(unsigned int hash, InstanceKlass* klass, ClassLoaderData* loader_data); DictionaryEntry* new_entry(unsigned int hash, InstanceKlass* klass, ClassLoaderData* loader_data);
DictionaryEntry* new_entry();
void free_entry(DictionaryEntry* entry); void free_entry(DictionaryEntry* entry);
void add_klass(Symbol* class_name, ClassLoaderData* loader_data, InstanceKlass* obj); void add_klass(Symbol* class_name, ClassLoaderData* loader_data, InstanceKlass* obj);
@ -94,14 +92,10 @@ public:
void always_strong_oops_do(OopClosure* blk); void always_strong_oops_do(OopClosure* blk);
void roots_oops_do(OopClosure* strong, OopClosure* weak); void roots_oops_do(OopClosure* strong, OopClosure* weak);
void always_strong_classes_do(KlassClosure* closure);
void classes_do(void f(Klass*)); void classes_do(void f(Klass*));
void classes_do(void f(Klass*, TRAPS), TRAPS); void classes_do(void f(Klass*, TRAPS), TRAPS);
void classes_do(void f(Klass*, ClassLoaderData*)); void classes_do(void f(Klass*, ClassLoaderData*));
void methods_do(void f(Method*));
void unlink(BoolObjectClosure* is_alive); void unlink(BoolObjectClosure* is_alive);
void remove_classes_in_error_state(); void remove_classes_in_error_state();
@ -211,7 +205,6 @@ public:
ProtectionDomainCacheTable(int table_size); ProtectionDomainCacheTable(int table_size);
ProtectionDomainCacheEntry* get(Handle protection_domain); ProtectionDomainCacheEntry* get(Handle protection_domain);
void free(ProtectionDomainCacheEntry* entry);
void unlink(BoolObjectClosure* cl); void unlink(BoolObjectClosure* cl);
@ -278,7 +271,6 @@ class DictionaryEntry : public HashtableEntry<InstanceKlass*, mtClass> {
void add_protection_domain(Dictionary* dict, Handle protection_domain); void add_protection_domain(Dictionary* dict, Handle protection_domain);
InstanceKlass* klass() const { return (InstanceKlass*)literal(); } InstanceKlass* klass() const { return (InstanceKlass*)literal(); }
InstanceKlass** klass_addr() { return (InstanceKlass**)literal_addr(); }
DictionaryEntry* next() const { DictionaryEntry* next() const {
return (DictionaryEntry*)HashtableEntry<InstanceKlass*, mtClass>::next(); return (DictionaryEntry*)HashtableEntry<InstanceKlass*, mtClass>::next();
@ -294,8 +286,6 @@ class DictionaryEntry : public HashtableEntry<InstanceKlass*, mtClass> {
ProtectionDomainEntry* pd_set() const { return _pd_set; } ProtectionDomainEntry* pd_set() const { return _pd_set; }
void set_pd_set(ProtectionDomainEntry* pd_set) { _pd_set = pd_set; } void set_pd_set(ProtectionDomainEntry* pd_set) { _pd_set = pd_set; }
bool has_protection_domain() { return _pd_set != NULL; }
// Tells whether the initiating class' protection can access the this _klass // Tells whether the initiating class' protection can access the this _klass
bool is_valid_protection_domain(Handle protection_domain) { bool is_valid_protection_domain(Handle protection_domain) {
if (!ProtectionDomainVerification) return true; if (!ProtectionDomainVerification) return true;

View file

@ -57,19 +57,6 @@ void LoaderConstraintTable::free_entry(LoaderConstraintEntry *entry) {
Hashtable<InstanceKlass*, mtClass>::free_entry(entry); Hashtable<InstanceKlass*, mtClass>::free_entry(entry);
} }
// Enhanced Class Redefinition support
void LoaderConstraintTable::classes_do(KlassClosure* f) {
for (int index = 0; index < table_size(); index++) {
for (LoaderConstraintEntry* probe = bucket(index);
probe != NULL;
probe = probe->next()) {
if (probe->klass() != NULL) {
f->do_klass(probe->klass());
}
}
}
}
// The loaderConstraintTable must always be accessed with the // The loaderConstraintTable must always be accessed with the
// SystemDictionary lock held. This is true even for readers as // SystemDictionary lock held. This is true even for readers as
// entries in the table could be being dynamically resized. // entries in the table could be being dynamically resized.

View file

@ -61,9 +61,6 @@ public:
return (LoaderConstraintEntry**)Hashtable<InstanceKlass*, mtClass>::bucket_addr(i); return (LoaderConstraintEntry**)Hashtable<InstanceKlass*, mtClass>::bucket_addr(i);
} }
// Enhanced Class Redefinition support
void classes_do(KlassClosure* f);
// Check class loader constraints // Check class loader constraints
bool add_entry(Symbol* name, InstanceKlass* klass1, Handle loader1, bool add_entry(Symbol* name, InstanceKlass* klass1, Handle loader1,
InstanceKlass* klass2, Handle loader2); InstanceKlass* klass2, Handle loader2);

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2017, 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
@ -175,37 +175,6 @@ PlaceholderTable::PlaceholderTable(int table_size)
: TwoOopHashtable<Symbol*, mtClass>(table_size, sizeof(PlaceholderEntry)) { : TwoOopHashtable<Symbol*, mtClass>(table_size, sizeof(PlaceholderEntry)) {
} }
void PlaceholderTable::classes_do(KlassClosure* f) {
for (int index = 0; index < table_size(); index++) {
for (PlaceholderEntry* probe = bucket(index);
probe != NULL;
probe = probe->next()) {
probe->classes_do(f);
}
}
}
void PlaceholderEntry::classes_do(KlassClosure* closure) {
assert(klassname() != NULL, "should have a non-null klass");
if (_instanceKlass != NULL) {
closure->do_klass(instance_klass());
}
}
// do all entries in the placeholder table
void PlaceholderTable::entries_do(void f(Symbol*)) {
for (int index = 0; index < table_size(); index++) {
for (PlaceholderEntry* probe = bucket(index);
probe != NULL;
probe = probe->next()) {
f(probe->klassname());
}
}
}
#ifndef PRODUCT #ifndef PRODUCT
// Note, doesn't append a cr // Note, doesn't append a cr
void PlaceholderEntry::print() const { void PlaceholderEntry::print() const {

View file

@ -98,12 +98,6 @@ public:
Symbol* name, ClassLoaderData* loader_data, Symbol* name, ClassLoaderData* loader_data,
classloadAction action, Thread* thread); classloadAction action, Thread* thread);
// GC support.
void classes_do(KlassClosure* f);
// JVMTI support
void entries_do(void f(Symbol*));
#ifndef PRODUCT #ifndef PRODUCT
void print(); void print();
#endif #endif
@ -329,10 +323,6 @@ class PlaceholderEntry : public HashtableEntry<Symbol*, mtClass> {
return (actionToQueue(action) == NULL); return (actionToQueue(action) == NULL);
} }
// GC support
// Applies "f->do_oop" to all root oops in the placeholder table.
void classes_do(KlassClosure* closure);
// Print method doesn't append a cr // Print method doesn't append a cr
void print() const PRODUCT_RETURN; void print() const PRODUCT_RETURN;
void verify() const; void verify() const;

View file

@ -1885,14 +1885,6 @@ void SystemDictionary::always_strong_oops_do(OopClosure* blk) {
roots_oops_do(blk, NULL); roots_oops_do(blk, NULL);
} }
void SystemDictionary::always_strong_classes_do(KlassClosure* closure) {
// Follow all system classes and temporary placeholders in dictionary
dictionary()->always_strong_classes_do(closure);
// Placeholders. These represent classes we're actively loading.
placeholders()->classes_do(closure);
}
// Calculate a "good" systemdictionary size based // Calculate a "good" systemdictionary size based
// on predicted or current loaded classes count // on predicted or current loaded classes count
int SystemDictionary::calculate_systemdictionary_size(int classcount) { int SystemDictionary::calculate_systemdictionary_size(int classcount) {
@ -1974,31 +1966,6 @@ void SystemDictionary::oops_do(OopClosure* f) {
invoke_method_table()->oops_do(f); invoke_method_table()->oops_do(f);
} }
// Extended Class redefinition support.
// If one of these classes is replaced, we need to replace it in these places.
// KlassClosure::do_klass should take the address of a class but we can
// change that later.
void SystemDictionary::preloaded_classes_do(KlassClosure* f) {
for (int k = (int)FIRST_WKID; k < (int)WKID_LIMIT; k++) {
f->do_klass(_well_known_klasses[k]);
}
{
for (int i = 0; i < T_VOID+1; i++) {
if (_box_klasses[i] != NULL) {
assert(i >= T_BOOLEAN, "checking");
f->do_klass(_box_klasses[i]);
}
}
}
FilteredFieldsMap::classes_do(f);
}
void SystemDictionary::lazily_loaded_classes_do(KlassClosure* f) {
f->do_klass(_abstract_ownable_synchronizer_klass);
}
// Just the classes from defining class loaders // Just the classes from defining class loaders
// Don't iterate over placeholders // Don't iterate over placeholders
void SystemDictionary::classes_do(void f(Klass*)) { void SystemDictionary::classes_do(void f(Klass*)) {
@ -2018,12 +1985,10 @@ void SystemDictionary::classes_do(void f(Klass*, ClassLoaderData*)) {
dictionary()->classes_do(f); dictionary()->classes_do(f);
} }
void SystemDictionary::placeholders_do(void f(Symbol*)) {
placeholders()->entries_do(f);
}
void SystemDictionary::methods_do(void f(Method*)) { void SystemDictionary::methods_do(void f(Method*)) {
dictionary()->methods_do(f); // Walk methods in loaded classes
ClassLoaderDataGraph::methods_do(f);
// Walk method handle intrinsics
invoke_method_table()->methods_do(f); invoke_method_table()->methods_do(f);
} }

View file

@ -347,16 +347,14 @@ public:
TRAPS); TRAPS);
// Iterate over all klasses in dictionary // Iterate over all klasses in dictionary
// Just the classes from defining class loaders // Just the classes from defining class loaders
static void classes_do(void f(Klass*)); static void classes_do(void f(Klass*));
// Added for initialize_itable_for_klass to handle exceptions // Added for initialize_itable_for_klass to handle exceptions
static void classes_do(void f(Klass*, TRAPS), TRAPS); static void classes_do(void f(Klass*, TRAPS), TRAPS);
// All classes, and their class loaders // All classes, and their class loaders, including initiating class loaders
static void classes_do(void f(Klass*, ClassLoaderData*)); static void classes_do(void f(Klass*, ClassLoaderData*));
static void placeholders_do(void f(Symbol*)); // Iterate over all methods in all klasses
// Iterate over all methods in all klasses in dictionary
static void methods_do(void f(Method*)); static void methods_do(void f(Method*));
// Garbage collection support // Garbage collection support
@ -364,7 +362,6 @@ public:
// This method applies "blk->do_oop" to all the pointers to "system" // This method applies "blk->do_oop" to all the pointers to "system"
// classes and loaders. // classes and loaders.
static void always_strong_oops_do(OopClosure* blk); static void always_strong_oops_do(OopClosure* blk);
static void always_strong_classes_do(KlassClosure* closure);
// Unload (that is, break root links to) all unmarked classes and // Unload (that is, break root links to) all unmarked classes and
// loaders. Returns "true" iff something was unloaded. // loaders. Returns "true" iff something was unloaded.
@ -383,10 +380,6 @@ public:
// System loader lock // System loader lock
static oop system_loader_lock() { return _system_loader_lock_obj; } static oop system_loader_lock() { return _system_loader_lock_obj; }
protected:
// Extended Redefine classes support (tbi)
static void preloaded_classes_do(KlassClosure* f);
static void lazily_loaded_classes_do(KlassClosure* f);
public: public:
// Sharing support. // Sharing support.
static void reorder_dictionary(); static void reorder_dictionary();

View file

@ -62,11 +62,6 @@ class LatestMethodCache : public CHeapObj<mtClass> {
Method* get_method(); Method* get_method();
// Enhanced Class Redefinition support
void classes_do(void f(Klass*)) {
f(_klass);
}
// CDS support. Replace the klass in this with the archive version // CDS support. Replace the klass in this with the archive version
// could use this for Enhanced Class Redefinition also. // could use this for Enhanced Class Redefinition also.
void serialize(SerializeClosure* f) { void serialize(SerializeClosure* f) {

View file

@ -213,14 +213,6 @@ class JvmtiGetLoadedClassesClosure : public StackObj {
} }
} }
static void prim_array_increment_with_loader(Klass* array, ClassLoaderData* loader_data) {
JvmtiGetLoadedClassesClosure* that = JvmtiGetLoadedClassesClosure::get_this();
oop class_loader = loader_data->class_loader();
if (class_loader == JNIHandles::resolve(that->get_initiatingLoader())) {
that->set_count(that->get_count() + 1);
}
}
static void add_with_loader(Klass* k, ClassLoaderData* loader_data) { static void add_with_loader(Klass* k, ClassLoaderData* loader_data) {
JvmtiGetLoadedClassesClosure* that = JvmtiGetLoadedClassesClosure::get_this(); JvmtiGetLoadedClassesClosure* that = JvmtiGetLoadedClassesClosure::get_this();
if (that->available()) { if (that->available()) {

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2017, 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
@ -51,14 +51,6 @@ void PrivilegedElement::oops_do(OopClosure* f) {
} while(cur != NULL); } while(cur != NULL);
} }
void PrivilegedElement::classes_do(KlassClosure* f) {
PrivilegedElement *cur = this;
do {
f->do_klass(cur->_klass);
cur = cur->_next;
} while(cur != NULL);
}
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
#ifndef PRODUCT #ifndef PRODUCT

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2017, 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
@ -39,7 +39,6 @@ class PrivilegedElement VALUE_OBJ_CLASS_SPEC {
public: public:
void initialize(vframeStream* vf, oop context, PrivilegedElement* next, TRAPS); void initialize(vframeStream* vf, oop context, PrivilegedElement* next, TRAPS);
void oops_do(OopClosure* f); void oops_do(OopClosure* f);
void classes_do(KlassClosure* f);
intptr_t* frame_id() const { return _frame_id; } intptr_t* frame_id() const { return _frame_id; }
oop privileged_context() const { return _privileged_context; } oop privileged_context() const { return _privileged_context; }
oop class_loader() const { return InstanceKlass::cast(_klass)->class_loader(); } oop class_loader() const { return InstanceKlass::cast(_klass)->class_loader(); }

View file

@ -112,7 +112,7 @@ void print_method_profiling_data() {
ResourceMark rm; ResourceMark rm;
HandleMark hm; HandleMark hm;
collected_profiled_methods = new GrowableArray<Method*>(1024); collected_profiled_methods = new GrowableArray<Method*>(1024);
ClassLoaderDataGraph::methods_do(collect_profiled_methods); SystemDictionary::methods_do(collect_profiled_methods);
collected_profiled_methods->sort(&compare_methods); collected_profiled_methods->sort(&compare_methods);
int count = collected_profiled_methods->length(); int count = collected_profiled_methods->length();
@ -163,7 +163,7 @@ void print_method_invocation_histogram() {
collected_invoked_methods->sort(&compare_methods); collected_invoked_methods->sort(&compare_methods);
// //
tty->cr(); tty->cr();
tty->print_cr("Histogram Over MethodOop Invocation Counters (cutoff = " INTX_FORMAT "):", MethodHistogramCutoff); tty->print_cr("Histogram Over Method Invocation Counters (cutoff = " INTX_FORMAT "):", MethodHistogramCutoff);
tty->cr(); tty->cr();
tty->print_cr("____Count_(I+C)____Method________________________Module_________________"); tty->print_cr("____Count_(I+C)____Method________________________Module_________________");
unsigned total = 0, int_total = 0, comp_total = 0, static_total = 0, final_total = 0, unsigned total = 0, int_total = 0, comp_total = 0, static_total = 0, final_total = 0,

View file

@ -196,12 +196,6 @@ class FilteredFieldsMap : AllStatic {
} }
return nflds; return nflds;
} }
// Enhance Class Redefinition Support
static void classes_do(KlassClosure* f) {
for (int i = 0; i < _filtered_fields->length(); i++) {
f->do_klass(_filtered_fields->at(i)->klass());
}
}
}; };

View file

@ -1824,8 +1824,10 @@ void VM_HeapDumper::doit() {
check_segment_length(); check_segment_length();
// HPROF_GC_ROOT_STICKY_CLASS // HPROF_GC_ROOT_STICKY_CLASS
// These should be classes in the NULL class loader data, and not all classes
// if !ClassUnloading
StickyClassDumper class_dumper(writer()); StickyClassDumper class_dumper(writer());
SystemDictionary::always_strong_classes_do(&class_dumper); ClassLoaderData::the_null_class_loader_data()->classes_do(&class_dumper);
// fixes up the length of the dump record and writes the HPROF_HEAP_DUMP_END record. // fixes up the length of the dump record and writes the HPROF_HEAP_DUMP_END record.
DumperSupport::end_of_dump(writer()); DumperSupport::end_of_dump(writer());