26 #define SHARE_VM_CLASSFILE_DICTIONARY_HPP 27 28 #include "classfile/protectionDomainCache.hpp" 29 #include "classfile/systemDictionary.hpp" 30 #include "oops/instanceKlass.hpp" 31 #include "oops/oop.hpp" 32 #include "runtime/orderAccess.hpp" 33 #include "utilities/hashtable.hpp" 34 #include "utilities/ostream.hpp" 35 36 class DictionaryEntry; 37 class BoolObjectClosure; 38 39 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 40 // The data structure for the class loader data dictionaries (and the shared system 41 // dictionary). 42 43 class Dictionary : public Hashtable<InstanceKlass*, mtClass> { 44 friend class VMStructs; 45 46 ClassLoaderData* _loader_data; // backpointer to owning loader 47 ClassLoaderData* loader_data() const { return _loader_data; } 48 49 DictionaryEntry* get_entry(int index, unsigned int hash, Symbol* name); 50 51 protected: 52 static size_t entry_size(); 53 public: 54 Dictionary(ClassLoaderData* loader_data, int table_size); 55 Dictionary(ClassLoaderData* loader_data, int table_size, HashtableBucket<mtClass>* t, int number_of_entries); 56 ~Dictionary(); 57 58 DictionaryEntry* new_entry(unsigned int hash, InstanceKlass* klass); 59 60 void add_klass(int index, unsigned int hash, Symbol* class_name, InstanceKlass* obj); 61 62 InstanceKlass* find_class(int index, unsigned int hash, Symbol* name); 63 64 InstanceKlass* find_shared_class(int index, unsigned int hash, Symbol* name); 65 66 // GC support 67 void oops_do(OopClosure* f); 68 void roots_oops_do(OopClosure* strong, OopClosure* weak); 69 70 void classes_do(void f(InstanceKlass*)); 71 void classes_do(void f(InstanceKlass*, TRAPS), TRAPS); 72 void all_entries_do(void f(InstanceKlass*, ClassLoaderData*)); 73 void classes_do(MetaspaceClosure* it); 74 75 void unlink(BoolObjectClosure* is_alive); 76 void remove_classes_in_error_state(); 77 78 // Unload classes whose defining loaders are unloaded 79 void do_unloading(); 80 81 // Protection domains 82 InstanceKlass* find(int index, unsigned int hash, Symbol* name, Handle protection_domain); 83 bool is_valid_protection_domain(int index, unsigned int hash, 84 Symbol* name, 85 Handle protection_domain); 86 void add_protection_domain(int index, unsigned int hash, 87 InstanceKlass* klass, 88 Handle protection_domain, TRAPS); 89 90 // Sharing support 91 void reorder_dictionary_for_sharing(); 92 93 void print_on(outputStream* st) const; 94 void verify(); 95 DictionaryEntry* bucket(int i) const { 96 return (DictionaryEntry*)Hashtable<InstanceKlass*, mtClass>::bucket(i); 97 } 98 99 // The following method is not MT-safe and must be done under lock. 100 DictionaryEntry** bucket_addr(int i) { 101 return (DictionaryEntry**)Hashtable<InstanceKlass*, mtClass>::bucket_addr(i); 102 } 103 | 26 #define SHARE_VM_CLASSFILE_DICTIONARY_HPP 27 28 #include "classfile/protectionDomainCache.hpp" 29 #include "classfile/systemDictionary.hpp" 30 #include "oops/instanceKlass.hpp" 31 #include "oops/oop.hpp" 32 #include "runtime/orderAccess.hpp" 33 #include "utilities/hashtable.hpp" 34 #include "utilities/ostream.hpp" 35 36 class DictionaryEntry; 37 class BoolObjectClosure; 38 39 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 40 // The data structure for the class loader data dictionaries (and the shared system 41 // dictionary). 42 43 class Dictionary : public Hashtable<InstanceKlass*, mtClass> { 44 friend class VMStructs; 45 46 static bool _some_dictionary_needs_resizing; 47 bool _resizable; 48 bool _needs_resizing; 49 void check_if_needs_resize(); 50 51 ClassLoaderData* _loader_data; // backpointer to owning loader 52 ClassLoaderData* loader_data() const { return _loader_data; } 53 54 DictionaryEntry* get_entry(int index, unsigned int hash, Symbol* name); 55 56 protected: 57 static size_t entry_size(); 58 public: 59 Dictionary(ClassLoaderData* loader_data, int table_size, bool resizable = false); 60 Dictionary(ClassLoaderData* loader_data, int table_size, HashtableBucket<mtClass>* t, int number_of_entries, bool resizable = false); 61 ~Dictionary(); 62 63 static bool does_any_dictionary_needs_resizing(); 64 bool resize_if_needed(); 65 66 DictionaryEntry* new_entry(unsigned int hash, InstanceKlass* klass); 67 68 void add_klass(unsigned int hash, Symbol* class_name, InstanceKlass* obj); 69 70 InstanceKlass* find_class(int index, unsigned int hash, Symbol* name); 71 72 InstanceKlass* find_shared_class(int index, unsigned int hash, Symbol* name); 73 74 // GC support 75 void oops_do(OopClosure* f); 76 void roots_oops_do(OopClosure* strong, OopClosure* weak); 77 78 void classes_do(void f(InstanceKlass*)); 79 void classes_do(void f(InstanceKlass*, TRAPS), TRAPS); 80 void all_entries_do(void f(InstanceKlass*, ClassLoaderData*)); 81 void classes_do(MetaspaceClosure* it); 82 83 void unlink(BoolObjectClosure* is_alive); 84 void remove_classes_in_error_state(); 85 86 // Unload classes whose defining loaders are unloaded 87 void do_unloading(); 88 89 // Protection domains 90 InstanceKlass* find(unsigned int hash, Symbol* name, Handle protection_domain); 91 bool is_valid_protection_domain(unsigned int hash, 92 Symbol* name, 93 Handle protection_domain); 94 void add_protection_domain(int index, unsigned int hash, 95 InstanceKlass* klass, 96 Handle protection_domain, TRAPS); 97 98 // Sharing support 99 void reorder_dictionary_for_sharing(); 100 101 void print_on(outputStream* st) const; 102 void verify(); 103 DictionaryEntry* bucket(int i) const { 104 return (DictionaryEntry*)Hashtable<InstanceKlass*, mtClass>::bucket(i); 105 } 106 107 // The following method is not MT-safe and must be done under lock. 108 DictionaryEntry** bucket_addr(int i) { 109 return (DictionaryEntry**)Hashtable<InstanceKlass*, mtClass>::bucket_addr(i); 110 } 111 |