84 85 86 void Dictionary::free_entry(DictionaryEntry* entry) { 87 // avoid recursion when deleting linked list 88 while (entry->pd_set() != NULL) { 89 ProtectionDomainEntry* to_delete = entry->pd_set(); 90 entry->set_pd_set(to_delete->next()); 91 delete to_delete; 92 } 93 // Unlink from the Hashtable prior to freeing 94 unlink_entry(entry); 95 FREE_C_HEAP_ARRAY(char, entry); 96 } 97 98 99 bool DictionaryEntry::contains_protection_domain(oop protection_domain) const { 100 #ifdef ASSERT 101 if (protection_domain == instance_klass()->protection_domain()) { 102 // Ensure this doesn't show up in the pd_set (invariant) 103 bool in_pd_set = false; 104 for (ProtectionDomainEntry* current = _pd_set; 105 current != NULL; 106 current = current->next()) { 107 if (current->protection_domain() == protection_domain) { 108 in_pd_set = true; 109 break; 110 } 111 } 112 if (in_pd_set) { 113 assert(false, "A klass's protection domain should not show up " 114 "in its sys. dict. PD set"); 115 } 116 } 117 #endif /* ASSERT */ 118 119 if (protection_domain == instance_klass()->protection_domain()) { 120 // Succeeds trivially 121 return true; 122 } 123 124 for (ProtectionDomainEntry* current = _pd_set; 125 current != NULL; 126 current = current->next()) { 127 if (current->protection_domain() == protection_domain) return true; 128 } 129 return false; 130 } 131 132 133 void DictionaryEntry::add_protection_domain(Dictionary* dict, Handle protection_domain) { 134 assert_locked_or_safepoint(SystemDictionary_lock); 135 if (!contains_protection_domain(protection_domain())) { 136 ProtectionDomainCacheEntry* entry = SystemDictionary::cache_get(protection_domain); 137 ProtectionDomainEntry* new_head = 138 new ProtectionDomainEntry(entry, _pd_set); 139 // Warning: Preserve store ordering. The SystemDictionary is read 140 // without locks. The new ProtectionDomainEntry must be 141 // complete before other threads can be allowed to see it 142 // via a store to _pd_set. 143 OrderAccess::release_store_ptr(&_pd_set, new_head); 144 } 145 LogTarget(Trace, protectiondomain) lt; 146 if (lt.is_enabled()) { 147 LogStream ls(lt); 148 print_count(&ls); 149 } 150 } 151 152 153 void Dictionary::do_unloading() { 154 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); 155 156 // The NULL class loader doesn't initiate loading classes from other class loaders 157 if (loader_data() == ClassLoaderData::the_null_class_loader_data()) { 158 return; 159 } 160 161 // Remove unloaded entries and classes from this dictionary 162 DictionaryEntry* probe = NULL; 163 for (int index = 0; index < table_size(); index++) { | 84 85 86 void Dictionary::free_entry(DictionaryEntry* entry) { 87 // avoid recursion when deleting linked list 88 while (entry->pd_set() != NULL) { 89 ProtectionDomainEntry* to_delete = entry->pd_set(); 90 entry->set_pd_set(to_delete->next()); 91 delete to_delete; 92 } 93 // Unlink from the Hashtable prior to freeing 94 unlink_entry(entry); 95 FREE_C_HEAP_ARRAY(char, entry); 96 } 97 98 99 bool DictionaryEntry::contains_protection_domain(oop protection_domain) const { 100 #ifdef ASSERT 101 if (protection_domain == instance_klass()->protection_domain()) { 102 // Ensure this doesn't show up in the pd_set (invariant) 103 bool in_pd_set = false; 104 for (ProtectionDomainEntry* current = pd_set_acquire(); 105 current != NULL; 106 current = current->next()) { 107 if (current->protection_domain() == protection_domain) { 108 in_pd_set = true; 109 break; 110 } 111 } 112 if (in_pd_set) { 113 assert(false, "A klass's protection domain should not show up " 114 "in its sys. dict. PD set"); 115 } 116 } 117 #endif /* ASSERT */ 118 119 if (protection_domain == instance_klass()->protection_domain()) { 120 // Succeeds trivially 121 return true; 122 } 123 124 for (ProtectionDomainEntry* current = pd_set_acquire(); 125 current != NULL; 126 current = current->next()) { 127 if (current->protection_domain() == protection_domain) return true; 128 } 129 return false; 130 } 131 132 133 void DictionaryEntry::add_protection_domain(Dictionary* dict, Handle protection_domain) { 134 assert_locked_or_safepoint(SystemDictionary_lock); 135 if (!contains_protection_domain(protection_domain())) { 136 ProtectionDomainCacheEntry* entry = SystemDictionary::cache_get(protection_domain); 137 ProtectionDomainEntry* new_head = 138 new ProtectionDomainEntry(entry, pd_set()); 139 // Warning: Preserve store ordering. The SystemDictionary is read 140 // without locks. The new ProtectionDomainEntry must be 141 // complete before other threads can be allowed to see it 142 // via a store to _pd_set. 143 release_set_pd_set(new_head); 144 } 145 LogTarget(Trace, protectiondomain) lt; 146 if (lt.is_enabled()) { 147 LogStream ls(lt); 148 print_count(&ls); 149 } 150 } 151 152 153 void Dictionary::do_unloading() { 154 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); 155 156 // The NULL class loader doesn't initiate loading classes from other class loaders 157 if (loader_data() == ClassLoaderData::the_null_class_loader_data()) { 158 return; 159 } 160 161 // Remove unloaded entries and classes from this dictionary 162 DictionaryEntry* probe = NULL; 163 for (int index = 0; index < table_size(); index++) { |