46 |
46 |
47 DictionaryEntry* get_entry(int index, unsigned int hash, |
47 DictionaryEntry* get_entry(int index, unsigned int hash, |
48 Symbol* name, Handle loader); |
48 Symbol* name, Handle loader); |
49 |
49 |
50 DictionaryEntry* bucket(int i) { |
50 DictionaryEntry* bucket(int i) { |
51 return (DictionaryEntry*)Hashtable<klassOop>::bucket(i); |
51 return (DictionaryEntry*)Hashtable<klassOop, mtClass>::bucket(i); |
52 } |
52 } |
53 |
53 |
54 // The following method is not MT-safe and must be done under lock. |
54 // The following method is not MT-safe and must be done under lock. |
55 DictionaryEntry** bucket_addr(int i) { |
55 DictionaryEntry** bucket_addr(int i) { |
56 return (DictionaryEntry**)Hashtable<klassOop>::bucket_addr(i); |
56 return (DictionaryEntry**)Hashtable<klassOop, mtClass>::bucket_addr(i); |
57 } |
57 } |
58 |
58 |
59 void add_entry(int index, DictionaryEntry* new_entry) { |
59 void add_entry(int index, DictionaryEntry* new_entry) { |
60 Hashtable<klassOop>::add_entry(index, (HashtableEntry<oop>*)new_entry); |
60 Hashtable<klassOop, mtClass>::add_entry(index, (HashtableEntry<oop, mtClass>*)new_entry); |
61 } |
61 } |
62 |
62 |
63 |
63 |
64 public: |
64 public: |
65 Dictionary(int table_size); |
65 Dictionary(int table_size); |
66 Dictionary(int table_size, HashtableBucket* t, int number_of_entries); |
66 Dictionary(int table_size, HashtableBucket<mtClass>* t, int number_of_entries); |
67 |
67 |
68 DictionaryEntry* new_entry(unsigned int hash, klassOop klass, oop loader); |
68 DictionaryEntry* new_entry(unsigned int hash, klassOop klass, oop loader); |
69 |
69 |
70 DictionaryEntry* new_entry(); |
70 DictionaryEntry* new_entry(); |
71 |
71 |
145 }; |
145 }; |
146 |
146 |
147 // An entry in the system dictionary, this describes a class as |
147 // An entry in the system dictionary, this describes a class as |
148 // { klassOop, loader, protection_domain }. |
148 // { klassOop, loader, protection_domain }. |
149 |
149 |
150 class DictionaryEntry : public HashtableEntry<klassOop> { |
150 class DictionaryEntry : public HashtableEntry<klassOop, mtClass> { |
151 friend class VMStructs; |
151 friend class VMStructs; |
152 private: |
152 private: |
153 // Contains the set of approved protection domains that can access |
153 // Contains the set of approved protection domains that can access |
154 // this system dictionary entry. |
154 // this system dictionary entry. |
155 ProtectionDomainEntry* _pd_set; |
155 ProtectionDomainEntry* _pd_set; |
164 |
164 |
165 klassOop klass() const { return (klassOop)literal(); } |
165 klassOop klass() const { return (klassOop)literal(); } |
166 klassOop* klass_addr() { return (klassOop*)literal_addr(); } |
166 klassOop* klass_addr() { return (klassOop*)literal_addr(); } |
167 |
167 |
168 DictionaryEntry* next() const { |
168 DictionaryEntry* next() const { |
169 return (DictionaryEntry*)HashtableEntry<klassOop>::next(); |
169 return (DictionaryEntry*)HashtableEntry<klassOop, mtClass>::next(); |
170 } |
170 } |
171 |
171 |
172 DictionaryEntry** next_addr() { |
172 DictionaryEntry** next_addr() { |
173 return (DictionaryEntry**)HashtableEntry<klassOop>::next_addr(); |
173 return (DictionaryEntry**)HashtableEntry<klassOop, mtClass>::next_addr(); |
174 } |
174 } |
175 |
175 |
176 oop loader() const { return _loader; } |
176 oop loader() const { return _loader; } |
177 void set_loader(oop loader) { _loader = loader; } |
177 void set_loader(oop loader) { _loader = loader; } |
178 oop* loader_addr() { return &_loader; } |
178 oop* loader_addr() { return &_loader; } |
246 |
246 |
247 address property_data() const { return _property_data; } |
247 address property_data() const { return _property_data; } |
248 void set_property_data(address p) { _property_data = p; } |
248 void set_property_data(address p) { _property_data = p; } |
249 |
249 |
250 SymbolPropertyEntry* next() const { |
250 SymbolPropertyEntry* next() const { |
251 return (SymbolPropertyEntry*)HashtableEntry<Symbol*>::next(); |
251 return (SymbolPropertyEntry*)HashtableEntry<Symbol*, mtSymbol>::next(); |
252 } |
252 } |
253 |
253 |
254 SymbolPropertyEntry** next_addr() { |
254 SymbolPropertyEntry** next_addr() { |
255 return (SymbolPropertyEntry**)HashtableEntry<Symbol*>::next_addr(); |
255 return (SymbolPropertyEntry**)HashtableEntry<Symbol*, mtSymbol>::next_addr(); |
256 } |
256 } |
257 |
257 |
258 oop* property_oop_addr() { return &_property_oop; } |
258 oop* property_oop_addr() { return &_property_oop; } |
259 |
259 |
260 void print_on(outputStream* st) const { |
260 void print_on(outputStream* st) const { |
276 }; |
276 }; |
277 |
277 |
278 // A system-internal mapping of symbols to pointers, both managed |
278 // A system-internal mapping of symbols to pointers, both managed |
279 // and unmanaged. Used to record the auto-generation of each method |
279 // and unmanaged. Used to record the auto-generation of each method |
280 // MethodHandle.invoke(S)T, for all signatures (S)T. |
280 // MethodHandle.invoke(S)T, for all signatures (S)T. |
281 class SymbolPropertyTable : public Hashtable<Symbol*> { |
281 class SymbolPropertyTable : public Hashtable<Symbol*, mtSymbol> { |
282 friend class VMStructs; |
282 friend class VMStructs; |
283 private: |
283 private: |
284 SymbolPropertyEntry* bucket(int i) { |
284 SymbolPropertyEntry* bucket(int i) { |
285 return (SymbolPropertyEntry*) Hashtable<Symbol*>::bucket(i); |
285 return (SymbolPropertyEntry*) Hashtable<Symbol*, mtSymbol>::bucket(i); |
286 } |
286 } |
287 |
287 |
288 // The following method is not MT-safe and must be done under lock. |
288 // The following method is not MT-safe and must be done under lock. |
289 SymbolPropertyEntry** bucket_addr(int i) { |
289 SymbolPropertyEntry** bucket_addr(int i) { |
290 return (SymbolPropertyEntry**) Hashtable<Symbol*>::bucket_addr(i); |
290 return (SymbolPropertyEntry**) Hashtable<Symbol*, mtSymbol>::bucket_addr(i); |
291 } |
291 } |
292 |
292 |
293 void add_entry(int index, SymbolPropertyEntry* new_entry) { |
293 void add_entry(int index, SymbolPropertyEntry* new_entry) { |
294 ShouldNotReachHere(); |
294 ShouldNotReachHere(); |
295 } |
295 } |
296 void set_entry(int index, SymbolPropertyEntry* new_entry) { |
296 void set_entry(int index, SymbolPropertyEntry* new_entry) { |
297 ShouldNotReachHere(); |
297 ShouldNotReachHere(); |
298 } |
298 } |
299 |
299 |
300 SymbolPropertyEntry* new_entry(unsigned int hash, Symbol* symbol, intptr_t symbol_mode) { |
300 SymbolPropertyEntry* new_entry(unsigned int hash, Symbol* symbol, intptr_t symbol_mode) { |
301 SymbolPropertyEntry* entry = (SymbolPropertyEntry*) Hashtable<Symbol*>::new_entry(hash, symbol); |
301 SymbolPropertyEntry* entry = (SymbolPropertyEntry*) Hashtable<Symbol*, mtSymbol>::new_entry(hash, symbol); |
302 // Hashtable with Symbol* literal must increment and decrement refcount. |
302 // Hashtable with Symbol* literal must increment and decrement refcount. |
303 symbol->increment_refcount(); |
303 symbol->increment_refcount(); |
304 entry->set_symbol_mode(symbol_mode); |
304 entry->set_symbol_mode(symbol_mode); |
305 entry->set_property_oop(NULL); |
305 entry->set_property_oop(NULL); |
306 entry->set_property_data(NULL); |
306 entry->set_property_data(NULL); |
307 return entry; |
307 return entry; |
308 } |
308 } |
309 |
309 |
310 public: |
310 public: |
311 SymbolPropertyTable(int table_size); |
311 SymbolPropertyTable(int table_size); |
312 SymbolPropertyTable(int table_size, HashtableBucket* t, int number_of_entries); |
312 SymbolPropertyTable(int table_size, HashtableBucket<mtSymbol>* t, int number_of_entries); |
313 |
313 |
314 void free_entry(SymbolPropertyEntry* entry) { |
314 void free_entry(SymbolPropertyEntry* entry) { |
315 // decrement Symbol refcount here because hashtable doesn't. |
315 // decrement Symbol refcount here because hashtable doesn't. |
316 entry->literal()->decrement_refcount(); |
316 entry->literal()->decrement_refcount(); |
317 Hashtable<Symbol*>::free_entry(entry); |
317 Hashtable<Symbol*, mtSymbol>::free_entry(entry); |
318 } |
318 } |
319 |
319 |
320 unsigned int compute_hash(Symbol* sym, intptr_t symbol_mode) { |
320 unsigned int compute_hash(Symbol* sym, intptr_t symbol_mode) { |
321 // Use the regular identity_hash. |
321 // Use the regular identity_hash. |
322 return Hashtable<Symbol*>::compute_hash(sym) ^ symbol_mode; |
322 return Hashtable<Symbol*, mtSymbol>::compute_hash(sym) ^ symbol_mode; |
323 } |
323 } |
324 |
324 |
325 int index_for(Symbol* name, intptr_t symbol_mode) { |
325 int index_for(Symbol* name, intptr_t symbol_mode) { |
326 return hash_to_index(compute_hash(name, symbol_mode)); |
326 return hash_to_index(compute_hash(name, symbol_mode)); |
327 } |
327 } |