25
25
#include " precompiled.hpp"
26
26
#include " classfile/classLoaderData.inline.hpp"
27
27
#include " classfile/placeholders.hpp"
28
- #include " classfile/systemDictionary.hpp"
29
- #include " oops/oop.inline.hpp"
28
+ #include " runtime/mutexLocker.hpp"
30
29
#include " utilities/hashtable.inline.hpp"
31
30
32
31
// Placeholder methods
@@ -61,26 +60,29 @@ void PlaceholderTable::free_entry(PlaceholderEntry* entry) {
61
60
// All threads examining the placeholder table must hold the
62
61
// SystemDictionary_lock, so we don't need special precautions
63
62
// on store ordering here.
64
- void PlaceholderTable::add_entry (int index, unsigned int hash,
65
- Symbol* class_name, ClassLoaderData* loader_data,
66
- bool havesupername, Symbol* supername){
63
+ PlaceholderEntry* PlaceholderTable::add_entry (unsigned int hash,
64
+ Symbol* class_name, ClassLoaderData* loader_data,
65
+ bool havesupername, Symbol* supername){
67
66
assert_locked_or_safepoint (SystemDictionary_lock);
68
67
assert (class_name != NULL , " adding NULL obj" );
69
68
70
69
// Both readers and writers are locked so it's safe to just
71
70
// create the placeholder and insert it in the list without a membar.
72
71
PlaceholderEntry* entry = new_entry (hash, class_name, loader_data, havesupername, supername);
73
- add_entry (index, entry);
72
+ int index = hash_to_index (hash);
73
+ Hashtable<Symbol*, mtClass>::add_entry (index, entry);
74
+ return entry;
74
75
}
75
76
76
77
77
78
// Remove a placeholder object.
78
- void PlaceholderTable::remove_entry (int index, unsigned int hash,
79
+ void PlaceholderTable::remove_entry (unsigned int hash,
79
80
Symbol* class_name,
80
81
ClassLoaderData* loader_data) {
81
82
assert_locked_or_safepoint (SystemDictionary_lock);
83
+ int index = hash_to_index (hash);
82
84
PlaceholderEntry** p = bucket_addr (index);
83
- while (*p) {
85
+ while (*p != NULL ) {
84
86
PlaceholderEntry *probe = *p;
85
87
if (probe->hash () == hash && probe->equals (class_name, loader_data)) {
86
88
// Delete entry
@@ -92,11 +94,12 @@ void PlaceholderTable::remove_entry(int index, unsigned int hash,
92
94
}
93
95
}
94
96
95
- PlaceholderEntry* PlaceholderTable::get_entry (int index, unsigned int hash,
96
- Symbol* class_name,
97
- ClassLoaderData* loader_data) {
97
+ PlaceholderEntry* PlaceholderTable::get_entry (unsigned int hash,
98
+ Symbol* class_name,
99
+ ClassLoaderData* loader_data) {
98
100
assert_locked_or_safepoint (SystemDictionary_lock);
99
101
102
+ int index = hash_to_index (hash);
100
103
for (PlaceholderEntry *place_probe = bucket (index);
101
104
place_probe != NULL ;
102
105
place_probe = place_probe->next ()) {
@@ -108,36 +111,35 @@ PlaceholderEntry* PlaceholderTable::get_entry(int index, unsigned int hash,
108
111
return NULL ;
109
112
}
110
113
111
- Symbol* PlaceholderTable::find_entry (int index, unsigned int hash,
112
- Symbol* class_name,
113
- ClassLoaderData* loader_data) {
114
- PlaceholderEntry* probe = get_entry (index, hash, class_name, loader_data);
115
- return (probe? probe->klassname (): (Symbol*) NULL );
114
+ Symbol* PlaceholderTable::find_entry (unsigned int hash,
115
+ Symbol* class_name,
116
+ ClassLoaderData* loader_data) {
117
+ PlaceholderEntry* probe = get_entry (hash, class_name, loader_data);
118
+ return (probe != NULL ? probe->klassname () : NULL );
116
119
}
117
120
118
121
// find_and_add returns probe pointer - old or new
119
122
// If no entry exists, add a placeholder entry
120
123
// If entry exists, reuse entry
121
124
// For both, push SeenThread for classloadAction
122
125
// if havesupername: this is used for circularity for instanceklass loading
123
- PlaceholderEntry* PlaceholderTable::find_and_add (int index, unsigned int hash,
126
+ PlaceholderEntry* PlaceholderTable::find_and_add (unsigned int hash,
124
127
Symbol* name,
125
128
ClassLoaderData* loader_data,
126
129
classloadAction action,
127
130
Symbol* supername,
128
131
Thread* thread) {
129
- PlaceholderEntry* probe = get_entry (index, hash, name, loader_data);
132
+ PlaceholderEntry* probe = get_entry (hash, name, loader_data);
130
133
if (probe == NULL ) {
131
134
// Nothing found, add place holder
132
- add_entry (index, hash, name, loader_data, (action == LOAD_SUPER), supername);
133
- probe = get_entry (index, hash, name, loader_data);
135
+ probe = add_entry (hash, name, loader_data, (action == LOAD_SUPER), supername);
134
136
} else {
135
137
if (action == LOAD_SUPER) {
136
138
probe->set_havesupername (true );
137
139
probe->set_supername (supername);
138
140
}
139
141
}
140
- if (probe) probe->add_seen_thread (thread, action);
142
+ probe->add_seen_thread (thread, action);
141
143
return probe;
142
144
}
143
145
@@ -155,18 +157,18 @@ PlaceholderEntry* PlaceholderTable::find_and_add(int index, unsigned int hash,
155
157
// Note: you can be in both placeholders and systemDictionary
156
158
// Therefore - must always check SD first
157
159
// Ignores the case where entry is not found
158
- void PlaceholderTable::find_and_remove (int index, unsigned int hash,
160
+ void PlaceholderTable::find_and_remove (unsigned int hash,
159
161
Symbol* name, ClassLoaderData* loader_data,
160
162
classloadAction action,
161
163
Thread* thread) {
162
164
assert_locked_or_safepoint (SystemDictionary_lock);
163
- PlaceholderEntry *probe = get_entry (index, hash, name, loader_data);
165
+ PlaceholderEntry *probe = get_entry (hash, name, loader_data);
164
166
if (probe != NULL ) {
165
167
probe->remove_seen_thread (thread, action);
166
168
// If no other threads using this entry, and this thread is not using this entry for other states
167
169
if ((probe->superThreadQ () == NULL ) && (probe->loadInstanceThreadQ () == NULL )
168
170
&& (probe->defineThreadQ () == NULL ) && (probe->definer () == NULL )) {
169
- remove_entry (index, hash, name, loader_data);
171
+ remove_entry (hash, name, loader_data);
170
172
}
171
173
}
172
174
}
0 commit comments