39 friend class ClassLoaderDataGraphKlassIteratorStatic; 40 friend class ClassLoaderDataGraphIterator; 41 friend class VMStructs; 42 private: 43 // All CLDs (except the null CLD) can be reached by walking _head->_next->... 44 static ClassLoaderData* volatile _head; 45 static ClassLoaderData* _unloading; 46 47 // Set if there's anything to purge in the deallocate lists or previous versions 48 // during a safepoint after class unloading in a full GC. 49 static bool _should_clean_deallocate_lists; 50 static bool _safepoint_cleanup_needed; 51 52 // OOM has been seen in metaspace allocation. Used to prevent some 53 // allocations until class unloading 54 static bool _metaspace_oom; 55 56 static volatile size_t _num_instance_classes; 57 static volatile size_t _num_array_classes; 58 59 static ClassLoaderData* add_to_graph(Handle class_loader, bool is_unsafe_anonymous); 60 static ClassLoaderData* add(Handle class_loader, bool is_unsafe_anonymous); 61 62 public: 63 static ClassLoaderData* find_or_create(Handle class_loader); 64 static void clean_module_and_package_info(); 65 static void purge(); 66 static void clear_claimed_marks(); 67 static void clear_claimed_marks(int claim); 68 // Iteration through CLDG inside a safepoint; GC support 69 static void cld_do(CLDClosure* cl); 70 static void cld_unloading_do(CLDClosure* cl); 71 static void roots_cld_do(CLDClosure* strong, CLDClosure* weak); 72 static void always_strong_cld_do(CLDClosure* cl); 73 // Iteration through CLDG not by GC. 74 static void loaded_cld_do(CLDClosure* cl); 75 // klass do 76 // Walking classes through the ClassLoaderDataGraph include array classes. It also includes 77 // classes that are allocated but not loaded, classes that have errors, and scratch classes 78 // for redefinition. These classes are removed during the next class unloading. 79 // Walking the ClassLoaderDataGraph also includes unsafe anonymous classes. 80 static void classes_do(KlassClosure* klass_closure); 81 static void classes_do(void f(Klass* const)); 82 static void methods_do(void f(Method*)); 83 static void modules_do(void f(ModuleEntry*)); 84 static void modules_unloading_do(void f(ModuleEntry*)); 85 static void packages_do(void f(PackageEntry*)); 86 static void packages_unloading_do(void f(PackageEntry*)); 87 static void loaded_classes_do(KlassClosure* klass_closure); 88 static void unlocked_loaded_classes_do(KlassClosure* klass_closure); 89 static void classes_unloading_do(void f(Klass* const)); 90 static bool do_unloading(); 91 92 // Expose state to avoid logging overhead in safepoint cleanup tasks. 93 static inline bool should_clean_metaspaces_and_reset(); 94 static void set_should_clean_deallocate_lists() { _should_clean_deallocate_lists = true; } 95 static void clean_deallocate_lists(bool purge_previous_versions); 96 static void walk_metadata_and_clean_metaspaces(); 97 98 // dictionary do 99 // Iterate over all klasses in dictionary, but | 39 friend class ClassLoaderDataGraphKlassIteratorStatic; 40 friend class ClassLoaderDataGraphIterator; 41 friend class VMStructs; 42 private: 43 // All CLDs (except the null CLD) can be reached by walking _head->_next->... 44 static ClassLoaderData* volatile _head; 45 static ClassLoaderData* _unloading; 46 47 // Set if there's anything to purge in the deallocate lists or previous versions 48 // during a safepoint after class unloading in a full GC. 49 static bool _should_clean_deallocate_lists; 50 static bool _safepoint_cleanup_needed; 51 52 // OOM has been seen in metaspace allocation. Used to prevent some 53 // allocations until class unloading 54 static bool _metaspace_oom; 55 56 static volatile size_t _num_instance_classes; 57 static volatile size_t _num_array_classes; 58 59 static ClassLoaderData* add_to_graph(Handle class_loader, bool is_shortlived); 60 static ClassLoaderData* add(Handle class_loader, bool is_shortlived); 61 62 public: 63 static ClassLoaderData* find_or_create(Handle class_loader); 64 static void clean_module_and_package_info(); 65 static void purge(); 66 static void clear_claimed_marks(); 67 static void clear_claimed_marks(int claim); 68 // Iteration through CLDG inside a safepoint; GC support 69 static void cld_do(CLDClosure* cl); 70 static void cld_unloading_do(CLDClosure* cl); 71 static void roots_cld_do(CLDClosure* strong, CLDClosure* weak); 72 static void always_strong_cld_do(CLDClosure* cl); 73 // Iteration through CLDG not by GC. 74 static void loaded_cld_do(CLDClosure* cl); 75 // klass do 76 // Walking classes through the ClassLoaderDataGraph include array classes. It also includes 77 // classes that are allocated but not loaded, classes that have errors, and scratch classes 78 // for redefinition. These classes are removed during the next class unloading. 79 // Walking the ClassLoaderDataGraph also includes hidden and unsafe anonymous classes. 80 static void classes_do(KlassClosure* klass_closure); 81 static void classes_do(void f(Klass* const)); 82 static void methods_do(void f(Method*)); 83 static void modules_do(void f(ModuleEntry*)); 84 static void modules_unloading_do(void f(ModuleEntry*)); 85 static void packages_do(void f(PackageEntry*)); 86 static void packages_unloading_do(void f(PackageEntry*)); 87 static void loaded_classes_do(KlassClosure* klass_closure); 88 static void unlocked_loaded_classes_do(KlassClosure* klass_closure); 89 static void classes_unloading_do(void f(Klass* const)); 90 static bool do_unloading(); 91 92 // Expose state to avoid logging overhead in safepoint cleanup tasks. 93 static inline bool should_clean_metaspaces_and_reset(); 94 static void set_should_clean_deallocate_lists() { _should_clean_deallocate_lists = true; } 95 static void clean_deallocate_lists(bool purge_previous_versions); 96 static void walk_metadata_and_clean_metaspaces(); 97 98 // dictionary do 99 // Iterate over all klasses in dictionary, but |