12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/classLoaderData.inline.hpp"
27 #include "classfile/sharedClassUtil.hpp"
28 #include "classfile/dictionary.hpp"
29 #include "classfile/protectionDomainCache.hpp"
30 #include "classfile/systemDictionary.hpp"
31 #include "classfile/systemDictionaryShared.hpp"
32 #include "memory/iterator.hpp"
33 #include "memory/resourceArea.hpp"
34 #include "oops/oop.inline.hpp"
35 #include "runtime/orderAccess.inline.hpp"
36 #include "utilities/hashtable.inline.hpp"
37
38 DictionaryEntry* Dictionary::_current_class_entry = NULL;
39 int Dictionary::_current_class_index = 0;
40
41 size_t Dictionary::entry_size() {
42 if (DumpSharedSpaces) {
43 return SystemDictionaryShared::dictionary_entry_size();
44 } else {
45 return sizeof(DictionaryEntry);
46 }
47 }
48
49 Dictionary::Dictionary(int table_size)
50 : TwoOopHashtable<InstanceKlass*, mtClass>(table_size, (int)entry_size()) {
51 _current_class_index = 0;
119 current != NULL;
120 current = current->next()) {
121 if (current->protection_domain() == protection_domain) return true;
122 }
123 return false;
124 }
125
126
127 void DictionaryEntry::add_protection_domain(Dictionary* dict, Handle protection_domain) {
128 assert_locked_or_safepoint(SystemDictionary_lock);
129 if (!contains_protection_domain(protection_domain())) {
130 ProtectionDomainCacheEntry* entry = dict->cache_get(protection_domain);
131 ProtectionDomainEntry* new_head =
132 new ProtectionDomainEntry(entry, _pd_set);
133 // Warning: Preserve store ordering. The SystemDictionary is read
134 // without locks. The new ProtectionDomainEntry must be
135 // complete before other threads can be allowed to see it
136 // via a store to _pd_set.
137 OrderAccess::release_store_ptr(&_pd_set, new_head);
138 }
139 if (log_is_enabled(Trace, protectiondomain)) {
140 ResourceMark rm;
141 outputStream* log = Log(protectiondomain)::trace_stream();
142 print_count(log);
143 }
144 }
145
146
147 void Dictionary::do_unloading() {
148 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
149
150 // Remove unloadable entries and classes from system dictionary
151 DictionaryEntry* probe = NULL;
152 for (int index = 0; index < table_size(); index++) {
153 for (DictionaryEntry** p = bucket_addr(index); *p != NULL; ) {
154 probe = *p;
155 Klass* e = probe->klass();
156 ClassLoaderData* loader_data = probe->loader_data();
157
158 InstanceKlass* ik = InstanceKlass::cast(e);
159
160 // Only unload classes that are not strongly reachable
161 if (!is_strongly_reachable(loader_data, e)) {
162 // Entry was not visited in phase1 (negated test from phase1)
|
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/classLoaderData.inline.hpp"
27 #include "classfile/sharedClassUtil.hpp"
28 #include "classfile/dictionary.hpp"
29 #include "classfile/protectionDomainCache.hpp"
30 #include "classfile/systemDictionary.hpp"
31 #include "classfile/systemDictionaryShared.hpp"
32 #include "logging/log.hpp"
33 #include "logging/logStream.hpp"
34 #include "memory/iterator.hpp"
35 #include "memory/resourceArea.hpp"
36 #include "oops/oop.inline.hpp"
37 #include "runtime/orderAccess.inline.hpp"
38 #include "utilities/hashtable.inline.hpp"
39
40 DictionaryEntry* Dictionary::_current_class_entry = NULL;
41 int Dictionary::_current_class_index = 0;
42
43 size_t Dictionary::entry_size() {
44 if (DumpSharedSpaces) {
45 return SystemDictionaryShared::dictionary_entry_size();
46 } else {
47 return sizeof(DictionaryEntry);
48 }
49 }
50
51 Dictionary::Dictionary(int table_size)
52 : TwoOopHashtable<InstanceKlass*, mtClass>(table_size, (int)entry_size()) {
53 _current_class_index = 0;
121 current != NULL;
122 current = current->next()) {
123 if (current->protection_domain() == protection_domain) return true;
124 }
125 return false;
126 }
127
128
129 void DictionaryEntry::add_protection_domain(Dictionary* dict, Handle protection_domain) {
130 assert_locked_or_safepoint(SystemDictionary_lock);
131 if (!contains_protection_domain(protection_domain())) {
132 ProtectionDomainCacheEntry* entry = dict->cache_get(protection_domain);
133 ProtectionDomainEntry* new_head =
134 new ProtectionDomainEntry(entry, _pd_set);
135 // Warning: Preserve store ordering. The SystemDictionary is read
136 // without locks. The new ProtectionDomainEntry must be
137 // complete before other threads can be allowed to see it
138 // via a store to _pd_set.
139 OrderAccess::release_store_ptr(&_pd_set, new_head);
140 }
141 LogTarget(Trace, protectiondomain) lt;
142 if (lt.is_enabled()) {
143 LogStream ls(lt);
144 print_count(&ls);
145 }
146 }
147
148
149 void Dictionary::do_unloading() {
150 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
151
152 // Remove unloadable entries and classes from system dictionary
153 DictionaryEntry* probe = NULL;
154 for (int index = 0; index < table_size(); index++) {
155 for (DictionaryEntry** p = bucket_addr(index); *p != NULL; ) {
156 probe = *p;
157 Klass* e = probe->klass();
158 ClassLoaderData* loader_data = probe->loader_data();
159
160 InstanceKlass* ik = InstanceKlass::cast(e);
161
162 // Only unload classes that are not strongly reachable
163 if (!is_strongly_reachable(loader_data, e)) {
164 // Entry was not visited in phase1 (negated test from phase1)
|